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
-import call_handler
from util import qtpie
from util import qwrappers
from util import qui_utils
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._voicemailRefreshDelay.setInterval(30 * 1000)
self._voicemailRefreshDelay.timeout.connect(self._on_call_missed)
self._voicemailRefreshDelay.setSingleShot(True)
- self._callHandler = call_handler.MissedCallWatcher()
- self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
+ self._callHandler = None
+ self._updateVoicemailOnMissedCall = False
self._defaultCredentials = "", ""
self._curentCredentials = "", ""
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._app.notifyOnMissed = config.getboolean("2 - Account Info", "notifyOnMissed")
self._app.notifyOnVoicemail = config.getboolean("2 - Account Info", "notifyOnVoicemail")
self._app.notifyOnSms = config.getboolean("2 - Account Info", "notifyOnSms")
+ self._updateVoicemailOnMissedCall = config.getboolean("2 - Account Info", "updateVoicemailOnMissedCall")
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)
config.set("2 - Account Info", "notifyOnMissed", repr(self._app.notifyOnMissed))
config.set("2 - Account Info", "notifyOnVoicemail", repr(self._app.notifyOnVoicemail))
config.set("2 - Account Info", "notifyOnSms", repr(self._app.notifyOnSms))
+ config.set("2 - Account Info", "updateVoicemailOnMissedCall", repr(self._updateVoicemailOnMissedCall))
backendId = 2 # For backwards compatibility
for tabIndex, tabTitle in enumerate(self._TAB_TITLES):
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"
import dialogs
self._accountDialog = dialogs.AccountDialog(self._app)
self._accountDialog.setIfNotificationsSupported(self._app.alarmHandler.backgroundNotificationsSupported)
+
+ if self._callHandler is None or not self._callHandler.isSupported:
+ self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_NOT_SUPPORTED
+ elif self._updateVoicemailOnMissedCall:
+ self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_ENABLED
+ else:
+ self._accountDialog.updateVMOnMissedCall = self._accountDialog.VOICEMAIL_CHECK_DISABLED
self._accountDialog.notifications = self._app.alarmHandler.alarmType
self._accountDialog.notificationTime = self._app.alarmHandler.recurrence
self._accountDialog.notifyOnMissed = self._app.notifyOnMissed
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:
callbackNumber = self._accountDialog.selectedCallback
self._session.set_callback_number(callbackNumber)
+ if self._callHandler is None or self._accountDialog.updateVMOnMissedCall == self._accountDialog.VOICEMAIL_CHECK_DISABLEDD:
+ pass
+ elif self._accountDialog.updateVMOnMissedCall == self._accountDialog.VOICEMAIL_CHECK_ENABLED:
+ self._updateVoicemailOnMissedCall = True
+ self._callHandler.start()
+ else:
+ self._updateVoicemailOnMissedCall = False
+ self._callHandler.stop()
if (
self._accountDialog.notifyOnMissed or
self._accountDialog.notifyOnVoicemail or
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):
for tab in self._tabsContents:
tab.enable()
self._initialize_tab(self._currentTab)
- self._callHandler.start()
-
- @QtCore.pyqtSlot()
+ if self._updateVoicemailOnMissedCall:
+ if self._callHandler is None:
+ import call_handler
+ self._callHandler = call_handler.MissedCallWatcher()
+ self._callHandler.callMissed.connect(self._voicemailRefreshDelay.start)
+ self._callHandler.start()
+
+ @qt_compat.Slot()
@misc_utils.log_exception(_moduleLogger)
def _on_logout(self):
with qui_utils.notify_error(self._errorLog):
for tab in self._tabsContents:
tab.disable()
- self._callHandler.stop()
+ 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):