summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-11-07 04:48:12 +0900
committerkali <kali@leap.se>2012-11-07 04:50:26 +0900
commit6032f776cabcd04aa7f4e1f55a34ecfec2775e85 (patch)
treec82600d3ad656b9ab6bf8d23e36a2b79c9f33e64 /src
parent00009f8a7de957c4d53c10855cae1396108203c3 (diff)
changes to update_signal
+ Fix update + Rename + Changed signature (we update progress bar from slot now)
Diffstat (limited to 'src')
-rw-r--r--src/leap/gui/firstrun/providerinfo.py42
-rw-r--r--src/leap/gui/firstrun/providersetup.py14
-rw-r--r--src/leap/gui/progress.py21
-rw-r--r--src/leap/gui/utils.py10
4 files changed, 64 insertions, 23 deletions
diff --git a/src/leap/gui/firstrun/providerinfo.py b/src/leap/gui/firstrun/providerinfo.py
index f5f5518a..52b4873f 100644
--- a/src/leap/gui/firstrun/providerinfo.py
+++ b/src/leap/gui/firstrun/providerinfo.py
@@ -2,22 +2,26 @@
Provider Info Page, used in First run Wizard
"""
+from PyQt4 import QtCore
from PyQt4 import QtGui
+from leap.gui.progress import ValidationPage
+
from leap.gui.constants import APP_LOGO
-class ProviderInfoPage(QtGui.QWizardPage):
+class ProviderInfoPage(ValidationPage):
def __init__(self, parent=None):
super(ProviderInfoPage, self).__init__(parent)
self.setTitle("Provider Info")
- self.setSubTitle("Available information about chosen provider.")
+ #self.setSubTitle("Available information about chosen provider.")
self.setPixmap(
QtGui.QWizard.LogoPixmap,
QtGui.QPixmap(APP_LOGO))
+ def create_info_panel(self):
displayName = QtGui.QLabel("")
description = QtGui.QLabel("")
enrollment_policy = QtGui.QLabel("")
@@ -28,15 +32,18 @@ class ProviderInfoPage(QtGui.QWizardPage):
self.description = description
self.enrollment_policy = enrollment_policy
+ # this trick allows us to reparent
+ QtCore.QObjectCleanupHandler().add(self.layout)
layout = QtGui.QGridLayout()
+
layout.addWidget(displayName, 0, 1)
layout.addWidget(description, 1, 1)
layout.addWidget(enrollment_policy, 2, 1)
self.setLayout(layout)
+ self.update()
- def initializePage(self):
- # XXX move to show info...
+ def show_provider_info(self):
# XXX get multilingual objects
# directly from the config object
@@ -59,9 +66,32 @@ class ProviderInfoPage(QtGui.QWizardPage):
self.enrollment_policy.setText(
'enrollment policy: %s' % enroll)
+ def _do_checks(self, update_signal=None):
+ """
+ executes actual checks in a separate thread
+ """
+ import time
+ update_signal.emit("head_sentinel", 0)
+ time.sleep(0.5)
+ update_signal.emit("something", 10)
+ time.sleep(0.5)
+ update_signal.emit("done", 90)
+ time.sleep(1)
+ update_signal.emit("end_sentinel", 100)
+ time.sleep(1)
+
+ def _do_validation(self):
+ """
+ called after _do_checks has finished
+ (connected to checker thread finished signal)
+ """
+ print 'validation...'
+ self.progress.hide()
+ self.stepsTableWidget.hide()
+ self.create_info_panel()
+ self.show_provider_info()
+
def nextId(self):
wizard = self.wizard()
next_ = "providersetupvalidation"
return wizard.get_page_index(next_)
-
-
diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py
index 63f55d00..c039dfc5 100644
--- a/src/leap/gui/firstrun/providersetup.py
+++ b/src/leap/gui/firstrun/providersetup.py
@@ -21,7 +21,7 @@ class ProviderSetupValidationPage(ValidationPage):
QtGui.QWizard.LogoPixmap,
QtGui.QPixmap(APP_LOGO))
- def _do_checks(self, signal=None):
+ def _do_checks(self, update_signal=None):
"""
executes actual checks in a separate thread
"""
@@ -33,8 +33,7 @@ class ProviderSetupValidationPage(ValidationPage):
pCertChecker = wizard.providercertchecker
certchecker = pCertChecker(domain=domain)
- signal.emit('Fetching CA certificate')
- self.progress.setValue(30)
+ update_signal.emit('Fetching CA certificate', 30)
if pconfig:
ca_cert_uri = pconfig.get('ca_cert_uri').geturl()
@@ -54,8 +53,7 @@ class ProviderSetupValidationPage(ValidationPage):
time.sleep(2)
- signal.emit('Checking CA fingerprint')
- self.progress.setValue(66)
+ update_signal.emit('Checking CA fingerprint', 66)
#ca_cert_fingerprint = pconfig.get('ca_cert_fingerprint', None)
# XXX get fingerprint dict (types)
@@ -69,8 +67,7 @@ class ProviderSetupValidationPage(ValidationPage):
# should catch exception
#return False
- signal.emit('Validating api certificate')
- self.progress.setValue(90)
+ update_signal.emit('Validating api certificate', 90)
#api_uri = pconfig.get('api_uri', None)
#try:
@@ -91,8 +88,7 @@ class ProviderSetupValidationPage(ValidationPage):
time.sleep(0.5)
#ca_cert_path = checker.ca_cert_path
- self.progress.setValue(100)
- signal.emit('end_sentinel')
+ update_signal.emit('end_sentinel', 100)
time.sleep(1)
def _do_validation(self):
diff --git a/src/leap/gui/progress.py b/src/leap/gui/progress.py
index d04e0f1f..16a55e3a 100644
--- a/src/leap/gui/progress.py
+++ b/src/leap/gui/progress.py
@@ -7,7 +7,7 @@ try:
except ImportError:
# We must be in 2.6
from leap.util.dicts import OrderedDict
-import time
+#import time
from PyQt4 import QtCore
from PyQt4 import QtGui
@@ -16,6 +16,8 @@ from leap.baseapp.mainwindow import FunThread
from leap.gui import mainwindow_rc
+CHECKMARK_IMG = ":/images/checked.png"
+
class ImgWidget(QtGui.QWidget):
@@ -154,13 +156,13 @@ class ValidationPage(QtGui.QWizardPage):
# signals
- stepChanged = QtCore.pyqtSignal([str])
+ stepChanged = QtCore.pyqtSignal([str, int])
def __init__(self, parent=None):
super(ValidationPage, self).__init__(parent)
self.steps = ProgressStepContainer()
- self.progress = QtGui.QProgressBar()
+ self.progress = QtGui.QProgressBar(self)
# steps table widget
self.stepsTableWidget = StepsTableWidget(self)
@@ -213,9 +215,12 @@ class ValidationPage(QtGui.QWizardPage):
print 'populate table. width=%s' % width
table.horizontalHeader().resizeSection(0, width * FIRST_COLUMN_PERCENT)
- def onStepStatusChanged(self, status):
- if status != "end_sentinel":
+ def onStepStatusChanged(self, status, progress=None):
+ if status not in ("head_sentinel", "end_sentinel"):
self.add_status_line(status)
+ if progress:
+ self.progress.setValue(progress)
+ self.progress.update()
def add_status_line(self, message):
print 'adding status line...'
@@ -232,8 +237,8 @@ class ValidationPage(QtGui.QWizardPage):
table.setCellWidget(
index - 1,
ProgressStep.DONE,
- # XXX pass image in rc
- ImgWidget(img=":/images/checked.png"))
+ ImgWidget(img=CHECKMARK_IMG))
+ table.update()
def go_back(self):
self.wizard().back()
@@ -253,7 +258,7 @@ class ValidationPage(QtGui.QWizardPage):
"""
signal = self.stepChanged
self.checks = FunThread(
- self._do_checks(signal=signal))
+ self._do_checks(update_signal=signal))
self.checks.finished.connect(self._do_validation)
self.checks.begin()
print 'check thread started!'
diff --git a/src/leap/gui/utils.py b/src/leap/gui/utils.py
new file mode 100644
index 00000000..8b1e3630
--- /dev/null
+++ b/src/leap/gui/utils.py
@@ -0,0 +1,10 @@
+"""
+utility functions to work with gui objects
+"""
+
+
+def layout_widgets(layout):
+ """
+ return a generator with all widgets in a layout
+ """
+ return (layout.itemAt(i) for i in range(layout.count()))