forked from openlp/openlp
Revert attempt to try to hide powerpoint presentation window. Instead try to minimized the flashing in the taskbar.
This commit is contained in:
parent
a5cebb73c4
commit
6cd2704814
@ -151,6 +151,7 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
self.slide_count = 0
|
self.slide_count = 0
|
||||||
self.blank_slide = 1
|
self.blank_slide = 1
|
||||||
self.blank_click = None
|
self.blank_click = None
|
||||||
|
self.presentation_hwnd = None
|
||||||
|
|
||||||
def load_presentation(self):
|
def load_presentation(self):
|
||||||
"""
|
"""
|
||||||
@ -269,6 +270,9 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
log.exception(e)
|
log.exception(e)
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
|
# Stop powerpoint from flashing in the taskbar
|
||||||
|
if self.presentation_hwnd:
|
||||||
|
win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0)
|
||||||
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
||||||
if len(ScreenList().screen_list) > 1:
|
if len(ScreenList().screen_list) > 1:
|
||||||
Registry().get('main_window').activateWindow()
|
Registry().get('main_window').activateWindow()
|
||||||
@ -353,10 +357,11 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
log.exception('AttributeError while in start_presentation')
|
log.exception('AttributeError while in start_presentation')
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
# Hide the presentation windows icon from the taskbar, if enabled and if powerpoint 2007 or newer
|
# Find the presentation window and save the handle for later
|
||||||
if ppt_window and Settings().value('presentations/powerpoint hide in taskbar') and \
|
self.presentation_hwnd = None
|
||||||
float(self.presentation.Application.Version) >= 12.0:
|
if ppt_window:
|
||||||
log.debug('main display size: y=%d, height=%d, x=%d, width=%d' % (size.y(), size.height(), size.x(), size.width()))
|
log.debug('main display size: y=%d, height=%d, x=%d, width=%d'
|
||||||
|
% (size.y(), size.height(), size.x(), size.width()))
|
||||||
win32gui.EnumWindows(self._window_enum_callback, size)
|
win32gui.EnumWindows(self._window_enum_callback, size)
|
||||||
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
||||||
if len(ScreenList().screen_list) > 1:
|
if len(ScreenList().screen_list) > 1:
|
||||||
@ -365,26 +370,30 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
def _window_enum_callback(self, hwnd, size):
|
def _window_enum_callback(self, hwnd, size):
|
||||||
"""
|
"""
|
||||||
Method for callback from win32gui.EnumWindows.
|
Method for callback from win32gui.EnumWindows.
|
||||||
Used to hide the powerpoint presentation window from the taskbar.
|
Used to find the powerpoint presentation window and stop it flashing in the taskbar.
|
||||||
"""
|
"""
|
||||||
# Get the size of the current window and if it matches the size of our main display we assume
|
# 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.
|
# it is the powerpoint presentation window.
|
||||||
(left, top, right, bottom) = win32gui.GetWindowRect(hwnd)
|
(left, top, right, bottom) = win32gui.GetWindowRect(hwnd)
|
||||||
log.debug('window size: left=%d, top=%d, right=%d, width=%d' % (left, top, right, bottom))
|
log.debug('window size: left=%d, top=%d, right=%d, width=%d' % (left, top, right, bottom))
|
||||||
log.debug('compare size: %d and %d, %d and %d, %d and %d, %d and %d' % (size.y(), top, size.height(), (bottom - top), size.x(), left, size.width(), (right - left)))
|
log.debug('compare size: %d and %d, %d and %d, %d and %d, %d and %d'
|
||||||
|
% (size.y(), top, size.height(), (bottom - top), size.x(), left, size.width(), (right - left)))
|
||||||
log.debug('window title: %s' % win32gui.GetWindowText(hwnd))
|
log.debug('window title: %s' % win32gui.GetWindowText(hwnd))
|
||||||
|
module_name = ''
|
||||||
try:
|
try:
|
||||||
t,p = win32process.GetWindowThreadProcessId(hwnd)
|
thread_ud, process_id = win32process.GetWindowThreadProcessId(hwnd)
|
||||||
handle = win32api.OpenProcess(0x0410, False, p)
|
handle = win32api.OpenProcess((win32con.PROCESS_VM_READ | win32con.PROCESS_QUERY_INFORMATION),
|
||||||
nama = win32process.GetModuleFileNameEx(handle, 0)
|
False, process_id)
|
||||||
log.debug('module name: %s' % nama)
|
module_name = win32process.GetModuleFileNameEx(handle, 0)
|
||||||
|
log.debug('module name: %s' % module_name)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.debug('could not get window module name')
|
log.debug('could not get window module name')
|
||||||
if size.y() == top and size.height() == (bottom - top) and size.x() == left and size.width() == (right - left):
|
if size.y() == top and size.height() == (bottom - top) and size.x() == left and \
|
||||||
win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
|
size.width() == (right - left) and 'POWERPNT.EXE' in module_name:
|
||||||
win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE,
|
log.debug('Found a match and will save the handle')
|
||||||
win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_TOOLWINDOW)
|
self.presentation_hwnd = hwnd
|
||||||
win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
|
# Stop powerpoint from flashing in the taskbar
|
||||||
|
win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0)
|
||||||
|
|
||||||
def get_slide_number(self):
|
def get_slide_number(self):
|
||||||
"""
|
"""
|
||||||
@ -458,6 +467,9 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
if self.get_slide_number() > self.get_slide_count():
|
if self.get_slide_number() > self.get_slide_count():
|
||||||
log.debug('past end, stepping back to previous')
|
log.debug('past end, stepping back to previous')
|
||||||
self.previous_step()
|
self.previous_step()
|
||||||
|
# Stop powerpoint from flashing in the taskbar
|
||||||
|
if self.presentation_hwnd:
|
||||||
|
win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0)
|
||||||
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
|
||||||
if len(ScreenList().screen_list) > 1:
|
if len(ScreenList().screen_list) > 1:
|
||||||
Registry().get('main_window').activateWindow()
|
Registry().get('main_window').activateWindow()
|
||||||
|
@ -79,9 +79,6 @@ class PresentationTab(SettingsTab):
|
|||||||
self.ppt_window_check_box = QtGui.QCheckBox(self.powerpoint_group_box)
|
self.ppt_window_check_box = QtGui.QCheckBox(self.powerpoint_group_box)
|
||||||
self.ppt_window_check_box.setObjectName('ppt_window_check_box')
|
self.ppt_window_check_box.setObjectName('ppt_window_check_box')
|
||||||
self.powerpoint_layout.addWidget(self.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)
|
self.left_layout.addWidget(self.powerpoint_group_box)
|
||||||
# Pdf options
|
# Pdf options
|
||||||
self.pdf_group_box = QtGui.QGroupBox(self.left_column)
|
self.pdf_group_box = QtGui.QGroupBox(self.left_column)
|
||||||
@ -132,9 +129,6 @@ class PresentationTab(SettingsTab):
|
|||||||
self.ppt_window_check_box.setText(
|
self.ppt_window_check_box.setText(
|
||||||
translate('PresentationPlugin.PresentationTab',
|
translate('PresentationPlugin.PresentationTab',
|
||||||
'Let PowerPoint control the size and position of the presentation window.'))
|
'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 (PowerPoint 2007 and newer)'))
|
|
||||||
self.pdf_program_check_box.setText(
|
self.pdf_program_check_box.setText(
|
||||||
translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:'))
|
translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:'))
|
||||||
|
|
||||||
@ -162,8 +156,6 @@ class PresentationTab(SettingsTab):
|
|||||||
self.ppt_slide_click_check_box.setEnabled(powerpoint_available)
|
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.setChecked(Settings().value(self.settings_section + '/powerpoint control window'))
|
||||||
self.ppt_window_check_box.setEnabled(powerpoint_available)
|
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
|
# load pdf-program settings
|
||||||
enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program')
|
enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program')
|
||||||
self.pdf_program_check_box.setChecked(enable_pdf_program)
|
self.pdf_program_check_box.setChecked(enable_pdf_program)
|
||||||
@ -206,10 +198,6 @@ class PresentationTab(SettingsTab):
|
|||||||
if Settings().value(setting_key) != self.ppt_window_check_box.checkState():
|
if Settings().value(setting_key) != self.ppt_window_check_box.checkState():
|
||||||
Settings().setValue(setting_key, self.ppt_window_check_box.checkState())
|
Settings().setValue(setting_key, self.ppt_window_check_box.checkState())
|
||||||
changed = True
|
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
|
# Save pdf-settings
|
||||||
pdf_program = self.pdf_program_path.text()
|
pdf_program = self.pdf_program_path.text()
|
||||||
enable_pdf_program = self.pdf_program_check_box.checkState()
|
enable_pdf_program = self.pdf_program_check_box.checkState()
|
||||||
|
@ -46,8 +46,7 @@ __default_settings__ = {'presentations/override app': QtCore.Qt.Unchecked,
|
|||||||
'presentations/presentations files': [],
|
'presentations/presentations files': [],
|
||||||
'presentations/thumbnail_scheme': '',
|
'presentations/thumbnail_scheme': '',
|
||||||
'presentations/powerpoint slide click advance': QtCore.Qt.Unchecked,
|
'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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user