20 |
20 |
21 import Utilities |
21 import Utilities |
22 import Preferences |
22 import Preferences |
23 |
23 |
24 from eric5config import getConfig |
24 from eric5config import getConfig |
|
25 |
25 |
26 |
26 class TrayStarter(QSystemTrayIcon): |
27 class TrayStarter(QSystemTrayIcon): |
27 """ |
28 """ |
28 Class implementing a starter for the system tray. |
29 Class implementing a starter for the system tray. |
29 """ |
30 """ |
30 def __init__(self): |
31 def __init__(self): |
31 """ |
32 """ |
32 Constructor |
33 Constructor |
33 """ |
34 """ |
34 QSystemTrayIcon.__init__(self, |
35 QSystemTrayIcon.__init__(self, |
35 UI.PixmapCache.getIcon(Preferences.getTrayStarter("TrayStarterIcon"))) |
36 UI.PixmapCache.getIcon(Preferences.getTrayStarter("TrayStarterIcon"))) |
36 |
37 |
37 self.maxMenuFilePathLen = 75 |
38 self.maxMenuFilePathLen = 75 |
38 |
39 |
39 self.rsettings = QSettings(QSettings.IniFormat, |
40 self.rsettings = QSettings(QSettings.IniFormat, |
40 QSettings.UserScope, |
41 QSettings.UserScope, |
41 Globals.settingsNameOrganization, |
42 Globals.settingsNameOrganization, |
42 Globals.settingsNameRecent) |
43 Globals.settingsNameRecent) |
43 |
44 |
44 self.recentProjects = [] |
45 self.recentProjects = [] |
45 self.__loadRecentProjects() |
46 self.__loadRecentProjects() |
46 self.recentMultiProjects = [] |
47 self.recentMultiProjects = [] |
91 self.trUtf8("Compare Files"), self.__startDiff) |
92 self.trUtf8("Compare Files"), self.__startDiff) |
92 self.__menu.addAction(UI.PixmapCache.getIcon("compareFiles.png"), |
93 self.__menu.addAction(UI.PixmapCache.getIcon("compareFiles.png"), |
93 self.trUtf8("Compare Files side by side"), self.__startCompare) |
94 self.trUtf8("Compare Files side by side"), self.__startCompare) |
94 self.__menu.addSeparator() |
95 self.__menu.addSeparator() |
95 |
96 |
96 self.__menu.addAction(UI.PixmapCache.getIcon("sqlBrowser.png"), |
97 self.__menu.addAction(UI.PixmapCache.getIcon("sqlBrowser.png"), |
97 self.trUtf8("SQL Browser"), self.__startSqlBrowser) |
98 self.trUtf8("SQL Browser"), self.__startSqlBrowser) |
98 self.__menu.addSeparator() |
99 self.__menu.addSeparator() |
99 |
100 |
100 self.__menu.addAction(UI.PixmapCache.getIcon("iconEditor.png"), |
101 self.__menu.addAction(UI.PixmapCache.getIcon("iconEditor.png"), |
101 self.trUtf8("Icon Editor"), self.__startIconEditor) |
102 self.trUtf8("Icon Editor"), self.__startIconEditor) |
102 self.__menu.addSeparator() |
103 self.__menu.addSeparator() |
103 |
104 |
104 self.__menu.addAction(UI.PixmapCache.getIcon("pluginInstall.png"), |
105 self.__menu.addAction(UI.PixmapCache.getIcon("pluginInstall.png"), |
105 self.trUtf8("Install Plugin"), self.__startPluginInstall) |
106 self.trUtf8("Install Plugin"), self.__startPluginInstall) |
111 |
112 |
112 self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"), |
113 self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"), |
113 self.trUtf8('Preferences'), self.__startPreferences) |
114 self.trUtf8('Preferences'), self.__startPreferences) |
114 self.__menu.addAction(UI.PixmapCache.getIcon("erict.png"), |
115 self.__menu.addAction(UI.PixmapCache.getIcon("erict.png"), |
115 self.trUtf8("eric5 IDE"), self.__startEric) |
116 self.trUtf8("eric5 IDE"), self.__startEric) |
116 self.__menu.addAction(UI.PixmapCache.getIcon("editor.png"), |
117 self.__menu.addAction(UI.PixmapCache.getIcon("editor.png"), |
117 self.trUtf8("eric5 Mini Editor"), self.__startMiniEditor) |
118 self.trUtf8("eric5 Mini Editor"), self.__startMiniEditor) |
118 self.__menu.addSeparator() |
119 self.__menu.addSeparator() |
119 |
120 |
120 self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"), |
121 self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"), |
121 self.trUtf8('Preferences (tray starter)'), self.__showPreferences) |
122 self.trUtf8('Preferences (tray starter)'), self.__showPreferences) |
341 if idx < 10: |
342 if idx < 10: |
342 formatStr = '&{0:d}. {1}' |
343 formatStr = '&{0:d}. {1}' |
343 else: |
344 else: |
344 formatStr = '{0:d}. {1}' |
345 formatStr = '{0:d}. {1}' |
345 act = self.recentProjectsMenu.addAction( |
346 act = self.recentProjectsMenu.addAction( |
346 formatStr.format(idx, |
347 formatStr.format(idx, |
347 Utilities.compactPath(rp, self.maxMenuFilePathLen))) |
348 Utilities.compactPath(rp, self.maxMenuFilePathLen))) |
348 act.setData(rp) |
349 act.setData(rp) |
349 idx += 1 |
350 idx += 1 |
350 |
351 |
351 def __showRecentMultiProjectsMenu(self): |
352 def __showRecentMultiProjectsMenu(self): |
363 if idx < 10: |
364 if idx < 10: |
364 formatStr = '&{0:d}. {1}' |
365 formatStr = '&{0:d}. {1}' |
365 else: |
366 else: |
366 formatStr = '{0:d}. {1}' |
367 formatStr = '{0:d}. {1}' |
367 act = self.recentMultiProjectsMenu.addAction( |
368 act = self.recentMultiProjectsMenu.addAction( |
368 formatStr.format(idx, |
369 formatStr.format(idx, |
369 Utilities.compactPath(rmp, self.maxMenuFilePathLen))) |
370 Utilities.compactPath(rmp, self.maxMenuFilePathLen))) |
370 act.setData(rmp) |
371 act.setData(rmp) |
371 idx += 1 |
372 idx += 1 |
372 |
373 |
373 def __showRecentFilesMenu(self): |
374 def __showRecentFilesMenu(self): |
385 if idx < 10: |
386 if idx < 10: |
386 formatStr = '&{0:d}. {1}' |
387 formatStr = '&{0:d}. {1}' |
387 else: |
388 else: |
388 formatStr = '{0:d}. {1}' |
389 formatStr = '{0:d}. {1}' |
389 act = self.recentFilesMenu.addAction( |
390 act = self.recentFilesMenu.addAction( |
390 formatStr.format(idx, |
391 formatStr.format(idx, |
391 Utilities.compactPath(rf, self.maxMenuFilePathLen))) |
392 Utilities.compactPath(rf, self.maxMenuFilePathLen))) |
392 act.setData(rf) |
393 act.setData(rf) |
393 idx += 1 |
394 idx += 1 |
394 |
395 |
395 def __openRecent(self, act): |
396 def __openRecent(self, act): |
396 """ |
397 """ |
397 Private method to open a project or file from the list of rencently opened |
398 Private method to open a project or file from the list of rencently opened |
398 projects or files. |
399 projects or files. |
399 |
400 |
400 @param act reference to the action that triggered (QAction) |
401 @param act reference to the action that triggered (QAction) |
401 """ |
402 """ |
402 filename = act.data() |
403 filename = act.data() |
406 def __showPreferences(self): |
407 def __showPreferences(self): |
407 """ |
408 """ |
408 Private slot to set the preferences. |
409 Private slot to set the preferences. |
409 """ |
410 """ |
410 from Preferences.ConfigurationDialog import ConfigurationDialog |
411 from Preferences.ConfigurationDialog import ConfigurationDialog |
411 dlg = ConfigurationDialog(None, 'Configuration', True, |
412 dlg = ConfigurationDialog(None, 'Configuration', True, |
412 fromEric = True, |
413 fromEric=True, |
413 displayMode = ConfigurationDialog.TrayStarterMode) |
414 displayMode=ConfigurationDialog.TrayStarterMode) |
414 dlg.preferencesChanged.connect(self.preferencesChanged) |
415 dlg.preferencesChanged.connect(self.preferencesChanged) |
415 dlg.show() |
416 dlg.show() |
416 dlg.showConfigurationPageByName("trayStarterPage") |
417 dlg.showConfigurationPageByName("trayStarterPage") |
417 dlg.exec_() |
418 dlg.exec_() |
418 QApplication.processEvents() |
419 QApplication.processEvents() |