diff options
Diffstat (limited to 'src/leap/gui')
-rw-r--r-- | src/leap/gui/mainwindow.py | 65 | ||||
-rw-r--r-- | src/leap/gui/ui/mainwindow.ui | 119 |
2 files changed, 159 insertions, 25 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 6a73fb76..71dff1c5 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -42,6 +42,11 @@ from leap.services.eip.vpnlaunchers import (VPNLauncherException, EIPNoPolkitAuthAgentAvailable) from leap.util import __version__ as VERSION from leap.util.checkerthread import CheckerThread +from leap.common.events import server +from leap.common.events import ( + register, + events_pb2 as proto, +) from ui_mainwindow import Ui_MainWindow @@ -61,6 +66,8 @@ class MainWindow(QtGui.QMainWindow): # Keyring KEYRING_KEY = "leap_client" + new_updates = QtCore.Signal(object) + def __init__(self, standalone=False): """ Constructor for the client main window @@ -71,6 +78,12 @@ class MainWindow(QtGui.QMainWindow): """ QtGui.QMainWindow.__init__(self) + server.ensure_server(port=8090) + + register(signal=proto.UPDATER_NEW_UPDATES, + callback=self._new_updates_available) + self._updates_content = "" + self.CONNECTING_ICON = QtGui.QPixmap(":/images/conn_connecting.png") self.CONNECTED_ICON = QtGui.QPixmap(":/images/conn_connected.png") self.ERROR_ICON = QtGui.QPixmap(":/images/conn_error.png") @@ -196,6 +209,11 @@ class MainWindow(QtGui.QMainWindow): self._center_window() + self.ui.lblNewUpdates.setVisible(False) + self.ui.btnMore.setVisible(False) + self.ui.btnMore.clicked.connect(self._updates_details) + self.new_updates.connect(self._react_to_new_updates) + init_platform() self._wizard = None @@ -228,6 +246,53 @@ class MainWindow(QtGui.QMainWindow): self.ui.chkAutoLogin.setEnabled(enable) self._settings.set_remember(enable) + def _new_updates_available(self, req): + """ + Callback for the new updates event + + @param req: Request type + @type req: leap.common.events.events_pb2.SignalRequest + """ + self.new_updates.emit(req) + + def _react_to_new_updates(self, req): + """ + SLOT + TRIGGER: self._new_updates_available + + Displays the new updates label and sets the updates_content + """ + self.moveToThread(QtCore.QCoreApplication.instance().thread()) + self.ui.lblNewUpdates.setVisible(True) + self.ui.btnMore.setVisible(True) + self._updates_content = req.content + + def _updates_details(self): + """ + Parses and displays the updates details + """ + msg = "" + if len(self._updates_content) == 0: + # We assume that if there is nothing in the contents, then + # the LEAPClient bundle is what needs updating. + msg = self.tr("The LEAPClient app is ready to update, please" + " restart the application.") + else: + files = self._updates_content.split(", ") + files_str = "" + for f in files: + final_name = f.replace("/data/", "") + final_name = final_name.replace(".thp", "") + files_str += final_name + files_str += "\n" + msg = self.tr("The LEAPClient app is ready to update, please" + " restart the application so the following " + "components get updated:\n%s") % (files_str,) + + QtGui.QMessageBox.information(self, + self.tr("Updates available"), + msg) + def _finish_init(self): self.ui.cmbProviders.addItems(self._configured_providers()) self._show_systray() diff --git a/src/leap/gui/ui/mainwindow.ui b/src/leap/gui/ui/mainwindow.ui index ca3db95c..b42ff180 100644 --- a/src/leap/gui/ui/mainwindow.ui +++ b/src/leap/gui/ui/mainwindow.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>405</width> + <width>415</width> <height>579</height> </rect> </property> @@ -28,7 +28,20 @@ </property> <widget class="QWidget" name="centralwidget"> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="2"> + <item row="15" column="2"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="6" column="2"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -41,8 +54,8 @@ </property> </spacer> </item> - <item row="1" column="0" colspan="2"> - <spacer name="horizontalSpacer"> + <item row="7" column="3" colspan="2"> + <spacer name="horizontalSpacer_2"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -54,20 +67,20 @@ </property> </spacer> </item> - <item row="9" column="2"> - <spacer name="verticalSpacer_2"> + <item row="7" column="0" colspan="2"> + <spacer name="horizontalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>20</width> - <height>40</height> + <width>40</width> + <height>20</height> </size> </property> </spacer> </item> - <item row="2" column="0" colspan="5"> + <item row="8" column="0" colspan="5"> <widget class="QStackedWidget" name="stackedWidget"> <property name="currentIndex"> <number>1</number> @@ -290,20 +303,7 @@ </widget> </widget> </item> - <item row="1" column="3" colspan="2"> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="2"> + <item row="7" column="2"> <widget class="QLabel" name="label"> <property name="autoFillBackground"> <bool>false</bool> @@ -319,6 +319,75 @@ </property> </widget> </item> + <item row="0" column="0" colspan="5"> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="2" column="0"> + <spacer name="horizontalSpacer_8"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="1"> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="lblNewUpdates"> + <property name="text"> + <string>There are new updates available, please restart.</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="btnMore"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>More...</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="3"> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> @@ -326,7 +395,7 @@ <rect> <x>0</x> <y>0</y> - <width>405</width> + <width>415</width> <height>25</height> </rect> </property> |