Hide the powerpoint presentation window from the taskbar - can be disabled from the settings.

This commit is contained in:
Tomas Groth 2015-05-08 10:17:35 +02:00
parent bf665a8549
commit b52a4e640c
4 changed files with 32 additions and 2 deletions

View File

@ -1 +1 @@
2.1.3
2.1.4

View File

@ -34,8 +34,10 @@ from openlp.core.common import is_win, Settings
if is_win():
from win32com.client import DispatchWithEvents
import win32com
import win32con
import winreg
import win32ui
import win32gui
import pywintypes
@ -339,10 +341,26 @@ class PowerpointDocument(PresentationDocument):
except AttributeError as e:
log.exception('AttributeError while in start_presentation')
log.exception(e)
if ppt_window and Settings().value('presentations/powerpoint hide in taskbar'):
win32gui.EnumWindows(self._window_enum_callback, size)
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
if len(ScreenList().screen_list) > 1:
Registry().get('main_window').activateWindow()
def _window_enum_callback(self, hwnd, size):
"""
Method for callback from win32gui.EnumWindows.
Used to hide the powerpoint presentation window from the taskbar.
"""
# Get the size of the current window and if it matches the size of our main display we assume
# it is the powerpoint presentation window and hides it from the taskbar.
(left, top, right, bottom) = win32gui.GetWindowRect(hwnd)
if size.y() == top and size.height() == (bottom - top) and size.x() == left and size.width() == (right - left):
win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE,
win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_TOOLWINDOW)
win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
def get_slide_number(self):
"""
Returns the current slide number.

View File

@ -79,6 +79,9 @@ class PresentationTab(SettingsTab):
self.ppt_window_check_box = QtGui.QCheckBox(self.powerpoint_group_box)
self.ppt_window_check_box.setObjectName('ppt_window_check_box')
self.powerpoint_layout.addWidget(self.ppt_window_check_box)
self.ppt_hide_check_box = QtGui.QCheckBox(self.powerpoint_group_box)
self.ppt_hide_check_box.setObjectName('ppt_hide_check_box')
self.powerpoint_layout.addWidget(self.ppt_hide_check_box)
self.left_layout.addWidget(self.powerpoint_group_box)
# Pdf options
self.pdf_group_box = QtGui.QGroupBox(self.left_column)
@ -129,6 +132,8 @@ class PresentationTab(SettingsTab):
self.ppt_window_check_box.setText(
translate('PresentationPlugin.PresentationTab',
'Let PowerPoint control the size and position of the presentation window.'))
self.ppt_hide_check_box.setText(
translate('PresentationPlugin.PresentationTab', 'Hide PowerPoint presentation windows from the taskbar'))
self.pdf_program_check_box.setText(
translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:'))
@ -156,6 +161,8 @@ class PresentationTab(SettingsTab):
self.ppt_slide_click_check_box.setEnabled(powerpoint_available)
self.ppt_window_check_box.setChecked(Settings().value(self.settings_section + '/powerpoint control window'))
self.ppt_window_check_box.setEnabled(powerpoint_available)
self.ppt_hide_check_box.setChecked(Settings().value(self.settings_section + '/powerpoint hide in taskbar'))
self.ppt_hide_check_box.setEnabled(powerpoint_available)
# load pdf-program settings
enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program')
self.pdf_program_check_box.setChecked(enable_pdf_program)
@ -198,6 +205,10 @@ class PresentationTab(SettingsTab):
if Settings().value(setting_key) != self.ppt_window_check_box.checkState():
Settings().setValue(setting_key, self.ppt_window_check_box.checkState())
changed = True
setting_key = self.settings_section + '/powerpoint hide in taskbar'
if Settings().value(setting_key) != self.ppt_hide_check_box.checkState():
Settings().setValue(setting_key, self.ppt_hide_check_box.checkState())
changed = True
# Save pdf-settings
pdf_program = self.pdf_program_path.text()
enable_pdf_program = self.pdf_program_check_box.checkState()

View File

@ -46,7 +46,8 @@ __default_settings__ = {'presentations/override app': QtCore.Qt.Unchecked,
'presentations/presentations files': [],
'presentations/thumbnail_scheme': '',
'presentations/powerpoint slide click advance': QtCore.Qt.Unchecked,
'presentations/powerpoint control window': QtCore.Qt.Unchecked
'presentations/powerpoint control window': QtCore.Qt.Unchecked,
'presentations/powerpoint hide in taskbar': QtCore.Qt.Checked
}