From 51dee24be94567334dfb8765cbd3bb23dcae9ee3 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 04:10:50 +0900 Subject: init QSettings - save window geometry --- src/leap/baseapp/leap_app.py | 10 +++++++++- src/leap/baseapp/mainwindow.py | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 98ca292e..49f7ceda 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -1,5 +1,9 @@ import logging +import sip +sip.setapi('QVariant', 2) + +from PyQt4 import QtCore from PyQt4 import QtGui from leap.gui import mainwindow_rc @@ -35,7 +39,7 @@ class MainWindowMixin(object): self.setWindowTitle("LEAP Client") self.set_app_icon() - self.resize(400, 300) + #self.resize(400, 300) self.set_statusbarMessage('ready') logger.debug('set ready.........') @@ -88,6 +92,10 @@ class MainWindowMixin(object): """ cleans state before shutting down app. """ + # save geometry for restoring + settings = QtCore.QSettings() + settings.setValue("Geometry", self.saveGeometry()) + # TODO:make sure to shutdown all child process / threads # in conductor # XXX send signal instead? diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 55be55f7..d3656cd4 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -30,14 +30,19 @@ class LeapWindow(QtGui.QMainWindow, def __init__(self, opts): logger.debug('init leap window') self.debugmode = getattr(opts, 'debug', False) - super(LeapWindow, self).__init__() if self.debugmode: self.createLogBrowser() + EIPConductorAppMixin.__init__(self, opts=opts) StatusAwareTrayIconMixin.__init__(self) MainWindowMixin.__init__(self) + settings = QtCore.QSettings() + geom = settings.value("Geometry") + if geom: + self.restoreGeometry(geom) + self.initchecks = InitChecksThread(self.run_eip_checks) # bind signals -- cgit v1.2.3 From a92ea6fcc5e2e10c6df6d41b52a5d98044317eba Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 05:32:15 +0900 Subject: wizard called from main app if not run before. --- src/leap/baseapp/mainwindow.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index d3656cd4..63242fd2 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -26,6 +26,7 @@ class LeapWindow(QtGui.QMainWindow, newLogLine = QtCore.pyqtSignal([str]) statusChange = QtCore.pyqtSignal([object]) + initReady = QtCore.pyqtSignal([]) def __init__(self, opts): logger.debug('init leap window') @@ -42,6 +43,7 @@ class LeapWindow(QtGui.QMainWindow, geom = settings.value("Geometry") if geom: self.restoreGeometry(geom) + self.wizard_done = settings.value("FirstRunWizardDone") self.initchecks = InitChecksThread(self.run_eip_checks) @@ -55,9 +57,20 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) + self.initReady.connect(self.runchecks_and_eipconnect) # ... all ready. go! - + if self.wizard_done: + self.initReady.emit() + else: + # need to run first-run-wizard + from leap.gui.firstrunwizard import FirstRunWizard + wizard = FirstRunWizard( + parent=self, + success_cb=self.initReady.emit) + wizard.show() + + def runchecks_and_eipconnect(self): self.initchecks.begin() -- cgit v1.2.3 From b9d1b57976984d1032b3abc810f462a80fdc55aa Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 07:00:42 +0900 Subject: focus fix for wizard --- src/leap/baseapp/mainwindow.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 63242fd2..1accac30 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -26,6 +26,7 @@ class LeapWindow(QtGui.QMainWindow, newLogLine = QtCore.pyqtSignal([str]) statusChange = QtCore.pyqtSignal([object]) + mainappReady = QtCore.pyqtSignal([]) initReady = QtCore.pyqtSignal([]) def __init__(self, opts): @@ -57,13 +58,22 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) + + # do frwizard and init signals + self.mainappReady.connect(self.do_first_run_wizard_check) self.initReady.connect(self.runchecks_and_eipconnect) # ... all ready. go! + # calls do_first_run_wizard_check + self.mainappReady.emit() + + def do_first_run_wizard_check(self): + logger.debug('first run wizard check...') if self.wizard_done: self.initReady.emit() else: # need to run first-run-wizard + logger.debug('running first run wizard') from leap.gui.firstrunwizard import FirstRunWizard wizard = FirstRunWizard( parent=self, -- cgit v1.2.3 From 3e2eb0cb1878a9494650ea1278ef2f9211ebdaac Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 10:10:04 +0900 Subject: add menu for running wizard at will it's still buggy in that it does not bother to stop the ongoing checks or connection. we should take care of that soon. --- src/leap/baseapp/leap_app.py | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 49f7ceda..460d1269 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -27,9 +27,9 @@ class MainWindowMixin(object): widget = QtGui.QWidget() self.setCentralWidget(widget) + mainLayout = QtGui.QVBoxLayout() # add widgets to layout #self.createWindowHeader() - mainLayout = QtGui.QVBoxLayout() #mainLayout.addWidget(self.headerBox) mainLayout.addWidget(self.statusIconBox) if self.debugmode: @@ -37,11 +37,51 @@ class MainWindowMixin(object): mainLayout.addWidget(self.loggerBox) widget.setLayout(mainLayout) + self.createMainActions() + self.createMainMenus() + self.setWindowTitle("LEAP Client") self.set_app_icon() - #self.resize(400, 300) self.set_statusbarMessage('ready') - logger.debug('set ready.........') + + def createMainActions(self): + #self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O", + #triggered=self.open) + + self.firstRunWizardAct = QtGui.QAction( + "&First run wizard...", self, + triggered=self.launch_first_run_wizard) + self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) + + #self.aboutQtAct = QtGui.QAction("About &Qt", self, + #triggered=QtGui.qApp.aboutQt) + + def createMainMenus(self): + self.connMenu = QtGui.QMenu("&Connections", self) + #self.viewMenu.addSeparator() + self.connMenu.addAction(self.quitAction) + + self.settingsMenu = QtGui.QMenu("&Settings", self) + self.settingsMenu.addAction(self.firstRunWizardAct) + + self.helpMenu = QtGui.QMenu("&Help", self) + self.helpMenu.addAction(self.aboutAct) + #self.helpMenu.addAction(self.aboutQtAct) + + self.menuBar().addMenu(self.connMenu) + self.menuBar().addMenu(self.settingsMenu) + self.menuBar().addMenu(self.helpMenu) + + def launch_first_run_wizard(self): + settings = QtCore.QSettings() + settings.setValue('FirstRunWizardDone', False) + logger.debug('should run first run wizard again...') + + from leap.gui.firstrunwizard import FirstRunWizard + wizard = FirstRunWizard( + parent=self, + success_cb=self.initReady.emit) + wizard.show() def set_app_icon(self): icon = QtGui.QIcon(APP_LOGO) -- cgit v1.2.3