diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2020-01-25 02:38:20 -0500 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2020-01-25 02:38:20 -0500 |
| commit | 3106aa185417abafef62dcdc16676187348a2ad1 (patch) | |
| tree | 6eb32db535e9abfbf6afdacc277e4f0b68325a47 /python | |
| parent | bb20e584c4702fd7c1a861a8540e1b6e2652818c (diff) | |
remember most recently selected snippet
Diffstat (limited to 'python')
| -rw-r--r-- | python/examples/snippets/__init__.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/python/examples/snippets/__init__.py b/python/examples/snippets/__init__.py index 5434010a..c1c17a97 100644 --- a/python/examples/snippets/__init__.py +++ b/python/examples/snippets/__init__.py @@ -185,6 +185,11 @@ class Snippets(QDialog): else: self.edit.setMinimumWidth(80 * font.averageCharWidth()) self.edit.setMinimumHeight(30 * font.lineSpacing()) + if self.settings.contains("ui/snippeteditor/selected"): + selectedName = self.settings.value("ui/snippeteditor/selected") + self.tree.selectionModel().select(self.files.index(selectedName), QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) + if self.tree.selectionModel().hasSelection(): + self.selectFile(self.tree.selectionModel().selection(), None) # Set dialog layout self.setLayout(hlayout) @@ -258,13 +263,14 @@ class Snippets(QDialog): self.resetting = False return newSelection = self.files.filePath(new.indexes()[0]) + self.settings.setValue("ui/snippeteditor/selected", newSelection) if QFileInfo(newSelection).isDir(): self.readOnly(True) self.tree.clearSelection() self.currentFile = "" return - if old.length() > 0: + if old and old.length() > 0: oldSelection = self.files.filePath(old.indexes()[0]) if not QFileInfo(oldSelection).isDir() and self.snippetChanged(): question = QMessageBox.question(self, self.tr("Discard"), self.tr("Snippet changed. Discard changes?")) |
