9 |
9 |
10 import sys |
10 import sys |
11 import os |
11 import os |
12 |
12 |
13 from PyQt4.QtCore import QProcess, QSettings, QFileInfo |
13 from PyQt4.QtCore import QProcess, QSettings, QFileInfo |
14 from PyQt4.QtGui import QSystemTrayIcon, QMenu, qApp, QCursor |
14 from PyQt4.QtGui import QSystemTrayIcon, QMenu, qApp, QCursor, QApplication, QDialog |
15 |
15 |
16 from E5Gui import E5MessageBox |
16 from E5Gui import E5MessageBox |
17 |
17 |
18 import Globals |
18 import Globals |
19 import UI.PixmapCache |
19 import UI.PixmapCache |
20 |
20 |
21 import Utilities |
21 import Utilities |
|
22 import Preferences |
22 |
23 |
23 from eric5config import getConfig |
24 from eric5config import getConfig |
24 |
25 |
25 class TrayStarter(QSystemTrayIcon): |
26 class TrayStarter(QSystemTrayIcon): |
26 """ |
27 """ |
62 |
64 |
63 self.recentFilesMenu = QMenu(self.trUtf8('Recent Files'), self.__menu) |
65 self.recentFilesMenu = QMenu(self.trUtf8('Recent Files'), self.__menu) |
64 self.recentFilesMenu.aboutToShow.connect(self.__showRecentFilesMenu) |
66 self.recentFilesMenu.aboutToShow.connect(self.__showRecentFilesMenu) |
65 self.recentFilesMenu.triggered.connect(self.__openRecent) |
67 self.recentFilesMenu.triggered.connect(self.__openRecent) |
66 |
68 |
67 act = self.__menu.addAction(self.trUtf8("Eric5 tray starter")) |
69 act = self.__menu.addAction( |
|
70 self.trUtf8("Eric5 tray starter"), self.__about) |
68 font = act.font() |
71 font = act.font() |
69 font.setBold(True) |
72 font.setBold(True) |
70 act.setFont(font) |
73 act.setFont(font) |
71 self.__menu.addSeparator() |
74 self.__menu.addSeparator() |
72 |
75 |
106 self.trUtf8('Preferences'), self.__startPreferences) |
109 self.trUtf8('Preferences'), self.__startPreferences) |
107 self.__menu.addAction(UI.PixmapCache.getIcon("erict.png"), |
110 self.__menu.addAction(UI.PixmapCache.getIcon("erict.png"), |
108 self.trUtf8("eric5 IDE"), self.__startEric) |
111 self.trUtf8("eric5 IDE"), self.__startEric) |
109 self.__menu.addAction(UI.PixmapCache.getIcon("editor.png"), |
112 self.__menu.addAction(UI.PixmapCache.getIcon("editor.png"), |
110 self.trUtf8("eric5 Mini Editor"), self.__startMiniEditor) |
113 self.trUtf8("eric5 Mini Editor"), self.__startMiniEditor) |
|
114 self.__menu.addSeparator() |
|
115 |
|
116 self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"), |
|
117 self.trUtf8('Preferences (tray starter)'), self.__showPreferences) |
111 self.__menu.addSeparator() |
118 self.__menu.addSeparator() |
112 |
119 |
113 # recent files |
120 # recent files |
114 self.menuRecentFilesAct = self.__menu.addMenu(self.recentFilesMenu) |
121 self.menuRecentFilesAct = self.__menu.addMenu(self.recentFilesMenu) |
115 # recent multi projects |
122 # recent multi projects |
382 @param act reference to the action that triggered (QAction) |
389 @param act reference to the action that triggered (QAction) |
383 """ |
390 """ |
384 filename = act.data() |
391 filename = act.data() |
385 if filename: |
392 if filename: |
386 self.__startProc("eric5.py", filename) |
393 self.__startProc("eric5.py", filename) |
|
394 |
|
395 def __showPreferences(self): |
|
396 """ |
|
397 Private slot to set the preferences. |
|
398 """ |
|
399 from Preferences.ConfigurationDialog import ConfigurationDialog |
|
400 dlg = ConfigurationDialog(None, 'Configuration', True, |
|
401 fromEric = True, |
|
402 displayMode = ConfigurationDialog.TrayStarterMode) |
|
403 dlg.preferencesChanged.connect(self.preferencesChanged) |
|
404 dlg.show() |
|
405 dlg.showConfigurationPageByName("trayStarterPage") |
|
406 dlg.exec_() |
|
407 QApplication.processEvents() |
|
408 if dlg.result() == QDialog.Accepted: |
|
409 dlg.setPreferences() |
|
410 Preferences.syncPreferences() |
|
411 self.preferencesChanged() |
|
412 |
|
413 def preferencesChanged(self): |
|
414 """ |
|
415 Public slot to handle a change of preferences. |
|
416 """ |
|
417 self.setIcon( |
|
418 UI.PixmapCache.getIcon(Preferences.getTrayStarter("TrayStarterIcon"))) |
|
419 |
|
420 def __about(self): |
|
421 """ |
|
422 Private slot to handle the About dialog. |
|
423 """ |
|
424 from Plugins.AboutPlugin.AboutDialog import AboutDialog |
|
425 dlg = AboutDialog() |
|
426 dlg.exec_() |