Skip to content

Commit 7c2ef48

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 90347a4 commit 7c2ef48

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
@@ -409,6 +409,22 @@ def setAutoSaveEnabled(self, state):
409409
"""
410410
self.uiAutoSaveSettingsCHK.setChecked(state)
411411

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

@@ -1239,6 +1257,9 @@ def closeEvent(self, event):
12391257
def closeLoggerByAction(self):
12401258
if self.uiConfirmBeforeCloseCHK.isChecked():
12411259
msg = "Are you sure you want to close PrEditor?"
1260+
1261+
state_str = "enabled" if self.autoSaveEnabled() else "disabled"
1262+
msg += f"\n\nAuto Save is {state_str}"
12421263
ret = QMessageBox.question(
12431264
self,
12441265
'Confirm close',
@@ -1321,6 +1342,7 @@ def recordPrefs(self, manual=False, disableFileMonitoring=False):
13211342
'guiFont': self.font().toString(),
13221343
'consoleFont': self.console().font().toString(),
13231344
'autoSaveSettings': self.autoSaveEnabled(),
1345+
'promptOnLinkedChange': self.promptOnLinkedChange(),
13241346
'autoPrompt': self.uiAutoPromptCHK.isChecked(),
13251347
'errorHyperlinks': self.uiErrorHyperlinksCHK.isChecked(),
13261348
'uiStatusLbl_limit': self.uiStatusLBL.limit(),
@@ -1343,6 +1365,7 @@ def recordPrefs(self, manual=False, disableFileMonitoring=False):
13431365
'max_recent_workboxes': self.uiMaxNumRecentWorkboxesSPIN.value(),
13441366
'closedWorkboxData': self.getClosedWorkboxData(),
13451367
'confirmBeforeClose': self.uiConfirmBeforeCloseCHK.isChecked(),
1368+
'displayExtraTooltipInfo': self.uiExtraTooltipInfoCHK.isChecked(),
13461369
}
13471370
)
13481371

@@ -1574,6 +1597,7 @@ def restorePrefs(self, skip_geom=False):
15741597
self.uiSpellCheckEnabledCHK.setChecked(pref.get('spellCheckEnabled', False))
15751598
self.uiSpellCheckEnabledCHK.setDisabled(False)
15761599
self.setAutoSaveEnabled(pref.get('autoSaveSettings', True))
1600+
self.setPromptOnLinkedChange(pref.get('promptOnLinkedChange', True))
15771601
self.uiAutoPromptCHK.setChecked(pref.get('autoPrompt', False))
15781602
self.uiErrorHyperlinksCHK.setChecked(pref.get('errorHyperlinks', True))
15791603
self.uiStatusLBL.setLimit(pref.get('uiStatusLbl_limit', 5))
@@ -1646,7 +1670,9 @@ def restorePrefs(self, skip_geom=False):
16461670

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

1649-
self.uiExtraTooltipInfoCHK.setChecked(pref.get("uiExtraTooltipInfoCHK", False))
1673+
self.uiExtraTooltipInfoCHK.setChecked(
1674+
pref.get("displayExtraTooltipInfo", False)
1675+
)
16501676

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

0 commit comments

Comments
 (0)