126 self.recent = [] |
126 self.recent = [] |
127 self.__loadRecent() |
127 self.__loadRecent() |
128 |
128 |
129 self.bookmarked = [] |
129 self.bookmarked = [] |
130 bs = Preferences.Prefs.settings.value("Bookmarked/Sources") |
130 bs = Preferences.Prefs.settings.value("Bookmarked/Sources") |
131 if bs.isValid(): |
131 if bs is not None: |
132 self.bookmarked = bs.toStringList() |
132 self.bookmarked = bs |
133 |
133 |
134 # initialize the autosave timer |
134 # initialize the autosave timer |
135 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
135 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
136 self.autosaveTimer = QTimer(self) |
136 self.autosaveTimer = QTimer(self) |
137 self.autosaveTimer.setObjectName("AutosaveTimer") |
137 self.autosaveTimer.setObjectName("AutosaveTimer") |
164 Private method to load the recently opened filenames. |
164 Private method to load the recently opened filenames. |
165 """ |
165 """ |
166 self.recent = [] |
166 self.recent = [] |
167 Preferences.Prefs.rsettings.sync() |
167 Preferences.Prefs.rsettings.sync() |
168 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
168 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
169 if rs.isValid(): |
169 if rs is not None: |
170 for f in rs.toStringList(): |
170 for f in rs: |
171 if QFileInfo(f).exists(): |
171 if QFileInfo(f).exists(): |
172 self.recent.append(f) |
172 self.recent.append(f) |
173 |
173 |
174 def __saveRecent(self): |
174 def __saveRecent(self): |
175 """ |
175 """ |
176 Private method to save the list of recently opened filenames. |
176 Private method to save the list of recently opened filenames. |
177 """ |
177 """ |
178 Preferences.Prefs.rsettings.setValue(recentNameFiles, QVariant(self.recent)) |
178 Preferences.Prefs.rsettings.setValue(recentNameFiles, self.recent) |
179 Preferences.Prefs.rsettings.sync() |
179 Preferences.Prefs.rsettings.sync() |
180 |
180 |
181 def getMostRecent(self): |
181 def getMostRecent(self): |
182 """ |
182 """ |
183 Public method to get the most recently opened file. |
183 Public method to get the most recently opened file. |
699 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
699 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
700 exporters = supportedExporters.keys() |
700 exporters = supportedExporters.keys() |
701 exporters.sort() |
701 exporters.sort() |
702 for exporter in exporters: |
702 for exporter in exporters: |
703 act = menu.addAction(supportedExporters[exporter]) |
703 act = menu.addAction(supportedExporters[exporter]) |
704 act.setData(QVariant(exporter)) |
704 act.setData(exporter) |
705 |
705 |
706 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
706 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
707 |
707 |
708 return menu |
708 return menu |
709 |
709 |
3473 |
3473 |
3474 @param act reference to the action that was triggered (QAction) |
3474 @param act reference to the action that was triggered (QAction) |
3475 """ |
3475 """ |
3476 aw = self.activeWindow() |
3476 aw = self.activeWindow() |
3477 if aw: |
3477 if aw: |
3478 exporterFormat = act.data().toString() |
3478 exporterFormat = act.data() |
3479 aw.exportFile(exporterFormat) |
3479 aw.exportFile(exporterFormat) |
3480 |
3480 |
3481 def newEditor(self): |
3481 def newEditor(self): |
3482 """ |
3482 """ |
3483 Public slot to generate a new empty editor. |
3483 Public slot to generate a new empty editor. |
3538 else: |
3538 else: |
3539 formatStr = '%d. %s' |
3539 formatStr = '%d. %s' |
3540 act = self.recentMenu.addAction(\ |
3540 act = self.recentMenu.addAction(\ |
3541 formatStr % (idx, |
3541 formatStr % (idx, |
3542 Utilities.compactPath(rs, self.ui.maxMenuFilePathLen))) |
3542 Utilities.compactPath(rs, self.ui.maxMenuFilePathLen))) |
3543 act.setData(QVariant(rs)) |
3543 act.setData(rs) |
3544 act.setEnabled(QFileInfo(rs).exists()) |
3544 act.setEnabled(QFileInfo(rs).exists()) |
3545 idx += 1 |
3545 idx += 1 |
3546 |
3546 |
3547 self.recentMenu.addSeparator() |
3547 self.recentMenu.addSeparator() |
3548 self.recentMenu.addAction(\ |
3548 self.recentMenu.addAction(\ |
3571 self.bookmarkedMenu.clear() |
3571 self.bookmarkedMenu.clear() |
3572 |
3572 |
3573 for rp in self.bookmarked: |
3573 for rp in self.bookmarked: |
3574 act = self.bookmarkedMenu.addAction(\ |
3574 act = self.bookmarkedMenu.addAction(\ |
3575 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)) |
3575 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)) |
3576 act.setData(QVariant(rp)) |
3576 act.setData(rp) |
3577 act.setEnabled(QFileInfo(rp).exists()) |
3577 act.setEnabled(QFileInfo(rp).exists()) |
3578 |
3578 |
3579 if len(self.bookmarked): |
3579 if len(self.bookmarked): |
3580 self.bookmarkedMenu.addSeparator() |
3580 self.bookmarkedMenu.addSeparator() |
3581 self.bookmarkedMenu.addAction(\ |
3581 self.bookmarkedMenu.addAction(\ |
4280 "%s%s" % ( |
4280 "%s%s" % ( |
4281 Utilities.compactPath( |
4281 Utilities.compactPath( |
4282 filename, |
4282 filename, |
4283 self.ui.maxMenuFilePathLen - len(bmSuffix)), |
4283 self.ui.maxMenuFilePathLen - len(bmSuffix)), |
4284 bmSuffix)) |
4284 bmSuffix)) |
4285 act.setData(QVariant([QVariant(filename), QVariant(bookmark)])) |
4285 act.setData([filename, bookmark]) |
4286 |
4286 |
4287 def __bookmarkSelected(self, act): |
4287 def __bookmarkSelected(self, act): |
4288 """ |
4288 """ |
4289 Private method to handle the bookmark selected signal. |
4289 Private method to handle the bookmark selected signal. |
4290 |
4290 |
4291 @param act reference to the action that triggered (QAction) |
4291 @param act reference to the action that triggered (QAction) |
4292 """ |
4292 """ |
4293 try: |
4293 bmList = act.data() |
4294 qvList = act.data().toPyObject() |
4294 filename = bmList[0] |
4295 filename = qvList[0] |
4295 line = bmList[1] |
4296 line = qvList[1] |
|
4297 except AttributeError: |
|
4298 qvList = act.data().toList() |
|
4299 filename = qvList[0].toString() |
|
4300 line = qvList[1].toInt()[0] |
|
4301 self.openSourceFile(filename, line) |
4296 self.openSourceFile(filename, line) |
4302 |
4297 |
4303 def __bookmarkToggled(self, editor): |
4298 def __bookmarkToggled(self, editor): |
4304 """ |
4299 """ |
4305 Private slot to handle the bookmarkToggled signal. |
4300 Private slot to handle the bookmarkToggled signal. |
4450 |
4445 |
4451 # save the list of recently opened projects |
4446 # save the list of recently opened projects |
4452 self.__saveRecent() |
4447 self.__saveRecent() |
4453 |
4448 |
4454 # save the list of recently opened projects |
4449 # save the list of recently opened projects |
4455 Preferences.Prefs.settings.setValue('Bookmarked/Sources', |
4450 Preferences.Prefs.settings.setValue('Bookmarked/Sources', self.bookmarked) |
4456 QVariant(self.bookmarked)) |
|
4457 |
4451 |
4458 if len(self.editors): |
4452 if len(self.editors): |
4459 return False |
4453 return False |
4460 else: |
4454 else: |
4461 return True |
4455 return True |