Tools/TrayStarter.py

changeset 701
fc587a1c2f8b
parent 564
b3d966393ba9
child 791
9ec2ac20e54e
--- a/Tools/TrayStarter.py	Sat Oct 23 19:54:52 2010 +0200
+++ b/Tools/TrayStarter.py	Sun Oct 24 17:34:10 2010 +0200
@@ -11,7 +11,7 @@
 import os
 
 from PyQt4.QtCore import QProcess, QSettings, QFileInfo
-from PyQt4.QtGui  import QSystemTrayIcon, QMenu, qApp, QCursor
+from PyQt4.QtGui  import QSystemTrayIcon, QMenu, qApp, QCursor, QApplication, QDialog
 
 from E5Gui import E5MessageBox
 
@@ -19,6 +19,7 @@
 import UI.PixmapCache
 
 import Utilities
+import Preferences
 
 from eric5config import getConfig
 
@@ -30,7 +31,8 @@
         """
         Constructor
         """
-        QSystemTrayIcon.__init__(self, UI.PixmapCache.getIcon("erict.png"))
+        QSystemTrayIcon.__init__(self, 
+            UI.PixmapCache.getIcon(Preferences.getTrayStarter("TrayStarterIcon")))
         
         self.maxMenuFilePathLen = 75
         
@@ -64,7 +66,8 @@
         self.recentFilesMenu.aboutToShow.connect(self.__showRecentFilesMenu)
         self.recentFilesMenu.triggered.connect(self.__openRecent)
         
-        act = self.__menu.addAction(self.trUtf8("Eric5 tray starter"))
+        act = self.__menu.addAction(
+            self.trUtf8("Eric5 tray starter"), self.__about)
         font = act.font()
         font.setBold(True)
         act.setFont(font)
@@ -110,6 +113,10 @@
             self.trUtf8("eric5 Mini Editor"), self.__startMiniEditor)
         self.__menu.addSeparator()
         
+        self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"),
+            self.trUtf8('Preferences (tray starter)'), self.__showPreferences)
+        self.__menu.addSeparator()
+        
         # recent files
         self.menuRecentFilesAct = self.__menu.addMenu(self.recentFilesMenu)
         # recent multi projects
@@ -383,4 +390,37 @@
         """
         filename = act.data()
         if filename:
-            self.__startProc("eric5.py", filename)
\ No newline at end of file
+            self.__startProc("eric5.py", filename)
+    
+    def __showPreferences(self):
+        """
+        Private slot to set the preferences.
+        """
+        from Preferences.ConfigurationDialog import ConfigurationDialog
+        dlg = ConfigurationDialog(None, 'Configuration', True, 
+                                  fromEric = True, 
+                                  displayMode = ConfigurationDialog.TrayStarterMode)
+        dlg.preferencesChanged.connect(self.preferencesChanged)
+        dlg.show()
+        dlg.showConfigurationPageByName("trayStarterPage")
+        dlg.exec_()
+        QApplication.processEvents()
+        if dlg.result() == QDialog.Accepted:
+            dlg.setPreferences()
+            Preferences.syncPreferences()
+            self.preferencesChanged()
+    
+    def preferencesChanged(self):
+        """
+        Public slot to handle a change of preferences.
+        """
+        self.setIcon(
+            UI.PixmapCache.getIcon(Preferences.getTrayStarter("TrayStarterIcon")))
+
+    def __about(self):
+        """
+        Private slot to handle the About dialog.
+        """
+        from Plugins.AboutPlugin.AboutDialog import AboutDialog
+        dlg = AboutDialog()
+        dlg.exec_()

eric ide

mercurial