Exemple #1
0
	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

		cachePath = linux_utils.get_resource_path("cache", constants.__app_name__)
		self._session = session.Session(self._errorLog, cachePath)
		self._session.error.connect(self._on_session_error)
		self._session.loggedIn.connect(self._on_login)
		self._session.loggedOut.connect(self._on_logout)
		self._session.draft.recipientsChanged.connect(self._on_recipients_changed)
		self._session.newMessages.connect(self._on_new_message_alert)
		self._app.alarmHandler.applicationNotifySignal.connect(self._on_app_alert)
		self._voicemailRefreshDelay = QtCore.QTimer()
		self._voicemailRefreshDelay.setInterval(30 * 1000)
		self._voicemailRefreshDelay.timeout.connect(self._on_call_missed)
		self._voicemailRefreshDelay.setSingleShot(True)
		self._callHandler = None
		self._updateVoicemailOnMissedCall = False

		self._defaultCredentials = "", ""
		self._curentCredentials = "", ""
		self._currentTab = 0

		self._credentialsDialog = None
		self._smsEntryDialog = None
		self._accountDialog = None

		self._tabsContents = [
			DelayedWidget(self._app, self._TAB_SETTINGS_NAMES[i])
			for i in xrange(self.MAX_TABS)
		]
		for tab in self._tabsContents:
			tab.disable()

		self._tabWidget = QtGui.QTabWidget()
		if qui_utils.screen_orientation() == QtCore.Qt.Vertical:
			self._tabWidget.setTabPosition(QtGui.QTabWidget.South)
		else:
			self._tabWidget.setTabPosition(QtGui.QTabWidget.West)
		defaultTabIconSize = self._tabWidget.iconSize()
		defaultTabIconWidth, defaultTabIconHeight = defaultTabIconSize.width(), defaultTabIconSize.height()
		for tabIndex, (tabTitle, tabIcon) in enumerate(
			zip(self._TAB_TITLES, self._TAB_ICONS)
		):
			icon = self._app.get_icon(tabIcon)
			if constants.IS_MAEMO and icon is not None:
				tabTitle = ""

			if icon is None:
				self._tabWidget.addTab(self._tabsContents[tabIndex].toplevel, tabTitle)
			else:
				iconSize = icon.availableSizes()[0]
				defaultTabIconWidth = max(defaultTabIconWidth, iconSize.width())
				defaultTabIconHeight = max(defaultTabIconHeight, iconSize.height())
				self._tabWidget.addTab(self._tabsContents[tabIndex].toplevel, icon, tabTitle)
		defaultTabIconWidth = max(defaultTabIconWidth, 32)
		defaultTabIconHeight = max(defaultTabIconHeight, 32)
		self._tabWidget.setIconSize(QtCore.QSize(defaultTabIconWidth, defaultTabIconHeight))
		self._tabWidget.currentChanged[int].connect(self._on_tab_changed)
		self._tabWidget.setContentsMargins(0, 0, 0, 0)

		self._layout.addWidget(self._tabWidget)

		self._loginAction = QtGui.QAction(None)
		self._loginAction.setText("Login")
		self._loginAction.triggered.connect(self._on_login_requested)

		self._importAction = QtGui.QAction(None)
		self._importAction.setText("Import")
		self._importAction.triggered.connect(self._on_import)

		self._accountAction = QtGui.QAction(None)
		self._accountAction.setText("Account")
		self._accountAction.triggered.connect(self._on_account)

		self._refreshConnectionAction = QtGui.QAction(None)
		self._refreshConnectionAction.setText("Refresh Connection")
		self._refreshConnectionAction.setShortcut(QtGui.QKeySequence("CTRL+a"))
		self._refreshConnectionAction.triggered.connect(self._on_refresh_connection)

		self._refreshTabAction = QtGui.QAction(None)
		self._refreshTabAction.setText("Refresh Tab")
		self._refreshTabAction.setShortcut(QtGui.QKeySequence("CTRL+r"))
		self._refreshTabAction.triggered.connect(self._on_refresh)

		fileMenu = self._window.menuBar().addMenu("&File")
		fileMenu.addAction(self._loginAction)
		fileMenu.addAction(self._refreshTabAction)
		fileMenu.addAction(self._refreshConnectionAction)

		toolsMenu = self._window.menuBar().addMenu("&Tools")
		toolsMenu.addAction(self._accountAction)
		toolsMenu.addAction(self._importAction)
		toolsMenu.addAction(self._app.aboutAction)

		self._initialize_tab(self._tabWidget.currentIndex())
		self.set_fullscreen(self._app.fullscreenAction.isChecked())
		self.update_orientation(self._app.orientation)
Exemple #2
0
	def load_settings(self):
		settingsPath = linux_utils.get_resource_path(
			"config", constants.__app_name__, "settings.json"
		)
		try:
			with open(settingsPath) as settingsFile:
				settings = simplejson.load(settingsFile)
		except IOError, e:
			_moduleLogger.info("No settings")
			settings = {}
		except ValueError:
			_moduleLogger.info("Settings were corrupt")
			settings = {}

		isPortraitDefault = qui_utils.screen_orientation() == QtCore.Qt.Vertical
		self._fullscreenAction.setChecked(settings.get("isFullScreen", False))
		self._orientationAction.setChecked(settings.get("isPortrait", isPortraitDefault))

	def save_settings(self):
		settings = {
			"isFullScreen": self._fullscreenAction.isChecked(),
			"isPortrait": self._orientationAction.isChecked(),
		}

		settingsPath = linux_utils.get_resource_path(
			"config", constants.__app_name__, "settings.json"
		)
		with open(settingsPath, "w") as settingsFile:
			simplejson.dump(settings, settingsFile)