diff --git a/portprotonqt/dialogs.py b/portprotonqt/dialogs.py index 4aca009..b81f433 100644 --- a/portprotonqt/dialogs.py +++ b/portprotonqt/dialogs.py @@ -13,7 +13,8 @@ from portprotonqt.config_utils import get_portproton_location from portprotonqt.localization import _ from portprotonqt.logger import get_logger import portprotonqt.themes.standart.styles as default_styles -from portprotonqt.themes.standart.styles import FileExplorerStyles +from portprotonqt.theme_manager import ThemeManager +from portprotonqt.custom_widgets import AutoSizeButton if TYPE_CHECKING: from portprotonqt.main_window import MainWindow @@ -88,8 +89,10 @@ class FileSelectedSignal(QObject): file_selected = Signal(str) # Сигнал с путем к выбранному файлу class FileExplorer(QDialog): - def __init__(self, parent=None, file_filter=None): + def __init__(self, parent=None, theme=None, file_filter=None): super().__init__(parent) + self.theme = theme if theme else default_styles + self.theme_manager = ThemeManager() self.file_signal = FileSelectedSignal() self.file_filter = file_filter # Store the file filter self.mime_db = QMimeDatabase() # Initialize QMimeDatabase for mimetype detection @@ -98,7 +101,6 @@ class FileExplorer(QDialog): # Настройки окна self.setWindowModality(Qt.WindowModality.ApplicationModal) self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint) - self.setStyleSheet(FileExplorerStyles.WINDOW_STYLE) # Find InputManager from parent self.input_manager = None @@ -153,28 +155,28 @@ class FileExplorer(QDialog): self.drives_container = QWidget() self.drives_container.setLayout(self.drives_layout) self.drives_scroll.setWidget(self.drives_container) - self.drives_scroll.setStyleSheet(FileExplorerStyles.BUTTON_STYLE) - self.drives_scroll.setFixedHeight(50) + self.drives_scroll.setStyleSheet(self.theme.SCROLL_AREA_STYLE) + self.drives_scroll.setFixedHeight(60) self.main_layout.addWidget(self.drives_scroll) # Путь self.path_label = QLabel() - self.path_label.setStyleSheet(FileExplorerStyles.PATH_LABEL_STYLE) + self.path_label.setStyleSheet(self.theme.FILE_EXPLORER_PATH_LABEL_STYLE) self.main_layout.addWidget(self.path_label) # Список файлов self.file_list = QListWidget() - self.file_list.setStyleSheet(FileExplorerStyles.LIST_STYLE) + self.file_list.setStyleSheet(self.theme.FILE_EXPLORER_STYLE) self.file_list.itemClicked.connect(self.handle_item_click) self.main_layout.addWidget(self.file_list) # Кнопки self.button_layout = QHBoxLayout() self.button_layout.setSpacing(10) - self.select_button = QPushButton(_("Select")) - self.cancel_button = QPushButton(_("Cancel")) - self.select_button.setStyleSheet(FileExplorerStyles.BUTTON_STYLE) - self.cancel_button.setStyleSheet(FileExplorerStyles.BUTTON_STYLE) + self.select_button = AutoSizeButton(_("Select"), icon=self.theme_manager.get_icon("apply")) + self.cancel_button = AutoSizeButton(_("Cancel"), icon=self.theme_manager.get_icon("cancel")) + self.select_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE) + self.cancel_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE) self.button_layout.addWidget(self.select_button) self.button_layout.addWidget(self.cancel_button) self.main_layout.addLayout(self.button_layout) @@ -246,8 +248,8 @@ class FileExplorer(QDialog): drives = self.get_mounted_drives() for drive in drives: drive_name = os.path.basename(drive) or drive.split('/')[-1] or drive - button = QPushButton(drive_name) - button.setStyleSheet(FileExplorerStyles.BUTTON_STYLE) + button = AutoSizeButton(drive_name, icon=self.theme_manager.get_icon("mount_point")) + button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE) button.clicked.connect(lambda checked, path=drive: self.change_drive(path)) self.drives_layout.addWidget(button) self.drives_layout.addStretch() @@ -266,7 +268,7 @@ class FileExplorer(QDialog): try: if self.current_path != "/": item = QListWidgetItem("../") - item.setIcon(QIcon.fromTheme("folder-symbolic")) + item.setIcon(self.theme_manager.get_icon("folder")) self.file_list.addItem(item) items = os.listdir(self.current_path) @@ -282,7 +284,7 @@ class FileExplorer(QDialog): for d in sorted(dirs): item = QListWidgetItem(f"{d}/") - item.setIcon(QIcon.fromTheme("folder-symbolic")) + item.setIcon(self.theme_manager.get_icon("folder")) self.file_list.addItem(item) for f in sorted(files): diff --git a/portprotonqt/themes/standart/images/icons/apply.svg b/portprotonqt/themes/standart/images/icons/apply.svg new file mode 100644 index 0000000..d35141a --- /dev/null +++ b/portprotonqt/themes/standart/images/icons/apply.svg @@ -0,0 +1 @@ + diff --git a/portprotonqt/themes/standart/images/icons/folder.svg b/portprotonqt/themes/standart/images/icons/folder.svg new file mode 100644 index 0000000..36e7bec --- /dev/null +++ b/portprotonqt/themes/standart/images/icons/folder.svg @@ -0,0 +1,3 @@ + diff --git a/portprotonqt/themes/standart/images/icons/mount_point.svg b/portprotonqt/themes/standart/images/icons/mount_point.svg new file mode 100644 index 0000000..88064da --- /dev/null +++ b/portprotonqt/themes/standart/images/icons/mount_point.svg @@ -0,0 +1,3 @@ + diff --git a/portprotonqt/themes/standart/styles.py b/portprotonqt/themes/standart/styles.py index 8d21e6e..bcb4e59 100644 --- a/portprotonqt/themes/standart/styles.py +++ b/portprotonqt/themes/standart/styles.py @@ -856,6 +856,72 @@ SETTINGS_CHECKBOX_STYLE = f""" }} """ +FILE_EXPLORER_STYLE = f""" + QListView {{ + font-size: {font_size_a}; + font-family: {font_family}; + background-color: {color_c}; + color: {color_f}; + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; + }} + QListView::item {{ + padding: 8px; + margin: 0px 5px; + border-bottom: {border_b} rgba(255, 255, 255, 0.1); + }} + QListView::item:selected {{ + background-color: {color_a}; + color: {color_f}; + border-radius: {border_radius_a}; + }} + QListView::item:hover {{ + background-color: {color_a}; + color: {color_f}; + border-radius: {border_radius_a}; + }} + QListView::item:focus {{ + background-color: {color_a}; + color: {color_f}; + border-radius: {border_radius_a}; + }} + QScrollBar:vertical {{ + width: 10px; + border: {border_a}; + border-radius: 5px; + background: {color_c}; + }} + QScrollBar::handle:vertical {{ + background: #bebebe; + border: {border_a}; + border-radius: 5px; + }} + QScrollBar::add-line:vertical {{ + border: {border_a}; + background: {color_c}; + border-bottom-right-radius: 5px; + }} + QScrollBar::sub-line:vertical {{ + border: {border_a}; + background: {color_c}; + border-top-right-radius: 5px; + }} + QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {{ + border: {border_a}; + width: 3px; + height: 3px; + background: none; + }} +""" + +FILE_EXPLORER_PATH_LABEL_STYLE = f""" + QLabel {{ + color: {color_a}; + font-size: {font_size_a}; + font-family: {font_family}; + }} +""" + # ФУНКЦИЯ ДЛЯ ДИНАМИЧЕСКОГО ГРАДИЕНТА (ДЕТАЛИ ИГР) # Функции из этой темы срабатывает всегда вне зависимости от выбранной темы, функции из других тем работают только в этих темах def detail_page_style(stops): @@ -866,57 +932,3 @@ def detail_page_style(stops): border-radius: {border_radius_b}; }} """ - -class FileExplorerStyles: - WINDOW_STYLE = """ - QDialog { - background-color: #2d2d2d; - color: #ffffff; - font-family: "Arial"; - font-size: 14px; - } - """ - - PATH_LABEL_STYLE = """ - QLabel { - color: #3daee9; - font-size: 16px; - padding: 5px; - } - """ - - LIST_STYLE = """ - QListWidget { - font-size: 16px; - background-color: #353535; - color: #eee; - border: 1px solid #444; - border-radius: 4px; - } - QListWidget::item { - padding: 8px; - border-bottom: 1px solid #444; - } - QListWidget::item:selected { - background-color: #3daee9; - color: white; - border-radius: 2px; - } - """ - - BUTTON_STYLE = """ - QPushButton { - background-color: #3daee9; - color: white; - border: none; - padding: 8px 16px; - border-radius: 4px; - font-size: 14px; - } - QPushButton:hover { - background-color: #2c9fd8; - } - QPushButton:pressed { - background-color: #1a8fc7; - } - """