From b52a4e640c90ec611f4f8207fdb266c0df8ceea1 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 8 May 2015 10:17:35 +0200 Subject: [PATCH] Hide the powerpoint presentation window from the taskbar - can be disabled from the settings. --- openlp/.version | 2 +- .../presentations/lib/powerpointcontroller.py | 18 ++++++++++++++++++ .../presentations/lib/presentationtab.py | 11 +++++++++++ .../presentations/presentationplugin.py | 3 ++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/openlp/.version b/openlp/.version index ac2cdeba0..7d2ed7c70 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.1.3 +2.1.4 diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 6d0f52872..ed86e6132 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -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. diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index a93ceb7b9..af6a5d4c8 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -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() diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 361df514c..5065c6064 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -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 }