summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/statuspanel.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-09-05 22:38:57 +0200
committerKali Kaneko <kali@leap.se>2013-09-05 22:38:57 +0200
commit9a82c662bbc334a66f3aa021f1bbbc1f32cddcc8 (patch)
tree82e2ead16de0535c3f4e5db7f1e5381339eb5cd6 /src/leap/bitmask/gui/statuspanel.py
parentc1203f645af746f1eb2ea9d8140035586b123ff4 (diff)
parent58420cb3d10cd5eceacbd88a6bc7fdfdc4a85f88 (diff)
Merge remote-tracking branch 'ivan-github/feature/3659_display-mx-status-in-tray' into develop
Diffstat (limited to 'src/leap/bitmask/gui/statuspanel.py')
-rw-r--r--src/leap/bitmask/gui/statuspanel.py50
1 files changed, 38 insertions, 12 deletions
diff --git a/src/leap/bitmask/gui/statuspanel.py b/src/leap/bitmask/gui/statuspanel.py
index 49d7e24a..3a91f08e 100644
--- a/src/leap/bitmask/gui/statuspanel.py
+++ b/src/leap/bitmask/gui/statuspanel.py
@@ -356,6 +356,16 @@ class StatusPanelWidget(QtGui.QWidget):
leap_assert_type(action_eip_status, QtGui.QAction)
self._action_eip_status = action_eip_status
+ def set_action_mail_status(self, action_mail_status):
+ """
+ Sets the action_mail_status to use.
+
+ :param action_mail_status: action_mail_status to be used
+ :type action_mail_status: QtGui.QAction
+ """
+ leap_assert_type(action_mail_status, QtGui.QAction)
+ self._action_mail_status = action_mail_status
+
def set_global_status(self, status, error=False):
"""
Sets the global status label.
@@ -538,6 +548,27 @@ class StatusPanelWidget(QtGui.QWidget):
def set_provider(self, provider):
self.ui.lblProvider.setText(provider)
+ def _set_mail_status(self, status, ready=False):
+ """
+ Sets the Encrypted Mail status in the label and in the tray icon.
+
+ :param status: the status text to display
+ :type status: unicode
+ :param ready: if mx is ready or not.
+ :type ready: bool
+ """
+ self.ui.lblMailStatus.setText(status)
+
+ tray_status = self.tr('Encrypted Mail is OFF')
+
+ icon = QtGui.QPixmap(self.MAIL_OFF_ICON)
+ if ready:
+ icon = QtGui.QPixmap(self.MAIL_ON_ICON)
+ tray_status = self.tr('Encrypted Mail is ON')
+
+ self.ui.lblMailIcon.setPixmap(icon)
+ self._action_mail_status.setText(tray_status)
+
def _mail_handle_soledad_events(self, req):
"""
Callback for ...
@@ -557,7 +588,7 @@ class StatusPanelWidget(QtGui.QWidget):
:param req: Request type
:type req: leap.common.events.events_pb2.SignalRequest
"""
- self.ui.lblMailStatus.setText(self.tr("Starting..."))
+ self._set_mail_status(self.tr("Starting..."))
ext_status = ""
@@ -596,7 +627,7 @@ class StatusPanelWidget(QtGui.QWidget):
if self._smtp_started and self._imap_started:
return
- self.ui.lblMailStatus.setText(self.tr("Starting..."))
+ self._set_mail_status(self.tr("Starting..."))
ext_status = ""
@@ -644,14 +675,11 @@ class StatusPanelWidget(QtGui.QWidget):
ext_status = self.tr("SMTP has started...")
self._smtp_started = True
if self._smtp_started and self._imap_started:
- self.ui.lblMailStatus.setText(self.tr("ON"))
- self.ui.lblMailIcon.setPixmap(QtGui.QPixmap(self.MAIL_ON_ICON))
- self.ui.lblMailIcon.setPixmap(
- QtGui.QPixmap(":/images/mail-locked.png"))
+ self._set_mail_status(self.tr("ON"), ready=True)
ext_status = ""
elif req.event == proto.SMTP_SERVICE_FAILED_TO_START:
ext_status = self.tr("SMTP failed to start, check the logs.")
- self.ui.lblMailStatus.setText(self.tr("Failed"))
+ self._set_mail_status(self.tr("Failed"))
else:
leap_assert(False,
"Don't know how to handle this state: %s"
@@ -684,19 +712,17 @@ class StatusPanelWidget(QtGui.QWidget):
ext_status = self.tr("IMAP has started...")
self._imap_started = True
if self._smtp_started and self._imap_started:
- self.ui.lblMailStatus.setText(self.tr("ON"))
- self.ui.lblMailIcon.setPixmap(QtGui.QPixmap(self.MAIL_ON_ICON))
+ self._set_mail_status(self.tr("ON"), ready=True)
ext_status = ""
elif req.event == proto.IMAP_SERVICE_FAILED_TO_START:
ext_status = self.tr("IMAP failed to start, check the logs.")
- self.ui.lblMailStatus.setText(self.tr("Failed"))
+ self._set_mail_status(self.tr("Failed"))
elif req.event == proto.IMAP_UNREAD_MAIL:
if self._smtp_started and self._imap_started:
self.ui.lblUnread.setText(
self.tr("%s Unread Emails") % (req.content))
self.ui.lblUnread.setVisible(req.content != "0")
- self.ui.lblMailStatus.setText(self.tr("ON"))
- self.ui.lblMailIcon.setPixmap(QtGui.QPixmap(self.MAIL_ON_ICON))
+ self._set_mail_status(self.tr("ON"), ready=True)
else:
leap_assert(False,
"Don't know how to handle this state: %s"