-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaida64.py
More file actions
79 lines (65 loc) · 2.82 KB
/
aida64.py
File metadata and controls
79 lines (65 loc) · 2.82 KB
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
import configparser
def load_aida64_config(ui):
"""
Load settings from the [Aida64] section of config.ini into the GUI.
Args:
ui: The GUI object containing the widgets to be updated.
"""
config = configparser.ConfigParser()
config.read('config.ini')
if 'Aida64' in config:
aida64 = config['Aida64']
# Load mode: split the comma-separated string and check corresponding checkboxes
mode = aida64.get('mode', '')
modes = [m.strip() for m in mode.split(',') if m.strip()]
ui.aida64_mode_cache_checkBox.setChecked('Cache' in modes)
ui.aida64_mode_cpu_checkBox.setChecked('CPU' in modes)
ui.aida64_mode_fpu_checkBox.setChecked('FPU' in modes)
ui.aida64_mode_ram_checkBox.setChecked('RAM' in modes)
# Load useAvx: set checkbox based on '0' or '1'
use_avx = aida64.get('useAvx', '0')
ui.aida64_useAvx_checkBox.setChecked(use_avx == '1')
# Load maxMemory: set spinbox value, default to 80 if invalid
max_memory = aida64.get('maxMemory', '80')
try:
ui.aida64_maxMemory_spinBox.setValue(int(max_memory))
except ValueError:
ui.aida64_maxMemory_spinBox.setValue(80)
else:
# If [Aida64] section is missing, set default GUI values
ui.aida64_mode_cache_checkBox.setChecked(False)
ui.aida64_mode_cpu_checkBox.setChecked(False)
ui.aida64_mode_fpu_checkBox.setChecked(False)
ui.aida64_mode_ram_checkBox.setChecked(False)
ui.aida64_useAvx_checkBox.setChecked(False)
ui.aida64_maxMemory_spinBox.setValue(80)
def apply_aida64_config(ui):
"""
Apply current GUI settings to the [Aida64] section of config.ini.
Args:
ui: The GUI object containing the widgets with current values.
"""
config = configparser.ConfigParser()
config.read('config.ini')
# Ensure [Aida64] section exists
if 'Aida64' not in config:
config['Aida64'] = {}
aida64 = config['Aida64']
# Apply mode: collect checked modes and join with ', '
modes = []
if ui.aida64_mode_cache_checkBox.isChecked():
modes.append('Cache')
if ui.aida64_mode_cpu_checkBox.isChecked():
modes.append('CPU')
if ui.aida64_mode_fpu_checkBox.isChecked():
modes.append('FPU')
if ui.aida64_mode_ram_checkBox.isChecked():
modes.append('RAM')
aida64['mode'] = ', '.join(modes)
# Apply useAvx: '1' if checked, '0' otherwise
aida64['useAvx'] = '1' if ui.aida64_useAvx_checkBox.isChecked() else '0'
# Apply maxMemory: convert spinbox value to string
aida64['maxMemory'] = str(ui.aida64_maxMemory_spinBox.value())
# Write the updated config to file
with open('config.ini', 'w') as configfile:
config.write(configfile)