Merge pull request #517 from joshuacant/master

Adds: window size/position saving, dynamic column widths, double-click row action
This commit is contained in:
exislow
2025-09-30 22:40:54 +02:00
committed by GitHub
2 changed files with 32 additions and 5 deletions
+24 -5
View File
@@ -152,7 +152,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
""" """
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
# self.setGeometry(50, 50, 500, 300)
self.setWindowTitle("TIDAL Downloader Next Generation!") self.setWindowTitle("TIDAL Downloader Next Generation!")
# Logging redirect. # Logging redirect.
@@ -160,7 +159,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# XStream.stderr().messageWritten.connect(self._log_output) # XStream.stderr().messageWritten.connect(self._log_output)
self.settings = Settings() self.settings = Settings()
self._init_threads() self._init_threads()
self._init_gui() self._init_gui()
self._init_tree_results_model(self.model_tr_results) self._init_tree_results_model(self.model_tr_results)
@@ -181,6 +179,12 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def _init_gui(self) -> None: def _init_gui(self) -> None:
"""Initialize GUI-specific variables and state.""" """Initialize GUI-specific variables and state."""
self.setGeometry(
self.settings.data.window_x,
self.settings.data.window_y,
self.settings.data.window_w,
self.settings.data.window_h,
)
self.spinners: dict[QtWidgets.QWidget, QtWaitingSpinner] = {} self.spinners: dict[QtWidgets.QWidget, QtWaitingSpinner] = {}
def init_tidal(self, tidal: Tidal | None = None): def init_tidal(self, tidal: Tidal | None = None):
@@ -356,9 +360,15 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
## Styling ## Styling
tree.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder) tree.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder)
tree.setColumnHidden(1, True) tree.setColumnHidden(1, True)
tree.setColumnWidth(2, 150) normal_width = max(150, (self.width() * 0.13)) # 12% for normal fields
tree.setColumnWidth(3, 150) narrow_width = max(90, (self.width() * 0.06)) # 6% for shorter fields
tree.setColumnWidth(4, 150) skinny_width = max(60, (self.width() * 0.03)) # 3% for very short fields
tree.setColumnWidth(2, normal_width) # artist
tree.setColumnWidth(3, normal_width) # title
tree.setColumnWidth(4, normal_width) # album
tree.setColumnWidth(5, skinny_width) # duration
tree.setColumnWidth(6, narrow_width) # quality
tree.setColumnWidth(7, narrow_width) # date
header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
# Connect the contextmenu # Connect the contextmenu
tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
@@ -1115,6 +1125,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# Results # Results
self.tr_results.expanded.connect(self.on_tr_results_expanded) self.tr_results.expanded.connect(self.on_tr_results_expanded)
self.tr_results.clicked.connect(self.on_result_item_clicked) self.tr_results.clicked.connect(self.on_result_item_clicked)
self.tr_results.doubleClicked.connect(lambda: self.thread_it(self.on_download_results))
# Download Queue # Download Queue
self.tr_queue_download.itemClicked.connect(self.on_queue_download_item_clicked) self.tr_queue_download.itemClicked.connect(self.on_queue_download_item_clicked)
@@ -1673,6 +1684,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
Args: Args:
event (QtGui.QCloseEvent): The close event. event (QtGui.QCloseEvent): The close event.
""" """
# Save the main window size and position
self.settings.data.window_x = self.x()
self.settings.data.window_y = self.y()
self.settings.data.window_w = self.width()
self.settings.data.window_h = self.height()
self.settings.save()
self.shutdown = True self.shutdown = True
handling_app: HandlingApp = HandlingApp() handling_app: HandlingApp = HandlingApp()
+8
View File
@@ -46,6 +46,10 @@ class Settings:
playlist_create: bool = False playlist_create: bool = False
metadata_replay_gain: bool = True metadata_replay_gain: bool = True
metadata_write_url: bool = True metadata_write_url: bool = True
window_x: int = 50
window_y: int = 50
window_w: int = 1200
window_h: int = 800
@dataclass_json @dataclass_json
@@ -101,6 +105,10 @@ class HelpSettings:
playlist_create: str = "Creates a '_playlist.m3u8' file for downloaded albums, playlists and mixes." playlist_create: str = "Creates a '_playlist.m3u8' file for downloaded albums, playlists and mixes."
metadata_replay_gain: str = "Replay gain information will be written to metadata." metadata_replay_gain: str = "Replay gain information will be written to metadata."
metadata_write_url: str = "URL of the media file will be written to metadata." metadata_write_url: str = "URL of the media file will be written to metadata."
window_x: str = "X-Coordinate of saved window location."
window_y: str = "Y-Coordinate of saved window location."
window_w: str = "Width of saved window size."
window_h: str = "Height of saved window size."
@dataclass_json @dataclass_json