self._fullscreenAction.setShortcut(QtGui.QKeySequence("CTRL+Enter"))
self._fullscreenAction.toggled.connect(self._on_toggle_fullscreen)
+ self._orientationAction = QtGui.QAction(None)
+ self._orientationAction.setText("Orientation")
+ self._orientationAction.setCheckable(True)
+ self._orientationAction.setShortcut(QtGui.QKeySequence("CTRL+o"))
+ self._orientationAction.toggled.connect(self._on_toggle_orientation)
+
self._logAction = QtGui.QAction(None)
self._logAction.setText("Log")
self._logAction.setShortcut(QtGui.QKeySequence("CTRL+l"))
blobs = "", ""
isFullscreen = False
+ isPortrait = qui_utils.screen_orientation() == QtCore.Qt.Vertical
tabIndex = 0
try:
blobs = [
]
isFullscreen = config.getboolean(constants.__pretty_app_name__, "fullscreen")
tabIndex = config.getint(constants.__pretty_app_name__, "tab")
+ isPortrait = config.getboolean(constants.__pretty_app_name__, "portrait")
except ConfigParser.NoOptionError, e:
_moduleLogger.info(
"Settings file %s is missing option %s" % (
)
self._mainWindow.set_default_credentials(*creds)
self._fullscreenAction.setChecked(isFullscreen)
+ self._orientationAction.setChecked(isPortrait)
self._mainWindow.set_current_tab(tabIndex)
self._mainWindow.load_settings(config)
config.add_section(constants.__pretty_app_name__)
config.set(constants.__pretty_app_name__, "tab", str(self._mainWindow.get_current_tab()))
config.set(constants.__pretty_app_name__, "fullscreen", str(self._fullscreenAction.isChecked()))
+ config.set(constants.__pretty_app_name__, "portrait", str(self._orientationAction.isChecked()))
for i, value in enumerate(self._mainWindow.get_default_credentials()):
blob = base64.b64encode(value)
config.set(constants.__pretty_app_name__, "bin_blob_%i" % i, blob)
return self._fullscreenAction
@property
+ def orientationAction(self):
+ return self._orientationAction
+
+ @property
def logAction(self):
return self._logAction
@QtCore.pyqtSlot()
@QtCore.pyqtSlot(bool)
@misc_utils.log_exception(_moduleLogger)
+ def _on_toggle_orientation(self, checked = False):
+ for window in self._walk_children():
+ window.set_orientation(checked)
+
+ @QtCore.pyqtSlot()
+ @QtCore.pyqtSlot(bool)
+ @misc_utils.log_exception(_moduleLogger)
def _on_log(self, checked = False):
with open(constants._user_logpath_, "r") as f:
logLines = f.xreadlines()
self._window = QtGui.QMainWindow(parent)
self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
- qui_utils.set_autorient(self._window, True)
qui_utils.set_stackable(self._window, True)
self._window.setWindowTitle("%s" % constants.__pretty_app_name__)
self._window.setCentralWidget(centralWidget)
self._window.addAction(self._closeWindowAction)
self._window.addAction(self._app.quitAction)
self._window.addAction(self._app.fullscreenAction)
+ self._window.addAction(self._app.orientationAction)
else:
fileMenu = self._window.menuBar().addMenu("&File")
fileMenu.addAction(self._loginTabAction)
toolsMenu.addAction(self._importTabAction)
toolsMenu.addAction(self._aboutAction)
+ self._window.addAction(self._app.orientationAction)
+
self._window.addAction(self._app.logAction)
self._initialize_tab(self._tabWidget.currentIndex())
self.set_fullscreen(self._app.fullscreenAction.isChecked())
+ self.set_orientation(self._app.orientationAction.isChecked())
@property
def window(self):
for child in self.walk_children():
child.set_fullscreen(isFullscreen)
+ def set_orientation(self, isPortrait):
+ if isPortrait:
+ self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
+ qui_utils.set_window_orientation(QtCore.Qt.Vertical)
+ else:
+ self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
+ qui_utils.set_window_orientation(QtCore.Qt.Horizontal)
+ for child in self.walk_children():
+ child.set_orientation(isPortrait)
+
def _initialize_tab(self, index):
assert index < self.MAX_TABS, "Invalid tab"
if not self._tabsContents[index].has_child():
self._dialog.setWindowTitle("Login")
self._dialog.setLayout(self._layout)
self._dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose, False)
- qui_utils.set_autorient(self._dialog, True)
self._buttonLayout.accepted.connect(self._dialog.accept)
self._buttonLayout.rejected.connect(self._dialog.reject)
self._dialog = QtGui.QDialog()
self._dialog.setWindowTitle("About")
self._dialog.setLayout(self._layout)
- qui_utils.set_autorient(self._dialog, True)
self._buttonLayout.rejected.connect(self._dialog.reject)
self._closeWindowAction = QtGui.QAction(None)
self._dialog = QtGui.QDialog()
self._dialog.setWindowTitle("Account")
self._dialog.setLayout(self._layout)
- qui_utils.set_autorient(self._dialog, True)
self._buttonLayout.accepted.connect(self._dialog.accept)
self._buttonLayout.rejected.connect(self._dialog.reject)
centralWidget.setLayout(self._layout)
self._window = QtGui.QMainWindow(parent)
- qui_utils.set_autorient(self._window, True)
+ qui_utils.set_window_orientation(QtCore.Qt.Horizontal)
qui_utils.set_stackable(self._window, True)
self._window.setWindowTitle("Contact")
self._window.setCentralWidget(centralWidget)
def _maemo_set_autorient(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
+ window.setAttribute(QtCore.Qt.WA_Maemo5AutoOrientation, isStackable)
try:
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 screen_orientation():
+ geom = QtGui.QApplication.desktop().screenGeometry()
+ if geom.width() <= geom.height():
+ return QtCore.Qt.Vertical
+ else:
+ return QtCore.Qt.Horizontal
-def _null_set_portrait(window, isStackable):
+def _null_set_window_orientation(window, orientation):
pass
-def _maemo_set_portrait(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
+def _maemo_set_window_orientation(window, orientation):
+ if orientation == QtCore.Qt.Vertical:
+ newHint = QtCore.Qt.WA_Maemo5LandscapeOrientation
+ oldHint = QtCore.Qt.WA_Maemo5PortraitOrientation
+ elif orientation == QtCore.Qt.Horizontal:
+ oldHint = QtCore.Qt.WA_Maemo5LandscapeOrientation
+ newHint = QtCore.Qt.WA_Maemo5PortraitOrientation
+ window.setAttribute(oldHint, False)
+ window.setAttribute(newHint, True)
try:
+ QtCore.Qt.WA_Maemo5LandscapeOrientation
QtCore.Qt.WA_Maemo5PortraitOrientation
- set_portrait = _maemo_set_portrait
+ set_window_orientation = _maemo_set_window_orientation
except AttributeError:
- set_portrait = _null_set_portrait
+ set_window_orientation = _null_set_window_orientation
def _null_show_progress_indicator(window, isStackable):
def _maemo_show_progress_indicator(window, isStackable):
- window.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, isStackable)
+ window.setAttribute(QtCore.Qt.WA_Maemo5ShowProgressIndicator, isStackable)
try:
mark_numbers_preferred = _null_mark_numbers_preferred
-def screen_orientation():
- geom = QtGui.QApplication.desktop().screenGeometry()
- if geom.width() <= geom.height():
- return QtCore.Qt.Vertical
- else:
- return QtCore.Qt.Horizontal
-
-
def _null_get_theme_icon(iconNames, fallback = None):
icon = fallback if fallback is not None else QtGui.QIcon()
return icon