import logging
import logging.handlers
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
import constants
import alarm_handler
def _new_main_window(self):
return MainWindow(None, self)
- @QtCore.pyqtSlot()
- @QtCore.pyqtSlot(bool)
+ @qt_compat.Slot()
+ @qt_compat.Slot(bool)
@misc_utils.log_exception(_moduleLogger)
def _on_about(self, checked = True):
with qui_utils.notify_error(self._errorLog):
def __init__(self, parent, app):
qwrappers.WindowWrapper.__init__(self, parent, app)
self._window.setWindowTitle("%s" % constants.__pretty_app_name__)
+ self._window.resized.connect(self._on_window_resized)
self._errorLog = self._app.errorLog
self._session = session.Session(self._errorLog, constants._data_path_)
self._initialize_tab(self._tabWidget.currentIndex())
self.set_fullscreen(self._app.fullscreenAction.isChecked())
- self.set_orientation(self._app.orientationAction.isChecked())
+ self.update_orientation(self._app.orientation)
def set_default_credentials(self, username, password):
self._defaultCredentials = username, password
def load_settings(self, config):
blobs = "", ""
isFullscreen = False
- isPortrait = qui_utils.screen_orientation() == QtCore.Qt.Vertical
+ orientation = self._app.orientation
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")
+ orientation = config.get(constants.__pretty_app_name__, "orientation")
except ConfigParser.NoOptionError, e:
_moduleLogger.info(
"Settings file %s is missing option %s" % (
)
self.set_default_credentials(*creds)
self._app.fullscreenAction.setChecked(isFullscreen)
- self._app.orientationAction.setChecked(isPortrait)
+ self._app.set_orientation(orientation)
self.set_current_tab(tabIndex)
backendId = 2 # For backwards compatibility
config.add_section(constants.__pretty_app_name__)
config.set(constants.__pretty_app_name__, "tab", str(self.get_current_tab()))
config.set(constants.__pretty_app_name__, "fullscreen", str(self._app.fullscreenAction.isChecked()))
- config.set(constants.__pretty_app_name__, "portrait", str(self._app.orientationAction.isChecked()))
+ config.set(constants.__pretty_app_name__, "orientation", str(self._app.orientation))
for i, value in enumerate(self.get_default_credentials()):
blob = base64.b64encode(value)
config.set(constants.__pretty_app_name__, "bin_blob_%i" % i, blob)
for settingName, settingValue in tabSettings.iteritems():
config.set(sectionName, settingName, settingValue)
- def set_orientation(self, isPortrait):
- qwrappers.WindowWrapper.set_orientation(self, isPortrait)
- if isPortrait:
- self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
- else:
+ def update_orientation(self, orientation):
+ qwrappers.WindowWrapper.update_orientation(self, orientation)
+ windowOrientation = self.idealWindowOrientation
+ if windowOrientation == QtCore.Qt.Horizontal:
self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
+ else:
+ self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
def _initialize_tab(self, index):
assert index < self.MAX_TABS, "Invalid tab"
if not accountNumberToDisplay:
accountNumberToDisplay = "Not Available (%s)" % self._session.state
self._accountDialog.set_account_number(accountNumberToDisplay)
+ self._accountDialog.orientation = self._app.orientation
+
response = self._accountDialog.run(self.window)
if response == QtGui.QDialog.Accepted:
if self._accountDialog.doClear:
self._app.notifyOnMissed = self._accountDialog.notifyOnMissed
self._app.notifyOnVoicemail = self._accountDialog.notifyOnVoicemail
self._app.notifyOnSms = self._accountDialog.notifyOnSms
+ self._app.set_orientation(self._accountDialog.orientation)
self._app.save_settings()
elif response == QtGui.QDialog.Rejected:
_moduleLogger.info("Cancelled")
else:
_moduleLogger.info("Unknown response")
- @QtCore.pyqtSlot()
+ @qt_compat.Slot()
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_window_resized(self):
+ with qui_utils.notify_error(self._app.errorLog):
+ windowOrientation = self.idealWindowOrientation
+ if windowOrientation == QtCore.Qt.Horizontal:
+ self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
+ else:
+ self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
+
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_new_message_alert(self):
with qui_utils.notify_error(self._errorLog):
else:
self._app.ledHandler.on()
- @QtCore.pyqtSlot()
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_call_missed(self):
with qui_utils.notify_error(self._errorLog):
self._session.update_messages(self._session.MESSAGE_VOICEMAILS, force=True)
- @QtCore.pyqtSlot(str)
+ @qt_compat.Slot(str)
@misc_utils.log_exception(_moduleLogger)
def _on_session_error(self, message):
with qui_utils.notify_error(self._errorLog):
self._errorLog.push_error(message)
- @QtCore.pyqtSlot()
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_login(self):
with qui_utils.notify_error(self._errorLog):
self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
self._callHandler.start()
- @QtCore.pyqtSlot()
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_logout(self):
with qui_utils.notify_error(self._errorLog):
if self._callHandler is not None:
self._callHandler.stop()
- @QtCore.pyqtSlot()
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_app_alert(self):
with qui_utils.notify_error(self._errorLog):
}[(self._app.notifyOnSms, self._app.notifyOnVoicemail)]
self._session.update_messages(messageType, force=True)
- @QtCore.pyqtSlot()
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_recipients_changed(self):
with qui_utils.notify_error(self._errorLog):
def _on_child_close(self, obj = None):
self._smsEntryDialog = None
- @QtCore.pyqtSlot()
- @QtCore.pyqtSlot(bool)
+ @qt_compat.Slot()
+ @qt_compat.Slot(bool)
@misc_utils.log_exception(_moduleLogger)
def _on_login_requested(self, checked = True):
with qui_utils.notify_error(self._errorLog):
self._prompt_for_login()
- @QtCore.pyqtSlot(int)
+ @qt_compat.Slot(int)
@misc_utils.log_exception(_moduleLogger)
def _on_tab_changed(self, index):
with qui_utils.notify_error(self._errorLog):
if self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_APPLICATION:
self._app.ledHandler.off()
- @QtCore.pyqtSlot()
- @QtCore.pyqtSlot(bool)
+ @qt_compat.Slot()
+ @qt_compat.Slot(bool)
@misc_utils.log_exception(_moduleLogger)
def _on_refresh(self, checked = True):
with qui_utils.notify_error(self._errorLog):
self._tabsContents[self._currentTab].refresh(force=True)
- @QtCore.pyqtSlot()
- @QtCore.pyqtSlot(bool)
+ @qt_compat.Slot()
+ @qt_compat.Slot(bool)
@misc_utils.log_exception(_moduleLogger)
def _on_refresh_connection(self, checked = True):
with qui_utils.notify_error(self._errorLog):
self._session.refresh_connection()
- @QtCore.pyqtSlot()
- @QtCore.pyqtSlot(bool)
+ @qt_compat.Slot()
+ @qt_compat.Slot(bool)
@misc_utils.log_exception(_moduleLogger)
def _on_import(self, checked = True):
with qui_utils.notify_error(self._errorLog):
if self._tabsContents[self.CONTACTS_TAB].has_child:
self._tabsContents[self.CONTACTS_TAB].child.update_addressbooks()
- @QtCore.pyqtSlot()
- @QtCore.pyqtSlot(bool)
+ @qt_compat.Slot()
+ @qt_compat.Slot(bool)
@misc_utils.log_exception(_moduleLogger)
def _on_account(self, checked = True):
with qui_utils.notify_error(self._errorLog):