add config and change logo
This commit is contained in:
@@ -3,10 +3,11 @@ from zoneinfo import ZoneInfo
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QAbstractItemView
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, QSortFilterProxyModel
|
||||
from qfluentwidgets import (
|
||||
PushButton, TableView, FluentIcon as Fi, PillPushButton
|
||||
TableView, FluentIcon as Fi, PillPushButton, PrimaryPushButton
|
||||
)
|
||||
|
||||
from common.utils import SAFE_MAP_ICON, SAFE_MAP
|
||||
from common.config import cfg
|
||||
|
||||
# dict[str, str | int] 就是
|
||||
# {
|
||||
@@ -104,9 +105,9 @@ class MainInterface(QWidget):
|
||||
self.setLayout(self.vly_m)
|
||||
|
||||
self.hly_top = QHBoxLayout()
|
||||
self.pbn_refresh = PushButton(Fi.SYNC, "刷新", self)
|
||||
self.pbn_add = PushButton(Fi.ADD, "添加", self)
|
||||
self.pbn_delete = PushButton(Fi.DELETE, "删除", self)
|
||||
self.pbn_refresh = PrimaryPushButton(Fi.SYNC, "刷新", self)
|
||||
self.pbn_add = PrimaryPushButton(Fi.ADD, "添加", self)
|
||||
self.pbn_delete = PrimaryPushButton(Fi.DELETE, "删除", self)
|
||||
|
||||
safe_checks = [
|
||||
("安全", 1), ("未知", 0), ("不安全", -1), ("未记录", -2),
|
||||
@@ -146,6 +147,7 @@ class MainInterface(QWidget):
|
||||
self.tbv_m.setColumnWidth(0, 250)
|
||||
self.tbv_m.setColumnWidth(1, 200)
|
||||
self.tbv_m.setColumnWidth(3, 180)
|
||||
self.tbv_m.scrollDelagate.verticalSmoothScroll.setSmoothMode(cfg.get(cfg.smooth_mode))
|
||||
|
||||
self.vly_m.addWidget(self.tbv_m)
|
||||
|
||||
|
||||
@@ -1,30 +1,39 @@
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtCore import Qt, QThread, QModelIndex
|
||||
from PySide6.QtGui import QIcon
|
||||
from qfluentwidgets import MSFluentWindow, setTheme, Theme, InfoBar, FluentIcon as Fi, InfoBarPosition
|
||||
|
||||
from qfluentwidgets import (
|
||||
MSFluentWindow, setTheme, InfoBar, FluentIcon as Fi, InfoBarPosition,
|
||||
NavigationItemPosition, setThemeColor
|
||||
)
|
||||
from common.utils import show_quick_tip, accept_warning
|
||||
from common.api_worker import ApiWorker
|
||||
from components.ext_dialog import ExtensionDialog
|
||||
from components.main_interface import MainInterface
|
||||
from components.settings_interface import SettingsInterface
|
||||
from common.config import cfg
|
||||
|
||||
|
||||
class MainWindow(MSFluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, title: str, width: int, height: int):
|
||||
super().__init__()
|
||||
self.setWindowTitle("插件安全标记")
|
||||
self.setWindowTitle(title)
|
||||
self.setWindowIcon(QIcon(":/logo.png"))
|
||||
# self.navigationInterface.hide()
|
||||
self.resize(1000, 760)
|
||||
self.resize(width, height)
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w // 2 - self.width() // 2, h // 2 - self.height() // 2)
|
||||
setTheme(Theme.LIGHT)
|
||||
setTheme(cfg.theme)
|
||||
setThemeColor(cfg.get(cfg.themeColor))
|
||||
|
||||
# --- UI ---
|
||||
self.main_interface = MainInterface(parent=self)
|
||||
self.settings_interface = SettingsInterface(name="settings", parent=self)
|
||||
self.addSubInterface(self.main_interface, Fi.HOME, "主页", Fi.HOME_FILL)
|
||||
self.addSubInterface(self.settings_interface, Fi.SETTING, "设置",
|
||||
position=NavigationItemPosition.BOTTOM)
|
||||
|
||||
self.stackedWidget.setAnimationEnabled(cfg.get(cfg.switch_animation))
|
||||
|
||||
# --- 初始化后台工作线程和 QObject ---
|
||||
self.thread = QThread()
|
||||
|
||||
71
components/settings_interface.py
Normal file
71
components/settings_interface.py
Normal file
@@ -0,0 +1,71 @@
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QWidget
|
||||
from qfluentwidgets import (
|
||||
ScrollArea, ExpandLayout, SettingCardGroup,
|
||||
OptionsSettingCard, CustomColorSettingCard, setTheme, setThemeColor,
|
||||
SwitchSettingCard, InfoBar, InfoBarPosition
|
||||
)
|
||||
from qfluentwidgets import FluentIcon as Fi
|
||||
from common.config import cfg
|
||||
|
||||
|
||||
class SettingsInterface(ScrollArea):
|
||||
|
||||
def __init__(self, name: str, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName(name.replace(" ", "-"))
|
||||
self.cw = QWidget(self)
|
||||
self.ely = ExpandLayout(self.cw)
|
||||
self.setWidget(self.cw)
|
||||
self.setWidgetResizable(True)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.enableTransparentBackground()
|
||||
|
||||
self.personal_group = SettingCardGroup("个性化", self.cw)
|
||||
self.theme_card = OptionsSettingCard(
|
||||
cfg.themeMode,
|
||||
Fi.BRUSH,
|
||||
"应用主题",
|
||||
"修改应用的外观",
|
||||
texts=["浅色", "深色", "跟随系统"],
|
||||
parent=self.personal_group,
|
||||
)
|
||||
self.theme_color_card = CustomColorSettingCard(
|
||||
cfg.themeColor,
|
||||
Fi.PALETTE,
|
||||
"主题色",
|
||||
"修改应用的主题颜色",
|
||||
parent=self.personal_group,
|
||||
)
|
||||
self.switch_animation_card = SwitchSettingCard(
|
||||
Fi.SCROLL,
|
||||
"切换动画",
|
||||
"切换不同页面时是否显示动画",
|
||||
configItem=cfg.switch_animation,
|
||||
parent=self.personal_group,
|
||||
)
|
||||
self.smooth_mode_card = OptionsSettingCard(
|
||||
cfg.smooth_mode,
|
||||
Fi.LEAF,
|
||||
"滚动模式",
|
||||
"修改视图滚动模式",
|
||||
texts=["无滚动", "匀速滚动", "线性滚动", "二次缓动", "余弦平滑"],
|
||||
parent=self.personal_group,
|
||||
)
|
||||
|
||||
self.personal_group.addSettingCard(self.theme_card)
|
||||
self.personal_group.addSettingCard(self.theme_color_card)
|
||||
self.personal_group.addSettingCard(self.switch_animation_card)
|
||||
self.personal_group.addSettingCard(self.smooth_mode_card)
|
||||
|
||||
self.ely.setSpacing(28)
|
||||
self.ely.setContentsMargins(20, 20, 20, 20)
|
||||
self.ely.addWidget(self.personal_group)
|
||||
|
||||
cfg.themeChanged.connect(setTheme)
|
||||
cfg.appRestartSig.connect(self.show_restart_tip)
|
||||
self.theme_color_card.colorChanged.connect(lambda c: setThemeColor(c))
|
||||
|
||||
def show_restart_tip(self):
|
||||
InfoBar.warning("", "设置已更新,重启应用生效。", duration=5000,
|
||||
position=InfoBarPosition.BOTTOM_RIGHT, parent=self.window())
|
||||
Reference in New Issue
Block a user