~ubuntu-branches/ubuntu/vivid/youker-assistant/vivid

« back to all changes in this revision

Viewing changes to qml/func/common/Button.qml

  • Committer: Package Import Robot
  • Author(s): Jack Yu
  • Date: 2013-09-02 23:17:45 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130902231745-psyl14qxslg1g3dp
Tags: 0.1.6-0ubuntu1
* Modify SystemDispatcher and SessionDispatcher Classes.
* Add watch file into debian folder.
* Resolve status of onekey button(LP #1216236 ).
* Add monitorball code into systemdbus daemon.
* Optimize the status button.
* Add fcitx configuration function.
* Fix bugs due to bad references to apt lib.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 */
16
16
import QtQuick 1.1
 
17
import SystemType 0.1
17
18
Item {
18
19
    id: btn
19
20
    signal clicked
 
21
    signal exited
 
22
    signal entered
20
23
//    property string text
21
 
//    property string text : ""
22
 
    property string hoverimage: "scan-start.png"
 
24
    property string text : ""
 
25
    property string hoverimage: "green1.png"
 
26
 
 
27
 
 
28
    //-----------------------------------------------
 
29
    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
 
30
    property string setbtn_flag: ""
 
31
    property string get_msg: ""
 
32
    property bool check_flag: true
 
33
 
 
34
    signal send_dynamic_picture(string str);
 
35
    //信号绑定,绑定qt的信号finishCleanWork,该信号emit时触发onFinishCleanWork,按钮恢复使能
 
36
    Connections{
 
37
         target: systemdispatcher
 
38
             onFinishCleanWorkMain: {
 
39
                 if(setbtn_flag =="onekey")
 
40
                 {
 
41
                    if (msg == "") {
 
42
                        btn.enabled=true;
 
43
                        if (setbtn_flag == "onekey") {
 
44
                            btnImg.source = "../../img/icons/green3.png"
 
45
                            displaytext.text = "一键清理";
 
46
                        }
 
47
                     }
 
48
                    else if (msg == "u") {
 
49
                         btn.enabled=true;
 
50
                    }
 
51
                    else if (msg == "c") {
 
52
                         btn.enabled=true;
 
53
                    }
 
54
                    else if (msg == "h") {
 
55
                        btn.enabled=true;
 
56
                    }
 
57
                    else if (msg == "k") {
 
58
                        btn.enabled=true;
 
59
                    }
 
60
                    else if (msg == "o") {
 
61
                        btn.enabled=true;
 
62
                        displaytext.text = "再次清理"
 
63
                    }
 
64
                 }
 
65
          }
 
66
    }
 
67
    Connections
 
68
    {
 
69
        target: systemdispatcher
 
70
        onFinishCleanWorkSecond: {
 
71
            if(setbtn_flag=="smallonekey")
 
72
            {
 
73
                if (msg == "") {
 
74
                     btn.enabled=true;
 
75
                    btnImg.source = "../../img/icons/green1.png"
 
76
                    displaytext.text = "一键清理";
 
77
                 }
 
78
                 else if (msg == "u") {
 
79
                     btn.enabled=true;
 
80
                 }
 
81
                 else if (msg == "c") {
 
82
                     btn.enabled=true;
 
83
                 }
 
84
                else if (msg == "h") {
 
85
                    btn.enabled=true;
 
86
                }
 
87
                else if (msg == "k") {
 
88
                    btn.enabled=true;
 
89
                }
 
90
                else if (msg == "o") {
 
91
                    btn.enabled=true;
 
92
                    displaytext.text = "再次清理"
 
93
                }
 
94
            }
 
95
        }
 
96
    }
 
97
    //-----------------------------------------------
 
98
 
23
99
    BorderImage {
24
100
        id: buttonImage
25
101
        source: "../../img/icons/" + btn.hoverimage
50
126
//        onExited: btnImg.source = ""
51
127
 
52
128
        onEntered: {
53
 
            if (hoverimage == "return.png")
54
 
                btnImg.source = "../../img/icons/return-hover.png"
55
 
            else if (hoverimage == "sort.png")
56
 
                btnImg.source = "../../img/icons/sort-hover.png"
57
 
            else if (hoverimage == "selectpic.png")
58
 
                btnImg.source = "../../img/icons/selectpic-hover.png"
59
 
            else if (hoverimage == "use.png")
60
 
                btnImg.source = "../../img/icons/use-hover.png"
 
129
            btn.entered();
 
130
            if (hoverimage == "green1.png") {
 
131
                btnImg.source = "../../img/icons/green1-hover.png"
 
132
//                if(setbtn_flag=="smallonekey")
 
133
//                    displaytext.text = "再次清理";
 
134
            }
 
135
            else if (hoverimage == "blue1.png")
 
136
                btnImg.source = "../../img/icons/blue1-hover.png"
 
137
            else if (hoverimage == "green2.png")
 
138
                btnImg.source = "../../img/icons/green2-hover.png"
 
139
            else if (hoverimage == "gray1.png")
 
140
                btnImg.source = "../../img/icons/gray1-hover.png"
 
141
            else if (hoverimage == "blue2.png")
 
142
                btnImg.source = "../../img/icons/blue2-hover.png"
 
143
            else if (hoverimage == "blue3.png")
 
144
                btnImg.source = "../../img/icons/blue3-hover.png"
 
145
            else if (hoverimage == "blue4.png")
 
146
                btnImg.source = "../../img/icons/blue4-hover.png"
 
147
            else if (hoverimage == "green3.png") {
 
148
                btnImg.source = "../../img/icons/green3-hover.png"
 
149
//                if(setbtn_flag =="onekey")
 
150
//                    displaytext.text = "再次清理";
 
151
            }
61
152
            else
62
153
                btnImg.source = "../../img/toolWidget/menu_hover.png"
 
154
//            if (hoverimage == "return.png")
 
155
//                btnImg.source = "../../img/icons/return-hover.png"
 
156
//            else if (hoverimage == "sort.png")
 
157
//                btnImg.source = "../../img/icons/sort-hover.png"
 
158
//            else if (hoverimage == "selectpic.png")
 
159
//                btnImg.source = "../../img/icons/selectpic-hover.png"
 
160
//            else if (hoverimage == "use.png")
 
161
//                btnImg.source = "../../img/icons/use-hover.png"
 
162
//            else
 
163
//                btnImg.source = "../../img/toolWidget/menu_hover.png"
63
164
        }
64
165
        onPressed: {
65
 
            if (hoverimage == "return.png")
66
 
                btnImg.source = "../../img/icons/return-hover.png"
67
 
            else if (hoverimage == "sort.png")
68
 
                btnImg.source = "../../img/icons/sort-hover.png"
69
 
            else if (hoverimage == "selectpic.png")
70
 
                btnImg.source = "../../img/icons/selectpic-hover.png"
71
 
            else if (hoverimage == "use.png")
72
 
                btnImg.source = "../../img/icons/use-hover.png"
 
166
            if (hoverimage == "green1.png")
 
167
                btnImg.source = "../../img/icons/green1-hover.png"
 
168
            else if (hoverimage == "blue1.png")
 
169
                btnImg.source = "../../img/icons/blue1-hover.png"
 
170
            else if (hoverimage == "green2.png")
 
171
                btnImg.source = "../../img/icons/green2-hover.png"
 
172
            else if (hoverimage == "gray1.png")
 
173
                btnImg.source = "../../img/icons/gray1-hover.png"
 
174
            else if (hoverimage == "blue2.png")
 
175
                btnImg.source = "../../img/icons/blue2-hover.png"
 
176
            else if (hoverimage == "blue3.png")
 
177
                btnImg.source = "../../img/icons/blue3-hover.png"
 
178
            else if (hoverimage == "blue4.png")
 
179
                btnImg.source = "../../img/icons/blue4-hover.png"
 
180
            else if (hoverimage == "green3.png")
 
181
                btnImg.source = "../../img/icons/green3-hover.png"
73
182
            else
74
183
                btnImg.source = "../../img/toolWidget/menu_press.png"
 
184
//            if (hoverimage == "return.png")
 
185
//                btnImg.source = "../../img/icons/return-hover.png"
 
186
//            else if (hoverimage == "sort.png")
 
187
//                btnImg.source = "../../img/icons/sort-hover.png"
 
188
//            else if (hoverimage == "selectpic.png")
 
189
//                btnImg.source = "../../img/icons/selectpic-hover.png"
 
190
//            else if (hoverimage == "use.png")
 
191
//                btnImg.source = "../../img/icons/use-hover.png"
 
192
//            else
 
193
//                btnImg.source = "../../img/toolWidget/menu_press.png"
75
194
 
76
195
        }
77
196
        //要判断松开是鼠标位置
78
197
        onReleased: {
79
 
            if (hoverimage == "return.png")
80
 
                btnImg.source = "../../img/icons/return.png"
81
 
            else if (hoverimage == "sort.png")
82
 
                btnImg.source = "../../img/icons/sort.png"
83
 
            else if (hoverimage == "selectpic.png")
84
 
                btnImg.source = "../../img/icons/selectpic.png"
85
 
            else if (hoverimage == "use.png")
86
 
                btnImg.source = "../../img/icons/use.png"
 
198
            if (hoverimage == "green1.png")
 
199
                btnImg.source = "../../img/icons/green1.png"
 
200
            else if (hoverimage == "blue1.png")
 
201
                btnImg.source = "../../img/icons/blue1.png"
 
202
            else if (hoverimage == "green2.png")
 
203
                btnImg.source = "../../img/icons/green2.png"
 
204
            else if (hoverimage == "gray1.png")
 
205
                btnImg.source = "../../img/icons/gray1.png"
 
206
            else if (hoverimage == "blue2.png")
 
207
                btnImg.source = "../../img/icons/blue2.png"
 
208
            else if (hoverimage == "blue3.png")
 
209
                btnImg.source = "../../img/icons/blue3.png"
 
210
            else if (hoverimage == "blue4.png")
 
211
                btnImg.source = "../../img/icons/blue4.png"
 
212
            else if (hoverimage == "green3.png")
 
213
                btnImg.source = "../../img/icons/green3.png"
87
214
            else
88
215
                btnImg.source = "../../img/toolWidget/menu_hover.png"
89
 
        }
90
 
 
91
 
        onExited: btnImg.source = ""
92
 
 
93
 
 
94
 
 
95
 
        onClicked: { btn.clicked(); }
 
216
//            if (hoverimage == "return.png")
 
217
//                btnImg.source = "../../img/icons/return.png"
 
218
//            else if (hoverimage == "sort.png")
 
219
//                btnImg.source = "../../img/icons/sort.png"
 
220
//            else if (hoverimage == "selectpic.png")
 
221
//                btnImg.source = "../../img/icons/selectpic.png"
 
222
//            else if (hoverimage == "use.png")
 
223
//                btnImg.source = "../../img/icons/use.png"
 
224
//            else
 
225
//                btnImg.source = "../../img/toolWidget/menu_hover.png"
 
226
        }
 
227
 
 
228
        onExited: {
 
229
            btn.exited();
 
230
            btnImg.source = ""
 
231
        }
 
232
 
 
233
        onClicked: {
 
234
            btn.clicked();
 
235
 
 
236
 
 
237
 
 
238
            //----------------
 
239
            if(check_flag)
 
240
            {
 
241
                if (setbtn_flag == "onekey") {
 
242
                    send_dynamic_picture("onekey");
 
243
                    systemdispatcher.set_user_homedir_qt();
 
244
                    systemdispatcher.clean_by_main_one_key_qt(systemdispatcher.get_onekey_args());
 
245
//                    displaytext.text = "清理完毕"
 
246
//                        btnImg.source = "../img/icons/onekeyover.png"  //首页点击后更换图片的位置7-30
 
247
//                    btn.text="清理完毕";
 
248
                    btn.enabled=false;
 
249
                }
 
250
                else if (setbtn_flag == "smallonekey") {
 
251
                    systemdispatcher.set_user_homedir_qt();
 
252
                    systemdispatcher.clean_by_second_one_key_qt(systemdispatcher.get_onekey_args2());
 
253
//                        btnImg.source = "../img/icons/clear-over.png"  //首页点击后更换图片的位置7-30
 
254
//                    displaytext.text = "清理完毕"
 
255
//                    btn.text="清理完毕";
 
256
                    btn.enabled=false;
 
257
                }
 
258
            }
 
259
            else
 
260
                sessiondispatcher.send_warningdialog_msg("友情提示:","对不起,您没有选中清理项,请确认!");
 
261
        }
96
262
    }
97
 
//    Text {
98
 
//        color: "white"
99
 
////        visible: (btn.text == "") ? false : true
100
 
//        anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15
101
 
//        text: btn.text; style: Text.Raised; styleColor: "black"
 
263
//    Image {
 
264
//        id: testbtn
 
265
//        source: "../../img/icons/arrowhead.png"
 
266
//        visible: (setbtn_flag == "onekey") ? true : false
 
267
//        anchors.verticalCenter: parent.verticalCenter
 
268
//        anchors.left: parent.left
 
269
//        anchors.leftMargin: 10
102
270
//    }
 
271
    Text {
 
272
        id: displaytext
 
273
        color: "white"
 
274
//        visible: (btn.text == "") ? false : true
 
275
        anchors.centerIn: buttonImage
 
276
//        font.bold: true
 
277
        font.family: "Helvetica"
 
278
        font.pixelSize: 16
 
279
        text: btn.text
 
280
        style: Text.Sunken
 
281
//        style: Text.Raised
 
282
//        styleColor: "black"
 
283
        styleColor: "#AAAAAA"
 
284
    }
103
285
    states: [
104
286
        State {
105
287
            name: "Pressed"
108
290
        }
109
291
    ]
110
292
}
 
293
 
 
294
 
 
295
 
 
296
 
 
297
 
 
298
 
 
299
//Item {
 
300
//    id: btn
 
301
////    signal clicked
 
302
////    property string text
 
303
////    property string text : ""
 
304
////    property string hoverimage: "scan-start.png"
 
305
 
 
306
////  按钮的颜色和字体处理
 
307
//    property string color1:"#87bc1d"
 
308
//    property string color2:"#6b9e00"
 
309
//    property string bordercolor:"#6fa200"
 
310
//    property string text:""
 
311
//    property int textsize:10
 
312
//    property bool bold: false
 
313
 
 
314
//    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
 
315
////    color: "transparent"
 
316
//    property SystemDispatcher dis: systemdispatcher
 
317
////    property string iconName: "onekeyBtn.png"
 
318
//    property string setbtn_flag: ""
 
319
 
 
320
//    property string get_msg: ""
 
321
//    property bool check_flag: true
 
322
 
 
323
//    signal clicked();   //如果没有选中任何清理项,提示警告框!first page
 
324
 
 
325
//    signal send_dynamic_picture(string str);
 
326
//    //信号绑定,绑定qt的信号finishCleanWork,该信号emit时触发onFinishCleanWork,按钮恢复使能
 
327
//    Connections{
 
328
//         target: systemdispatcher
 
329
//             onFinishCleanWorkMain: {
 
330
//                 if(setbtn_flag =="onekey"||setbtn_flag=="smallonekey")
 
331
//                 {
 
332
//                    if (msg == "") {
 
333
//                        btn.enabled=true;
 
334
//                        if (setbtn_flag == "onekey")
 
335
//                            btnImg.source = "../img/icons/onekeyBtn.png"
 
336
//                     }
 
337
//                    else if (msg == "u") {
 
338
//                         btn.enabled=true;
 
339
//                    }
 
340
//                    else if (msg == "c") {
 
341
//                         btn.enabled=true;
 
342
//                    }
 
343
//                    else if (msg == "h") {
 
344
//                        btn.enabled=true;
 
345
//                    }
 
346
//                    else if (msg == "k") {
 
347
//                        btn.enabled=true;
 
348
//                    }
 
349
//                 }
 
350
//          }
 
351
//    }
 
352
//    Connections
 
353
//    {
 
354
//        target: systemdispatcher
 
355
//        onFinishCleanWorkSecond: {
 
356
//            if(setbtn_flag =="onekey"||setbtn_flag=="smallonekey")
 
357
//            {
 
358
//                if (msg == "") {
 
359
//                     btn.enabled=true;
 
360
//                    btnImg.source = "../img/icons/onekey.png"
 
361
//                 }
 
362
//                 else if (msg == "u") {
 
363
//                     btn.enabled=true;
 
364
//                 }
 
365
//                 else if (msg == "c") {
 
366
//                     btn.enabled=true;
 
367
//                 }
 
368
//                else if (msg == "h") {
 
369
//                    btn.enabled=true;
 
370
//                }
 
371
//                else if (msg == "k") {
 
372
//                    btn.enabled=true;
 
373
//                }
 
374
//            }
 
375
//        }
 
376
//    }
 
377
 
 
378
////    BorderImage {
 
379
////        id: buttonImage
 
380
////        source: "../../img/icons/" + btn.hoverimage
 
381
////        width: btn.width; height: btn.height
 
382
////    }
 
383
////    BorderImage {
 
384
////        id: pressed
 
385
////        opacity: 0
 
386
////        source: "../../img/icons/unselect.png"
 
387
////        width: btn.width; height: btn.height
 
388
////    }
 
389
 
 
390
//    Rectangle{
 
391
//        id:btnrec
 
392
//        anchors.centerIn: parent
 
393
//        width:btn.width
 
394
//        height:btn.height
 
395
//        border.color: bordercolor
 
396
//        radius:3
 
397
//        smooth:true
 
398
//        gradient: Gradient{
 
399
//            GradientStop{position: 0.0; color: color1}
 
400
//            GradientStop{position: 1.0; color: color2}
 
401
//        }
 
402
//        Image {
 
403
//            id: btnImg
 
404
//            anchors.fill: parent
 
405
//            source: ""
 
406
//        }
 
407
//        MouseArea {
 
408
//            id: mouseRegion
 
409
//            anchors.fill: parent
 
410
//            hoverEnabled: true
 
411
//            onEntered:{
 
412
//                btnImg.source = "../../img/toolWidget/menu_hover.png"
 
413
//            }
 
414
//            onPressed: btnImg.source = "../../img/toolWidget/menu_press.png"
 
415
//            //要判断松开是鼠标位置
 
416
//            onReleased:btnImg.source = "../../img/toolWidget/menu_hover.png"
 
417
//            onExited: btnImg.source = ""
 
418
//            onClicked: {
 
419
//                btn.clicked();    //如果没有选中任何清理项,提示警告框,发出信号...
 
420
//                if(check_flag)
 
421
//                {
 
422
//                    if (setbtn_flag == "onekey") {
 
423
//                        send_dynamic_picture("onekey");
 
424
//                        systemdispatcher.set_user_homedir_qt();
 
425
//                        systemdispatcher.clean_by_main_one_key_qt(systemdispatcher.get_onekey_args());
 
426
////                        btnImg.source = "../img/icons/onekeyover.png"  //首页点击后更换图片的位置7-30
 
427
//                        btn.text="清理完毕";
 
428
//                        btn.enabled=false;
 
429
//                    }
 
430
//                    else if (setbtn_flag == "smallonekey") {
 
431
//                        systemdispatcher.set_user_homedir_qt();
 
432
//                        systemdispatcher.clean_by_second_one_key_qt(systemdispatcher.get_onekey_args2());
 
433
////                        btnImg.source = "../img/icons/clear-over.png"  //首页点击后更换图片的位置7-30
 
434
//                        btn.text="清理完毕";
 
435
//                        btn.enabled=false;
 
436
//                    }
 
437
//                }
 
438
//                else
 
439
//                    sessiondispatcher.send_warningdialog_msg("友情提示:","对不起,您没有选中清理项,请确认!");
 
440
//            }
 
441
//        }
 
442
//    }
 
443
//    Text {
 
444
//        anchors.centerIn:parent
 
445
//        text: btn.text
 
446
//        font.bold: bold
 
447
//        font.pointSize: textsize
 
448
//        color: "white"
 
449
//    }
 
450
 
 
451
////    Text {
 
452
////        color: "white"
 
453
//////        visible: (btn.text == "") ? false : true
 
454
////        anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15
 
455
////        text: btn.text; style: Text.Raised; styleColor: "black"
 
456
////    }
 
457
////    states: [
 
458
////        State {
 
459
////            name: "Pressed"
 
460
////            when: mouseRegion.pressed == true
 
461
////            PropertyChanges { target: pressed; opacity: 1 }
 
462
////        }
 
463
////    ]
 
464
//}