Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
feat(config): 新增删除缓存功能
Browse files Browse the repository at this point in the history
  • Loading branch information
ambition_echo committed Nov 22, 2022
1 parent aa3b7df commit d484a42
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 44 deletions.
12 changes: 12 additions & 0 deletions earth_wallpaper/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import shutil

from PySide6.QtCore import Qt, QSettings, Signal
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QWidget, QMessageBox, QFileDialog
Expand Down Expand Up @@ -82,6 +84,7 @@ def _connect_(self):
self.applyBtn.clicked.connect(self.write_config)
self.selectFile.clicked.connect(self.select_file)
self.selectDir.clicked.connect(self.select_dir)
self.clearCache.clicked.connect(self.clear_cache)

def check(self):
if os.path.exists(self.config_path):
Expand Down Expand Up @@ -196,3 +199,12 @@ def select_file(self):
"24h壁纸文件 (*.ddw *.zip);;")
logger.info(f"获取到文件地址{file}")
self.wallpaperFile.setText(file[0])

@staticmethod
def clear_cache():
cache = PlatformInfo.download_dir()
if os.path.exists(cache):
shutil.rmtree(cache)
logger.info(f"删除缓存目录: {cache}")
message = QMessageBox()
QMessageBox.information(message, "清理缓存", "已删除全部缓存壁纸", QMessageBox.Yes)
38 changes: 22 additions & 16 deletions earth_wallpaper/ui/UI_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Ui_Config(object):
def setupUi(self, Config):
if not Config.objectName():
Config.setObjectName(u"Config")
Config.resize(346, 534)
Config.resize(346, 572)
self.gridLayout_3 = QGridLayout(Config)
self.gridLayout_3.setObjectName(u"gridLayout_3")
self.AppSettings = QGroupBox(Config)
Expand Down Expand Up @@ -182,6 +182,20 @@ def setupUi(self, Config):

self.gridLayout_3.addWidget(self.AppSettings, 0, 0, 1, 3)

self.applySpacer = QSpacerItem(57, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

self.gridLayout_3.addItem(self.applySpacer, 2, 0, 1, 1)

self.applyBtn = QPushButton(Config)
self.applyBtn.setObjectName(u"applyBtn")

self.gridLayout_3.addWidget(self.applyBtn, 2, 1, 1, 1)

self.closeBtn = QPushButton(Config)
self.closeBtn.setObjectName(u"closeBtn")

self.gridLayout_3.addWidget(self.closeBtn, 2, 2, 1, 1)

self.SystemSettings = QGroupBox(Config)
self.SystemSettings.setObjectName(u"SystemSettings")
sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
Expand Down Expand Up @@ -248,22 +262,13 @@ def setupUi(self, Config):

self.gridLayout.addLayout(self.addGroup, 1, 0, 1, 1)

self.clearCache = QPushButton(self.SystemSettings)
self.clearCache.setObjectName(u"clearCache")

self.gridLayout_3.addWidget(self.SystemSettings, 1, 0, 1, 3)

self.applySpacer = QSpacerItem(57, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

self.gridLayout_3.addItem(self.applySpacer, 2, 0, 1, 1)

self.applyBtn = QPushButton(Config)
self.applyBtn.setObjectName(u"applyBtn")

self.gridLayout_3.addWidget(self.applyBtn, 2, 1, 1, 1)
self.gridLayout.addWidget(self.clearCache, 2, 0, 1, 1)

self.closeBtn = QPushButton(Config)
self.closeBtn.setObjectName(u"closeBtn")

self.gridLayout_3.addWidget(self.closeBtn, 2, 2, 1, 1)
self.gridLayout_3.addWidget(self.SystemSettings, 1, 0, 1, 3)


self.retranslateUi(Config)
Expand Down Expand Up @@ -297,14 +302,15 @@ def retranslateUi(self, Config):
self.People.setText(QCoreApplication.translate("Config", u"People", None))
self.selectFile.setText(QCoreApplication.translate("Config", u"\u6d4f\u89c8", None))
self.selectDir.setText(QCoreApplication.translate("Config", u"\u6d4f\u89c8", None))
self.applyBtn.setText(QCoreApplication.translate("Config", u"\u5e94\u7528", None))
self.closeBtn.setText(QCoreApplication.translate("Config", u"\u5173\u95ed", None))
self.SystemSettings.setTitle(QCoreApplication.translate("Config", u"\u7cfb\u7edf\u8bbe\u7f6e", None))
self.proxy_l.setText(QCoreApplication.translate("Config", u"\u7f51\u7edc\u4ee3\u7406\uff1a", None))
self.proxyNone.setText(QCoreApplication.translate("Config", u"\u65e0", None))
self.proxyHttp.setText(QCoreApplication.translate("Config", u"http", None))
self.proxySocks.setText(QCoreApplication.translate("Config", u"socks", None))
self.add_l.setText(QCoreApplication.translate("Config", u"\u5730\u5740\uff1a", None))
self.port_l.setText(QCoreApplication.translate("Config", u":", None))
self.applyBtn.setText(QCoreApplication.translate("Config", u"\u5e94\u7528", None))
self.closeBtn.setText(QCoreApplication.translate("Config", u"\u5173\u95ed", None))
self.clearCache.setText(QCoreApplication.translate("Config", u"\u5220\u9664\u7f13\u5b58", None))
# retranslateUi

63 changes: 35 additions & 28 deletions earth_wallpaper/ui/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>346</width>
<height>534</height>
<height>572</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -238,6 +238,33 @@ color: #774444;</string>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="applySpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>57</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="applyBtn">
<property name="text">
<string>应用</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="closeBtn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="SystemSettings">
<property name="sizePolicy">
Expand Down Expand Up @@ -322,36 +349,16 @@ color: #774444;</string>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="clearCache">
<property name="text">
<string>删除缓存</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="applySpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>57</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="applyBtn">
<property name="text">
<string>应用</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="closeBtn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down

0 comments on commit d484a42

Please sign in to comment.