Compare commits

...

1 Commits

Author SHA1 Message Date
KeksNino 695b80c6de feat: add tabs to settings menu 2026-02-07 01:47:25 +01:00
3 changed files with 55 additions and 18 deletions
+16 -17
View File
@@ -1,6 +1,9 @@
from core.utils.config.settings import save_settings
from core.utils.data.state import state
from core.utils.general.logs import consoleLog
from core.interface.utils.tabhelper import general_tab
from core.interface.utils.tabhelper import paths_tab
from core.interface.utils.tabhelper import network_tab
from PySide6 import QtWidgets
from PySide6.QtWidgets import (
QLineEdit,
@@ -13,7 +16,8 @@ from PySide6.QtWidgets import (
QSpinBox,
QCheckBox,
QFileDialog,
QComboBox
QComboBox,
QTabWidget,
)
import platform
@@ -23,10 +27,9 @@ def settings_dialog(self):
consoleLog("Settings dialog opened")
dialog = QDialog(self)
dialog.setWindowTitle("Settings")
dialog.setFixedSize(800, 550)
dialog.setFixedSize(700, 450)
dialog.setLayout(QVBoxLayout())
dialog.layout().addWidget(QLabel("Settings"))
def close_settings():
dialog.reject()
@@ -58,7 +61,6 @@ def settings_dialog(self):
autoresume_layout.addStretch()
autoresume_checkbox.setChecked(state.autoresume)
autoresume_layout.addWidget(autoresume_checkbox)
dialog.layout().addWidget(autoresume_container)
# transparent window checkbox
@@ -73,12 +75,11 @@ def settings_dialog(self):
transparent_window_checkbox.setChecked(state.window_transparency)
transparent_window_checkbox.toggled.connect(lambda checked: setattr(state, 'window_transparency', checked))
transparent_window_layout.addWidget(transparent_window_checkbox)
dialog.layout().addWidget(transparent_window_container)
##################
# SERVER SETTING #
##################
api_url_container = QWidget()
api_url_layout = QHBoxLayout()
@@ -88,7 +89,6 @@ def settings_dialog(self):
api_url_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
api_url_container.setLayout(api_url_layout)
api_url.setText(state.api_url)
dialog.layout().addWidget(api_url_container)
#################
# DOWNLOAD PATH #
@@ -103,7 +103,6 @@ def settings_dialog(self):
download_path_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
download_path_container.setLayout(download_path_layout)
download_path.setText(state.download_path)
dialog.layout().addWidget(download_path_container)
def browse_download_path():
dir_path = QFileDialog.getExistingDirectory(dialog, "Select Download Directory", state.download_path)
@@ -127,7 +126,6 @@ def settings_dialog(self):
image_path_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
image_path_container.setLayout(image_path_layout)
image_path.setText(state.image_path)
dialog.layout().addWidget(image_path_container)
def browse_image_path():
file_path = QFileDialog.getOpenFileName(dialog, "Select Image File", state.image_path, "Image Files (*.png *.jpg)")[0]
@@ -154,8 +152,7 @@ def settings_dialog(self):
down_speed_limit_layout.addWidget(down_speed_limit)
down_speed_limit.setFixedWidth(180)
down_speed_limit.setFixedHeight(30)
dialog.layout().addWidget(down_speed_limit_container)
up_speed_limit_container = QWidget()
up_speed_limit_layout = QHBoxLayout()
@@ -168,7 +165,6 @@ def settings_dialog(self):
up_speed_limit_layout.addWidget(up_speed_limit)
up_speed_limit.setFixedWidth(180)
up_speed_limit.setFixedHeight(30)
dialog.layout().addWidget(up_speed_limit_container)
######################
# CONNECTION CONFIGS #
@@ -186,7 +182,6 @@ def settings_dialog(self):
max_connections_layout.addWidget(max_connections)
max_connections.setFixedWidth(180)
max_connections.setFixedHeight(30)
dialog.layout().addWidget(max_connections_container)
####################
# DOWNLOAD CONFIGS #
@@ -204,7 +199,6 @@ def settings_dialog(self):
max_downloads_layout.addWidget(max_downloads)
max_downloads.setFixedWidth(180)
max_downloads.setFixedHeight(30)
dialog.layout().addWidget(max_downloads_container)
#####################
# INTERFACE BINDING #
@@ -232,8 +226,7 @@ def settings_dialog(self):
interface_select.setFixedHeight(30)
interface_layout.addWidget(interface_select)
interface_container.setLayout(interface_layout)
dialog.layout().addWidget(interface_container)
###############
# SAVE/CANCEL #
@@ -259,6 +252,12 @@ def settings_dialog(self):
layout.addWidget(cancel_btn)
layout.addWidget(save_btn)
self.tabs = QTabWidget()
self.tab1 = general_tab("General", autoresume_container, transparent_window_container, self.tabs)
self.tab2 = paths_tab("Paths", download_path_container, image_path_container, self.tabs)
self.tab3 = network_tab("Network", update_checkbox_container, interface_container, max_connections_container, max_downloads_container, up_speed_limit_container, down_speed_limit_container, api_url_container, self.tabs)
dialog.layout().addWidget(self.tabs)
dialog.layout().addLayout(layout)
dialog.exec()
-1
View File
@@ -362,7 +362,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
# Tabs
self.tabs = QTabWidget()
self.tabs = QTabWidget()
self.tabs.setStyleSheet("""
QTabBar::tab {
font-size: 11px;
+39
View File
@@ -15,3 +15,42 @@ def create_tab(title, searchbar, software_list, tabs, dlbutton, layout2):
tab.setLayout(layout)
tabs.addTab(tab, title)
return tab
#################
# SETTINGS TABS #
#################
def general_tab(title, autoresume, transparent_window, tabs):
tab = QWidget()
layout = QVBoxLayout()
layout.addWidget(autoresume)
layout.addWidget(transparent_window)
layout.addStretch()
tab.setLayout(layout)
tabs.addTab(tab, title)
return tab
def paths_tab(title, download_path, image_path, tabs):
tab = QWidget()
layout = QVBoxLayout()
layout.addWidget(download_path)
layout.addWidget(image_path)
layout.addStretch()
tab.setLayout(layout)
tabs.addTab(tab, title)
return tab
def network_tab(title, update_checkbox, network_interface, max_connections, max_downloads, up_speed_limit, down_speed_limit, api_url, tabs):
tab = QWidget()
layout = QVBoxLayout()
layout.addWidget(update_checkbox)
layout.addWidget(network_interface)
layout.addWidget(max_connections)
layout.addWidget(max_downloads)
layout.addWidget(up_speed_limit)
layout.addWidget(down_speed_limit)
layout.addWidget(api_url)
layout.addStretch()
tab.setLayout(layout)
tabs.addTab(tab, title)
return tab