Commits

Arne Babenhauserheide  committed 78a5f6c

added general config dialog

  • Participants
  • Parent commits 99e6b77

Comments (0)

Files changed (4)

File images/Wikimedia_Flattr_Button.png

Added
New image
   (from http://www.staerk.de/thorsten/index.php/Hacking_KDE) -done, left here for reference to the site.
 
 PyPI url: http://pypi.python.org/pypi/pyRadKDE
+Website: http://draketo.de/light/english/pyrad
 """
 
 __doc__ += __install__ + __usage__ + __plans__ + __ideas__
 # for starting programs
 from subprocess import Popen
 
+# basics, currently only for prefix
+import sys
 # For circles
 from math import sin, cos, pi
 # and parsing a command string into words for Popen
 # and system independent home folder location
 from user import home
 
+# and a webbrowser
+import webbrowser
+
 # basic graphical stuff
 from PyQt4.QtGui import QWidget, QGridLayout, QVBoxLayout, QHBoxLayout, QCursor, QIcon, QLabel, QLineEdit, QPushButton, QKeySequence, QPolygon
 # basic definitions and datatypes
         # now a flattr line
         self.flattr_layout = QHBoxLayout()
         self.flattr_left = QLabel("""If you like
-pyRad""")
-        self.flattr_right = QLabel("""Why don’t you
+              pyRad""")
+        self.flattr_left.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
+        #self.flattr_left.setAlignment(Qt.Right)
+        self.flattr_right = QLabel("""Why don't you
 Flattr me? :)""")
-        self.flattr_html = QWebView()
-        # I use the flattr button from Wikimedia commons to avoid data retention hassles. TODO: ship our own flattr button to avoid the web access. 
-        self.flattr_html.setHtml("""<a href="http://flattr.com/thing/58752/pyRad-a-wheel-type-command-interface-for-KDE">
-<img src="http://upload.wikimedia.org/wikipedia/commons/4/49/Flattr_Button.png" alt="Flattr this" title="Flattr this" border="0" /></a></body></html>""")
-        self.flattr_html.sizeHint = (50, 20)
+        # get the icon, either systemwide or local
+        loader = KIconLoader()
+        flattr_pix = loader.loadIcon(join(sys.prefix, "share", "pyrad", "Wikimedia_Flattr_Button.png"), 0)
+        if flattr_pix.isNull():
+            flattr_pix = loader.loadIcon(join("images", "Wikimedia_Flattr_Button.png"), 0)
+        ic = QIcon(flattr_pix) # for a QPushButten
+        self.flattr_icon = QPushButton()
+        self.flattr_icon.setIcon(ic)
         self.flattr_layout.addWidget(self.flattr_left)
-        self.flattr_layout.addWidget(self.flattr_html)
+        self.flattr_layout.addWidget(self.flattr_icon)
         self.flattr_layout.addWidget(self.flattr_right)
         self.lay.addLayout(self.flattr_layout)
+        self.pyrad_url = QLabel("^ <a href='http://draketo.de/light/english/pyrad'>http://draketo.de/light/english/pyrad</a> ^")
+        self.lay.addWidget(self.pyrad_url)
+
+        # connect signals
+        self.connect(self.flattr_icon, SIGNAL("clicked()"), self.openFlattrUrl)
+        self.connect(self.config_keyboard, SIGNAL("clicked()"), self.openShortcutConfig)
+        self.connect(self.config_gestures, SIGNAL("clicked()"), self.openGesturesConfig)
+
+    def openShortcutConfig(self):
+        """Open the Keyboard Shortcut config dialog"""
+        Popen(["kcmshell4", "keys"])
+
+    def openGesturesConfig(self):
+        """Open the Keyboard Shortcut config dialog"""
+        Popen(["kcmshell4", "khotkeys"])
+
+    def openFlattrUrl(self):
+        """Open the flattr Url for the pyrad."""
+        self.openUrl("http://flattr.com/thing/58752/pyRad-a-wheel-type-command-interface-for-KDE")
+    
+    def openUrl(self, url):
+        """open a given URL in the browser"""
+        webbrowser.open(url)
 
 class ConfigEditor(KDialog):
     """edit the base config"""
         # Add the ConfigWidget
         self.main = ConfigWidget(self)
         self.setMainWidget(self.main)
+        self.setCaption("configure the Rad")
         
     def config(self):
         """Show and raise the config dialog."""
                 elif event.button() == Qt.RightButton and i != self.circle[0]:
                     self.editLabel(i)
                     break
-		elif event.button() == Qt.RightButton and i == self.circle[0]:
+		elif event.button() == Qt.RightButton and i == self.circle[0] and i.action is None:
 		    # TODO: right-click on the middle item should show the options. 
 		    # currently we just don't edit it. 
                     self.editor_config.config()
 """pyRad setup (install)"""
 
 # We use the advanced setuptools.
-from setuptools import setup
+try:
+    from distutils.core import setup
+except ImportError: 
+    from setuptools import setup
 # If we have one or more packages, we also need to import find packages
 # It is currently not necessary.
 # The corresponding line in setup() is commented out, too.
             ],
       url='http://bitbucket.org/ArneBab/pyrad',
       #packages = find_packages('.'),
+      data_files = [("share/pyrad", ["images/Wikimedia_Flattr_Button.png"])], 
       py_modules=["rad"],
       scripts=["pyrad.py"]
      )