summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-10-05 05:32:15 +0900
committerkali <kali@leap.se>2012-10-05 05:32:15 +0900
commita92ea6fcc5e2e10c6df6d41b52a5d98044317eba (patch)
treec1ee5ad1a4ece846d3f9f12717d7617f0e8ecece /src/leap
parent87a3deb2c419eb7cb6ab6937042310cf5d0370c0 (diff)
wizard called from main app if not run before.
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/app.py1
-rw-r--r--src/leap/baseapp/mainwindow.py15
-rwxr-xr-xsrc/leap/gui/firstrunwizard.py19
3 files changed, 32 insertions, 3 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index a5e09d80..341f6a6e 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -3,6 +3,7 @@ import logging
# This is only needed for Python v2 but is harmless for Python v3.
import sip
sip.setapi('QVariant', 2)
+sip.setapi('QString', 2)
from PyQt4.QtGui import (QApplication, QSystemTrayIcon, QMessageBox)
from leap import __version__ as VERSION
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()
diff --git a/src/leap/gui/firstrunwizard.py b/src/leap/gui/firstrunwizard.py
index bf1f351c..b93dc8e9 100755
--- a/src/leap/gui/firstrunwizard.py
+++ b/src/leap/gui/firstrunwizard.py
@@ -1,14 +1,18 @@
#!/usr/bin/env python
-# This is only needed for Python v2 but is harmless for Python v3.
+import logging
+
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
+from PyQt4 import QtCore
from PyQt4 import QtGui
# XXX change and use some other stuff.
import firstrunwizard_rc
+logger = logging.getLogger(__name__)
+
# registration ######################
# move to base/
@@ -83,13 +87,16 @@ QLabel { color: red;
class FirstRunWizard(QtGui.QWizard):
- def __init__(self, parent=None, providers=None):
+ def __init__(self, parent=None, providers=None, success_cb=None):
super(FirstRunWizard, self).__init__(parent)
if not providers:
providers = ('springbok',)
self.providers = providers
+ # success callback
+ self.success_cb = success_cb
+
self.addPage(IntroPage())
self.addPage(SelectProviderPage(providers=providers))
@@ -119,6 +126,14 @@ class FirstRunWizard(QtGui.QWizard):
# and pass a dict with options
# XXX unless one exists by default...
+ settings = QtCore.QSettings()
+ settings.setValue("FirstRunWizardDone", True)
+
+ logger.debug('First Run Wizard Done.')
+ cb = self.success_cb
+ if cb and callable(cb):
+ self.success_cb()
+
def get_provider(self):
provider = self.field('provider_index')
return self.providers[provider]