Commits

Arne Babenhauserheide  committed 622f95a

Refactoring to allow for using KUniqueApplication instead of KApplication (avoid startup times).

  • Participants
  • Parent commits a610ce6

Comments (0)

Files changed (3)

     app = initKApp()
     # And get and show the GUI
     rad = Rad()
-    rad.show()
     #rad.close()
     # Finally we execute the program - and return the exit code from the program.
     return app.exec_()
 
 ### Imports ###
 
+# First the basic python stuff
+# for starting programs
+from subprocess import Popen
+
+# For circles
+from math import sin, cos, pi
+# and parsing a command string into words for Popen
+from shlex import split as split_action
+# Finally some path tools for loading a config file
+from os.path import join, isfile
+
+# and system independent home folder location
+from user import home
+
 # basic graphical stuff
 from PyQt4.QtGui import QWidget, QGridLayout, QCursor, QIcon, QLabel, QLineEdit
 # basic definitions and datatypes
 # And a basic dialog class for the edit item dialog.
 from PyKDE4.kdeui import KDialog
 
-# For circles
-from math import sin, cos, pi
-# And for starting programs
-from subprocess import Popen
-
-# and parsing a command string into words for Popen
-from shlex import split as split_action
-# Finally some path tools for loading a config file
-from os.path import join, isfile
-
-# and system independent home folder location
-from user import home
-
 
 ### Constants ###
 
         self.setAttribute(Qt.WA_DeleteOnClose)
         self.setAttribute(Qt.WA_TranslucentBackground)
 
+        #: Option to decide if we should die on focus lost - used for prompts
+        self.die_on_focus_out = True
+
+        # Add a name
+        self.setWindowTitle(__appname__)
+
+        # And an icon
+        self.iconloader = KIconLoader()
+        icon = QIcon(self.iconloader.loadIcon(PROGRAM_ICON, 0))
+        self.setWindowIcon(icon)
+
         # resize
         self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
 
+        # Add a circle-list for all items
+        self.circle = []
+
+        # Setup the circle
+        self.setup()
+
+    def setup(self): 
+        """Setup the items in the circle - used to show the app anew."""
         # Move below the cursor
         self.move_to_cursor()
-        self.setWindowTitle(__appname__)
 
         # Make sure we get focus events
         self.setFocusPolicy(Qt.StrongFocus)
 
-        #: Option to decide if we should die on focus lost - used for prompts
-        self.die_on_focus_out = True
-
-        # Add an icon
-        self.iconloader = KIconLoader()
-        icon = QIcon(self.iconloader.loadIcon(PROGRAM_ICON, 0))
-        self.setWindowIcon(icon)
-
         # Load the items from the config file.
         items = self.load_config()
 
-        # Add a circle-list for all items
-        self.circle = []
-
         # And arrange them as labels in a circle
         self.arrange_in_circle(items)
 
         # but we only initialize it when we really need it. 
         self.editor = None # ItemEditor(self)
 
+        # Show the app
+        self.show()
+
 
     def focusOutEvent(self, event):
         """Close when we lose the focus and the mouse isn't inside the window."""

File speedtest.py

     # And get and show the GUI
     return app
 
+def importAllRad():
+    """Import all I need for rad.py."""
+    # basic graphical stuff
+    from PyQt4.QtGui import QWidget, QGridLayout, QCursor, QIcon, QLabel, QLineEdit
+    # basic definitions and datatypes
+    from PyQt4.QtCore import Qt, QPointF
+
+    ## 0.162s till here. - variance in the 0.05s range (guess from experience)
+    
+    # Basics for KDE integration
+    from PyKDE4.kdecore import ki18n, KAboutData
+    ## 0.217s till here.
+    from PyKDE4.kdeui import KIconLoader
+    ## 0.318s till here.
+    # And a basic dialog class for the edit item dialog.
+    from PyKDE4.kdeui import KDialog
+    ## 0.350s till here. 
+    
+    # For circles
+    from math import sin, cos, pi
+    # And for starting programs
+    from subprocess import Popen
+    ## 0.369s
+    ## rest irrelevant
+    
+    # and parsing a command string into words for Popen
+    from shlex import split as split_action
+    # Finally some path tools for loading a config file
+    from os.path import join, isfile
+    
+    # and system independent home folder location
+    from user import home
+