+ def get_current_tab(self):
+ return self._currentTab
+
+ def set_current_tab(self, tabIndex):
+ self._tabWidget.setCurrentIndex(tabIndex)
+
+ def load_settings(self, config):
+ blobs = "", ""
+ isFullscreen = False
+ isPortrait = qui_utils.screen_orientation() == QtCore.Qt.Vertical
+ tabIndex = 0
+ try:
+ blobs = [
+ config.get(constants.__pretty_app_name__, "bin_blob_%i" % i)
+ for i in xrange(len(self.get_default_credentials()))
+ ]
+ 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" % (
+ constants._user_settings_,
+ e.option,
+ ),
+ )
+ except ConfigParser.NoSectionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing section %s" % (
+ constants._user_settings_,
+ e.section,
+ ),
+ )
+ except Exception:
+ _moduleLogger.exception("Unknown loading error")
+
+ try:
+ self._app.alarmHandler.load_settings(config, "alarm")
+ 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" % (
+ constants._user_settings_,
+ e.option,
+ ),
+ )
+ except ConfigParser.NoSectionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing section %s" % (
+ constants._user_settings_,
+ e.section,
+ ),
+ )
+ except Exception:
+ _moduleLogger.exception("Unknown loading error")
+
+ creds = (
+ base64.b64decode(blob)
+ for blob in blobs
+ )
+ self.set_default_credentials(*creds)
+ self._app.fullscreenAction.setChecked(isFullscreen)
+ self._app.orientationAction.setChecked(isPortrait)
+ self.set_current_tab(tabIndex)
+
+ backendId = 2 # For backwards compatibility
+ for tabIndex, tabTitle in enumerate(self._TAB_TITLES):
+ sectionName = "%s - %s" % (backendId, tabTitle)
+ settings = self._tabsContents[tabIndex].get_settings()
+ for settingName in settings.iterkeys():
+ try:
+ settingValue = config.get(sectionName, settingName)
+ except ConfigParser.NoOptionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing section %s" % (
+ constants._user_settings_,
+ e.section,
+ ),
+ )
+ return
+ except ConfigParser.NoSectionError, e:
+ _moduleLogger.info(
+ "Settings file %s is missing section %s" % (
+ constants._user_settings_,
+ e.section,
+ ),
+ )
+ return
+ except Exception:
+ _moduleLogger.exception("Unknown loading error")
+ return
+ settings[settingName] = settingValue
+ self._tabsContents[tabIndex].set_settings(settings)
+
+ def save_settings(self, config):
+ 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()))
+ 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.add_section("alarm")
+ self._app.alarmHandler.save_settings(config, "alarm")
+ config.add_section("2 - Account Info")
+ 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):
+ sectionName = "%s - %s" % (backendId, tabTitle)
+ config.add_section(sectionName)
+ tabSettings = self._tabsContents[tabIndex].get_settings()
+ 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)