1
1
from PyQt5 import QtCore , QtGui , QtWidgets
2
- import os , sys
2
+ import os
3
+ import sys
4
+
3
5
4
6
class Ui_OptionsWin (object ):
5
7
def setupUi (self , OptionsWin ):
6
8
self .appPath = str (os .getcwd ())
7
9
self .tempPath = self .appPath + "\Data\prxUserMeta\\ "
8
- #Settings
10
+ # Settings
9
11
self .userFont = "Arial"
10
12
self .userPort = "1337"
13
+ self .userIp = ""
11
14
self .userIPath = self .appPath
12
15
self .userDPath = self .appPath
13
16
self .userHB = "False"
14
17
try :
15
- with open (self . tempPath + " pref.ini" ) as file :
18
+ with open ("Data/Pref/ pref.ini" ) as file :
16
19
content = file .readlines ()
17
20
self .userFont = content [0 ][2 : - 1 ]
18
21
self .userPort = content [1 ][2 : - 1 ]
19
- self .userIPath = content [2 ][6 : - 1 ]
20
- self .userDPath = content [3 ][6 : - 1 ]
21
- self .userHB = (content [4 ][content [4 ].find (":" )+ 1 :])
22
+ self .userIp = content [2 ][3 : - 1 ]
23
+ self .userIPath = content [3 ][6 : - 1 ]
24
+ self .userDPath = content [4 ][6 : - 1 ]
25
+ self .userHB = (content [5 ][content [4 ].find (":" )+ 1 :])
22
26
except :
23
27
pass
24
28
@@ -30,37 +34,54 @@ def setupUi(self, OptionsWin):
30
34
self .font .setFamily (self .userFont )
31
35
self .font .setPointSize (10 )
32
36
OptionsWin .setFont (self .font )
33
- self .OptionsWin = OptionsWin # For class methods to use
37
+ self .OptionsWin = OptionsWin # For class methods to use
34
38
35
39
self .Window_btn = QtWidgets .QDialogButtonBox (OptionsWin )
36
- self .Window_btn .setGeometry (QtCore .QRect (30 , 210 , 156 , 23 ))
37
- self .Window_btn .setStandardButtons (QtWidgets .QDialogButtonBox .Cancel | QtWidgets .QDialogButtonBox .Save )
40
+ self .Window_btn .setGeometry (QtCore .QRect (30 , 210 , 300 , 23 ))
41
+ self .Window_btn .setStandardButtons (
42
+ QtWidgets .QDialogButtonBox .Cancel | QtWidgets .QDialogButtonBox .Save )
38
43
self .Window_btn .setObjectName ("Window_btn" )
39
44
40
45
self .Window_btn .accepted .connect (self .SaveOptions )
41
46
self .Window_btn .rejected .connect (OptionsWin .close )
42
47
48
+ self .Default_btn = QtWidgets .QDialogButtonBox (OptionsWin )
49
+ self .Default_btn .setGeometry (QtCore .QRect (25 , 210 , 110 , 23 ))
50
+
51
+ self .Default_btn .setStandardButtons (
52
+ QtWidgets .QDialogButtonBox .Yes )
53
+ self .Default_btn .button (QtWidgets .QDialogButtonBox .Yes ).setText (
54
+ "Default settings" )
55
+ self .Default_btn .setObjectName ("Default_btn" )
56
+
57
+ self .Default_btn .accepted .connect (self .ResetDefaults )
58
+
43
59
self .BrowseIconPath_btn = QtWidgets .QToolButton (OptionsWin )
44
- self .BrowseIconPath_btn .setGeometry (QtCore .QRect (410 , 69 , 31 , 24 ))
60
+ self .BrowseIconPath_btn .setGeometry (QtCore .QRect (410 , 89 , 31 , 24 ))
45
61
self .BrowseIconPath_btn .setObjectName ("BrowseIconPath_btn" )
46
62
self .BrowseDownloadPath_btn = QtWidgets .QToolButton (OptionsWin )
47
- self .BrowseDownloadPath_btn .setGeometry (QtCore .QRect (410 , 99 , 31 , 24 ))
63
+ self .BrowseDownloadPath_btn .setGeometry (QtCore .QRect (410 , 119 , 31 , 24 ))
48
64
self .BrowseDownloadPath_btn .setObjectName ("BrowseDownloadPath_btn" )
49
65
50
66
self .BrowseDownloadPath_btn .clicked .connect (self .GetDownloadPath )
51
67
self .BrowseIconPath_btn .clicked .connect (self .GetIconPath )
52
-
68
+
53
69
self .Port_label = QtWidgets .QLabel (OptionsWin )
54
70
self .Port_label .setGeometry (QtCore .QRect (30 , 40 , 120 , 22 ))
55
71
self .Port_label .setObjectName ("Port_label" )
72
+
73
+ self .IP_label = QtWidgets .QLabel (OptionsWin )
74
+ self .IP_label .setObjectName ("IP_Label" )
75
+ self .IP_label .setGeometry (QtCore .QRect (30 , 59 , 120 , 22 ))
76
+
56
77
self .Font_label = QtWidgets .QLabel (OptionsWin )
57
78
self .Font_label .setGeometry (QtCore .QRect (30 , 8 , 120 , 22 ))
58
79
self .Font_label .setObjectName ("Font_label" )
59
80
self .IconPath_label = QtWidgets .QLabel (OptionsWin )
60
- self .IconPath_label .setGeometry (QtCore .QRect (30 , 70 , 120 , 22 ))
81
+ self .IconPath_label .setGeometry (QtCore .QRect (30 , 89 , 120 , 22 ))
61
82
self .IconPath_label .setObjectName ("IconPath_label" )
62
83
self .DownloadPath_label = QtWidgets .QLabel (OptionsWin )
63
- self .DownloadPath_label .setGeometry (QtCore .QRect (30 , 100 , 135 , 22 ))
84
+ self .DownloadPath_label .setGeometry (QtCore .QRect (30 , 119 , 135 , 22 ))
64
85
self .DownloadPath_label .setObjectName ("DownloadPath_label" )
65
86
self .ShowHB_label = QtWidgets .QLabel (OptionsWin )
66
87
self .ShowHB_label .setGeometry (QtCore .QRect (30 , 150 , 99 , 31 ))
@@ -73,6 +94,15 @@ def setupUi(self, OptionsWin):
73
94
self .Port .setAlignment (QtCore .Qt .AlignCenter )
74
95
self .Port .setClearButtonEnabled (True )
75
96
self .Port .setObjectName ("Port" )
97
+
98
+ self .IP = QtWidgets .QLineEdit (OptionsWin )
99
+ self .IP .setGeometry (QtCore .QRect (170 , 59 , 271 , 22 ))
100
+ self .IP .setCursor (QtGui .QCursor (QtCore .Qt .ArrowCursor ))
101
+ self .IP .setMaxLength (28 )
102
+ self .IP .setAlignment (QtCore .Qt .AlignCenter )
103
+ self .IP .setClearButtonEnabled (True )
104
+ self .IP .setObjectName ("IP" )
105
+
76
106
self .Font = QtWidgets .QFontComboBox (OptionsWin )
77
107
self .Font .setGeometry (QtCore .QRect (170 , 8 , 271 , 22 ))
78
108
self .Font .setFont (self .font )
@@ -81,15 +111,15 @@ def setupUi(self, OptionsWin):
81
111
self .Font .setCurrentFont (self .font )
82
112
self .Font .setObjectName ("Font" )
83
113
self .IconPath = QtWidgets .QLineEdit (OptionsWin )
84
- self .IconPath .setGeometry (QtCore .QRect (170 , 70 , 241 , 22 ))
114
+ self .IconPath .setGeometry (QtCore .QRect (170 , 89 , 241 , 22 ))
85
115
self .IconPath .setCursor (QtGui .QCursor (QtCore .Qt .ArrowCursor ))
86
116
self .IconPath .setText ("" )
87
117
self .IconPath .setMaxLength (50 )
88
118
self .IconPath .setAlignment (QtCore .Qt .AlignCenter )
89
119
self .IconPath .setReadOnly (True )
90
120
self .IconPath .setObjectName ("IconPath" )
91
121
self .DownloadPath = QtWidgets .QLineEdit (OptionsWin )
92
- self .DownloadPath .setGeometry (QtCore .QRect (170 , 100 , 241 , 22 ))
122
+ self .DownloadPath .setGeometry (QtCore .QRect (170 , 119 , 241 , 22 ))
93
123
self .DownloadPath .setCursor (QtGui .QCursor (QtCore .Qt .ArrowCursor ))
94
124
self .DownloadPath .setText ("" )
95
125
self .DownloadPath .setMaxLength (50 )
@@ -114,15 +144,19 @@ def setupUi(self, OptionsWin):
114
144
self .plainTextEdit .setGeometry (QtCore .QRect (270 , 140 , 171 , 51 ))
115
145
self .plainTextEdit .setFont (self .font )
116
146
self .plainTextEdit .setStyleSheet ("color: rgb(255, 53, 53);" )
117
- self .plainTextEdit .setVerticalScrollBarPolicy (QtCore .Qt .ScrollBarAlwaysOff )
118
- self .plainTextEdit .setHorizontalScrollBarPolicy (QtCore .Qt .ScrollBarAlwaysOff )
147
+ self .plainTextEdit .setVerticalScrollBarPolicy (
148
+ QtCore .Qt .ScrollBarAlwaysOff )
149
+ self .plainTextEdit .setHorizontalScrollBarPolicy (
150
+ QtCore .Qt .ScrollBarAlwaysOff )
119
151
self .plainTextEdit .setReadOnly (True )
120
152
self .plainTextEdit .setObjectName ("plainTextEdit" )
121
153
122
154
self .IconPath .raise_ ()
123
155
self .Window_btn .raise_ ()
156
+ self .Default_btn .raise_ ()
124
157
self .BrowseIconPath_btn .raise_ ()
125
158
self .Port_label .raise_ ()
159
+ self .IP_label .raise_ ()
126
160
self .Font_label .raise_ ()
127
161
self .IconPath_label .raise_ ()
128
162
self .Port .raise_ ()
@@ -144,33 +178,52 @@ def retranslateUi(self, OptionsWin):
144
178
self .BrowseIconPath_btn .setText (_translate ("OptionsWin" , "..." ))
145
179
self .BrowseDownloadPath_btn .setText (_translate ("OptionsWin" , "..." ))
146
180
self .Port_label .setText (_translate ("OptionsWin" , "Default Port" ))
181
+ self .IP_label .setText (_translate ("OptionsWin" , "Default IP" ))
147
182
self .Font_label .setText (_translate ("OptionsWin" , "Default Font" ))
148
- self .IconPath_label .setText (_translate ("OptionsWin" , "Default Icon Path" ))
183
+ self .IconPath_label .setText (_translate (
184
+ "OptionsWin" , "Default Icon Path" ))
149
185
self .ShowHB_label .setText (_translate ("OptionsWin" , "Show Homebrew" ))
150
186
self .Port .setPlaceholderText (_translate ("OptionsWin" , self .userPort ))
151
- self .IconPath .setPlaceholderText (_translate ("OptionsWin" , self .userIPath ))
187
+ self .IP .setPlaceholderText (_translate ("OptionsWin" , self .userIp ))
188
+ self .IconPath .setPlaceholderText (
189
+ _translate ("OptionsWin" , self .userIPath ))
152
190
self .Font .setCurrentText (_translate ("OptionsWin" , self .userFont ))
153
- self .DownloadPath_label .setText (_translate ("OptionsWin" , "Default Download Path" ))
154
- self .DownloadPath .setPlaceholderText (_translate ("OptionsWin" , self .userDPath ))
191
+ self .DownloadPath_label .setText (_translate (
192
+ "OptionsWin" , "Default Download Path" ))
193
+ self .DownloadPath .setPlaceholderText (
194
+ _translate ("OptionsWin" , self .userDPath ))
155
195
self .Yes .setText (_translate ("OptionsWin" , "Yes" ))
156
196
self .No .setText (_translate ("OptionsWin" , "No" ))
157
- self .plainTextEdit .setPlainText (_translate ("OptionsWin" , "Yes will allow you to change Homebrew / Applications icons\n (This will take longer to cache)" ))
158
-
197
+ self .plainTextEdit .setPlainText (_translate (
198
+ "OptionsWin" , "Yes will allow you to change Homebrew / Applications icons\n (This will take longer to cache)" ))
199
+
200
+ def ResetDefaults (self ):
201
+ try :
202
+ with open ("Data/Pref/pref.ini" , "w+" ) as file :
203
+ file .write ("Set to default" )
204
+ except :
205
+ pass
206
+
159
207
def SaveOptions (self ):
160
208
Font = self .Font .currentText ()
161
209
IconPath = self .IconPath .text ()
162
210
DownloadPath = self .DownloadPath .text ()
163
211
ShowHB = str (self .Yes .isChecked ())
164
212
Port = self .Port .text ()
165
- if len (Port ) == 0 :
213
+ IP = self .IP .text ()
214
+
215
+ if len (Port ) == 0 :
166
216
Port = self .userPort
167
- if len (IconPath ) == 0 :
217
+ if len (IP ) == 0 :
218
+ IP = self .userIp
219
+ if len (IconPath ) == 0 :
168
220
IconPath = self .userIPath
169
221
if len (DownloadPath ) == 0 :
170
222
DownloadPath = self .userDPath
171
223
172
- with open (self .tempPath + "pref.ini" , "w+" ) as file :
173
- file .write ("F:" + Font + "\n P:" + str (Port ) + "\n IPath:" + IconPath + "\n DPath:" + DownloadPath + "\n HB:" + ShowHB )
224
+ with open ("Data/Pref/pref.ini" , "w+" ) as file :
225
+ file .write ("F:" + Font + "\n P:" + str (Port ) + "\n IP:" + IP + "\n IPath:" +
226
+ IconPath + "\n DPath:" + DownloadPath + "\n HB:" + ShowHB )
174
227
self .OptionsWin .close ()
175
228
176
229
def GetDownloadPath (self ):
@@ -181,7 +234,8 @@ def GetDownloadPath(self):
181
234
dialog = QFileDialog ()
182
235
dialog .setOptions (opt )
183
236
dialog .setDirectory (self .appPath )
184
- path = QtWidgets .QFileDialog .getExistingDirectory (None , "Default Download Directory..." , self .appPath , options = opt )
237
+ path = QtWidgets .QFileDialog .getExistingDirectory (
238
+ None , "Default Download Directory..." , self .appPath , options = opt )
185
239
if path :
186
240
self .DownloadPath .setText (path )
187
241
@@ -193,10 +247,12 @@ def GetIconPath(self):
193
247
dialog = QFileDialog ()
194
248
dialog .setOptions (opt )
195
249
dialog .setDirectory (self .appPath )
196
- path = QtWidgets .QFileDialog .getExistingDirectory (None , "Default Icon Directory..." , self .appPath , options = opt )
250
+ path = QtWidgets .QFileDialog .getExistingDirectory (
251
+ None , "Default Icon Directory..." , self .appPath , options = opt )
197
252
if path :
198
253
self .IconPath .setText (path )
199
254
255
+
200
256
if __name__ == "__main__" :
201
257
import sys
202
258
app = QtWidgets .QApplication (sys .argv )
0 commit comments