diff --git a/src/config/setting.py b/src/config/setting.py index 8f38ad8..4d6d1b1 100644 --- a/src/config/setting.py +++ b/src/config/setting.py @@ -91,7 +91,7 @@ class Setting: CategorySize = SettingValue("GeneraSetting", 80, False) # ScaleLevel = SettingValue("GeneraSetting", 0, True, ["Auto", 100, 125, 150, 175, 200]) # IsUseTitleBar = SettingValue("GeneraSetting", 1, True) - + IsUsewindowsize = SettingValue("GeneraSetting", 0, False) FontName = SettingValue("GeneraSetting", "", True) FontSize = SettingValue("GeneraSetting", "", True) FontStyle = SettingValue("GeneraSetting", 0, True) diff --git a/src/interface/ui_setting_new.py b/src/interface/ui_setting_new.py index ca941a1..d3538cb 100644 --- a/src/interface/ui_setting_new.py +++ b/src/interface/ui_setting_new.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ################################################################################ -## Form generated from reading UI file 'ui_setting_new.ui' +## Form generated from reading UI file 'ui_setting_new1.ui' ## ## Created by: Qt User Interface Compiler version 6.2.4 ## @@ -83,7 +83,7 @@ class Ui_SettingNew(object): self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") - self.scrollAreaWidgetContents.setGeometry(QRect(0, -601, 727, 2937)) + self.scrollAreaWidgetContents.setGeometry(QRect(0, -296, 727, 3012)) self.scrollAreaWidgetContents.setStyleSheet(u"") self.verticalLayout_4 = QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_4.setObjectName(u"verticalLayout_4") @@ -366,6 +366,25 @@ class Ui_SettingNew(object): self.verticalLayout_4.addWidget(self.frame_13) + self.frame = QFrame(self.scrollAreaWidgetContents) + self.frame.setObjectName(u"frame") + self.frame.setFrameShape(QFrame.StyledPanel) + self.frame.setFrameShadow(QFrame.Raised) + self.verticalLayout_14 = QVBoxLayout(self.frame) + self.verticalLayout_14.setObjectName(u"verticalLayout_14") + self.label_13 = QLabel(self.frame) + self.label_13.setObjectName(u"label_13") + + self.verticalLayout_14.addWidget(self.label_13) + + self.windowsize = QCheckBox(self.frame) + self.windowsize.setObjectName(u"windowsize") + + self.verticalLayout_14.addWidget(self.windowsize) + + + self.verticalLayout_4.addWidget(self.frame) + self.frame_17 = QFrame(self.scrollAreaWidgetContents) self.frame_17.setObjectName(u"frame_17") self.frame_17.setFrameShape(QFrame.StyledPanel) @@ -1357,6 +1376,8 @@ class Ui_SettingNew(object): self.mainScaleButton3.setText(QCoreApplication.translate("SettingNew", u"150%", None)) self.mainScaleButton4.setText(QCoreApplication.translate("SettingNew", u"175%", None)) self.mainScaleButton5.setText(QCoreApplication.translate("SettingNew", u"200%", None)) + self.label_13.setText(QCoreApplication.translate("SettingNew", u"

\u4fdd\u5b58\u7a97\u53e3\u4f4d\u7f6e\u548c\u5927\u5c0f

", None)) + self.windowsize.setText(QCoreApplication.translate("SettingNew", u"\u542f\u7528\u540e\u7acb\u5373\u751f\u6548", None)) self.label_38.setText(QCoreApplication.translate("SettingNew", u"\u5173\u95ed\u8bbe\u7f6e", None)) self.showCloseButton0.setText(QCoreApplication.translate("SettingNew", u"\u5173\u95ed\u540e\u9000\u51fa", None)) self.showCloseButton1.setText(QCoreApplication.translate("SettingNew", u"\u5173\u95ed\u540e\u6700\u5c0f\u5316\u5230\u6258\u76d8", None)) diff --git a/src/view/main/main_view.py b/src/view/main/main_view.py index d0b7adb..e8b6d6b 100644 --- a/src/view/main/main_view.py +++ b/src/view/main/main_view.py @@ -3,6 +3,8 @@ from functools import partial from PySide6.QtCore import Qt, QEvent, QPoint, Signal, QTimer, QSize from PySide6.QtGui import QIcon, QMouseEvent, QGuiApplication, QFont from PySide6.QtWidgets import QButtonGroup, QToolButton, QLabel +from PySide6.QtWidgets import QApplication, QMainWindow +from PySide6.QtCore import QSettings from component.dialog.loading_dialog import LoadingDialog from component.dialog.show_close_dialog import ShowCloseDialog @@ -34,7 +36,8 @@ class MainView(Main, QtTaskBase): # self.setAttribute(Qt.WA_PaintOnScreen, False) # 禁用屏幕缓存 # self.setAttribute(Qt.WA_NoSystemBackground, True) # 去除系统背景 # self.setAttribute(Qt.WA_OpaquePaintEvent, True) # 设置为不透明的paint event - self.resize(600, 600) + + #self.resize(600, 600) self.setWindowTitle(config.ProjectName) self.setWindowIcon(QIcon(":/png/icon/logo_round.png")) # self.setAttribute(Qt.WA_TranslucentBackground) @@ -55,9 +58,16 @@ class MainView(Main, QtTaskBase): # self.downloadView.setFixedWidth(150) # self.bookInfoView.setFixedWidth(150) self.myInitSize = QSize(desktop.width() // 4 * 3, desktop.height() // 4 * 3) - self.resize(desktop.width() // 4 * 3, desktop.height() // 4 * 3) - self.move(self.width() // 8+desktop.x(), max(0, desktop.height()-self.height()) // 2+desktop.y()) - print(desktop.size(), self.size()) + settings = QSettings('data/config.ini', QSettings.IniFormat) + settings.beginGroup('GeneraSetting') + keys = ['ScaleLevel', 'IsUsewindowsize'] + if all(settings.contains(key) for key in keys): + if settings.value('ScaleLevel', type=int) == 0: + self.resize(desktop.width() // 4 * 3, desktop.height() // 4 * 3) + self.move(self.width() // 8+desktop.x(), max(0, desktop.height()-self.height()) // 2+desktop.y()) + print(desktop.size(), self.size()) + if settings.value('IsUsewindowsize', type=int) == 1: + self.restore_window_size() self.setAttribute(Qt.WA_StyledBackground, True) self.loadingDialog = LoadingDialog(self) @@ -370,6 +380,36 @@ class MainView(Main, QtTaskBase): # self.myTrayIcon = None a0.accept() + def closeEvent(self, event): + self.save_window_size() + super().closeEvent(event) + + def save_window_size(self): + settings = QSettings('data/windowsize.ini',QSettings.IniFormat) + + settings.setValue('size', self.width()) + settings.setValue('size1', self.height()) + + settings.setValue('position',self.geometry().x()) + settings.setValue('position1', self.geometry().y()) + + def restore_window_size(self): + settings = QSettings('data/windowsize.ini', QSettings.IniFormat) + if settings.contains("size"): + size = int(settings.value('size')) + if settings.contains("size1"): + size1 = int(settings.value('size1')) + + if settings.contains("position"): + position = int(settings.value('position')) + if settings.contains("position1"): + position1 = int(settings.value('position1')) + + keys_to_check = ['size', 'size1', 'position', 'position1'] + if all(settings.contains(key) for key in keys_to_check): + self.setGeometry(position, position1, size, size1) + settings.endGroup() + def GetExitScreen(self): screens = QGuiApplication.screens() # print(self.pos()) diff --git a/src/view/setting/setting_view.py b/src/view/setting/setting_view.py index 3739ef8..93b7fbf 100644 --- a/src/view/setting/setting_view.py +++ b/src/view/setting/setting_view.py @@ -52,6 +52,7 @@ class SettingView(QtWidgets.QWidget, Ui_SettingNew): self.coverCheckBox.clicked.connect(partial(self.CheckButtonEvent, Setting.CoverIsOpenWaifu, self.coverCheckBox)) self.downAuto.clicked.connect(partial(self.CheckButtonEvent, Setting.DownloadAuto, self.downAuto)) # self.titleBox.clicked.connect(partial(self.CheckButtonEvent, Setting.IsUseTitleBar, self.titleBox)) + self.windowsize.clicked.connect(partial(self.CheckButtonEvent, Setting.IsUsewindowsize, self.windowsize)) self.openglBox.clicked.connect(partial(self.CheckButtonEvent, Setting.IsOpenOpenGL, self.openglBox)) self.grabGestureBox.clicked.connect(partial(self.CheckButtonEvent, Setting.IsGrabGesture, self.grabGestureBox)) # self.isShowClose.clicked.connect(partial(self.CheckButtonEvent, Setting.IsNotShowCloseTip, self.isShowClose)) @@ -254,6 +255,7 @@ class SettingView(QtWidgets.QWidget, Ui_SettingNew): self.sockEdit.setText(Setting.Sock5Proxy.value) self.chatProxy.setChecked(Setting.ChatProxy.value) # self.titleBox.setChecked(Setting.IsUseTitleBar.value) + self.windowsize.setChecked(Setting.IsUsewindowsize.value) self.openglBox.setChecked(Setting.IsOpenOpenGL.value) self.grabGestureBox.setChecked(Setting.IsGrabGesture.value) # self.isShowClose.setChecked(Setting.IsNotShowCloseTip.value) diff --git a/ui/ui_setting_new.ui b/ui/ui_setting_new.ui index 27e67d6..9539fdd 100644 --- a/ui/ui_setting_new.ui +++ b/ui/ui_setting_new.ui @@ -95,9 +95,9 @@ 0 - -601 + -296 727 - 2937 + 3012 @@ -636,6 +636,32 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + <html><head/><body><p><span style=" font-size:12pt;">保存窗口位置和大小</span></p></body></html> + + + + + + + 启用后立即生效 + + + + + + @@ -2415,12 +2441,12 @@ - - - + - + + +