-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathConfigWindow.py
197 lines (155 loc) · 6.68 KB
/
ConfigWindow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<<<<<<< HEAD
# -*- coding: utf-8 -*-
"""
Module implementing ConfigWindow.
"""
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QDialog, QFileDialog
import os
import sys
import autorun
from Ui_ConfigWindow import Ui_Dialog
class ConfigWindow(QDialog, Ui_Dialog):
"""
Class documentation goes here.
"""
def __init__(self, parent=None, settings=None):
"""
Constructor
@param parent reference to the parent widget (QWidget)
"""
super().__init__(parent)
self.setupUi(self)
self.autoRun.setChecked(autorun.exists('BingNiceWallpapers'))
self.storePathEdit.setText(
os.path.join(settings.value("pathToWallpaperDir"), '必应好壁纸壁纸库'))
self.storePathEdit_2.setText(
os.path.join(settings.value("pathToLikedWallpaperDir"), '收藏的必应壁纸'))
self.timeEdit.setTime(QTime.fromMSecsSinceStartOfDay(int(settings.value("timeoutInterval"))))
@pyqtSlot()
def on_browseButton_clicked(self):
pathToWallpaperDir = os.path.normpath(
QFileDialog.getExistingDirectory(self))
print('pathToWallpaperDir--------', pathToWallpaperDir) # 取消后 返回 点 . bugggggg
# 如果取消QFileDialog.getExistingDirectory的话,那么得到的就是 ‘’
# 如果目的地存在wallpaperDir同名文件夹会出错
if pathToWallpaperDir != '':
self.storePathEdit.setText(
os.path.join(pathToWallpaperDir, '必应好壁纸壁纸库'))
self.pathToWallpaperDir = pathToWallpaperDir
# else:
# self.tipsLabel.setText(
# '{} 已经存在,请选择别的位置'.format(pathToWallpaperDir))
@pyqtSlot()
def on_browseButton_2_clicked(self):
pathToLikedWallpaperDir = os.path.normpath(
QFileDialog.getExistingDirectory(self))
# 如果取消QFileDialog.getExistingDirectory的话,那么得到的就是 ‘’ and if
if pathToLikedWallpaperDir != '':
self.storePathEdit_2.setText(
os.path.join(pathToLikedWallpaperDir, '收藏的必应壁纸'))
self.pathToLikedWallpaperDir = pathToLikedWallpaperDir
# else:
# self.tipsLabel.setText(
# '{} 已经存在,请选择别的位置'.format(pathToWallpaperDir))
@pyqtSlot()
def on_open_clicked(self):
# 壁纸库
if os.path.exists(self.storePathEdit.text()): # 更改路径后,新路径还未存在
QDesktopServices.openUrl(QUrl.fromLocalFile(self.storePathEdit.text()))
@pyqtSlot()
def on_open_2_clicked(self):
# 收藏的必应壁纸
if os.path.exists(self.storePathEdit_2.text()):
QDesktopServices.openUrl(QUrl.fromLocalFile(self.storePathEdit_2.text()))
@pyqtSlot()
def closeEvent(self, event):
pass
# @pyqtSlot(bool)
# def on_autoRun_clicked(self, checked):
# regSettings = QSettings(
# r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
# print('on_autoRun_clicked-------', regSettings.allKeys())
# if checked:
# regSettings.setValue("BingNiceWallpapers",sys.executable)
# else:
# regSettings.remove("BingNiceWallpapers")
=======
# -*- coding: utf-8 -*-
"""
Module implementing ConfigWindow.
"""
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QDialog, QFileDialog
import os
import sys
import autorun
from Ui_ConfigWindow import Ui_Dialog
class ConfigWindow(QDialog, Ui_Dialog):
"""
Class documentation goes here.
"""
def __init__(self, parent=None, settings=None):
"""
Constructor
@param parent reference to the parent widget (QWidget)
"""
super().__init__(parent)
self.setupUi(self)
self.autoRun.setChecked(autorun.exists('BingNiceWallpapers'))
self.storePathEdit.setText(
os.path.join(settings.value("pathToWallpaperDir"), '必应好壁纸壁纸库'))
self.storePathEdit_2.setText(
os.path.join(settings.value("pathToLikedWallpaperDir"), '收藏的必应壁纸'))
self.timeEdit.setTime(QTime.fromMSecsSinceStartOfDay(int(settings.value("timeoutInterval"))))
@pyqtSlot()
def on_browseButton_clicked(self):
pathToWallpaperDir = os.path.normpath(
QFileDialog.getExistingDirectory(self))
print('pathToWallpaperDir--------', pathToWallpaperDir) # 取消后 返回 点 . bugggggg
# 如果取消QFileDialog.getExistingDirectory的话,那么得到的就是 ‘’
# 如果目的地存在wallpaperDir同名文件夹会出错
if pathToWallpaperDir != '':
self.storePathEdit.setText(
os.path.join(pathToWallpaperDir, '必应好壁纸壁纸库'))
self.pathToWallpaperDir = pathToWallpaperDir
# else:
# self.tipsLabel.setText(
# '{} 已经存在,请选择别的位置'.format(pathToWallpaperDir))
@pyqtSlot()
def on_browseButton_2_clicked(self):
pathToLikedWallpaperDir = os.path.normpath(
QFileDialog.getExistingDirectory(self))
# 如果取消QFileDialog.getExistingDirectory的话,那么得到的就是 ‘’ and if
if pathToLikedWallpaperDir != '':
self.storePathEdit_2.setText(
os.path.join(pathToLikedWallpaperDir, '收藏的必应壁纸'))
self.pathToLikedWallpaperDir = pathToLikedWallpaperDir
# else:
# self.tipsLabel.setText(
# '{} 已经存在,请选择别的位置'.format(pathToWallpaperDir))
@pyqtSlot()
def on_open_clicked(self):
# 壁纸库
if os.path.exists(self.storePathEdit.text()): # 更改路径后,新路径还未存在
QDesktopServices.openUrl(QUrl.fromLocalFile(self.storePathEdit.text()))
@pyqtSlot()
def on_open_2_clicked(self):
# 收藏的必应壁纸
if os.path.exists(self.storePathEdit_2.text()):
QDesktopServices.openUrl(QUrl.fromLocalFile(self.storePathEdit_2.text()))
@pyqtSlot()
def closeEvent(self, event):
pass
# @pyqtSlot(bool)
# def on_autoRun_clicked(self, checked):
# regSettings = QSettings(
# r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
# print('on_autoRun_clicked-------', regSettings.allKeys())
# if checked:
# regSettings.setValue("BingNiceWallpapers",sys.executable)
# else:
# regSettings.remove("BingNiceWallpapers")
>>>>>>> a9d19b1694df63504960fefae1aba696ea5de373