From 3fbc512a49923ac73d2413a083e0bb1f7e163866 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 05:20:31 +0900 Subject: actual split of classes into own modules still a bit rough, but makes everything a bit more readable. --- src/leap/baseapp/systray.py | 150 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 src/leap/baseapp/systray.py (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py new file mode 100644 index 00000000..7ef5cb01 --- /dev/null +++ b/src/leap/baseapp/systray.py @@ -0,0 +1,150 @@ +from PyQt4 import QtCore +from PyQt4 import QtGui + +from leap.gui import mainwindow_rc + + +class StatusAwareTrayIcon(object): + + def createIconGroupBox(self): + """ + dummy icongroupbox + (to be removed from here -- reference only) + """ + icons = { + 'disconnected': ':/images/conn_error.png', + 'connecting': ':/images/conn_connecting.png', + 'connected': ':/images/conn_connected.png' + } + con_widgets = { + 'disconnected': QtGui.QLabel(), + 'connecting': QtGui.QLabel(), + 'connected': QtGui.QLabel(), + } + con_widgets['disconnected'].setPixmap( + QtGui.QPixmap(icons['disconnected'])) + con_widgets['connecting'].setPixmap( + QtGui.QPixmap(icons['connecting'])) + con_widgets['connected'].setPixmap( + QtGui.QPixmap(icons['connected'])), + self.ConnectionWidgets = con_widgets + + con_icons = { + 'disconnected': QtGui.QIcon(icons['disconnected']), + 'connecting': QtGui.QIcon(icons['connecting']), + 'connected': QtGui.QIcon(icons['connected']) + } + self.Icons = con_icons + + self.statusIconBox = QtGui.QGroupBox("Connection Status") + statusIconLayout = QtGui.QHBoxLayout() + statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) + statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) + statusIconLayout.addWidget(self.ConnectionWidgets['connected']) + statusIconLayout.itemAt(1).widget().hide() + statusIconLayout.itemAt(2).widget().hide() + self.statusIconBox.setLayout(statusIconLayout) + + def createTrayIcon(self): + """ + creates the tray icon + """ + self.trayIconMenu = QtGui.QMenu(self) + + self.trayIconMenu.addAction(self.connectVPNAction) + self.trayIconMenu.addAction(self.dis_connectAction) + self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.minimizeAction) + self.trayIconMenu.addAction(self.maximizeAction) + self.trayIconMenu.addAction(self.restoreAction) + self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.quitAction) + + self.trayIcon = QtGui.QSystemTrayIcon(self) + self.setIcon('disconnected') + self.trayIcon.setContextMenu(self.trayIconMenu) + + def createActions(self): + """ + creates actions to be binded to tray icon + """ + self.connectVPNAction = QtGui.QAction("Connect to &VPN", self, + triggered=self.hide) + # XXX change action name on (dis)connect + self.dis_connectAction = QtGui.QAction( + "&(Dis)connect", self, + triggered=lambda: self.start_or_stopVPN()) + self.minimizeAction = QtGui.QAction("Mi&nimize", self, + triggered=self.hide) + self.maximizeAction = QtGui.QAction("Ma&ximize", self, + triggered=self.showMaximized) + self.restoreAction = QtGui.QAction("&Restore", self, + triggered=self.showNormal) + self.quitAction = QtGui.QAction("&Quit", self, + triggered=self.cleanupAndQuit) + + def setConnWidget(self, icon_name): + #print 'changing icon to %s' % icon_name + oldlayout = self.statusIconBox.layout() + + # XXX reuse with icons + # XXX move states to StateWidget + states = {"disconnected": 0, + "connecting": 1, + "connected": 2} + + for i in range(3): + oldlayout.itemAt(i).widget().hide() + new = states[icon_name] + oldlayout.itemAt(new).widget().show() + + def setIcon(self, name): + icon = self.Icons.get(name) + self.trayIcon.setIcon(icon) + self.setWindowIcon(icon) + + def getIcon(self, icon_name): + # XXX get from connection dict + icons = {'disconnected': 0, + 'connecting': 1, + 'connected': 2} + return icons.get(icon_name, None) + + def setIconToolTip(self): + """ + get readable status and place it on systray tooltip + """ + status = self.conductor.status.get_readable_status() + self.trayIcon.setToolTip(status) + + def iconActivated(self, reason): + """ + handles left click, left double click + showing the trayicon menu + """ + #XXX there's a bug here! + #menu shows on (0,0) corner first time, + #until double clicked at least once. + if reason in (QtGui.QSystemTrayIcon.Trigger, + QtGui.QSystemTrayIcon.DoubleClick): + self.trayIconMenu.show() + + @QtCore.pyqtSlot() + def onTimerTick(self): + self.statusUpdate() + + @QtCore.pyqtSlot(object) + def onStatusChange(self, status): + """ + slot for status changes. triggers new signals for + updating icon, status bar, etc. + """ + + #print('STATUS CHANGED! (on Qt-land)') + #print('%s -> %s' % (status.previous, status.current)) + icon_name = self.conductor.get_icon_name() + self.setIcon(icon_name) + #print 'icon = ', icon_name + + # change connection pixmap widget + self.setConnWidget(icon_name) -- cgit v1.2.3 From b0b2b342b698bbe5851e9312cd830938f8d564a5 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 06:01:50 +0900 Subject: further cleaning of main window by moving init functions to their base classes. plus a bit of juggling with order. --- src/leap/baseapp/systray.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 7ef5cb01..249a4f7e 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -6,6 +6,17 @@ from leap.gui import mainwindow_rc class StatusAwareTrayIcon(object): + def __init__(self, *args, **kwargs): + # StatusAwareTrayIcon init ################### + self.createIconGroupBox() + self.createActions() + self.createTrayIcon() + + self.trayIcon.show() + ############################################## + + self.timer = QtCore.QTimer() + def createIconGroupBox(self): """ dummy icongroupbox -- cgit v1.2.3 From 1826d9a0d5400c21a3f7af73eda2e843f0639271 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 06:37:45 +0900 Subject: add little docstrings to classes --- src/leap/baseapp/systray.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 249a4f7e..3fb64db1 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -5,16 +5,20 @@ from leap.gui import mainwindow_rc class StatusAwareTrayIcon(object): + """ + a mix of several functions needed + to create a systray and make it + get updated from conductor status + polling. + """ def __init__(self, *args, **kwargs): - # StatusAwareTrayIcon init ################### self.createIconGroupBox() self.createActions() self.createTrayIcon() - self.trayIcon.show() - ############################################## + # not sure if this really belongs here, but... self.timer = QtCore.QTimer() def createIconGroupBox(self): -- cgit v1.2.3 From 8ef9f6f6f155b4acd0a69f1611058c4f0ba07d42 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 06:58:15 +0900 Subject: refactor icon/iconpath dict closes #331 --- src/leap/baseapp/systray.py | 61 ++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 3fb64db1..f3832473 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -11,6 +11,24 @@ class StatusAwareTrayIcon(object): get updated from conductor status polling. """ + states = { + "disconnected": 0, + "connecting": 1, + "connected": 2} + + iconpath = { + "disconnected": ':/images/conn_error.png', + "connecting": ':/images/conn_connecting.png', + "connected": ':/images/conn_connected.png'} + + Icons = { + 'disconnected': lambda self: QtGui.QIcon( + self.iconpath['disconnected']), + 'connecting': lambda self: QtGui.QIcon( + self.iconpath['connecting']), + 'connected': lambda self: QtGui.QIcon( + self.iconpath['connected']) + } def __init__(self, *args, **kwargs): self.createIconGroupBox() @@ -26,31 +44,22 @@ class StatusAwareTrayIcon(object): dummy icongroupbox (to be removed from here -- reference only) """ - icons = { - 'disconnected': ':/images/conn_error.png', - 'connecting': ':/images/conn_connecting.png', - 'connected': ':/images/conn_connected.png' - } con_widgets = { 'disconnected': QtGui.QLabel(), 'connecting': QtGui.QLabel(), 'connected': QtGui.QLabel(), } con_widgets['disconnected'].setPixmap( - QtGui.QPixmap(icons['disconnected'])) + QtGui.QPixmap( + self.iconpath['disconnected'])) con_widgets['connecting'].setPixmap( - QtGui.QPixmap(icons['connecting'])) + QtGui.QPixmap( + self.iconpath['connecting'])) con_widgets['connected'].setPixmap( - QtGui.QPixmap(icons['connected'])), + QtGui.QPixmap( + self.iconpath['connected'])), self.ConnectionWidgets = con_widgets - con_icons = { - 'disconnected': QtGui.QIcon(icons['disconnected']), - 'connecting': QtGui.QIcon(icons['connecting']), - 'connected': QtGui.QIcon(icons['connected']) - } - self.Icons = con_icons - self.statusIconBox = QtGui.QGroupBox("Connection Status") statusIconLayout = QtGui.QHBoxLayout() statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) @@ -99,31 +108,20 @@ class StatusAwareTrayIcon(object): triggered=self.cleanupAndQuit) def setConnWidget(self, icon_name): - #print 'changing icon to %s' % icon_name oldlayout = self.statusIconBox.layout() - # XXX reuse with icons - # XXX move states to StateWidget - states = {"disconnected": 0, - "connecting": 1, - "connected": 2} - for i in range(3): oldlayout.itemAt(i).widget().hide() - new = states[icon_name] + new = self.states[icon_name] oldlayout.itemAt(new).widget().show() def setIcon(self, name): - icon = self.Icons.get(name) + icon = self.Icons.get(name)(self) self.trayIcon.setIcon(icon) self.setWindowIcon(icon) def getIcon(self, icon_name): - # XXX get from connection dict - icons = {'disconnected': 0, - 'connecting': 1, - 'connected': 2} - return icons.get(icon_name, None) + return self.states.get(icon_name, None) def setIconToolTip(self): """ @@ -154,12 +152,7 @@ class StatusAwareTrayIcon(object): slot for status changes. triggers new signals for updating icon, status bar, etc. """ - - #print('STATUS CHANGED! (on Qt-land)') - #print('%s -> %s' % (status.previous, status.current)) icon_name = self.conductor.get_icon_name() self.setIcon(icon_name) - #print 'icon = ', icon_name - # change connection pixmap widget self.setConnWidget(icon_name) -- cgit v1.2.3 From 8148bc9c8c113c41fcb18b397669b1f13447c653 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 6 Sep 2012 02:27:04 +0900 Subject: more generic error handler in EipConductorAppMixin documentation of the Exception Hierarchy and attributes. also a bit of general cleanup around error handling in conductor. Hopefully to be polished an abstracted to leap.base with time. not all errors are converted (and the old with_errors/ignoring errors) are still there, but we should be using this style of handlers from now on. wrapping up with this pseudo-feature for now. as we work on individual features we can mimick the exceptions that are working. --- src/leap/baseapp/systray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index f3832473..c696ee74 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -4,7 +4,7 @@ from PyQt4 import QtGui from leap.gui import mainwindow_rc -class StatusAwareTrayIcon(object): +class StatusAwareTrayIconMixin(object): """ a mix of several functions needed to create a systray and make it -- cgit v1.2.3 From 3c26d5b5427e788aebfa174de3f0689bb1e146d2 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 13 Sep 2012 04:55:21 +0900 Subject: display about and aboutqt dialogs --- src/leap/baseapp/systray.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index c696ee74..762dac13 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,6 +1,7 @@ from PyQt4 import QtCore from PyQt4 import QtGui +from leap import __version__ as VERSION from leap.gui import mainwindow_rc @@ -82,6 +83,9 @@ class StatusAwareTrayIconMixin(object): self.trayIconMenu.addAction(self.maximizeAction) self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.aboutAct) + self.trayIconMenu.addAction(self.aboutQtAct) + self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.quitAction) self.trayIcon = QtGui.QSystemTrayIcon(self) @@ -104,9 +108,19 @@ class StatusAwareTrayIconMixin(object): triggered=self.showMaximized) self.restoreAction = QtGui.QAction("&Restore", self, triggered=self.showNormal) + self.aboutAct = QtGui.QAction("&About", self, + triggered=self.about) + self.aboutQtAct = QtGui.QAction("About Q&t", self, + triggered=QtGui.qApp.aboutQt) self.quitAction = QtGui.QAction("&Quit", self, triggered=self.cleanupAndQuit) + def about(self): + # move to widget + QtGui.QMessageBox.about(self, "About", + "Running LEAP client
" + "version %s" % VERSION) + def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() -- cgit v1.2.3 From 1e9ae8c5cf64a347ee59b24ad426a8ed929127c1 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 14 Sep 2012 03:07:02 +0900 Subject: init icon --- src/leap/baseapp/systray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 762dac13..67448ba0 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -61,7 +61,7 @@ class StatusAwareTrayIconMixin(object): self.iconpath['connected'])), self.ConnectionWidgets = con_widgets - self.statusIconBox = QtGui.QGroupBox("Connection Status") + self.statusIconBox = QtGui.QGroupBox("EIP Connection Status") statusIconLayout = QtGui.QHBoxLayout() statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) -- cgit v1.2.3 From add7973b3d1633b2776cb90f237415c6cac65d99 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 14 Sep 2012 08:34:59 +0900 Subject: set app icon (shows on window, minimized icons and about dialog) --- src/leap/baseapp/systray.py | 68 ++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 19 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 67448ba0..dd872de0 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,9 +1,18 @@ +import logging + from PyQt4 import QtCore from PyQt4 import QtGui from leap import __version__ as VERSION from leap.gui import mainwindow_rc +logger = logging.getLogger(__name__) + + +class PseudoAction(QtGui.QAction): + def isSeparator(self): + return True + class StatusAwareTrayIconMixin(object): """ @@ -76,12 +85,15 @@ class StatusAwareTrayIconMixin(object): """ self.trayIconMenu = QtGui.QMenu(self) - self.trayIconMenu.addAction(self.connectVPNAction) - self.trayIconMenu.addAction(self.dis_connectAction) + self.trayIconMenu.addAction(self.statusAct) + self.trayIconMenu.addAction(self.connAct) + #self.trayIconMenu.addAction(self.dis_connectAction) + #self.trayIconMenu.addSeparator() + #self.trayIconMenu.addAction(self.minimizeAction) + #self.trayIconMenu.addAction(self.maximizeAction) + #self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() - self.trayIconMenu.addAction(self.minimizeAction) - self.trayIconMenu.addAction(self.maximizeAction) - self.trayIconMenu.addAction(self.restoreAction) + self.trayIconMenu.addAction(self.detailsAct) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.aboutAct) self.trayIconMenu.addAction(self.aboutQtAct) @@ -92,22 +104,32 @@ class StatusAwareTrayIconMixin(object): self.setIcon('disconnected') self.trayIcon.setContextMenu(self.trayIconMenu) + def bad(self): + logger.error('this should not be called') + def createActions(self): """ creates actions to be binded to tray icon """ - self.connectVPNAction = QtGui.QAction("Connect to &VPN", self, - triggered=self.hide) # XXX change action name on (dis)connect - self.dis_connectAction = QtGui.QAction( - "&(Dis)connect", self, - triggered=lambda: self.start_or_stopVPN()) - self.minimizeAction = QtGui.QAction("Mi&nimize", self, - triggered=self.hide) - self.maximizeAction = QtGui.QAction("Ma&ximize", self, - triggered=self.showMaximized) - self.restoreAction = QtGui.QAction("&Restore", self, - triggered=self.showNormal) + statusAct = PseudoAction( + "Encryption OFF", self) # , + statusAct.setSeparator(True) + self.statusAct = statusAct + self.statusAct.isSeparator = lambda: True + #triggered=self.bad) + self.connAct = QtGui.QAction(" turn &on", self, + triggered=lambda: self.start_or_stopVPN()) + + self.detailsAct = QtGui.QAction("&Details...", + self, + triggered=self.detailsWin) + #self.minimizeAction = QtGui.QAction("Mi&nimize", self, + #triggered=self.hide) + #self.maximizeAction = QtGui.QAction("Ma&ximize", self, + #triggered=self.showMaximized) + #self.restoreAction = QtGui.QAction("&Restore", self, + #triggered=self.showNormal) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About Q&t", self, @@ -115,11 +137,19 @@ class StatusAwareTrayIconMixin(object): self.quitAction = QtGui.QAction("&Quit", self, triggered=self.cleanupAndQuit) + def detailsWin(self): + logger.debug('details win toggle') + # XXX toggle main window visibility + # if visible: self.hide + # if hidden: self.show + def about(self): # move to widget QtGui.QMessageBox.about(self, "About", - "Running LEAP client
" - "version %s" % VERSION) + "LEAP client
" + "(version %s)
" + "" + "https://leap.se" % VERSION) def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() @@ -132,7 +162,7 @@ class StatusAwareTrayIconMixin(object): def setIcon(self, name): icon = self.Icons.get(name)(self) self.trayIcon.setIcon(icon) - self.setWindowIcon(icon) + #self.setWindowIcon(icon) def getIcon(self, icon_name): return self.states.get(icon_name, None) -- cgit v1.2.3 From cbd474e49e12e5fc0677dafe331b9c5ab3a2539a Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 20 Sep 2012 03:57:05 +0900 Subject: start hidden, and toggle details window from menu --- src/leap/baseapp/systray.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index dd872de0..f98bfa76 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -3,6 +3,7 @@ import logging from PyQt4 import QtCore from PyQt4 import QtGui +from leap import __branding as BRANDING from leap import __version__ as VERSION from leap.gui import mainwindow_rc @@ -138,18 +139,23 @@ class StatusAwareTrayIconMixin(object): triggered=self.cleanupAndQuit) def detailsWin(self): - logger.debug('details win toggle') - # XXX toggle main window visibility - # if visible: self.hide - # if hidden: self.show + visible = self.isVisible() + if visible: + self.hide() + else: + self.show() def about(self): # move to widget - QtGui.QMessageBox.about(self, "About", - "LEAP client
" - "(version %s)
" - "" - "https://leap.se" % VERSION) + flavor = BRANDING.get('short_name', None) + content = ("LEAP client
" + "(version %s)
" % VERSION) + if flavor: + content = content + ('
Flavor: %s
' % flavor) + content = content + ( + "
" + "https://leap.se") + QtGui.QMessageBox.about(self, "About", content) def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() -- cgit v1.2.3 From f2749fa3ff1df5875d3bc0b932a408031fee9874 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 20 Sep 2012 04:39:50 +0900 Subject: toggle connection on/off --- src/leap/baseapp/systray.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index f98bfa76..39a23f49 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -5,16 +5,12 @@ from PyQt4 import QtGui from leap import __branding as BRANDING from leap import __version__ as VERSION + from leap.gui import mainwindow_rc logger = logging.getLogger(__name__) -class PseudoAction(QtGui.QAction): - def isSeparator(self): - return True - - class StatusAwareTrayIconMixin(object): """ a mix of several functions needed @@ -86,10 +82,7 @@ class StatusAwareTrayIconMixin(object): """ self.trayIconMenu = QtGui.QMenu(self) - self.trayIconMenu.addAction(self.statusAct) self.trayIconMenu.addAction(self.connAct) - #self.trayIconMenu.addAction(self.dis_connectAction) - #self.trayIconMenu.addSeparator() #self.trayIconMenu.addAction(self.minimizeAction) #self.trayIconMenu.addAction(self.maximizeAction) #self.trayIconMenu.addAction(self.restoreAction) @@ -113,13 +106,7 @@ class StatusAwareTrayIconMixin(object): creates actions to be binded to tray icon """ # XXX change action name on (dis)connect - statusAct = PseudoAction( - "Encryption OFF", self) # , - statusAct.setSeparator(True) - self.statusAct = statusAct - self.statusAct.isSeparator = lambda: True - #triggered=self.bad) - self.connAct = QtGui.QAction(" turn &on", self, + self.connAct = QtGui.QAction("Encryption ON turn &off", self, triggered=lambda: self.start_or_stopVPN()) self.detailsAct = QtGui.QAction("&Details...", @@ -138,6 +125,15 @@ class StatusAwareTrayIconMixin(object): self.quitAction = QtGui.QAction("&Quit", self, triggered=self.cleanupAndQuit) + def toggleEIPAct(self): + # this is too simple by now. + # XXX We need to get the REAL info for Encryption state. + # (now is ON as soon as vpn launched) + if self.eip_service_started is True: + self.connAct.setText('Encryption ON turn o&ff') + else: + self.connAct.setText('Encryption OFF turn &on') + def detailsWin(self): visible = self.isVisible() if visible: -- cgit v1.2.3 From 886d04167e51ba07a71393bad5c41b04023db527 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 2 Oct 2012 06:43:15 +0900 Subject: moved eip checks to qthread to let icon show early --- src/leap/baseapp/systray.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 39a23f49..0ab37f7f 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -41,6 +41,7 @@ class StatusAwareTrayIconMixin(object): self.createIconGroupBox() self.createActions() self.createTrayIcon() + logger.debug('showing tray icon................') self.trayIcon.show() # not sure if this really belongs here, but... -- cgit v1.2.3 From 6cd947041b3352bebddf3863a86b0a15f8222bcf Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 21:22:36 +0900 Subject: fix seticon call breakage when interface dies --- src/leap/baseapp/systray.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 39a23f49..adcfe9b9 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -162,9 +162,10 @@ class StatusAwareTrayIconMixin(object): oldlayout.itemAt(new).widget().show() def setIcon(self, name): - icon = self.Icons.get(name)(self) - self.trayIcon.setIcon(icon) - #self.setWindowIcon(icon) + icon_fun = self.Icons.get(name) + if icon_fun and callable(icon_fun): + icon = icon_fun(self) + self.trayIcon.setIcon(icon) def getIcon(self, icon_name): return self.states.get(icon_name, None) -- cgit v1.2.3 From 479710e977327774b9ba9e1839f75b4a38b51e5f Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 8 Oct 2012 09:32:34 +0900 Subject: add leap-status to main window in non-debug mode not very DRY but just to have it ready for rc cut. --- src/leap/baseapp/systray.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 1939bc09..d5d44f61 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -41,7 +41,7 @@ class StatusAwareTrayIconMixin(object): self.createIconGroupBox() self.createActions() self.createTrayIcon() - logger.debug('showing tray icon................') + #logger.debug('showing tray icon................') self.trayIcon.show() # not sure if this really belongs here, but... @@ -75,6 +75,10 @@ class StatusAwareTrayIconMixin(object): statusIconLayout.addWidget(self.ConnectionWidgets['connected']) statusIconLayout.itemAt(1).widget().hide() statusIconLayout.itemAt(2).widget().hide() + + self.leapConnStatus = QtGui.QLabel("disconnected") + statusIconLayout.addWidget(self.leapConnStatus) + self.statusIconBox.setLayout(statusIconLayout) def createTrayIcon(self): @@ -84,9 +88,6 @@ class StatusAwareTrayIconMixin(object): self.trayIconMenu = QtGui.QMenu(self) self.trayIconMenu.addAction(self.connAct) - #self.trayIconMenu.addAction(self.minimizeAction) - #self.trayIconMenu.addAction(self.maximizeAction) - #self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.detailsAct) self.trayIconMenu.addSeparator() @@ -113,12 +114,6 @@ class StatusAwareTrayIconMixin(object): self.detailsAct = QtGui.QAction("&Details...", self, triggered=self.detailsWin) - #self.minimizeAction = QtGui.QAction("Mi&nimize", self, - #triggered=self.hide) - #self.maximizeAction = QtGui.QAction("Ma&ximize", self, - #triggered=self.showMaximized) - #self.restoreAction = QtGui.QAction("&Restore", self, - #triggered=self.showNormal) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About Q&t", self, @@ -197,10 +192,32 @@ class StatusAwareTrayIconMixin(object): @QtCore.pyqtSlot(object) def onStatusChange(self, status): """ - slot for status changes. triggers new signals for - updating icon, status bar, etc. + updates icon """ icon_name = self.conductor.get_icon_name() + + # XXX refactor. Use QStateMachine + + if icon_name in ("disconnected", "connected"): + self.changeLeapStatus.emit(icon_name) + + if icon_name in ("connecting"): + # let's see how it matches + leap_status_name = self.conductor.get_leap_status() + self.changeLeapStatus.emit(leap_status_name) + self.setIcon(icon_name) # change connection pixmap widget self.setConnWidget(icon_name) + + @QtCore.pyqtSlot(str) + def onChangeLeapConnStatus(self, newstatus): + """ + slot for LEAP status changes + not to be confused with onStatusChange. + this only updates the non-debug LEAP Status line + next to the connection icon. + """ + # XXX move bold to style sheet + self.leapConnStatus.setText( + "%s" % newstatus) -- cgit v1.2.3 From f043f9087232a416bf9fa7dbb0b8f9b6f4e0a04e Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 10 Oct 2012 03:59:01 +0900 Subject: fix for left-click on systray Closes #310 --- src/leap/baseapp/systray.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index d5d44f61..cc5d89df 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -100,6 +100,10 @@ class StatusAwareTrayIconMixin(object): self.setIcon('disconnected') self.trayIcon.setContextMenu(self.trayIconMenu) + #self.trayIconMenu.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + #self.trayIconMenu.customContextMenuRequested.connect( + #self.on_context_menu) + def bad(self): logger.error('this should not be called') @@ -178,12 +182,14 @@ class StatusAwareTrayIconMixin(object): handles left click, left double click showing the trayicon menu """ - #XXX there's a bug here! - #menu shows on (0,0) corner first time, - #until double clicked at least once. if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): - self.trayIconMenu.show() + context_menu = self.trayIcon.contextMenu() + # for some reason, context_menu.show() + # is failing in a way beyond my understanding. + # (not working the first time it's clicked). + # this works however. + context_menu.exec_(self.trayIcon.geometry().center()) @QtCore.pyqtSlot() def onTimerTick(self): -- cgit v1.2.3 From ff02a21ed6ef879c054b01134744068bdfeda664 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 24 Oct 2012 06:49:51 +0900 Subject: last page of wizard displays the connection steps --- src/leap/baseapp/systray.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index cc5d89df..061de98e 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -196,31 +196,31 @@ class StatusAwareTrayIconMixin(object): self.statusUpdate() @QtCore.pyqtSlot(object) - def onStatusChange(self, status): + def onOpenVPNStatusChange(self, status): """ - updates icon + updates icon, according to the openvpn status change. """ icon_name = self.conductor.get_icon_name() # XXX refactor. Use QStateMachine if icon_name in ("disconnected", "connected"): - self.changeLeapStatus.emit(icon_name) + self.eipStatusChange.emit(icon_name) if icon_name in ("connecting"): # let's see how it matches leap_status_name = self.conductor.get_leap_status() - self.changeLeapStatus.emit(leap_status_name) + self.eipStatusChange.emit(leap_status_name) self.setIcon(icon_name) # change connection pixmap widget self.setConnWidget(icon_name) @QtCore.pyqtSlot(str) - def onChangeLeapConnStatus(self, newstatus): + def onEIPConnStatusChange(self, newstatus): """ - slot for LEAP status changes - not to be confused with onStatusChange. + slot for EIP status changes + not to be confused with onOpenVPNStatusChange. this only updates the non-debug LEAP Status line next to the connection icon. """ -- cgit v1.2.3 From 593e4ba1ddf185d14f27c96ffb970fde7a3271fa Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 26 Oct 2012 02:04:34 +0900 Subject: fix systray context menu. Closes #761 --- src/leap/baseapp/systray.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 061de98e..bf57c0f8 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -129,10 +129,22 @@ class StatusAwareTrayIconMixin(object): # this is too simple by now. # XXX We need to get the REAL info for Encryption state. # (now is ON as soon as vpn launched) - if self.eip_service_started is True: + + # XXX get STATUS CONSTANTS INSTEAD + + icon_status = self.conductor.status.get_state_icon() + if icon_status == "connected": + self.connAct.setEnabled(True) self.connAct.setText('Encryption ON turn o&ff') - else: + return + if icon_status == "disconnected": + self.connAct.setEnabled(True) self.connAct.setText('Encryption OFF turn &on') + return + if icon_status == "connecting": + self.connAct.setDisabled(True) + self.connAct.setText('connecting...') + return def detailsWin(self): visible = self.isVisible() -- cgit v1.2.3 From b66f946c9e7bbdf4bfb7ceb7ffcf340257b2165e Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 26 Oct 2012 05:02:04 +0900 Subject: hide aboutQt menu entry --- src/leap/baseapp/systray.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index bf57c0f8..8777207c 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -92,7 +92,9 @@ class StatusAwareTrayIconMixin(object): self.trayIconMenu.addAction(self.detailsAct) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.aboutAct) - self.trayIconMenu.addAction(self.aboutQtAct) + # we should get this hidden inside the "about" dialog + # (as a little button maybe) + #self.trayIconMenu.addAction(self.aboutQtAct) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.quitAction) -- cgit v1.2.3 From 0a8a34879a701a2d045f628403c6a0f8be21dc82 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 26 Oct 2012 05:16:44 +0900 Subject: stop eip connection when first run wizard started Closes #716 --- src/leap/baseapp/systray.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 8777207c..06be2975 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -129,12 +129,9 @@ class StatusAwareTrayIconMixin(object): def toggleEIPAct(self): # this is too simple by now. - # XXX We need to get the REAL info for Encryption state. - # (now is ON as soon as vpn launched) - # XXX get STATUS CONSTANTS INSTEAD - icon_status = self.conductor.status.get_state_icon() + icon_status = self.conductor.get_icon_name() if icon_status == "connected": self.connAct.setEnabled(True) self.connAct.setText('Encryption ON turn o&ff') -- cgit v1.2.3 From 57bd393492fde434a1e3af60b607e8e9d757b9b3 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 21:48:22 +0900 Subject: moved thread code to gui/threads --- src/leap/baseapp/systray.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 06be2975..94a7a8f2 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,4 +1,7 @@ import logging +import sip +sip.setapi('QString', 2) +sip.setapi('QVariant', 2) from PyQt4 import QtCore from PyQt4 import QtGui -- cgit v1.2.3 From e111e9de0d33d12503233e754e2e4b01133acec9 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 14 Nov 2012 02:53:28 +0900 Subject: hide the systray icon until the firstrun wizard is complete Closes #762 --- src/leap/baseapp/systray.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 94a7a8f2..49f044aa 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -44,12 +44,14 @@ class StatusAwareTrayIconMixin(object): self.createIconGroupBox() self.createActions() self.createTrayIcon() - #logger.debug('showing tray icon................') - self.trayIcon.show() # not sure if this really belongs here, but... self.timer = QtCore.QTimer() + def show_systray_icon(self): + #logger.debug('showing tray icon................') + self.trayIcon.show() + def createIconGroupBox(self): """ dummy icongroupbox -- cgit v1.2.3 From 04d423e2a89034dfb86fe305108162fd2a696079 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 12 Dec 2012 03:29:31 +0900 Subject: tests for openvpn options and make the rest of tests pass after some changes in this branch (dirtyness in config files) --- src/leap/baseapp/systray.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 49f044aa..52060ae2 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -217,6 +217,8 @@ class StatusAwareTrayIconMixin(object): updates icon, according to the openvpn status change. """ icon_name = self.conductor.get_icon_name() + if not icon_name: + return # XXX refactor. Use QStateMachine -- cgit v1.2.3 From 89694babd14a9b2ba76095911b6884e359a12282 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 17 Dec 2012 05:05:37 +0900 Subject: network checker launched by signal fixes problem with provider domain not being defined during first run. --- src/leap/baseapp/systray.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 52060ae2..0dd0f195 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -230,6 +230,11 @@ class StatusAwareTrayIconMixin(object): leap_status_name = self.conductor.get_leap_status() self.eipStatusChange.emit(leap_status_name) + if icon_name == "connected": + # When we change to "connected', we launch + # the network checker. + self.initNetworkChecker.emit() + self.setIcon(icon_name) # change connection pixmap widget self.setConnWidget(icon_name) -- cgit v1.2.3 From b2e1e26e182bc86e01440ab3a93d3953f1fbcb4b Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 27 Dec 2012 07:08:10 +0900 Subject: fix window not raising to front in osx --- src/leap/baseapp/systray.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 0dd0f195..93fab716 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,4 +1,6 @@ import logging +import sys + import sip sip.setapi('QString', 2) sip.setapi('QVariant', 2) @@ -156,6 +158,8 @@ class StatusAwareTrayIconMixin(object): self.hide() else: self.show() + if sys.platform == "darwin": + self.raise_() def about(self): # move to widget -- cgit v1.2.3 From a5b4b7020daebbcb25c016cf1821818b71a2e457 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 9 Jan 2013 06:23:45 +0900 Subject: more missed strings to be translated plus initial translation. --- src/leap/baseapp/systray.py | 56 +++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'src/leap/baseapp/systray.py') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 93fab716..77eb3fe9 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -75,7 +75,8 @@ class StatusAwareTrayIconMixin(object): self.iconpath['connected'])), self.ConnectionWidgets = con_widgets - self.statusIconBox = QtGui.QGroupBox("EIP Connection Status") + self.statusIconBox = QtGui.QGroupBox( + self.tr("EIP Connection Status")) statusIconLayout = QtGui.QHBoxLayout() statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) @@ -83,7 +84,8 @@ class StatusAwareTrayIconMixin(object): statusIconLayout.itemAt(1).widget().hide() statusIconLayout.itemAt(2).widget().hide() - self.leapConnStatus = QtGui.QLabel("disconnected") + self.leapConnStatus = QtGui.QLabel( + self.tr("disconnected")) statusIconLayout.addWidget(self.leapConnStatus) self.statusIconBox.setLayout(statusIconLayout) @@ -113,26 +115,32 @@ class StatusAwareTrayIconMixin(object): #self.trayIconMenu.customContextMenuRequested.connect( #self.on_context_menu) - def bad(self): - logger.error('this should not be called') + #def bad(self): + #logger.error('this should not be called') def createActions(self): """ creates actions to be binded to tray icon """ # XXX change action name on (dis)connect - self.connAct = QtGui.QAction("Encryption ON turn &off", self, - triggered=lambda: self.start_or_stopVPN()) - - self.detailsAct = QtGui.QAction("&Details...", - self, - triggered=self.detailsWin) - self.aboutAct = QtGui.QAction("&About", self, - triggered=self.about) - self.aboutQtAct = QtGui.QAction("About Q&t", self, - triggered=QtGui.qApp.aboutQt) - self.quitAction = QtGui.QAction("&Quit", self, - triggered=self.cleanupAndQuit) + self.connAct = QtGui.QAction( + self.tr("Encryption ON turn &off"), + self, + triggered=lambda: self.start_or_stopVPN()) + + self.detailsAct = QtGui.QAction( + self.tr("&Details..."), + self, + triggered=self.detailsWin) + self.aboutAct = QtGui.QAction( + self.tr("&About"), self, + triggered=self.about) + self.aboutQtAct = QtGui.QAction( + self.tr("About Q&t"), self, + triggered=QtGui.qApp.aboutQt) + self.quitAction = QtGui.QAction( + self.tr("&Quit"), self, + triggered=self.cleanupAndQuit) def toggleEIPAct(self): # this is too simple by now. @@ -141,15 +149,17 @@ class StatusAwareTrayIconMixin(object): icon_status = self.conductor.get_icon_name() if icon_status == "connected": self.connAct.setEnabled(True) - self.connAct.setText('Encryption ON turn o&ff') + self.connAct.setText( + self.tr('Encryption ON turn o&ff')) return if icon_status == "disconnected": self.connAct.setEnabled(True) - self.connAct.setText('Encryption OFF turn &on') + self.connAct.setText( + self.tr('Encryption OFF turn &on')) return if icon_status == "connecting": self.connAct.setDisabled(True) - self.connAct.setText('connecting...') + self.connAct.setText(self.tr('connecting...')) return def detailsWin(self): @@ -164,14 +174,15 @@ class StatusAwareTrayIconMixin(object): def about(self): # move to widget flavor = BRANDING.get('short_name', None) - content = ("LEAP client
" - "(version %s)
" % VERSION) + content = self.tr( + ("LEAP client
" + "(version %s)
" % VERSION)) if flavor: content = content + ('
Flavor: %s
' % flavor) content = content + ( "
" "https://leap.se") - QtGui.QMessageBox.about(self, "About", content) + QtGui.QMessageBox.about(self, self.tr("About"), content) def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() @@ -209,6 +220,7 @@ class StatusAwareTrayIconMixin(object): # is failing in a way beyond my understanding. # (not working the first time it's clicked). # this works however. + # XXX in osx it shows some glitches. context_menu.exec_(self.trayIcon.geometry().center()) @QtCore.pyqtSlot() -- cgit v1.2.3