Added appearance settings.
This commit is contained in:
parent
6b808add85
commit
67f27c8a15
4 changed files with 44 additions and 3 deletions
|
@ -58,8 +58,12 @@ class GUI:
|
|||
def on_settings_change(self, key, value):
|
||||
self.settings.update_settings(key, value)
|
||||
|
||||
if key == "gui_update_rate":
|
||||
self.gui_update_timer.setInterval(1000 // value)
|
||||
match key:
|
||||
case "gui_update_rate":
|
||||
self.gui_update_timer.setInterval(1000 // value)
|
||||
|
||||
case "album_cover_size":
|
||||
self.track_info.set_size(value)
|
||||
|
||||
def on_track_change(self, previous_track, track):
|
||||
self.track_control.on_track_change(previous_track, track)
|
||||
|
|
|
@ -12,4 +12,5 @@ class Settings:
|
|||
latest_playlist: str=None
|
||||
load_on_start: bool=False
|
||||
gui_update_rate: int=20
|
||||
album_cover_size: int=64
|
||||
|
||||
|
|
|
@ -68,6 +68,27 @@ class Settings(QDockWidget):
|
|||
|
||||
self.tabs.addTab(self.behavior_settings, "Behavior")
|
||||
|
||||
self.appearance_settings = Category()
|
||||
|
||||
self.appearance_settings.track_info = SubCategory(
|
||||
"Track Info",
|
||||
"Settings related to the appearance of the track info bar"
|
||||
)
|
||||
self.appearance_settings.add_sub_category(self.appearance_settings.track_info)
|
||||
|
||||
self.appearance_settings.track_info.cover_size = QSpinBox()
|
||||
self.appearance_settings.track_info.cover_size.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||
self.appearance_settings.track_info.cover_size.setRange(16, 128)
|
||||
self.appearance_settings.track_info.cover_size.setSuffix("px")
|
||||
self.appearance_settings.track_info.cover_size.setSingleStep(10)
|
||||
self.appearance_settings.track_info.add_setting(
|
||||
"Album Cover Size",
|
||||
self.appearance_settings.track_info.cover_size,
|
||||
"The size of the album cover. (aspect-ratio: 1:1)"
|
||||
)
|
||||
|
||||
self.tabs.addTab(self.appearance_settings, "Appearance")
|
||||
|
||||
self.performance_settings = Category()
|
||||
|
||||
# self.performance_settings.memory = SubCategory("Memory", "Memory related settings")
|
||||
|
@ -103,6 +124,7 @@ class Settings(QDockWidget):
|
|||
self.behavior_settings.track.clear_cache.setChecked(self.app.settings.clear_track_cache)
|
||||
self.behavior_settings.playlist.load_on_start.setChecked(self.app.settings.load_on_start)
|
||||
self.performance_settings.cpu.gui_update_rate.setValue(self.app.settings.gui_update_rate)
|
||||
self.appearance_settings.track_info.cover_size.setValue(self.app.settings.album_cover_size)
|
||||
|
||||
def update_settings(self, key, value):
|
||||
match key:
|
||||
|
@ -118,9 +140,13 @@ class Settings(QDockWidget):
|
|||
case "gui_update_rate":
|
||||
self.performance_settings.cpu.gui_update_rate.setValue(value)
|
||||
|
||||
case "track_cover_size":
|
||||
self.appearance_settings.track_info.cover_size.setValue(value)
|
||||
|
||||
def write_settings(self):
|
||||
self.app.settings.library_path = self.file_settings.paths.library_path_input.text()
|
||||
self.app.settings.clear_track_cache = self.behavior_settings.track.clear_cache.isChecked()
|
||||
self.app.settings.load_on_start = self.behavior_settings.playlist.load_on_start.isChecked()
|
||||
self.app.settings.gui_update_rate = self.performance_settings.cpu.gui_update_rate.value()
|
||||
self.app.settings.album_cover_size = self.appearance_settings.track_info.cover_size.value()
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ class TrackInfo(QToolBar):
|
|||
self.wobuzz_logo = QPixmap(f"{self.app.utils.wobuzz_location}/icon.svg")
|
||||
|
||||
self.track_cover = QLabel(self)
|
||||
self.track_cover.setFixedSize(64, 64)
|
||||
self.track_cover.setMargin(4)
|
||||
self.set_size(self.app.settings.album_cover_size)
|
||||
self.track_cover.setScaledContents(True)
|
||||
self.track_cover.setPixmap(self.wobuzz_logo)
|
||||
self.addWidget(self.track_cover)
|
||||
|
@ -36,17 +37,24 @@ class TrackInfo(QToolBar):
|
|||
self.addWidget(self.info_container)
|
||||
|
||||
self.title = QLabel("Title", self.info_container)
|
||||
self.title.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum)
|
||||
self.title.setFont(self.title_font)
|
||||
info_container_layout.addWidget(self.title)
|
||||
|
||||
self.artist = QLabel("Artist", self.info_container)
|
||||
self.artist.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum)
|
||||
self.artist.setFont(self.artist_font)
|
||||
info_container_layout.addWidget(self.artist)
|
||||
|
||||
self.album = QLabel("Album", self.info_container)
|
||||
self.album.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum)
|
||||
self.album.setFont(self.album_font)
|
||||
info_container_layout.addWidget(self.album)
|
||||
|
||||
# spacer widget that makes the label spacing not depend on the container's height
|
||||
spacer_widget = QWidget(self.info_container)
|
||||
info_container_layout.addWidget(spacer_widget)
|
||||
|
||||
def update_info(self):
|
||||
current_playlist = self.app.player.current_playlist
|
||||
|
||||
|
@ -94,4 +102,6 @@ class TrackInfo(QToolBar):
|
|||
self.album.setText("")
|
||||
self.track_cover.setPixmap(self.wobuzz_logo)
|
||||
|
||||
def set_size(self, size: int):
|
||||
self.track_cover.setFixedSize(size, size)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue