forked from 7plus/7plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSettings.ahk
328 lines (292 loc) · 13.4 KB
/
CSettings.ahk
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*
Class: CSettings
A generic class for managing program settings.
*/
Class CSettings
{
;Properties which should be saved are stored in the subclass object.
;This allows to add dynamic properties to the instances of the classes during runtime which aren't saved.
;Notes:
;- All class names must start with C, but their instance variables must not!
;- The ini file will only use the name of the current (sub)category, not the full hierarchy, so the names of the (sub)categories should be unique.
Class CConnection
{
static UseProxy := false
static ProxyAddress := ""
static ProxyPort := ""
static ProxyType := 1
static ProxyAuthType := 1
static ProxyUser := ""
static ProxyPassword := ""
static ProxyAuth := ""
}
Connection := new this.CConnection()
Class CExplorer
{
Class CFastFolders
{
static ShowInPlacesBar := 0
static CleanFolderBand := 0
static ShowInFolderBand := 0
static Folder0 := "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
static FolderTitle0 := "Computer"
static Folder1 := "C:\"
static FolderTitle1 := "C:\"
static Folder2 := ""
static FolderTitle2 := ""
static Folder3 := ""
static FolderTitle3 := ""
static Folder4 := ""
static FolderTitle4 := ""
static Folder5 := ""
static FolderTitle5 := ""
static Folder6 := ""
static FolderTitle6 := ""
static Folder7 := ""
static FolderTitle7 := ""
static Folder8 := ""
static FolderTitle8 := ""
static Folder9 := ""
static FolderTitle9 := ""
}
FastFolders := new this.CFastFolders()
Class CTabs
{
static UseTabs := 1
static NewTabPosition := 1
static TabStartupPath := "C:\"
static ActivateTab := 1
static TabWindowClose := 1
static OnTabClose := 1
}
Tabs := new this.CTabs()
static AutoSelectFirstFile := 1
static ImproveEnter := 1
static AdvancedStatusBarInfo := 1
static MouseGestures := 1
static AutoCheckApplyToAllFiles := 1
static ScrollTreeUnderMouse := 1
static RememberPath := 1
static AlignNewExplorer := 1
static EnhancedRenaming := 1
static PasteImageAsFileName := "clip.png"
static PasteTextAsFileName := "clip.txt"
static PreviousPath := "C:\"
static CurrentPath := "C:\"
}
Explorer := new this.CExplorer()
Class CWindows
{
Class CSlideWindows
{
static HideSlideWindows := 1
static BorderActivationRequiresMouseUp := 1
static LimitToOnePerSide := 1
static BorderSize := 30
static ModifierKey := "Control"
}
SlideWindows := new this.CSlideWindows()
static ShowResizeTooltip := 0
static AutoCloseWindowsUpdate := 0
}
Windows := new this.CWindows()
Class CMisc
{
static ImageExtensions := "jpg,png,bmp,gif,tga,tif,ico,jpeg"
static DefaultImageExtension := "png"
static ImageQuality := 95
static GamepadRemoteControl := 0
static FixEditControlWordDelete := 1
static TabAutocompletion := 1
static FullscreenExclude := "VLC DirectX,OpWindow,CabinetWClass"
static FullscreenInclude := "Project64"
static RunAsAdmin := "Always/Ask"
static HideTrayIcon := 0
static IgnoredPrograms := "KeePass.exe"
static DefaultImageEditor := "%ProgramFiles%\Paint.NET\PaintDotNet.exe"
static DefaultTextEditor := "%ProgramFiles%\Notepad++\notepad++.exe"
}
Misc := new this.CMisc()
Class CGeneral
{
static DebugEnabled := false
static ProfilingEnabled := false
static AutoUpdate := true
static UseBeta := false
static FirstRun := true
static ShowAdvancedEvents := false
static ShowExecutingEvents := false
;static Language := "En"
static ShowTips := true
static ShownTips := "00000000000000000000000000000000000000000000000000000000000000" ;Array of values that indicate if a tip has been shown yet
static DontRegisterSelectionChanged := false
}
General := new this.CGeneral()
Class CIFTTT
{
static From := "The email address you use in the email channel of IFTTT"
static Server := "SMTP Server address, e.g. smtp.gmail.com"
static Port := 465
static TLS := true
static Username := "Email login name, e.g. [email protected]"
static Password := ""
static Timeout := 10
}
IFTTT := new this.CIFTTT()
;ModifiedKeyNames is a class containing mappings of new key names to old key names. It's used to ease transform from older
;nondescriptive key names to better fitting ones.
Class ModifiedKeyNames
{
static PasteImageAsFileName := "Image"
static PasteTextAsFileName := "Text"
static ShowInPlacesBar := "HKPlacesBar"
static CleanFolderBand := "HKCleanFolderBand"
static ShowInFolderBand := "HKFolderBand"
static AutoSelectFirstFile := "HKSelectFirstFile"
static ImproveEnter := "HKImproveEnter"
static AdvancedStatusBarInfo := "HKShowSpaceAndSize"
static MouseGestures := "HKMouseGestures"
static AutoCheckApplyToAllFiles := "HKAutoCheck"
static ScrollTreeUnderMouse := "ScrollUnderMouse"
static RememberPath := "RecallExplorerPath"
static DefaultImageExtension := "ImageExtension"
static FixEditControlWordDelete := "WordDelete"
static GamepadRemoteControl := "JoyControl"
static HideSlideWindows := "SlideWinHide"
static BorderActivationRequiresMouseUp := "SlideWindowRequireMouseUp"
static LimitToOnePerSide := "SlideWindowSideLimit"
static BorderSize := "SlideWindowsBorder"
static ModifierKey := "SlideWindowsModifier"
static AlignNewExplorer := "AlignExplorer"
static ShowAdvancedEvents := "ShowComplexEvents"
}
SetupConfigurationPath()
{
;Try to use config file from script dir in portable mode or when it wasn't neccessary to copy it to appdata yet
if(ApplicationState.IsPortable)
this.ConfigPath := A_ScriptDir
Else
{
this.ConfigPath := A_AppData "\7plus"
if(!FileExist(this.ConfigPath))
FileCreateDir, %ConfigPath%
}
this.IniPath := this.ConfigPath "\Settings.ini"
this.DllPath := A_ScriptDir "\lib" (A_PtrSize = 8 ? "\x64" : "")
}
Load(Category = "")
{
global FastFolders
if(!Category)
Category := this
;Subcategories are stored in instance objects while keys are stored in the class objects.
;Look for subcategories first
for key, value in Category
{
if key in base,ModifiedKeyNames,__Class,__Init
continue
;Subcategories are stored in the instance. Due to some quirk, there is also an empty key with their name in the base object,
;so we can nearly iterate over them as if they were located in the base.
; if(Category.HasKey(key))
; value := Category[key]
;Skip classes
if(SubStr(key, 1, 1) = "C" && IsObject(value) && value.HasKey("__Class"))
continue
if(IsObject(value))
this.Load(value)
}
;Now look for properties defined in the base object
for key, value in Category.base
{
if key in base,ModifiedKeyNames,__Class,__Init
continue
;Subcategories are stored in the instance. Due to some quirk, there is also an empty key with their name in the base object,
;so we can nearly iterate over them as if they were located in the base.
; if(Category.HasKey(key))
; value := Category[key]
;Skip classes
if(SubStr(key, 1, 1) = "C" && IsObject(value) && value.HasKey("__Class"))
continue
if(!IsObject(value) && !IsFunc(this[key]))
{
Class := SubStr(SubStr(Category.__Class, InStr(Category.__Class, ".", false, 0) + 1), 2)
;Read value from Ini file
AcquiredSetting := IniRead(this.IniPath, Class, key)
;Value not found under this key -> Use old key names
if(AcquiredSetting = "ERROR" && this.ModifiedKeyNames.HasKey(key))
AcquiredSetting := IniRead(this.IniPath, Class, this.ModifiedKeyNames[key])
;Value doesn't exist, use default
if(AcquiredSetting = "ERROR")
AcquiredSetting := Category.base[key]
;Set it to the instance object of Category, default values are still stored in base
Category[key] := AcquiredSetting
}
}
;Main recursion, do some further specific processing
if(Category = this)
{
FastFolders := new CFastFolders()
Loop 10
FastFolders[A_Index - 1] := Object("Path", this.Explorer.FastFolders["Folder" A_Index - 1], "Name", this.Explorer.FastFolders["FolderTitle" A_Index - 1])
;the path where the image/text files from clipboard are saved for copying
this.Explorer.PasteImageAsFileTempPath := A_Temp "\" this.Explorer.PasteImageAsFileName ; temp_img
this.Explorer.PasteTextAsFileTempPath := A_Temp "\" this.Explorer.PasteTextAsFileName ; temp_txt
;5 is really ugly quality, lower values don't really make sense
this.Misc.ImageQuality := Clamp(this.Misc.ImageQuality, 5, 100)
}
}
Save(Category = "")
{
global FastFolders
if(Category = "")
{
Category := this
;Make sure path exists to be sure
if(!FileExist(this.ConfigPath))
FileCreateDir % this.ConfigPath
;Purge old settings from last ini file
FileDelete, % this.IniPath
;Update the FastFolder values in this class
Loop 10
{
this.Explorer.FastFolders["Folder" A_Index - 1] := FastFolders[A_Index - 1].Path
this.Explorer.FastFolders["FolderTitle" A_Index - 1] := FastFolders[A_Index - 1].Name
}
this.General.FirstRun := 0
}
;Look for subcategories first
for key, value in Category
{
if key in base,__Class,__Init,ModifiedKeyNames
continue
;Subcategories and changed values are stored in the instance. Due to some quirk, there is also an empty key with their name in the base object,
;so we can nearly iterate over them as if they were located in the base.
; if(Category.HasKey(key))
; value := Category[key]
;Skip classes
if(IsObject(value) && SubStr(key, 1, 1) = "C" && value.HasKey("__Class"))
continue
;Value is an instance of a class
if(IsObject(value))
this.Save(value)
}
;Now look for keys defined in base object
for key, value in Category.base
{
if key in base,__Class,__Init,ModifiedKeyNames
continue
;If the key was changed it can be located in the instance object so it's preferrable to use that value.
if(Category.HasKey(key))
value := Category[key]
;Skip classes
if(IsObject(value) && SubStr(key, 1, 1) = "C" && value.HasKey("__Class"))
continue
;Value is a key in this category
if(!IsObject(value) && !IsFunc(this[key]))
{
Class := SubStr(SubStr(Category.__Class, InStr(Category.__Class, ".", false, 0) + 1), 2)
IniWrite(value, this.IniPath, Class, key)
}
}
}
}