-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathXIndex.xcsm
140 lines (120 loc) · 4.91 KB
/
XIndex.xcsm
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
//xlang Source, Name:XIndex.xcsm
//Date: Wed Sep 21:21:54 2018
class XIndexWindow : QMdiSubWindow
{
public QWidget indexPage;
QLabel [] labels = new QLabel[10];
QLabel lblnew, lblopen, verslabel;
QLabel lblhelp, lblrule;
Object state;
Recently.RecentlyObject [] objects = new Recently.RecentlyObject[10];
public bool create( @NotNilptr QWidget parent)
{
if (super.create(parent)) {
indexPage = new QWidget();
if (indexPage.load(UIManager.getUIData(__xPackageResource("ui/index.ui"))) == false) {
return false;
}
if (_system_.getPlatformId() == _system_.PLATFORM_MACOSX) {
//qt在macos下有widget背景和别的平台不一致的情况,所以这里手动设置一下风格
String wqss = "#Form{background-color:#3e3e42;}";
if (Setting.isDarkStyle() == false) {
wqss = "#Form{background-color:#f0f0f0;}";
}
indexPage.setStyleSheetString(wqss);
}
setWidget(indexPage);
indexPage.show();
setMaximized(true);
verslabel = (QLabel)indexPage.findByName("label");
lblrule = (QLabel)indexPage.findByName("label_22");
lblhelp = (QLabel)indexPage.findByName("label_17");
lblnew = (QLabel)indexPage.findByName("lblnew");
lblopen = (QLabel)indexPage.findByName("lblopen");
verslabel.setText("XStudio " + Utils.getAppMajorVersion());
for (int i =0; i < 10; i ++) {
labels[i] = (QLabel)indexPage.findByName("rl" + i);
labels[i].setOnMouseEventListener(recentlistener);
}
loadRecent();
state = XWorkspace.hideDocks();
lblhelp.setOnMouseEventListener(new onMouseEventListener() {
void onMouseButtonRelease(QObject obj, int Button, int x, int y, int flags, int source) {
if (Button == 1) {
String url = _system_.getAppPath().findVolumePath().appendPath("./document/html/index.html");
QCore.openLocal(String.formatPath(url, false));
}
}
});
lblrule.setOnMouseEventListener(new onMouseEventListener() {
void onMouseButtonRelease(QObject obj, int Button, int x, int y, int flags, int source) {
if (Button == 1) {
String url = _system_.getAppPath().findVolumePath().appendPath("./document/xrule.html");
QCore.openLocal(String.formatPath(url, false));
}
}
});
lblnew.setOnMouseEventListener(new onMouseEventListener() {
void onMouseButtonRelease(QObject obj, int Button, int x, int y, int flags, int source) {
if (Button == 1) {
XWorkspace.workspace.createProject();
}
}
});
lblopen.setOnMouseEventListener(new onMouseEventListener() {
void onMouseButtonRelease(QObject obj, int Button, int x, int y, int flags, int source) {
if (Button == 1) {
XWorkspace.workspace.doOpen();
}
}
});
XStudioApp._theApp.reconfig();
return true;
}
return false;
}
onMouseEventListener recentlistener = new onMouseEventListener()
{
void onMouseButtonRelease(QObject obj, int Button, int x, int y, int flags, int source) {
if (Button == 1) {
for (int i = 0; i < 10; i ++) {
if (labels[i] == obj) {
XWorkspace.workspace.loadProject(objects[i].path);
break;
}
}
}
}
};
public bool onClose()override
{
XWorkspace.workspace.indexPage = nilptr;
restore();
XStudioApp._theApp.reconfig();
return true;
}
public void restore()
{
if (state != nilptr) {
XWorkspace.showDocks(state);
}
}
public void loadRecent()
{
int c = Recently.count();
int rl = 0;
if (c > 10) {
c = 10;
}
for (int i = c - 1; i >= 0; i --) {
objects[rl] = Recently.getItem(i);
String proj_file_path = String.formatPath(objects[rl].path,false);
labels[rl].setText("<a style=\"color:#1684fb\">" + objects[rl].name + "</a> <small><em style=\"color:#fb8416\">" + objects[rl].date + "</small></em> <br /><a style=\" font-size:11px;text-overflow: ellipsis;overflow: hidden;\">" + proj_file_path + "</a>");
labels[rl].setToolTips(proj_file_path);
rl++;
}
while (rl < 10) {
labels[rl++].hide();
}
}
};