class VcsStatusMonitorThread(QThread): """ Class implementing the VCS status monitor thread base class. @signal vcsStatusMonitorData(QStringList) emitted to update the VCS status @signal vcsStatusMonitorStatus(QString, QString) emitted to signal the status of the monitoring thread (ok, nok, op) and a status message """ def __init__(self, interval, projectDir, vcs, parent = None): """ Constructor @param interval new interval in seconds (integer) @param projectDir project directory to monitor (string or QString) @param vcs reference to the version control object @param parent reference to the parent object (QObject) """ QThread.__init__(self, parent) self.setObjectName("VcsStatusMonitorThread") self.setTerminationEnabled(True) self.projectDir = QString(projectDir) self.vcs = vcs self.interval = interval self.autoUpdate = False self.statusList = QStringList() self.reportedStates = {} self.shouldUpdate = False self.monitorMutex = QMutex() self.monitorCondition = QWaitCondition() self.__stopIt = False def run(self): """ Protected method implementing the tasks action. """ while not self.__stopIt: # perform the checking task self.statusList.clear() self.emit(SIGNAL("vcsStatusMonitorStatus(QString, QString)"), QString("wait"), self.trUtf8("Waiting for lock")) try: locked = self.vcs.vcsExecutionMutex.tryLock(5000) except TypeError: locked = self.vcs.vcsExecutionMutex.tryLock() if locked: try: self.emit(SIGNAL("vcsStatusMonitorStatus(QString, QString)"), QString("op"), self.trUtf8("Checking repository status")) res, statusMsg = self._performMonitor() finally: self.vcs.vcsExecutionMutex.unlock() if res: status = QString("ok") else: status = QString("nok") self.emit(SIGNAL("vcsStatusMonitorStatus(QString, QString)"), QString("send"), self.trUtf8("Sending data")) self.emit(SIGNAL("vcsStatusMonitorData(QStringList)"), QStringList(self.statusList)) self.emit(SIGNAL("vcsStatusMonitorStatus(QString, QString)"), status, statusMsg) else: self.emit(SIGNAL("vcsStatusMonitorStatus(QString, QString)"), QString("timeout"), self.trUtf8("Timed out waiting for lock")) if self.autoUpdate and self.shouldUpdate: try: self.vcs.vcsUpdate(self.projectDir, True) continue # check again except TypeError: pass # compatibility for older VCS plugins self.shouldUpdate = False # wait until interval has expired checking for a stop condition self.monitorMutex.lock() if not self.__stopIt: self.monitorCondition.wait(self.monitorMutex, self.interval * 1000) self.monitorMutex.unlock() self.exit() def setInterval(self, interval): """ Public method to change the monitor interval. @param interval new interval in seconds (integer) """ locked = self.monitorMutex.tryLock() self.interval = interval self.monitorCondition.wakeAll() if locked: self.monitorMutex.unlock() def getInterval(self): """ Public method to get the monitor interval. @return interval in seconds (integer) """ return self.interval def setAutoUpdate(self, auto): """ Public method to enable the auto update function. @param auto status of the auto update function (boolean) """ self.autoUpdate = auto def getAutoUpdate(self): """ Public method to retrieve the status of the auto update function. @return status of the auto update function (boolean) """ return self.autoUpdate def checkStatus(self): """ Public method to wake up the status monitor thread. """ locked = self.monitorMutex.tryLock() self.monitorCondition.wakeAll() if locked: self.monitorMutex.unlock() def stop(self): """ Public method to stop the monitor thread. """ locked = self.monitorMutex.tryLock() self.__stopIt = True self.monitorCondition.wakeAll() if locked: self.monitorMutex.unlock() def clearCachedState(self, name): """ Public method to clear the cached VCS state of a file/directory. @param name name of the entry to be cleared (QString or string) """ project = e4App().getObject("Project") key = project.getRelativePath(unicode(name)) try: del self.reportedStates[key] except KeyError: pass def _performMonitor(self): """ Protected method implementing the real monitoring action. This method must be overridden and populate the statusList member variable with a list of strings giving the status in the first column and the path relative to the project directory starting with the third column. The allowed status flags are: <ul> <li>"A" path was added but not yet comitted</li> <li>"M" path has local changes</li> <li>"O" path was removed</li> <li>"R" path was deleted and then re-added</li> <li>"U" path needs an update</li> <li>"Z" path contains a conflict</li> <li>" " path is back at normal</li> </ul> @return tuple of flag indicating successful operation (boolean) and a status message in case of non successful operation (QString) """ raise RuntimeError('Not implemented')
class SCJProgress(QHBoxLayout): def __init__(self, parent=None, file=None, format=None, createDir=False ): super(SCJProgress, self).__init__(parent) self.format = format self.filename = file self.createDir = createDir self.process = SCJ(self.filename, self.format, createDir) self.output = QString(self.process.output) self.command = QStringList(self.process.command) self.log = QStringList() self.label = QLabel(self.output) self.label.setToolTip(self.trUtf8("Destination: %s" % self.output)) self.bar = QProgressBar(parent) self.bar.setToolTip(self.trUtf8("Source: %s" % self.filename)) self.bar.setValue(0) self.startbtn = QPushButton(parent) self.stopbtn = QPushButton(parent) self.cancelbtn = QPushButton(parent) self.logbtn = QPushButton(parent) self.cancelbtn.setMinimumSize(32,32) self.cancelbtn.setFlat(True) self.startbtn.setMinimumSize(32,32) self.startbtn.setFlat(True) self.stopbtn.setMinimumSize(32,32) self.stopbtn.setFlat(True) self.label.setMinimumSize(200,32) self.bar.setMinimumSize(100,16) self.bar.setMaximumHeight(16) self.addWidget(self.logbtn) self.logbtn.hide() self.addWidget(self.label) self.addWidget(self.bar) self.addWidget(self.startbtn) self.addWidget(self.stopbtn) self.addWidget(self.cancelbtn) self.retranslateUi() self.connect(self.startbtn, SIGNAL("clicked()"), self.start) self.connect(self.stopbtn, SIGNAL("clicked()"), self.stop) self.connect(self.cancelbtn, SIGNAL("clicked()"), self.remove) self.connect(self.logbtn, SIGNAL('clicked()'), self.showLog) self.connect(self.process, SIGNAL('progress(int)'), self.bar.setValue) self.connect(self.process, SIGNAL('error(QString)'), self.addLog) self.connect(self.process, SIGNAL('finished()'), self.enable) def retranslateUi(self): self.startbtn.setIcon(QIcon(u"images/play.png")) self.startbtn.setToolTip(self.trUtf8("Demarrer")) self.stopbtn.setIcon(QIcon(u"images/stop.png")) self.stopbtn.setToolTip(self.trUtf8("Stopper")) self.cancelbtn.setIcon(QIcon(u"images/remove.png")) self.cancelbtn.setToolTip(self.trUtf8("Annuler")) self.logbtn.setIcon(QIcon(u"images/log.png")) self.logbtn.setToolTip(self.trUtf8("Voir les details")) def start(self): self.log.clear() self.logbtn.hide() self.disable() self.process.start() self.process.resume() def stop(self): self.process.cancel() self.process.terminate() self.enable() def remove(self): self.removeWidget(self.label) self.removeWidget(self.bar) self.removeWidget(self.startbtn) self.removeWidget(self.stopbtn) self.removeWidget(self.cancelbtn) self.removeWidget(self.logbtn) self.label.hide() self.bar.hide() self.startbtn.hide() self.stopbtn.hide() self.cancelbtn.hide() self.logbtn.hide() self.emit(SIGNAL("void removed(QString)"), self.output) def showLog(self): QMessageBox.critical(None, u"Ooops", self.log.join("\n")) def addLog(self, log): self.log.append(log) self.logbtn.show() palette = QPalette() brush = QBrush(QColor(240, 100, 100)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Normal, QPalette.Background, brush) self.label.setPalette(palette) self.label.setAutoFillBackground(True) def enable(self): self.process = SCJ(self.filename, self.format, self.createDir) self.output = QString(self.process.output) self.command = QStringList(self.process.output) self.connect(self.process, SIGNAL('progress(int)'), self.bar.setValue) self.connect(self.process, SIGNAL('error(QString)'), self.addLog) self.connect(self.process, SIGNAL('finished()'), self.enable) self.cancelbtn.setEnabled(True) self.startbtn.setEnabled(True) def disable(self): self.cancelbtn.setEnabled(False) self.startbtn.setEnabled(False) self.label.setAutoFillBackground(False)
class PylouWidget(QGraphicsWidget): """Main Widget for Pylou.""" def __init__(self, parent): """Init class.""" QGraphicsWidget.__init__(self) self.applet = parent def init(self): """Start Pylou Widget.""" self.layou = QGraphicsLinearLayout(self) self.stringlist = QStringList() self.model = QStringListModel(self.applet) self.model.setStringList(self.stringlist) self.treeview = MyTreeView(self) self.treeview.setModel(self.model) self.lineEdit, self.label = MyLineEdit(self), Plasma.Label(self) self.label.setText("Search") self.layou.setOrientation(0x2) # Qt.Vertical self.layou.addItem(self.treeview) self.layou.addItem(self.label) self.layou.addItem(self.lineEdit) self.setLayout(self.layou) self.lineEdit.returnPressed.connect(self.addItem) self.setMinimumSize(200, 99) self.setMaximumSize(666, 666) # custom user choosed fonts user_font_family = QVariant(self.applet.configurations.readEntry( "TextFont", QVariant(QFont()))) self.treeview.nativeWidget().setFont(QFont(user_font_family)) # custom user choosed styles user_style_sheet = "color:{};alternate-background-color:{}".format( self.applet.configurations.readEntry("TextColor"), self.applet.configurations.readEntry("AlternateBColor")) self.treeview.nativeWidget().setStyleSheet(user_style_sheet) # Qt connecting people Applet.connect( self.lineEdit, SIGNAL("keyUPPressed"), self.prevHistoryItem) Applet.connect( self.lineEdit, SIGNAL("keyDownPressed"), self.nextHistoryItem) Applet.connect(self.treeview, SIGNAL("DblClick"), self.openFile) Applet.connect(self.treeview, SIGNAL("Click"), self.openDirectory) self.applet.appletDestroyed.connect(self.saveHistory) # History file self.histfile = HISTORY_FILE_PATH with open(self.histfile, 'r') as history_file: self.history = history_file.readlines() self.historyCurrentItem = 0 self.treeview.nativeWidget().hide() self.resize(self.minimumSize()) def saveHistory(self): """Write History to History file.""" with open(self.histfile, 'w') as history_file: history_file.writelines(self.history) def prevHistoryItem(self): """Navigate the History 1 Item Backwards.""" if self.historyCurrentItem < len(self.history): self.historyCurrentItem = self.historyCurrentItem + 1 try: self.lineEdit.setText(str(self.history[-self.historyCurrentItem])) except IndexError as error: print(error) self.label.setText("ERROR: History Empty.") def nextHistoryItem(self): """Navigate the History 1 Item Forwards.""" if self.historyCurrentItem > 1: self.historyCurrentItem = self.historyCurrentItem - 1 try: self.lineEdit.setText(str(self.history[-self.historyCurrentItem])) except IndexError as error: print(error) self.label.setText("ERROR: History Empty.") def addItem(self): """Add Items from Locate command.""" start_time = datetime.now().second self.stringlist.clear() lineText = self.lineEdit.text() if len(lineText) and str(lineText).strip() not in self.history: self.history.append(lineText + "\n") self.historyCurrentItem = 1 self.saveHistory() self.historyCurrentItem = self.historyCurrentItem - 1 command = "ionice --ignore --class 3 chrt --idle 0 " # Nice CPU / IO command += "locate --ignore-case --existing --quiet --limit 9999 {}" condition = str(self.applet.configurations.readEntry("Home")) == "true" if len(str(lineText).strip()) and condition: command_to_run = command.format( # Only Search inside Home folders path.join(path.expanduser("~"), "*{}*".format(lineText))) else: command_to_run = command.format(lineText) locate_output = Popen(command_to_run, shell=True, stdout=PIPE).stdout results = tuple(locate_output.readlines()) banned = self.applet.configurations.readEntry("Banned") banned_regex_pattern = str(banned).strip().lower().replace(" ", "|") for item in results: if not search(banned_regex_pattern, str(item)): # banned words self.stringlist.append(item[:-1]) purge() # Purge RegEX Cache self.model.setStringList(self.stringlist) self.treeview.nativeWidget().resizeColumnToContents(0) number_of_results = len(results) if number_of_results: # if tems found Focus on item list self.lineEdit.nativeWidget().clear() self.label.setText("Found {} results on {} seconds !".format( number_of_results, abs(datetime.now().second - start_time))) self.resize(500, 12 * number_of_results) self.treeview.nativeWidget().show() self.treeview.nativeWidget().setFocus() else: # if no items found Focus on LineEdit self.label.setText("Search") self.resize(self.minimumSize()) self.treeview.nativeWidget().hide() self.lineEdit.nativeWidget().selectAll() self.lineEdit.nativeWidget().setFocus() def openDirectory(self, index): """Take a model index and find the folder name then open the folder.""" item_to_open = path.dirname(str(self.model.data(index, 0).toString())) Popen("xdg-open '{}'".format(item_to_open), shell=True) def openFile(self, index): """Take a model index and find the filename then open the file.""" item_to_open = self.model.data(index, 0).toString() Popen("xdg-open '{}'".format(item_to_open), shell=True)
class TrayStarter(QSystemTrayIcon): """ Class implementing a starter for the system tray. """ def __init__(self): """ Constructor """ QSystemTrayIcon.__init__(self, UI.PixmapCache.getIcon( unicode(Preferences.getTrayStarter("TrayStarterIcon")))) self.maxMenuFilePathLen = 75 self.rsettings = QSettings(QSettings.IniFormat, QSettings.UserScope, Globals.settingsNameOrganization, Globals.settingsNameRecent) self.recentProjects = QStringList() self.__loadRecentProjects() self.recentMultiProjects = QStringList() self.__loadRecentMultiProjects() self.recentFiles = QStringList() self.__loadRecentFiles() self.connect(self, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.__activated) self.__menu = QMenu(self.trUtf8("Eric4 tray starter")) self.recentProjectsMenu = QMenu(self.trUtf8('Recent Projects'), self.__menu) self.connect(self.recentProjectsMenu, SIGNAL('aboutToShow()'), self.__showRecentProjectsMenu) self.connect(self.recentProjectsMenu, SIGNAL('triggered(QAction *)'), self.__openRecent) self.recentMultiProjectsMenu = \ QMenu(self.trUtf8('Recent Multiprojects'), self.__menu) self.connect(self.recentMultiProjectsMenu, SIGNAL('aboutToShow()'), self.__showRecentMultiProjectsMenu) self.connect(self.recentMultiProjectsMenu, SIGNAL('triggered(QAction *)'), self.__openRecent) self.recentFilesMenu = QMenu(self.trUtf8('Recent Files'), self.__menu) self.connect(self.recentFilesMenu, SIGNAL('aboutToShow()'), self.__showRecentFilesMenu) self.connect(self.recentFilesMenu, SIGNAL('triggered(QAction *)'), self.__openRecent) act = self.__menu.addAction( self.trUtf8("Eric4 tray starter"), self.__about) font = act.font() font.setBold(True) act.setFont(font) self.__menu.addSeparator() self.__menu.addAction(self.trUtf8("QRegExp editor"), self.__startQRegExp) self.__menu.addAction(self.trUtf8("Python re editor"), self.__startPyRe) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("uiPreviewer.png"), self.trUtf8("UI Previewer"), self.__startUIPreviewer) self.__menu.addAction(UI.PixmapCache.getIcon("trPreviewer.png"), self.trUtf8("Translations Previewer"), self.__startTRPreviewer) self.__menu.addAction(UI.PixmapCache.getIcon("unittest.png"), self.trUtf8("Unittest"), self.__startUnittest) self.__menu.addAction(UI.PixmapCache.getIcon("ericWeb.png"), self.trUtf8("eric4 Web Browser"), self.__startHelpViewer) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("diffFiles.png"), self.trUtf8("Compare Files"), self.__startDiff) self.__menu.addAction(UI.PixmapCache.getIcon("compareFiles.png"), self.trUtf8("Compare Files side by side"), self.__startCompare) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("sqlBrowser.png"), self.trUtf8("SQL Browser"), self.__startSqlBrowser) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("iconEditor.png"), self.trUtf8("Icon Editor"), self.__startIconEditor) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("pluginInstall.png"), self.trUtf8("Install Plugin"), self.__startPluginInstall) self.__menu.addAction(UI.PixmapCache.getIcon("pluginUninstall.png"), self.trUtf8("Uninstall Plugin"), self.__startPluginUninstall) self.__menu.addAction(UI.PixmapCache.getIcon("pluginRepository.png"), self.trUtf8("Plugin Repository"), self.__startPluginRepository) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("configure.png"), self.trUtf8('Preferences'), self.__startPreferences) self.__menu.addAction(UI.PixmapCache.getIcon("erict.png"), self.trUtf8("eric4 IDE"), self.__startEric) self.__menu.addAction(UI.PixmapCache.getIcon("editor.png"), self.trUtf8("eric4 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 self.menuRecentMultiProjectsAct = \ self.__menu.addMenu(self.recentMultiProjectsMenu) # recent projects self.menuRecentProjectsAct = self.__menu.addMenu(self.recentProjectsMenu) self.__menu.addSeparator() self.__menu.addAction(UI.PixmapCache.getIcon("exit.png"), self.trUtf8('Quit'), qApp.quit) def __loadRecentProjects(self): """ Private method to load the recently opened project filenames. """ rp = self.rsettings.value(Globals.recentNameProject) if rp.isValid(): for f in rp.toStringList(): if QFileInfo(f).exists(): self.recentProjects.append(f) def __loadRecentMultiProjects(self): """ Private method to load the recently opened multi project filenames. """ rmp = self.rsettings.value(Globals.recentNameMultiProject) if rmp.isValid(): for f in rmp.toStringList(): if QFileInfo(f).exists(): self.recentMultiProjects.append(f) def __loadRecentFiles(self): """ Private method to load the recently opened filenames. """ rf = self.rsettings.value(Globals.recentNameFiles) if rf.isValid(): for f in rf.toStringList(): if QFileInfo(f).exists(): self.recentFiles.append(f) def __activated(self, reason): """ Private slot to handle the activated signal. @param reason reason code of the signal (QSystemTrayIcon.ActivationReason) """ if reason == QSystemTrayIcon.Context or \ reason == QSystemTrayIcon.MiddleClick: self.__showContextMenu() elif reason == QSystemTrayIcon.DoubleClick: self.__startEric() def __showContextMenu(self): """ Private slot to show the context menu. """ self.menuRecentProjectsAct.setEnabled(len(self.recentProjects) > 0) self.menuRecentMultiProjectsAct.setEnabled(len(self.recentMultiProjects) > 0) self.menuRecentFilesAct.setEnabled(len(self.recentFiles) > 0) pos = QCursor.pos() x = pos.x() - self.__menu.sizeHint().width() pos.setX(x > 0 and x or 0) y = pos.y() - self.__menu.sizeHint().height() pos.setY(y > 0 and y or 0) self.__menu.popup(pos) def __startProc(self, applName, *applArgs): """ Private method to start an eric4 application. @param applName name of the eric4 application script (string) @param *applArgs variable list of application arguments """ proc = QProcess() applPath = os.path.join(getConfig("ericDir"), applName) args = QStringList() args.append(applPath) for arg in applArgs: args.append(unicode(arg)) if not os.path.isfile(applPath) or not proc.startDetached(sys.executable, args): QMessageBox.critical(self, self.trUtf8('Process Generation Error'), self.trUtf8( '<p>Could not start the process.<br>' 'Ensure that it is available as <b>%1</b>.</p>' ).arg(applPath), self.trUtf8('OK')) def __startMiniEditor(self): """ Private slot to start the eric4 Mini Editor. """ self.__startProc("eric4_editor.py", "--config=%s" % Utilities.getConfigDir()) def __startEric(self): """ Private slot to start the eric4 IDE. """ self.__startProc("eric4.py", "--config=%s" % Utilities.getConfigDir()) def __startPreferences(self): """ Private slot to start the eric4 configuration dialog. """ self.__startProc("eric4_configure.py", "--config=%s" % Utilities.getConfigDir()) def __startPluginInstall(self): """ Private slot to start the eric4 plugin installation dialog. """ self.__startProc("eric4_plugininstall.py", "--config=%s" % Utilities.getConfigDir()) def __startPluginUninstall(self): """ Private slot to start the eric4 plugin uninstallation dialog. """ self.__startProc("eric4_pluginuninstall.py", "--config=%s" % Utilities.getConfigDir()) def __startPluginRepository(self): """ Private slot to start the eric4 plugin repository dialog. """ self.__startProc("eric4_pluginrepository.py", "--config=%s" % Utilities.getConfigDir()) def __startHelpViewer(self): """ Private slot to start the eric4 web browser. """ self.__startProc("eric4_webbrowser.py", "--config=%s" % Utilities.getConfigDir()) def __startUIPreviewer(self): """ Private slot to start the eric4 UI previewer. """ self.__startProc("eric4_uipreviewer.py", "--config=%s" % Utilities.getConfigDir()) def __startTRPreviewer(self): """ Private slot to start the eric4 translations previewer. """ self.__startProc("eric4_trpreviewer.py", "--config=%s" % Utilities.getConfigDir()) def __startUnittest(self): """ Private slot to start the eric4 unittest dialog. """ self.__startProc("eric4_unittest.py", "--config=%s" % Utilities.getConfigDir()) def __startDiff(self): """ Private slot to start the eric4 diff dialog. """ self.__startProc("eric4_diff.py", "--config=%s" % Utilities.getConfigDir()) def __startCompare(self): """ Private slot to start the eric4 compare dialog. """ self.__startProc("eric4_compare.py", "--config=%s" % Utilities.getConfigDir()) def __startSqlBrowser(self): """ Private slot to start the eric4 sql browser dialog. """ self.__startProc("eric4_sqlbrowser.py", "--config=%s" % Utilities.getConfigDir()) def __startIconEditor(self): """ Private slot to start the eric4 icon editor dialog. """ self.__startProc("eric4_iconeditor.py", "--config=%s" % Utilities.getConfigDir()) def __startQRegExp(self): """ Private slot to start the eric4 QRegExp editor dialog. """ self.__startProc("eric4_qregexp.py", "--config=%s" % Utilities.getConfigDir()) def __startPyRe(self): """ Private slot to start the eric4 Python re editor dialog. """ self.__startProc("eric4_re.py", "--config=%s" % Utilities.getConfigDir()) def __showRecentProjectsMenu(self): """ Private method to set up the recent projects menu. """ self.recentProjects.clear() self.rsettings.sync() self.__loadRecentProjects() self.recentProjectsMenu.clear() idx = 1 for rp in self.recentProjects: if idx < 10: formatStr = '&%d. %s' else: formatStr = '%d. %s' act = self.recentProjectsMenu.addAction(\ formatStr % (idx, Utilities.compactPath(unicode(rp), self.maxMenuFilePathLen))) act.setData(QVariant(rp)) idx += 1 def __showRecentMultiProjectsMenu(self): """ Private method to set up the recent multi projects menu. """ self.recentMultiProjects.clear() self.rsettings.sync() self.__loadRecentMultiProjects() self.recentMultiProjectsMenu.clear() idx = 1 for rmp in self.recentMultiProjects: if idx < 10: formatStr = '&%d. %s' else: formatStr = '%d. %s' act = self.recentMultiProjectsMenu.addAction(\ formatStr % (idx, Utilities.compactPath(unicode(rmp), self.maxMenuFilePathLen))) act.setData(QVariant(rmp)) idx += 1 def __showRecentFilesMenu(self): """ Private method to set up the recent files menu. """ self.recentFiles.clear() self.rsettings.sync() self.__loadRecentFiles() self.recentFilesMenu.clear() idx = 1 for rf in self.recentFiles: if idx < 10: formatStr = '&%d. %s' else: formatStr = '%d. %s' act = self.recentFilesMenu.addAction(\ formatStr % (idx, Utilities.compactPath(unicode(rf), self.maxMenuFilePathLen))) act.setData(QVariant(rf)) idx += 1 def __openRecent(self, act): """ Private method to open a project or file from the list of rencently opened projects or files. @param act reference to the action that triggered (QAction) """ filename = unicode(act.data().toString()) if filename: self.__startProc("eric4.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) self.connect(dlg, SIGNAL('preferencesChanged'), 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( unicode(Preferences.getTrayStarter("TrayStarterIcon")))) def __about(self): """ Private slot to handle the About dialog. """ from Plugins.AboutPlugin.AboutDialog import AboutDialog dlg = AboutDialog() dlg.exec_()