Commits

Anonymous committed a094872

It's unique now - no new window appears, before the old has been closed.

Comments (0)

Files changed (2)

 
 # First the GUI class and the Data about the program
 from rad import Rad
-from rad import aboutData
-from rad import __version__
+#from rad import aboutData
+# Also SIGNAL and SLOT, so we doon't call PyQt4 directly from here.
+from rad import SIGNAL, SLOT
 
 # Then commandline arguments and handling
 from sys import argv
 from PyKDE4.kdecore import KCmdLineArgs
+# And AboutData - moved here, so we don't need to pull in GUI stuff to check if we're the first instance
+from PyKDE4.kdecore import ki18n, KAboutData
 
 # KApplication for basics
-from PyKDE4.kdeui import KApplication
-
+from PyKDE4.kdeui import KUniqueApplication
+    
 
 # and exiting.
 from sys import exit as exit_
 
+### Constants ###
+
+#: The PyRad version identifier
+__version__ = "0.2.0"
+
+
 ### Runner ###
 
+### About the Program ###
+
+# This also allows our users to use DrKonqui for crash recovery.
+
+def createAboutData():
+    """Create the aboutData for PyRad."""
+    appName     = "pyRad"
+    catalog     = ""
+    programName = ki18n ("Rad")
+    version     = __version__
+    description = ki18n ("A simple radial command menu - best called with a gesture")
+    license     = KAboutData.License_GPL
+    copyright   = ki18n ("(c) 2009 Arne Babenhauserheide")
+    text        = ki18n ("pyRad is heavily inspired by Kommando, which sadly didn't make it into KDE4. Kommando in turn was inspired by the Neverwinternights menu.")
+    homePage    = "draketo.de"
+    bugEmail    = "arne_bab@web.de"
+
+    aboutData   = KAboutData (appName, catalog, programName, version, description,
+                        license, copyright, text, homePage, bugEmail)
+    return aboutData
+
 def initKApp():
     """Initialize the KApplication."""
-    # First we need to compile the commandline args for KDE programs
+    # First we need the aboutData
+    aboutData = createAboutData()
+    # Now we need to compile the commandline args for KDE programs
     KCmdLineArgs.init (argv, aboutData)
     # Then do basic initializing
-    app = KApplication()
+    app = KUniqueApplication()
     # And get and show the GUI
     return app
 
 # basic graphical stuff
 from PyQt4.QtGui import QWidget, QGridLayout, QCursor, QIcon, QLabel, QLineEdit
 # basic definitions and datatypes
-from PyQt4.QtCore import Qt, QPointF
+from PyQt4.QtCore import Qt, QPointF, SIGNAL, SLOT
 
 # Basics for KDE integration
-from PyKDE4.kdecore import ki18n, KAboutData
 from PyKDE4.kdeui import KIconLoader
 # And a basic dialog class for the edit item dialog.
 from PyKDE4.kdeui import KDialog
 
 ### Constants ###
 
+#: The name of the program - used in the window name
+__appname__ = "pyRad"
 WINDOW_WIDTH = 250
 WINDOW_HEIGHT = 250
 CIRCLE_RADIUS = 80
 ]
 '''
 
-### About the Program ###
-
-# This also allows our users to use DrKonqui for crash recovery.
-
-#: The PyRad version identifier
-__version__ = "0.2.0"
-#: The name of the program - used in the window name
-__appname__ = "pyRad"
-
-def createAboutData():
-    """Create the aboutData for PyRad."""
-    appName     = __appname__
-    catalog     = ""
-    programName = ki18n ("Rad")
-    version     = __version__
-    description = ki18n ("A simple radial command menu - best called with a gesture")
-    license     = KAboutData.License_GPL
-    copyright   = ki18n ("(c) 2009 Arne Babenhauserheide")
-    text        = ki18n ("pyRad is heavily inspired by Kommando, which sadly didn't make it into KDE4. Kommando in turn was inspired by the Neverwinternights menu.")
-    homePage    = "draketo.de"
-    bugEmail    = "arne_bab@web.de"
-
-    aboutData   = KAboutData (appName, catalog, programName, version, description,
-                        license, copyright, text, homePage, bugEmail)
-    return aboutData
-
-# create the aboutData object
-aboutData = createAboutData()
-
 ### Window ###
 
 class ItemEditWidget(QWidget):
         # Add a circle-list for all items
         self.circle = []
 
-        # Setup the circle
+        # Setup the circle - TODO: Call it via KUniqueApplication.newInstance
         self.setup()
 
     def setup(self): 
-        """Setup the items in the circle - used to show the app anew."""
+        """Setup the items in the circle - used to show the app anew.
+
+        @param message: Gets the message from the uniqueCalled signal - currently just discarded.
+        """
         # Move below the cursor
         self.move_to_cursor()