diff options
| author | Warry <FunWarry@users.noreply.github.com> | 2025-12-04 12:03:31 +0100 |
|---|---|---|
| committer | Warry <FunWarry@users.noreply.github.com> | 2025-12-04 12:03:31 +0100 |
| commit | 75868b32d07aafe46b69649d2da0dc2c833f112d (patch) | |
| tree | 970a50f4cbf141af0e5e0856e087e347f3b5be48 /tidal_dl_ng/dialog.py | |
| parent | 428d34056be16ed9d28597253b333dfbd7f21a47 (diff) | |
| download | tidal-dl-ng-75868b32d07aafe46b69649d2da0dc2c833f112d.tar.gz | |
refactor: Restructure GUI components into separate modules for improved maintainability
Diffstat (limited to 'tidal_dl_ng/dialog.py')
| -rw-r--r-- | tidal_dl_ng/dialog.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tidal_dl_ng/dialog.py b/tidal_dl_ng/dialog.py index 6a2a8b7..2c01626 100644 --- a/tidal_dl_ng/dialog.py +++ b/tidal_dl_ng/dialog.py @@ -206,11 +206,20 @@ class DialogPreferences(QtWidgets.QDialog): self.ui.lw_categories.addItem("Paths & Formats") self.ui.lw_categories.addItem("Delimiters") - # Set the first category as selected + # Connect category selection to page switching before setting default + self.ui.lw_categories.currentRowChanged.connect(self._on_category_changed) + + # Set the first category as selected and force corresponding page self.ui.lw_categories.setCurrentRow(0) + self._on_category_changed(0) - # Connect category selection to page switching - self.ui.lw_categories.currentRowChanged.connect(self._on_category_changed) + # Add keyboard navigation for convenience + shortcut_next = QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key.Key_Tab), self) + shortcut_prev = QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key.Key_Backtab), self) + shortcut_next.activated.connect(lambda: self._navigate_categories(1) if self.ui.lw_categories.count() else None) + shortcut_prev.activated.connect( + lambda: self._navigate_categories(-1) if self.ui.lw_categories.count() else None + ) def _on_category_changed(self, index: int): """Handle category change to switch pages.""" @@ -335,3 +344,10 @@ class DialogPreferences(QtWidgets.QDialog): setattr(self.settings.data, item, getattr(self.ui, self.prefix_spin_box + item).value()) self.s_settings_save.emit() + + def _navigate_categories(self, direction: int) -> None: + """Move category selection forward/backward with wrap-around.""" + current = self.ui.lw_categories.currentRow() + count = self.ui.lw_categories.count() + target = (current + direction) % count + self.ui.lw_categories.setCurrentRow(target) |
