openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #26661
[Merge] lp:~springermac/openlp/mac_dock_fix into lp:openlp
Raoul Snyman has proposed merging lp:~springermac/openlp/mac_dock_fix into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Related bugs:
Bug #1247661 in OpenLP: "Cannot restore OpenLP after minimising on OSX"
https://bugs.launchpad.net/openlp/+bug/1247661
For more details, see:
https://code.launchpad.net/~springermac/openlp/mac_dock_fix/+merge/257466
Fix bug 1247661 by restoring to main window when the dock icon is clicked
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py 2015-01-22 20:12:23 +0000
+++ openlp/core/__init__.py 2015-04-25 18:57:58 +0000
@@ -250,7 +250,7 @@
def event(self, event):
"""
- Enables direct file opening on OS X
+ Enables platform specific event handling i.e. direct file opening on OS X
:param event: The event
"""
@@ -259,8 +259,19 @@
log.debug('Got open file event for %s!', file_name)
self.args.insert(0, file_name)
return True
- else:
- return QtGui.QApplication.event(self, event)
+ # Mac OS X should restore app window when user clicked on the OpenLP icon
+ # in the Dock bar. However, OpenLP consists of multiple windows and this
+ # does not work. This workaround fixes that.
+ # The main OpenLP window is restored when it was previously minimized.
+ elif event.type() == QtCore.QEvent.ApplicationActivate:
+ if is_macosx() and hasattr(self, 'main_window'):
+ if self.main_window.isMinimized():
+ # Copied from QWidget.setWindowState() docs on how to restore and activate a minimized window
+ # while preserving its maximized and/or full-screen state.
+ self.main_window.setWindowState(self.main_window.windowState() & ~QtCore.Qt.WindowMinimized |
+ QtCore.Qt.WindowActive)
+ return True
+ return QtGui.QApplication.event(self, event)
def parse_options(args):
=== modified file 'tests/functional/test_init.py'
--- tests/functional/test_init.py 2015-03-31 20:58:51 +0000
+++ tests/functional/test_init.py 2015-04-25 18:57:58 +0000
@@ -66,6 +66,22 @@
mocked_file_method.assert_called_once_with()
self.assertEqual(self.openlp.args[0], file_path, "The path should be in args.")
+ def application_activate_event_test(self):
+ """
+ Test that clicking on the dock icon on Mac OS X restores the main window if it is minimized
+ """
+ # GIVEN:
+ with patch('openlp.core.is_macosx') as mocked_is_macosx:
+ mocked_is_macosx.return_value = True
+ event = QtCore.QEvent(QtCore.QEvent.ApplicationActivate)
+
+ # WHEN:
+ result = self.openlp.event(event)
+
+ # THEN:
+ self.assertTrue(result, "The method should have returned True.")
+ self.assertFalse(self.openlp.main_window.isMinimized())
+
def backup_on_upgrade_first_install_test(self):
"""
Test that we don't try to backup on a new install
Follow ups