Adding orientation to the account dialog
authorEd Page <eopage@byu.net>
Tue, 19 Apr 2011 02:24:23 +0000 (21:24 -0500)
committerEd Page <eopage@byu.net>
Tue, 19 Apr 2011 23:49:33 +0000 (18:49 -0500)
src/dialcentral_qt.py
src/dialogs.py
src/util/qui_utils.py
src/util/qwrappers.py

index 4a789f4..99bf92b 100755 (executable)
@@ -458,7 +458,7 @@ class MainWindow(qwrappers.WindowWrapper):
                )
                self.set_default_credentials(*creds)
                self._app.fullscreenAction.setChecked(isFullscreen)
-               self.update_orientation(orientation)
+               self._app.set_orientation(orientation)
                self.set_current_tab(tabIndex)
 
                backendId = 2 # For backwards compatibility
@@ -567,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:
@@ -600,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")
index 0e1a92e..cbdeaf9 100644 (file)
@@ -199,6 +199,14 @@ class AccountDialog(object):
                self._callbackSelector = QtGui.QComboBox()
                #self._callbackSelector.setEditable(True)
                self._callbackSelector.setInsertPolicy(QtGui.QComboBox.InsertAtTop)
+               self._orientationSelector = QtGui.QComboBox()
+               for orientationMode in [
+                       self._app.DEFAULT_ORIENTATION,
+                       self._app.AUTO_ORIENTATION,
+                       self._app.LANDSCAPE_ORIENTATION,
+                       self._app.PORTRAIT_ORIENTATION,
+               ]:
+                       self._orientationSelector.addItem(orientationMode)
 
                self._update_notification_state()
 
@@ -217,9 +225,12 @@ class AccountDialog(object):
                self._credLayout.addWidget(self._smsNotificationButton, 5, 1)
                self._credLayout.addWidget(QtGui.QLabel("Other"), 6, 0)
                self._credLayout.addWidget(self._voicemailOnMissedButton, 6, 1)
+               self._credLayout.addWidget(QtGui.QLabel("Orientation"), 7, 0)
+               self._credLayout.addWidget(self._orientationSelector, 7, 1)
+               self._credLayout.addWidget(QtGui.QLabel(""), 8, 0)
+               self._credLayout.addWidget(QtGui.QLabel(""), 9, 0)
+               self._credLayout.addWidget(self._clearButton, 9, 1)
 
-               self._credLayout.addWidget(QtGui.QLabel(""), 7, 0)
-               self._credLayout.addWidget(self._clearButton, 7, 1)
                self._credWidget = QtGui.QWidget()
                self._credWidget.setLayout(self._credLayout)
                self._credWidget.setContentsMargins(0, 0, 0, 0)
@@ -275,6 +286,11 @@ class AccountDialog(object):
        def set_account_number(self, num):
                self._accountNumberLabel.setText(num)
 
+       orientation = property(
+               lambda self: str(self._orientationSelector.currentText()),
+               lambda self, mode: qui_utils.set_current_index(self._orientationSelector, mode),
+       )
+
        def _set_voicemail_on_missed(self, status):
                if status == self.VOICEMAIL_CHECK_NOT_SUPPORTED:
                        self._voicemailOnMissedButton.setChecked(False)
@@ -298,17 +314,9 @@ class AccountDialog(object):
 
        updateVMOnMissedCall = property(_get_voicemail_on_missed, _set_voicemail_on_missed)
 
-       def _set_notifications(self, enabled):
-               for i in xrange(self._notificationSelecter.count()):
-                       if self._notificationSelecter.itemText(i) == enabled:
-                               self._notificationSelecter.setCurrentIndex(i)
-                               break
-               else:
-                       self._notificationSelecter.setCurrentIndex(0)
-
        notifications = property(
                lambda self: str(self._notificationSelecter.currentText()),
-               _set_notifications,
+               lambda self, enabled: qui_utils.set_current_index(self._notificationSelecter, enabled),
        )
 
        notifyOnMissed = property(
index 325dc6e..ac43ee6 100644 (file)
@@ -293,6 +293,14 @@ class QSignalingMainWindow(QtGui.QMainWindow):
                self.resized.emit()
                return val
 
+def set_current_index(selector, itemText, default = 0):
+       for i in xrange(selector.count()):
+               if selector.itemText(i) == itemText:
+                       selector.setCurrentIndex(i)
+                       break
+       else:
+               itemText.setCurrentIndex(default)
+
 
 def _null_set_stackable(window, isStackable):
        pass
index 1f5b8ea..65ec755 100644 (file)
@@ -116,6 +116,10 @@ class ApplicationWrapper(object):
        def quitAction(self):
                return self._quitAction
 
+       def set_orientation(self, orientation):
+               self._orientation = orientation
+               self._mainWindow.update_orientation(self._orientation)
+
        @classmethod
        def _next_orientation(cls, current):
                return {
@@ -156,8 +160,7 @@ class ApplicationWrapper(object):
        @misc_utils.log_exception(_moduleLogger)
        def _on_next_orientation(self, checked = False):
                with qui_utils.notify_error(self._errorLog):
-                       self._orientation = self._next_orientation(self._orientation)
-                       self._mainWindow.update_orientation(self._orientation)
+                       self.set_orientation(self._next_orientation(self._orientation))
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_about(self, checked = True):