8 """ |
8 """ |
9 |
9 |
10 import sys |
10 import sys |
11 import os |
11 import os |
12 |
12 |
13 from PyQt4.QtCore import SIGNAL, QProcess, QSettings, QFileInfo, QVariant |
13 from PyQt4.QtCore import SIGNAL, QProcess, QSettings, QFileInfo |
14 from PyQt4.QtGui import QSystemTrayIcon, QMenu, qApp, QCursor, QMessageBox |
14 from PyQt4.QtGui import QSystemTrayIcon, QMenu, qApp, QCursor, QMessageBox |
15 |
15 |
16 import Globals |
16 import Globals |
17 import UI.PixmapCache |
17 import UI.PixmapCache |
18 |
18 |
129 def __loadRecentProjects(self): |
129 def __loadRecentProjects(self): |
130 """ |
130 """ |
131 Private method to load the recently opened project filenames. |
131 Private method to load the recently opened project filenames. |
132 """ |
132 """ |
133 rp = self.rsettings.value(Globals.recentNameProject) |
133 rp = self.rsettings.value(Globals.recentNameProject) |
134 if rp.isValid(): |
134 if rp is not None: |
135 for f in rp.toStringList(): |
135 for f in rp: |
136 if QFileInfo(f).exists(): |
136 if QFileInfo(f).exists(): |
137 self.recentProjects.append(f) |
137 self.recentProjects.append(f) |
138 |
138 |
139 def __loadRecentMultiProjects(self): |
139 def __loadRecentMultiProjects(self): |
140 """ |
140 """ |
141 Private method to load the recently opened multi project filenames. |
141 Private method to load the recently opened multi project filenames. |
142 """ |
142 """ |
143 rmp = self.rsettings.value(Globals.recentNameMultiProject) |
143 rmp = self.rsettings.value(Globals.recentNameMultiProject) |
144 if rmp.isValid(): |
144 if rmp is not None: |
145 for f in rmp.toStringList(): |
145 for f in rmp: |
146 if QFileInfo(f).exists(): |
146 if QFileInfo(f).exists(): |
147 self.recentMultiProjects.append(f) |
147 self.recentMultiProjects.append(f) |
148 |
148 |
149 def __loadRecentFiles(self): |
149 def __loadRecentFiles(self): |
150 """ |
150 """ |
151 Private method to load the recently opened filenames. |
151 Private method to load the recently opened filenames. |
152 """ |
152 """ |
153 rf = self.rsettings.value(Globals.recentNameFiles) |
153 rf = self.rsettings.value(Globals.recentNameFiles) |
154 if rf.isValid(): |
154 if rf is not None: |
155 for f in rf.toStringList(): |
155 for f in rf: |
156 if QFileInfo(f).exists(): |
156 if QFileInfo(f).exists(): |
157 self.recentFiles.append(f) |
157 self.recentFiles.append(f) |
158 |
158 |
159 def __activated(self, reason): |
159 def __activated(self, reason): |
160 """ |
160 """ |
317 else: |
317 else: |
318 formatStr = '%d. %s' |
318 formatStr = '%d. %s' |
319 act = self.recentProjectsMenu.addAction( |
319 act = self.recentProjectsMenu.addAction( |
320 formatStr % (idx, |
320 formatStr % (idx, |
321 Utilities.compactPath(rp, self.maxMenuFilePathLen))) |
321 Utilities.compactPath(rp, self.maxMenuFilePathLen))) |
322 act.setData(QVariant(rp)) |
322 act.setData(rp) |
323 idx += 1 |
323 idx += 1 |
324 |
324 |
325 def __showRecentMultiProjectsMenu(self): |
325 def __showRecentMultiProjectsMenu(self): |
326 """ |
326 """ |
327 Private method to set up the recent multi projects menu. |
327 Private method to set up the recent multi projects menu. |
339 else: |
339 else: |
340 formatStr = '%d. %s' |
340 formatStr = '%d. %s' |
341 act = self.recentMultiProjectsMenu.addAction( |
341 act = self.recentMultiProjectsMenu.addAction( |
342 formatStr % (idx, |
342 formatStr % (idx, |
343 Utilities.compactPath(rmp, self.maxMenuFilePathLen))) |
343 Utilities.compactPath(rmp, self.maxMenuFilePathLen))) |
344 act.setData(QVariant(rmp)) |
344 act.setData(rmp) |
345 idx += 1 |
345 idx += 1 |
346 |
346 |
347 def __showRecentFilesMenu(self): |
347 def __showRecentFilesMenu(self): |
348 """ |
348 """ |
349 Private method to set up the recent files menu. |
349 Private method to set up the recent files menu. |
361 else: |
361 else: |
362 formatStr = '%d. %s' |
362 formatStr = '%d. %s' |
363 act = self.recentFilesMenu.addAction(\ |
363 act = self.recentFilesMenu.addAction(\ |
364 formatStr % (idx, |
364 formatStr % (idx, |
365 Utilities.compactPath(rf, self.maxMenuFilePathLen))) |
365 Utilities.compactPath(rf, self.maxMenuFilePathLen))) |
366 act.setData(QVariant(rf)) |
366 act.setData(rf) |
367 idx += 1 |
367 idx += 1 |
368 |
368 |
369 def __openRecent(self, act): |
369 def __openRecent(self, act): |
370 """ |
370 """ |
371 Private method to open a project or file from the list of rencently opened |
371 Private method to open a project or file from the list of rencently opened |
372 projects or files. |
372 projects or files. |
373 |
373 |
374 @param act reference to the action that triggered (QAction) |
374 @param act reference to the action that triggered (QAction) |
375 """ |
375 """ |
376 filename = act.data().toString() |
376 filename = act.data() |
377 if filename: |
377 if filename: |
378 self.__startProc("eric4.py", filename) |
378 self.__startProc("eric4.py", filename) |