16 from PyQt6.QtCore import ( |
16 from PyQt6.QtCore import ( |
17 QCoreApplication, |
17 QCoreApplication, |
18 QPoint, |
18 QPoint, |
19 QSignalMapper, |
19 QSignalMapper, |
20 Qt, |
20 Qt, |
21 QTimer, |
|
22 pyqtSignal, |
21 pyqtSignal, |
23 pyqtSlot, |
22 pyqtSlot, |
24 ) |
23 ) |
25 from PyQt6.QtGui import QKeySequence, QPixmap |
24 from PyQt6.QtGui import QKeySequence, QPixmap |
26 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget |
25 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget |
131 |
130 |
132 self.bookmarked = [] |
131 self.bookmarked = [] |
133 bs = Preferences.getSettings().value("Bookmarked/Sources") |
132 bs = Preferences.getSettings().value("Bookmarked/Sources") |
134 if bs is not None: |
133 if bs is not None: |
135 self.bookmarked = bs |
134 self.bookmarked = bs |
136 |
|
137 # initialize the autosave timer |
|
138 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
|
139 self.autosaveTimer = QTimer(self) |
|
140 self.autosaveTimer.setObjectName("AutosaveTimer") |
|
141 self.autosaveTimer.setSingleShot(True) |
|
142 self.autosaveTimer.timeout.connect(self.__autosave) |
|
143 |
135 |
144 # initialize the APIs manager |
136 # initialize the APIs manager |
145 self.apisManager = APIsManager(parent=self) |
137 self.apisManager = APIsManager(parent=self) |
146 |
138 |
147 self.__cooperationClient = None |
139 self.__cooperationClient = None |
6136 for editor in self.editors: |
6128 for editor in self.editors: |
6137 ok = editor.saveFile() |
6129 ok = editor.saveFile() |
6138 if ok: |
6130 if ok: |
6139 self.setEditorName(editor, editor.getFileName()) |
6131 self.setEditorName(editor, editor.getFileName()) |
6140 |
6132 |
6141 # restart autosave timer |
|
6142 if self.autosaveInterval > 0: |
|
6143 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
6144 |
|
6145 def __exportMenuTriggered(self, act): |
6133 def __exportMenuTriggered(self, act): |
6146 """ |
6134 """ |
6147 Private method to handle the selection of an export format. |
6135 Private method to handle the selection of an export format. |
6148 |
6136 |
6149 @param act reference to the action that was triggered (QAction) |
6137 @param act reference to the action that was triggered (QAction) |
7432 # remove all split views, if this is supported |
7420 # remove all split views, if this is supported |
7433 if self.canSplit(): |
7421 if self.canSplit(): |
7434 while self.removeSplit(): |
7422 while self.removeSplit(): |
7435 pass |
7423 pass |
7436 |
7424 |
7437 # stop the autosave timer |
|
7438 if self.autosaveTimer.isActive(): |
|
7439 self.autosaveTimer.stop() |
|
7440 |
|
7441 # hide search and replace widget |
7425 # hide search and replace widget |
7442 self.__searchReplaceWidget.hide() |
7426 self.__searchReplaceWidget.hide() |
7443 |
7427 |
7444 # hide the AST Viewer via its action |
7428 # hide the AST Viewer via its action |
7445 self.astViewerAct.setChecked(False) |
7429 self.astViewerAct.setChecked(False) |
7472 self.bookmarkActGrp.setEnabled(True) |
7456 self.bookmarkActGrp.setEnabled(True) |
7473 self.__enableSpellingActions() |
7457 self.__enableSpellingActions() |
7474 self.astViewerAct.setEnabled(True) |
7458 self.astViewerAct.setEnabled(True) |
7475 self.disViewerAct.setEnabled(True) |
7459 self.disViewerAct.setEnabled(True) |
7476 |
7460 |
7477 # activate the autosave timer |
|
7478 if not self.autosaveTimer.isActive() and self.autosaveInterval > 0: |
|
7479 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
7480 |
|
7481 def __autosave(self): |
|
7482 """ |
|
7483 Private slot to save the contents of all editors automatically. |
|
7484 |
|
7485 Only named editors will be saved by the autosave timer. |
|
7486 """ |
|
7487 for editor in self.editors: |
|
7488 if editor.shouldAutosave(): |
|
7489 ok = editor.saveFile() |
|
7490 if ok: |
|
7491 self.setEditorName(editor, editor.getFileName()) |
|
7492 |
|
7493 # restart autosave timer |
|
7494 if self.autosaveInterval > 0: |
|
7495 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
7496 |
|
7497 def _checkActions(self, editor, setSb=True): |
7461 def _checkActions(self, editor, setSb=True): |
7498 """ |
7462 """ |
7499 Protected slot to check some actions for their enable/disable status |
7463 Protected slot to check some actions for their enable/disable status |
7500 and set the statusbar info. |
7464 and set the statusbar info. |
7501 |
7465 |
7615 |
7579 |
7616 This method performs the following actions |
7580 This method performs the following actions |
7617 <ul> |
7581 <ul> |
7618 <li>reread the colours for the syntax highlighting</li> |
7582 <li>reread the colours for the syntax highlighting</li> |
7619 <li>reloads the already created API objetcs</li> |
7583 <li>reloads the already created API objetcs</li> |
7620 <li>starts or stops the autosave timer</li> |
|
7621 <li><b>Note</b>: changes in viewmanager type are activated |
7584 <li><b>Note</b>: changes in viewmanager type are activated |
7622 on an application restart.</li> |
7585 on an application restart.</li> |
7623 </ul> |
7586 </ul> |
7624 """ |
7587 """ |
7625 # reload the APIs |
7588 # reload the APIs |
7628 # reload editor settings |
7591 # reload editor settings |
7629 for editor in self.editors: |
7592 for editor in self.editors: |
7630 zoom = editor.getZoom() |
7593 zoom = editor.getZoom() |
7631 editor.readSettings() |
7594 editor.readSettings() |
7632 editor.zoomTo(zoom) |
7595 editor.zoomTo(zoom) |
7633 |
|
7634 # reload the autosave timer setting |
|
7635 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
|
7636 if len(self.editors): |
|
7637 if self.autosaveTimer.isActive() and self.autosaveInterval == 0: |
|
7638 self.autosaveTimer.stop() |
|
7639 elif not self.autosaveTimer.isActive() and self.autosaveInterval > 0: |
|
7640 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
7641 |
7596 |
7642 self.__enableSpellingActions() |
7597 self.__enableSpellingActions() |
7643 |
7598 |
7644 def __editorSaved(self, fn, editor): |
7599 def __editorSaved(self, fn, editor): |
7645 """ |
7600 """ |