Skip to content

Commit ecc5527

Browse files
committed
Ui updates
- Simplify Options and Preferences layouts - Add Prompt on Linked File Change option (you will get visual clues even if this is turned off) - Better handling of deleted / renamed linked files - Handful of other small fixes
1 parent 34df005 commit ecc5527

File tree

7 files changed

+765
-722
lines changed

7 files changed

+765
-722
lines changed

preditor/gui/drag_tab_bar.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,10 @@ def tab_menu(self, pos, popup=True):
394394
act = menu.addAction('Explore File')
395395
act.triggered.connect(partial(self.explore_file, workbox))
396396

397-
act = menu.addAction('Re-link File')
397+
act = menu.addAction('Save As')
398+
act.triggered.connect(partial(self.save_and_link_file, workbox))
399+
400+
act = menu.addAction('Relink File')
398401
act.triggered.connect(partial(self.link_file, workbox))
399402

400403
act = menu.addAction('Unlink File')
@@ -421,10 +424,9 @@ def link_file(self, workbox):
421424
workbox (WorkboxMixin): The workbox contained in the clicked tab
422425
"""
423426
filename = workbox.__filename__()
424-
workbox.__set_file_monitoring_enabled__(False)
425-
workbox.__set_filename__("")
426427
filename, _other = QFileDialog.getOpenFileName(directory=filename)
427428
if filename and Path(filename).is_file():
429+
workbox.__set_file_monitoring_enabled__(False)
428430

429431
# First, save any unsaved text
430432
workbox.__save_prefs__()

preditor/gui/group_tab_widget/grouped_tab_widget.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def addTab(self, *args, **kwargs): # noqa: N802
109109
self.update_closable_tabs()
110110
return ret
111111

112-
def close_tab(self, index):
112+
def close_tab(self, index, ask=True):
113113
if self.count() == 1:
114114
msg = "You have to leave at least one tab open."
115115
QMessageBox.critical(
@@ -124,12 +124,16 @@ def close_tab(self, index):
124124
"/dev/null fund for wayward code?"
125125
)
126126

127-
ret = QMessageBox.question(
128-
self,
129-
'Donate to the cause?',
130-
msg,
131-
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.Cancel,
132-
)
127+
if ask:
128+
ret = QMessageBox.question(
129+
self,
130+
'Donate to the cause?',
131+
msg,
132+
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.Cancel,
133+
)
134+
else:
135+
ret = QMessageBox.StandardButton.Yes
136+
133137
if ret == QMessageBox.StandardButton.Yes:
134138
editor = self.widget(index)
135139
editor.__set_file_monitoring_enabled__(False)

preditor/gui/loggerwindow.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,22 @@ def setAutoSaveEnabled(self, state):
410410
"""
411411
self.uiAutoSaveSettingsCHK.setChecked(state)
412412

413+
def promptOnLinkedChange(self):
414+
"""Whether or not Prompt On Linked Change option is set
415+
416+
Returns:
417+
bool: Whether or not Prompt On Linked Change option is set
418+
"""
419+
return self.uiPromptOnLinkedChangeCHK.isChecked()
420+
421+
def setPromptOnLinkedChange(self, state):
422+
"""Set Prompt On Linked Change option option to state
423+
424+
Args:
425+
state (bool): State to set Prompt On Linked Change option
426+
"""
427+
self.uiPromptOnLinkedChangeCHK.setChecked(state)
428+
413429
def loadPlugins(self):
414430
"""Load any plugins that modify the LoggerWindow."""
415431
self.plugins = {}
@@ -1213,7 +1229,9 @@ def linkedFileChanged(self, filename):
12131229
continue
12141230
if Path(editor.__filename__()) == Path(filename):
12151231
editor.__set_file_monitoring_enabled__(False)
1232+
12161233
choice = editor.__maybe_reload_file__()
1234+
# Save a backup of any unsaved changes
12171235
if choice:
12181236
editor.__save_prefs__(saveLinkedFile=False, force=True)
12191237

@@ -1240,6 +1258,9 @@ def closeEvent(self, event):
12401258
def closeLoggerByAction(self):
12411259
if self.uiConfirmBeforeCloseCHK.isChecked():
12421260
msg = "Are you sure you want to close PrEditor?"
1261+
1262+
state_str = "enabled" if self.autoSaveEnabled() else "disabled"
1263+
msg += f"\n\nAuto Save is {state_str}"
12431264
ret = QMessageBox.question(
12441265
self,
12451266
'Confirm close',
@@ -1322,6 +1343,7 @@ def recordPrefs(self, manual=False, disableFileMonitoring=False):
13221343
'guiFont': self.font().toString(),
13231344
'consoleFont': self.console().font().toString(),
13241345
'autoSaveSettings': self.autoSaveEnabled(),
1346+
'promptOnLinkedChange': self.promptOnLinkedChange(),
13251347
'autoPrompt': self.uiAutoPromptCHK.isChecked(),
13261348
'errorHyperlinks': self.uiErrorHyperlinksCHK.isChecked(),
13271349
'uiStatusLbl_limit': self.uiStatusLBL.limit(),
@@ -1344,6 +1366,7 @@ def recordPrefs(self, manual=False, disableFileMonitoring=False):
13441366
'max_recent_workboxes': self.uiMaxNumRecentWorkboxesSPIN.value(),
13451367
'closedWorkboxData': self.getClosedWorkboxData(),
13461368
'confirmBeforeClose': self.uiConfirmBeforeCloseCHK.isChecked(),
1369+
'displayExtraTooltipInfo': self.uiExtraTooltipInfoCHK.isChecked(),
13471370
}
13481371
)
13491372

@@ -1575,6 +1598,7 @@ def restorePrefs(self, skip_geom=False):
15751598
self.uiSpellCheckEnabledCHK.setChecked(pref.get('spellCheckEnabled', False))
15761599
self.uiSpellCheckEnabledCHK.setDisabled(False)
15771600
self.setAutoSaveEnabled(pref.get('autoSaveSettings', True))
1601+
self.setPromptOnLinkedChange(pref.get('promptOnLinkedChange', True))
15781602
self.uiAutoPromptCHK.setChecked(pref.get('autoPrompt', False))
15791603
self.uiErrorHyperlinksCHK.setChecked(pref.get('errorHyperlinks', True))
15801604
self.uiStatusLBL.setLimit(pref.get('uiStatusLbl_limit', 5))
@@ -1647,7 +1671,9 @@ def restorePrefs(self, skip_geom=False):
16471671

16481672
self.dont_ask_again = pref.get('dont_ask_again', [])
16491673

1650-
self.uiExtraTooltipInfoCHK.setChecked(pref.get("uiExtraTooltipInfoCHK", False))
1674+
self.uiExtraTooltipInfoCHK.setChecked(
1675+
pref.get("displayExtraTooltipInfo", False)
1676+
)
16511677

16521678
# Allow any plugins to restore their own preferences
16531679
for name, plugin in self.plugins.items():

0 commit comments

Comments
 (0)