X-Git-Url: http://git.maemo.org/git/?p=gc-dialer;a=blobdiff_plain;f=src%2Fdialcentral_qt.py;h=99bf92b64cd4ca2a27dcd7f53490e8623fbd8c19;hp=4bf128a1fbffd0257791f4e591c76a859dce05eb;hb=4d3f5220e5eda8af2bb541abda59f531bf98e0ff;hpb=15b71884d9c5f1aca07719462ed0030b2d62684f diff --git a/src/dialcentral_qt.py b/src/dialcentral_qt.py index 4bf128a..99bf92b 100755 --- a/src/dialcentral_qt.py +++ b/src/dialcentral_qt.py @@ -256,6 +256,7 @@ class MainWindow(qwrappers.WindowWrapper): 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_) @@ -350,7 +351,7 @@ class MainWindow(qwrappers.WindowWrapper): 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 @@ -401,7 +402,7 @@ class MainWindow(qwrappers.WindowWrapper): def load_settings(self, config): blobs = "", "" isFullscreen = False - isPortrait = qui_utils.screen_orientation() == QtCore.Qt.Vertical + orientation = self._app.orientation tabIndex = 0 try: blobs = [ @@ -410,7 +411,7 @@ class MainWindow(qwrappers.WindowWrapper): ] 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" % ( @@ -457,7 +458,7 @@ class MainWindow(qwrappers.WindowWrapper): ) 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 @@ -493,7 +494,7 @@ class MainWindow(qwrappers.WindowWrapper): 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) @@ -514,12 +515,13 @@ class MainWindow(qwrappers.WindowWrapper): 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" @@ -565,6 +567,8 @@ class MainWindow(qwrappers.WindowWrapper): 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: @@ -598,6 +602,7 @@ class MainWindow(qwrappers.WindowWrapper): 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") @@ -606,6 +611,16 @@ class MainWindow(qwrappers.WindowWrapper): @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): if self._app.alarmHandler.alarmType == self._app.alarmHandler.ALARM_APPLICATION: