forked from 1111joe1111/ida_ea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ea_skin.py
127 lines (86 loc) · 3.35 KB
/
ea_skin.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
from ea_UI import Reskin_UI, Name_UI
from idaapi import *
from ea_utils import QtGui, save_config, config, root_dir
from threading import Thread
def color_selected(i, color):
back = "{:04x}".format(color.rgb())[2:]
buttons[i][0].setStyleSheet("background: " + "#" + back)
buttons[i][2] = back
def select_color(i):
global color
color = QtGui.QColorDialog()
color.setCustomColor(0, 0x212121)
color.setCurrentColor(QtGui.QColor.fromRgb(int(buttons[i][0].styleSheet().split("#")[1], 16)))
color.colorSelected.connect(lambda color: color_selected(i, color))
color.open()
def save_preset():
global name_ui
name_ui = QtGui.QFrame()
form_2 = Name_UI()
form_2.setupUi(name_ui)
name_ui.show()
form_2.pushButton.clicked.connect(lambda: save_preset_2(form_2, name_ui))
def save_preset_2(form_2, name_ui):
name = form_2.lineEdit.text()
form.comboBox.addItem(name)
config["skins"].append([name] + [item[2] for item in buttons])
save_config()
form.comboBox.setCurrentIndex(len(config["skins"] )- 1)
name_ui.close()
def changed(i):
for i, v in enumerate(config["skins"][i][1:]):
buttons[i][0].setStyleSheet("background: " + "#" + v)
buttons[i][2] = v
def apply_skin():
with open(root_dir + "style_template.css", "r") as r:
style = r.read()
for i, c in enumerate(item[2] for item in buttons):
style = style.replace("{%s}" % (i), "#" + c)
config["current_skin"] = [item[2] for item in buttons]
save_config()
QtGui.qApp.setStyleSheet(QtGui.qApp.styleSheet().split("/*IDA EA START*/")[0] + style)
def apply_initial_skin():
if config["current_skin"]:
with open(root_dir + "style_template.css", "r") as r:
style = r.read()
for i, c in enumerate(item for item in config["current_skin"]):
style = style.replace("{%s}" % (i), "#" + c)
QtGui.qApp.setStyleSheet(QtGui.qApp.styleSheet().split("/*IDA EA START*/")[0] + style)
def toggle_apply_onstartup(state):
config["apply_skin_on_startup"] = True if state else False
save_config()
def ea_reskin():
global a
global form
global buttons
a = QtGui.QFrame()
form = Reskin_UI()
form.setupUi(a)
a.show()
for i in config["skins"]:
form.comboBox.addItem(i[0])
form.comboBox.activated.connect(changed)
buttons = [
[form.pushButton, form.pushButton_2, None],
[form.pushButton_23, form.pushButton_24, None],
[form.pushButton_25, form.pushButton_26, None],
[form.pushButton_9, form.pushButton_10, None],
[form.pushButton_13, form.pushButton_14, None],
[form.pushButton_27, form.pushButton_28, None],
[form.pushButton_21, form.pushButton_22, None],
[form.pushButton_15, form.pushButton_16, None],
[form.pushButton_11, form.pushButton_12, None]
]
for x in range(len(buttons)):
buttons[x][0].clicked.connect(lambda x=x: select_color(x))
buttons[x][1].clicked.connect(lambda x=x: select_color(x))
form.pushButton_18.clicked.connect(save_preset)
form.pushButton_17.clicked.connect(lambda: process_ui_action("SetColors"))
form.pushButton_20.clicked.connect(apply_skin)
form.checkBox.stateChanged.connect(lambda x: toggle_apply_onstartup(x))
changed(0)
a = None
form = None
buttons = None
name_ui = None
color = None