-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStatusBarMgr.xcs
143 lines (128 loc) · 4.38 KB
/
StatusBarMgr.xcs
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
//xlang Source, Name:StatusBarMgr.xcs
//Date: Sat Aug 11:30:44 2018
class StatusBarMgr{
QMainWindow mainWindow;
static QStatusBar statusBar;
static StatusBarMgr statusmgr;
static QProgressBar progressBar;
static QLabel status;
static QPushButton background_task;
static Timer task_timer = new Timer();
public bool create(QMainWindow win){
mainWindow = win;
statusBar = mainWindow.getStatusBar();
statusmgr = this;
status = new QLabel();
status.create();
statusBar.addWidget(status, 1);
status.setText("已就绪");
background_task = new QPushButton();
background_task.create();
background_task.hide();
background_task.resize(20,20);
background_task.setFixedWidth(20);
statusBar.addPermanentWidget(background_task, 0);
background_task.setOnClickListener(new onClickListener(){
void onPress(QObject obj) override{
showDLMgr();
}
});
progressBar = new QProgressBar();
progressBar.create();
progressBar.resize(200,16);
progressBar.hide();
statusBar.addPermanentWidget(progressBar, 0);
task_timer.schedule(
new TimerTask(){
int step = 0;
bool showed = false;
void run()override{
bool bmust_update = false;
bool hasTask = DownloadCenter.hasTask();
if (showed != hasTask){
showed = !showed;
bmust_update = true;
mainWindow.runOnUi(new Runnable(){
void run()override{
background_task.setVisible(showed);
}
});
}
if (showed || bmust_update){
mainWindow.runOnUi(new Runnable(){
void run()override{
background_task.setStyleSheetString(String.format( "border:0; background-image:url(res/toolbar/dlstat_%d.png);background-repeat:no-repeat; background-position:center;background-attachment:fixed;", step++));
DownloadManager.updateProgress();
}
});
if (step > 5){
step = 0;
}
}
}
},300,-1);
return false;
}
public static void showStatusMessage(String text){
statusBar.runOnUi(new Runnable(){
void run()override{
status.setText(text);
}
});
}
public static bool showDLMgr()
{
QDialog newDlg = new QDialog();
if (newDlg.load(UIManager.getUIData(__xPackageResource("ui/dlmgr.ui"))) == false) {
return false;
}
DownloadManager dlmgr = new DownloadManager();
dlmgr.attach(newDlg);
return true;
}
public static void showWaitProgress(String text){
statusBar.runOnUi(new Runnable(){
void run()override{
progressBar.setMinimum(0);
progressBar.setMaximum(0);
progressBar.show();
if (text != nilptr){
status.setText(text);
}
}
});
}
public static void showProgress(String text, int value){
statusBar.runOnUi(new Runnable(){
void run()override{
progressBar.setMinimum(0);
progressBar.setMaximum(100);
progressBar.show();
progressBar.setValue(value);
if (text != nilptr){
status.setText(text);
}
}
});
}
public static void updateProgress(String text, int value){
statusBar.runOnUi(new Runnable(){
void run()override{
progressBar.setValue(value);
if (text != nilptr){
status.setText(text);
}
}
});
}
public static void hideProgress(String text){
statusBar.runOnUi(new Runnable(){
void run()override{
progressBar.hide();
if (text != nilptr){
status.setText(text);
}
}
});
}
};