From: Ed Page Date: Sat, 5 Jun 2010 17:54:40 +0000 (-0500) Subject: Add stackable windows and auto-rotation (last one is in theory only X-Git-Url: http://git.maemo.org/git/?p=gonvert;a=commitdiff_plain;h=06bdac8c0cfabeba48cdd51b3294aeee238e453b Add stackable windows and auto-rotation (last one is in theory only --- diff --git a/src/gonvert_qt.py b/src/gonvert_qt.py index 44677cf..1c322cc 100755 --- a/src/gonvert_qt.py +++ b/src/gonvert_qt.py @@ -13,6 +13,7 @@ from PyQt4 import QtGui from PyQt4 import QtCore import constants +import maeqt from util import misc as misc_utils import unit_data @@ -55,9 +56,6 @@ def split_number(number): class Gonvert(object): - # @todo get subwindows working - # @todo rotation support - _DATA_PATHS = [ os.path.dirname(__file__), os.path.join(os.path.dirname(__file__), "../data"), @@ -324,6 +322,8 @@ class QuickJump(object): self._window = QtGui.QMainWindow(parent) self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) + maeqt.set_autorient(self._window, True) + maeqt.set_stackable(self._window, True) if parent is not None: self._window.setWindowModality(QtCore.Qt.WindowModal) self._window.setWindowTitle("%s - Quick Jump" % constants.__pretty_app_name__) @@ -416,6 +416,8 @@ class Recent(object): self._window = QtGui.QMainWindow(parent) self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) + maeqt.set_autorient(self._window, True) + maeqt.set_stackable(self._window, True) if parent is not None: self._window.setWindowModality(QtCore.Qt.WindowModal) self._window.setWindowTitle("%s - Recent" % constants.__pretty_app_name__) @@ -521,6 +523,8 @@ class FavoriteCategoriesWindow(object): self._window = QtGui.QMainWindow(parent) self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) + maeqt.set_autorient(self._window, True) + maeqt.set_stackable(self._window, True) if parent is not None: self._window.setWindowModality(QtCore.Qt.WindowModal) self._window.setWindowTitle("%s - Favorites" % constants.__pretty_app_name__) @@ -619,6 +623,8 @@ class CategoryWindow(object): self._window = QtGui.QMainWindow(parent) self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) + maeqt.set_autorient(self._window, True) + maeqt.set_stackable(self._window, True) if parent is not None: self._window.setWindowModality(QtCore.Qt.WindowModal) self._window.setWindowTitle("%s - Categories" % constants.__pretty_app_name__) @@ -1023,6 +1029,8 @@ class UnitWindow(object): self._window = QtGui.QMainWindow(parent) self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) + maeqt.set_autorient(self._window, True) + maeqt.set_stackable(self._window, True) if parent is not None: self._window.setWindowModality(QtCore.Qt.WindowModal) self._window.setWindowTitle("%s - %s" % (constants.__pretty_app_name__, category)) diff --git a/src/maeqt.py b/src/maeqt.py new file mode 100644 index 0000000..b4c95a8 --- /dev/null +++ b/src/maeqt.py @@ -0,0 +1,76 @@ +from PyQt4 import QtCore + + +def _null_set_stackable(window, isStackable): + pass + + +def _maemo_set_stackable(window, isStackable): + window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable) + + +try: + QtCore.Qt.WA_Maemo5StackedWindow + set_stackable = _maemo_set_stackable +except AttributeError: + set_stackable = _null_set_stackable + + +def _null_set_autorient(window, isStackable): + pass + + +def _maemo_set_autorient(window, isStackable): + window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable) + + +try: + QtCore.Qt.WA_Maemo5AutoOrientation + set_autorient = _maemo_set_autorient +except AttributeError: + set_autorient = _null_set_autorient + + +def _null_set_landscape(window, isStackable): + pass + + +def _maemo_set_landscape(window, isStackable): + window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable) + + +try: + QtCore.Qt.WA_Maemo5LandscapeOrientation + set_landscape = _maemo_set_landscape +except AttributeError: + set_landscape = _null_set_landscape + + +def _null_set_portrait(window, isStackable): + pass + + +def _maemo_set_portrait(window, isStackable): + window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable) + + +try: + QtCore.Qt.WA_Maemo5PortraitOrientation + set_portrait = _maemo_set_portrait +except AttributeError: + set_portrait = _null_set_portrait + + +def _null_show_progress_indicator(window, isStackable): + pass + + +def _maemo_show_progress_indicator(window, isStackable): + window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable) + + +try: + QtCore.Qt.WA_Maemo5ShowProgressIndicator + show_progress_indicator = _maemo_show_progress_indicator +except AttributeError: + show_progress_indicator = _null_show_progress_indicator