1. Arne Babenhauserheide
  2. pyrad

Commits

Arne Babenhauserheide  committed 2702c60

register F12 and Meta-F12 (Win-F12) as global shortcuts to show the Rad.

  • Participants
  • Parent commits 044ddd2
  • Branches default

Comments (0)

Files changed (1)

File rad.py

View file
 from user import home
 
 # basic graphical stuff
-from PyQt4.QtGui import QWidget, QGridLayout, QCursor, QIcon, QLabel, QLineEdit, QPushButton
+from PyQt4.QtGui import QWidget, QGridLayout, QCursor, QIcon, QLabel, QLineEdit, QPushButton, QKeySequence
 # basic definitions and datatypes
 from PyQt4.QtCore import Qt, QPointF, SIGNAL, SLOT
 
 # Basics for KDE integration
-from PyKDE4.kdeui import KIconLoader
+from PyKDE4.kdeui import KIconLoader, KAction, KActionCollection, KShortcut
 # And a basic dialog class for the edit item dialog.
 from PyKDE4.kdeui import KDialog
 # also the KWindowSystem, so we can get ourselves to the foreground
 from PyKDE4.kdeui import KWindowSystem
+# and internationalization
+from PyKDE4.kdecore import i18n
 
 
 ### Constants ###
         # Add a circle-list for all items
         self.circle = []
 
+        # add a shortcut to show the Rad.
+        self.showAction = KActionCollection(self).addAction("show")
+        self.showAction.setHelpText(i18n("Show the PyRad"))
+        short = self.showAction.shortcut()
+        short.setPrimary(QKeySequence(Qt.Key_F12))
+        short.setAlternate(QKeySequence(Qt.META + Qt.Key_F12))
+        self.showAction.setShortcut(short)
+        self.showAction.setGlobalShortcut(short)
+        self.showAction.connect(self.showAction, SIGNAL("triggered(Qt::MouseButtons, Qt::KeyboardModifiers)"), self.showByShortcut)
+
         # Setup the circle - TODO: Call it via KUniqueApplication.newInstance
+        #self.setup()
+
+    def showByShortcut(self, mouseButtons=None, KeyboardModifiers=None):
         self.setup()
+        self.show()
+        self.toForeground()
 
     def toForeground(self):
         """Get into the foreground, so the user can click us."""