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/leap_app.py | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/leap/baseapp/leap_app.py (limited to 'src/leap/baseapp/leap_app.py') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py new file mode 100644 index 00000000..fb736ee3 --- /dev/null +++ b/src/leap/baseapp/leap_app.py @@ -0,0 +1,57 @@ +from PyQt4 import QtGui + +from leap.gui import mainwindow_rc + + +class MainWindow(object): + + def createWindowHeader(self): + """ + description lines for main window + """ + self.headerBox = QtGui.QGroupBox() + self.headerLabel = QtGui.QLabel("Encryption \ +Internet Proxy") + self.headerLabelSub = QtGui.QLabel("trust your \ +technolust") + + pixmap = QtGui.QPixmap(':/images/leapfrog.jpg') + frog_lbl = QtGui.QLabel() + frog_lbl.setPixmap(pixmap) + + headerLayout = QtGui.QHBoxLayout() + headerLayout.addWidget(frog_lbl) + headerLayout.addWidget(self.headerLabel) + headerLayout.addWidget(self.headerLabelSub) + headerLayout.addStretch() + self.headerBox.setLayout(headerLayout) + + def set_statusbarMessage(self, msg): + self.statusBar().showMessage(msg) + + def closeEvent(self, event): + """ + redefines close event (persistent window behaviour) + """ + if self.trayIcon.isVisible() and not self.debugmode: + QtGui.QMessageBox.information( + self, "Systray", + "The program will keep running " + "in the system tray. To " + "terminate the program, choose " + "Quit in the " + "context menu of the system tray entry.") + self.hide() + event.ignore() + if self.debugmode: + self.cleanupAndQuit() + + def cleanupAndQuit(self): + """ + cleans state before shutting down app. + """ + # TODO:make sure to shutdown all child process / threads + # in conductor + # XXX send signal instead? + self.conductor.cleanup() + QtGui.qApp.quit() -- 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/leap_app.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/leap/baseapp/leap_app.py') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index fb736ee3..1b4d7747 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -5,6 +5,28 @@ from leap.gui import mainwindow_rc class MainWindow(object): + def __init__(self, *args, **kwargs): + # XXX set initial visibility + # debug = no visible + + widget = QtGui.QWidget() + self.setCentralWidget(widget) + + self.createWindowHeader() + + # add widgets to layout + mainLayout = QtGui.QVBoxLayout() + mainLayout.addWidget(self.headerBox) + mainLayout.addWidget(self.statusIconBox) + if self.debugmode: + mainLayout.addWidget(self.statusBox) + mainLayout.addWidget(self.loggerBox) + widget.setLayout(mainLayout) + + self.setWindowTitle("LEAP Client") + self.resize(400, 300) + self.set_statusbarMessage('ready') + def createWindowHeader(self): """ description lines for main window -- 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/leap_app.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/leap/baseapp/leap_app.py') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 1b4d7747..def95da1 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -4,6 +4,10 @@ from leap.gui import mainwindow_rc class MainWindow(object): + """ + create the main window + for leap app + """ def __init__(self, *args, **kwargs): # XXX set initial visibility -- cgit v1.2.3