From cf9185e9e7cd83e599093b4b6789c5efdf560e98 Mon Sep 17 00:00:00 2001 From: Vxrtrauter <101264710+Vxrtrauter@users.noreply.github.com> Date: Wed, 8 Apr 2026 01:06:41 +0200 Subject: [PATCH] feat: Enhance accent color options in settings dialog and save functionality --- src/interface/dialogs/settings.py | 36 +++++++++++++++++++++++++++++-- src/utils/config/settings.py | 7 ++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/interface/dialogs/settings.py b/src/interface/dialogs/settings.py index 6b6a25e..811c4bc 100644 --- a/src/interface/dialogs/settings.py +++ b/src/interface/dialogs/settings.py @@ -1,9 +1,11 @@ from interface.utils.tabhelper import create_tab +from interface.dialogs.theme import _accent_selection_color from utils.config.settings import save_settings from interface.utils.svghelper import svg_icon from utils.logging.logs import consoleLog from PySide6.QtCore import Qt, QSize from utils.data.state import state +from PySide6.QtGui import QColor from PySide6 import QtWidgets from PySide6.QtWidgets import ( QLineEdit, @@ -13,9 +15,10 @@ from PySide6.QtWidgets import ( QDialog, QLabel, QHBoxLayout, - QSpinBox, QSlider, QCheckBox, + QSpinBox, QSlider, QCheckBox, QFileDialog, QComboBox, + QColorDialog ) import platform @@ -91,9 +94,31 @@ def settings_dialog(self): transparent_window_checkbox.toggled.connect(lambda checked: setattr(state, 'window_transparency', checked)) # Accent Color - accent_color_container, accent_color_input = create_widget(QLineEdit, "Accent Color (requires restart): ", width=180, height=30) + accent_color_container, accent_color_input = create_widget(QLineEdit, "Accent Color: ", width=180, height=30) + accent_color_button = QPushButton("") + accent_color_button.setFixedSize(21, 21) + accent_color_button.setCursor(Qt.CursorShape.PointingHandCursor) + + def update_accent_button_color(color_str): + c = color_str.strip() + accent_color_button.setStyleSheet( + f"QPushButton {{ background-color: {c if c else 'transparent'}; border: 1px solid palette(mid); border-radius: 3px; }}" + ) + + def browse_accent_color(): + current = accent_color_input.text().strip() + initial = QColor(current) if current else QColor() + color = QColorDialog.getColor(initial, dialog, "Select Accent Color") + if color.isValid(): + accent_color_input.setText(color.name()) + + accent_color_input.textChanged.connect(update_accent_button_color) + accent_color_button.clicked.connect(browse_accent_color) accent_color_input.setPlaceholderText("e.g. #fca7d7") accent_color_input.setText(state.accent_color) + update_accent_button_color(state.accent_color) + accent_color_container.layout().insertWidget(1, accent_color_button) + # API URL Widget api_url_container, api_url = create_widget(QLineEdit, "API Server URL: ", width=180, height=30) @@ -299,6 +324,13 @@ def settings_dialog(self): image_position=image_position_combo.currentText(), accent_color=accent_color_input.text().strip() ) + color = _accent_selection_color() + if color: + self.tracker_list.setStyleSheet( + f"QComboBox QAbstractItemView::item:selected {{ background: {color}; }}" + ) + else: + self.tracker_list.setStyleSheet("") cancel_btn.clicked.connect(dialog.reject) layout.addWidget(cancel_btn) diff --git a/src/utils/config/settings.py b/src/utils/config/settings.py index 09df0da..115fd7a 100644 --- a/src/utils/config/settings.py +++ b/src/utils/config/settings.py @@ -2,6 +2,9 @@ from network.libtorrent_int import update_settings from utils.config.config import create_config from utils.logging.logs import consoleLog from utils.data.state import state +import qdarktheme +import platform + @@ -36,6 +39,10 @@ def save_settings(close=lambda: None, apiurl=None, download_path=None, down_spee state.image_position = image_position if accent_color is not None: state.accent_color = accent_color + custom_colors = {"primary": state.accent_color} if state.accent_color else {} + if state.window_transparency and platform.system() != "Windows": + custom_colors["background"] = "#00000000" + qdarktheme.setup_theme("auto", custom_colors=custom_colors if custom_colors else None) update_settings() # Update LibTorrent Session Settings consoleLog("Saved Settings")