Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Failuresorm committed Nov 4, 2024
1 parent b5d60e0 commit d4ed11d
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/config/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 23 additions & 2 deletions src/interface/ui_setting_new.py
Original file line number Diff line number Diff line change
@@ -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
##
Expand Down Expand Up @@ -83,7 +83,7 @@ def setupUi(self, SettingNew):
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")
Expand Down Expand Up @@ -366,6 +366,25 @@ def setupUi(self, SettingNew):

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)
Expand Down Expand Up @@ -1357,6 +1376,8 @@ def retranslateUi(self, SettingNew):
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"<html><head/><body><p><span style=\" font-size:12pt;\">\u4fdd\u5b58\u7a97\u53e3\u4f4d\u7f6e\u548c\u5927\u5c0f</span></p></body></html>", 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))
Expand Down
48 changes: 44 additions & 4 deletions src/view/main/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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
Expand Down Expand Up @@ -34,7 +36,8 @@ def __init__(self):
# 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)
Expand All @@ -55,9 +58,16 @@ def __init__(self):
# 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)
Expand Down Expand Up @@ -370,6 +380,36 @@ def closeEvent(self, a0) -> None:
# 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())
Expand Down
2 changes: 2 additions & 0 deletions src/view/setting/setting_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, parent=None):
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))
Expand Down Expand Up @@ -254,6 +255,7 @@ def InitSetting(self):
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)
Expand Down
38 changes: 32 additions & 6 deletions ui/ui_setting_new.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-601</y>
<y>-296</y>
<width>727</width>
<height>2937</height>
<height>3012</height>
</rect>
</property>
<property name="styleSheet">
Expand Down Expand Up @@ -636,6 +636,32 @@
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;保存窗口位置和大小&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="windowsize">
<property name="text">
<string>启用后立即生效</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_17">
<property name="frameShape">
Expand Down Expand Up @@ -2415,12 +2441,12 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="showCloseButtonGroup"/>
<buttongroup name="saveNameGroup"/>
<buttongroup name="themeGroup"/>
<buttongroup name="mainScaleGroup"/>
<buttongroup name="proxyGroup"/>
<buttongroup name="logGroup"/>
<buttongroup name="mainScaleGroup"/>
<buttongroup name="saveNameGroup"/>
<buttongroup name="languageGroup"/>
<buttongroup name="showCloseButtonGroup"/>
<buttongroup name="themeGroup"/>
</buttongroups>
</ui>

0 comments on commit d4ed11d

Please sign in to comment.