diff options
author | kali <kali@leap.se> | 2012-09-04 07:11:46 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-09-04 07:11:46 +0900 |
commit | 6ef92e257ce1e605194cb26ff6cb804c7d2c3418 (patch) | |
tree | a2cf102515e381859445a42703184fb32556e78d /src/leap/baseapp/leap_app.py | |
parent | 83a3fed0d38e44e64cec027f9fd2fcd5a894f96a (diff) | |
parent | 3b752fcfac7a18891e2f948acae0cb4781678647 (diff) |
Merge branch 'feature/qt-refactor' into develop
closes #474: refactor Qt Code
Diffstat (limited to 'src/leap/baseapp/leap_app.py')
-rw-r--r-- | src/leap/baseapp/leap_app.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py new file mode 100644 index 00000000..def95da1 --- /dev/null +++ b/src/leap/baseapp/leap_app.py @@ -0,0 +1,83 @@ +from PyQt4 import QtGui + +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 + # 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 + """ + self.headerBox = QtGui.QGroupBox() + self.headerLabel = QtGui.QLabel("<font size=40><b>E</b>ncryption \ +<b>I</b>nternet <b>P</b>roxy</font>") + self.headerLabelSub = QtGui.QLabel("<i>trust your \ +technolust</i>") + + 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 " + "<b>Quit</b> 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() |