summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/gui/firstrun/providerselect.py15
-rw-r--r--src/leap/gui/progress.py18
-rw-r--r--src/leap/gui/utils.py24
3 files changed, 25 insertions, 32 deletions
diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py
index 3ffc6ff6..a4be51a9 100644
--- a/src/leap/gui/firstrun/providerselect.py
+++ b/src/leap/gui/firstrun/providerselect.py
@@ -13,6 +13,7 @@ from leap.base import exceptions as baseexceptions
from leap.eip import exceptions as eipexceptions
from leap.gui.progress import InlineValidationPage
from leap.gui import styles
+from leap.gui.utils import delay
from leap.util.web import get_https_domain_and_port
from leap.gui.constants import APP_LOGO
@@ -20,20 +21,8 @@ from leap.gui.constants import APP_LOGO
logger = logging.getLogger(__name__)
-def delay(obj, method_str):
- # XXX check newer version in progress.py...
- """
- this is a hack to get responsiveness in the ui
- """
- QtCore.QTimer().singleShot(
- 10,
- lambda: QtCore.QMetaObject.invokeMethod(
- obj, method_str))
-
-
class SelectProviderPage(InlineValidationPage):
- #disableCheckButton = QtCore.pyqtSignal()
launchChecks = QtCore.pyqtSignal()
def __init__(self, parent=None, providers=None):
@@ -183,8 +172,6 @@ class SelectProviderPage(InlineValidationPage):
QtCore.QMetaObject.invokeMethod(
self, "showStepsFrame")
- # is this still needed?
- # XXX can I doo delay(self, "do_checks") ?
delay(self, "launch_checks")
def _do_checks(self):
diff --git a/src/leap/gui/progress.py b/src/leap/gui/progress.py
index 6f13a1ac..64b87b2c 100644
--- a/src/leap/gui/progress.py
+++ b/src/leap/gui/progress.py
@@ -24,24 +24,6 @@ ICON_WAITING = ":/images/Emblem-question.png"
logger = logging.getLogger(__name__)
-# XXX import this from threads
-def delay(obj, method_str=None, call_args=None):
- """
- this is a hack to get responsiveness in the ui
- """
- if callable(obj) and not method_str:
- QtCore.QTimer().singleShot(
- 50,
- lambda: obj())
- return
-
- if method_str:
- QtCore.QTimer().singleShot(
- 50,
- lambda: QtCore.QMetaObject.invokeMethod(
- obj, method_str))
-
-
class ImgWidget(QtGui.QWidget):
# XXX move to widgets
diff --git a/src/leap/gui/utils.py b/src/leap/gui/utils.py
index 8b1e3630..f91ac3ef 100644
--- a/src/leap/gui/utils.py
+++ b/src/leap/gui/utils.py
@@ -1,6 +1,7 @@
"""
utility functions to work with gui objects
"""
+from PyQt4 import QtCore
def layout_widgets(layout):
@@ -8,3 +9,26 @@ def layout_widgets(layout):
return a generator with all widgets in a layout
"""
return (layout.itemAt(i) for i in range(layout.count()))
+
+
+DELAY_MSECS = 50
+
+
+def delay(obj, method_str=None, call_args=None):
+ """
+ Triggers a function or slot with a small delay.
+ this is a mainly a hack to get responsiveness in the ui
+ in cases in which the event loop freezes and the task
+ is not heavy enough to setup a processing queue.
+ """
+ if callable(obj) and not method_str:
+ fun = lambda: obj()
+
+ if method_str:
+ invoke = QtCore.QMetaObject.invokeMethod
+ if call_args:
+ fun = lambda: invoke(obj, method_str, call_args)
+ else:
+ fun = lambda: invoke(obj, method_str)
+
+ QtCore.QTimer().singleShot(DELAY_MSECS, fun)