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

« back to all changes in this revision

Viewing changes to qml/func/AptCruft.qml

  • Committer: Package Import Robot
  • Author(s): Kobe Lee (kylinkobe)
  • Date: 2013-09-18 16:22:14 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130918162214-6nqyjyf3cd3ynqky
Tags: 0.2.1-0ubuntu1
* Modify the mouse events of MonitorBall.
* Add reset button for clear pages.
* Add policykit for apt clear in sudodbus.
* Fixed the bug about software status and add masklayer.
* Rewrite the code of system information.
* Add some signals and slots.
* Fixed the bug about Software signals(LP: #1226389).
* Modify KThread and add base.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
Item {
25
25
    id:root
26
26
    width: parent.width
27
 
    height: 435//420//340
 
27
    height: 435
28
28
    property string btn_text: "开始扫描"
29
29
    property string apt_title: "包管理深度清理"
30
30
    property string apt_description: "深度清理包管理残留的deb包,节省磁盘空间"
37
37
    property bool apt_check_flag: true
38
38
    property bool apt_null_flag: false
39
39
    property int apt_num: apt_sub_num
40
 
 
 
40
    property int deleget_arrow :0
41
41
 
42
42
    signal apt_signal(string apt_msg);
43
43
    onApt_signal: {
44
44
        if (apt_msg == "AptWork") {
45
45
            //get data of cookies
46
46
            var apt_data = sessiondispatcher.scan_apt_cruft_qt();
47
 
            if (apt_data == "")
 
47
            if (apt_data == "") {
48
48
                root.apt_null_flag = true;
49
 
            else
 
49
                if(apt_statusImage.visible == true)
 
50
                    apt_statusImage.visible = false;
 
51
            }
 
52
            else {
50
53
                root.apt_null_flag = false;
 
54
                apt_statusImage.visible = true;
 
55
            }
51
56
            root.apt_sub_num = apt_data.length;
52
57
            systemdispatcher.clear_apt_args();
53
58
            apt_subModel.clear();
59
64
                    num++;
60
65
                }
61
66
                else {
62
 
                    apt_subModel.append({"itemTitle": splitlist[0], "desc": "","number": splitlist[1] + "字节"});
 
67
                    apt_subModel.append({"itemTitle": splitlist[0], "desc": "","number": splitlist[1]});
63
68
                    systemdispatcher.set_apt_args(splitlist[0]);
64
69
                }
65
70
            }
92
97
//                 titleBar.state = "AptWork";
93
98
//             }
94
99
//         }
 
100
        onFinishCleanWorkError: {
 
101
            if (apt_btn_flag == "apt_work") {
 
102
                if (msg == "apt") {
 
103
                    root.apt_work_result = msg;
 
104
                    root.state = "AptWorkError";
 
105
                    toolkits.alertMSG("清理出现异常!", mainwindow.pos.x, mainwindow.pos.y);
 
106
                }
 
107
            }
 
108
         }
95
109
        onFinishCleanWork: {
96
110
            if (apt_btn_flag == "apt_work") {
97
 
                if (msg == "apt") {
 
111
                if (msg == "") {
 
112
                    resetBtn.visible = true;
 
113
                }
 
114
                else if (msg == "apt") {
98
115
                    root.apt_work_result = msg;
99
116
                    root.state = "AptWorkFinish";
 
117
                    toolkits.alertMSG("清理完毕!", mainwindow.pos.x, mainwindow.pos.y);
 
118
                    apt_signal("AptWork");
100
119
                }
101
120
            }
102
121
        }
131
150
        spacing: 20
132
151
        width: parent.width
133
152
//        height: 50
134
 
        anchors { top: parent.top; topMargin: 20; left: parent.left; leftMargin: 20 }
 
153
        anchors { top: parent.top; topMargin: 20; left: parent.left; leftMargin: 27 }
135
154
        Image {
136
155
            id: apt_refreshArrow
137
156
            source: "../img/toolWidget/apt.png"
167
186
//        }
168
187
        Common.StatusImage {
169
188
            id: apt_statusImage
 
189
            visible: false
170
190
            iconName: "yellow.png"
171
191
            text: "未完成"
172
192
            anchors.verticalCenter: parent.verticalCenter
173
193
        }
174
 
 
175
 
        Common.Label {
176
 
            id: apt_label
177
 
            visible: false
178
 
            text: ""
179
 
            anchors.verticalCenter: parent.verticalCenter
180
 
        }
181
 
 
182
 
 
183
194
        Common.Button {
184
195
            id: apt_bitButton
185
196
            width: 120
186
197
            height: 39
187
198
            hoverimage: "green1.png"
188
199
            text: root.btn_text
 
200
            fontsize: 15
189
201
            anchors.verticalCenter: parent.verticalCenter
190
202
            onClicked: {
 
203
                resetBtn.visible = false;
191
204
                if(apt_check_flag)
192
205
                {
193
206
                //apt cruft
195
208
                     apt_signal("AptWork");
196
209
                     if(root.apt_null_flag == true) {
197
210
                        root.state = "AptWorkEmpty";
198
 
                        sessiondispatcher.send_warningdialog_msg("友情提示:","扫描内容为空,不再执行清理!");
 
211
                         deleget_arrow=0;
 
212
                        sessiondispatcher.showWarningDialog("友情提示:","扫描内容为空,不再执行清理!", mainwindow.pos.x, mainwindow.pos.y);
199
213
                     }
200
214
                     else if(root.apt_null_flag == false)
 
215
                     {
201
216
                        root.state = "AptWork";
 
217
                         deleget_arrow=1;
 
218
                         toolkits.alertMSG("扫描完成!", mainwindow.pos.x, mainwindow.pos.y);
 
219
                     }
202
220
                 }
203
221
                 else if (apt_btn_flag == "apt_work") {
204
222
                     systemdispatcher.clean_file_cruft_qt(systemdispatcher.get_apt_args(), "apt");
 
223
                     deleget_arrow=1;
205
224
                 }
206
225
                }
207
226
                else
208
 
                     sessiondispatcher.send_warningdialog_msg("友情提示:","对不起,您没有选择需要清理的项,请确认!")
209
 
            }
210
 
        }
211
 
//        Common.Button {
212
 
//            id: apt_bitButton
213
 
//            width: 120
214
 
//            height: 39
215
 
////            hoverimage: "scan-start.png"
216
 
//            text:"开始扫描"
217
 
//            bold:true
218
 
//            textsize: 12
219
 
//            anchors.verticalCenter: parent.verticalCenter
220
 
//            onClicked: {
221
 
//                if(apt_check_flag)
222
 
//                {
223
 
//                //apt cruft
224
 
//                 if (apt_btn_flag == "apt_scan") {
225
 
//                     apt_signal("AptWork");
226
 
//                     if(root.apt_null_flag == true) {
227
 
//                        root.state = "AptWorkEmpty";
228
 
//                        sessiondispatcher.send_warningdialog_msg("友情提示:","扫描内容为空,不再执行清理!");
229
 
//                     }
230
 
//                     else if(root.apt_null_flag == false)
231
 
//                        root.state = "AptWork";
232
 
//                 }
233
 
//                 else if (apt_btn_flag == "apt_work") {
234
 
//                     systemdispatcher.clean_file_cruft_qt(systemdispatcher.get_apt_args(), "apt");
235
 
//                 }
236
 
//                }
237
 
//                else
238
 
//                     sessiondispatcher.send_warningdialog_msg("友情提示:","对不起,您没有选择需要清理的项,请确认!")
239
 
//            }
240
 
//        }
 
227
                     sessiondispatcher.showWarningDialog("友情提示:","对不起,您没有选择需要清理的项,请确认!", mainwindow.pos.x, mainwindow.pos.y)
 
228
            }
 
229
        }
 
230
 
 
231
        SetBtn {
 
232
            id: resetBtn
 
233
            width: 12
 
234
            height: 15
 
235
            iconName: "revoke.png"
 
236
            visible: false
 
237
            anchors.verticalCenter: parent.verticalCenter
 
238
            onClicked: {
 
239
                resetBtn.visible = false;
 
240
                apt_subModel.clear();
 
241
                root.state = "AptWorkAGAIN";
 
242
            }
 
243
        }
241
244
    }
242
245
    //分割条
243
246
    Rectangle {
250
253
        }
251
254
        width: parent.width - 4
252
255
        height: 1
253
 
        color: "#b9c5cc"
 
256
        color: "#d8e0e6"
254
257
    }
255
258
 
256
 
//    Component {
257
 
//        id: listViewDelegate
258
 
//        Item {
259
 
//            id: delegate
260
 
//            property alias expandedItemCount: subItemRepeater.count
261
 
//            x: 5; y: 2
262
 
//            width: root.width
263
 
//            height: headerItemRect.height + subItemsRect.height
264
 
 
265
 
//            //母项
266
 
//            //checkbox, picture and words
267
 
//            Row {
268
 
//                id: headerItemRect
269
 
//                x: 5; y: 2
270
 
//                width: root.width
271
 
//                height: root.itemHeight
272
 
//                spacing: 170
273
 
//                Row{
274
 
//                    spacing: 15
275
 
//                    Image {
276
 
//                        id: clearImage
277
 
//                        fillMode: "PreserveAspectFit"
278
 
//                        height: parent.height*0.9
279
 
//                        source: picture
280
 
//                        smooth: true
281
 
//                    }
282
 
 
283
 
//                    Column {
284
 
//                        id: status_update_content
285
 
//                        spacing: 5
286
 
//                        anchors.verticalCenter: parent.verticalCenter
287
 
//                        Text {
288
 
//                            id: mytext
289
 
//                            text: itemTitle
290
 
//                            font.pointSize: 11
291
 
//                            color: "black"
292
 
//                        }
293
 
//                        Text {
294
 
//                            text: detailstr
295
 
//                            font.pointSize: 9
296
 
//                            color: "gray"
297
 
//                        }
298
 
//                    }
299
 
//                }
300
 
//            }//母项Row
301
 
//            Image {
302
 
//                id: arrow
303
 
//                fillMode: "PreserveAspectFit"
304
 
//                height: 28
305
 
//                width: 26
306
 
//                x:740
307
 
//                y:15
308
 
////                    height: parent.height*0.3
309
 
//                source: root.arrow
310
 
//                //当鼠标点击后,箭头图片旋转90度
311
 
////                    rotation: expanded ? 90 : 0
312
 
//                rotation: expanded ? 0 : -180
313
 
//                smooth: true
314
 
//                MouseArea {
315
 
//                    id: mouseRegion
316
 
//                    anchors.fill: parent
317
 
//                    onPressed: {
318
 
//                        expanded = !expanded
319
 
//                    }
320
 
//                }
321
 
//            }
322
 
 
323
 
//            //子项
324
 
//            Item {
325
 
//                id: subItemsRect
326
 
//                property int itemHeight: root.itemHeight
327
 
//                y: headerItemRect.height
328
 
//                width: root.width
329
 
//                //当高度需要扩展时,根据expandedItemCount数目和itemHeight高度去扩展
330
 
//                height: expanded ? delegate.expandedItemCount * itemHeight : 0
331
 
//                clip: true
332
 
//                opacity: 1
333
 
//                Behavior on height {
334
 
//                    SequentialAnimation {
335
 
//                        NumberAnimation { duration: 100; easing.type: Easing.InOutQuad }
336
 
//                    }
337
 
//                }
338
 
 
339
 
//                Column {
340
 
//                    width: root.width
341
 
//                    Repeater {
342
 
//                        id: subItemRepeater
343
 
//                        model: apt_subModel
344
 
//                        width: subItemsRect.width
345
 
//                        ListItem {
346
 
//                            id: subListItem
347
 
//                            split_status: true
348
 
//                            width: root.width
349
 
//                            height: subItemsRect.itemHeight
350
 
////                            text: subItemTitle
351
 
//                            text: itemTitle
352
 
//                            descript: desc
353
 
//                            size_num: number
354
 
//                            checkbox_status: root.apt_check_flag
355
 
////                            bgImage: "../../img/icons/list_subitem.png"
356
 
//                            bgImage: ""
357
 
//                            fontName: root.subItemFontName
358
 
//                            fontSize: root.subItemFontSize
359
 
//                            fontColor: root.subItemFontColor
360
 
//                            textIndent: 20
361
 
//                            btn_flag: root.apt_btn_flag
362
 
//                            onClicked: {}
363
 
//                        }
364
 
 
365
 
//                    }//Repeater
366
 
//                }//Column
367
 
//            }
368
 
//        }
369
 
//    }//Component
370
 
 
371
 
 
372
259
    Common.ScrollArea {
373
260
        frame:false
374
261
        anchors.top: apt_titlebar.bottom
375
 
        anchors.topMargin: 30
376
 
        height: root.height -apt_titlebar.height - 50
377
 
        width: parent.width
 
262
        anchors.topMargin: 20//30
 
263
        anchors.left:parent.left
 
264
        anchors.leftMargin: 27
 
265
        height: root.height -apt_titlebar.height - 37//50
 
266
        width: parent.width - 27 -2
378
267
        Item {
379
268
            width: parent.width
380
269
            height: (root.apt_num + 1) * 40 //450 + //this height must be higher than root.height, then the slidebar can display
384
273
                height: parent.height
385
274
                model: apt_mainModel
386
275
                delegate: Cleardelegate{
387
 
                    sub_num: apt_sub_num;sub_model: apt_subModel;btn_flag: apt_btn_flag
 
276
                    sub_num: apt_sub_num;sub_model: apt_subModel;btn_flag: apt_btn_flag;arrow_display:deleget_arrow;
388
277
                    delegate_flag: true
389
278
                    onSubpressed: {root.apt_num=hMark}
390
279
                    onCheckchanged: {root.apt_check_flag=checkchange}
405
294
    states: [
406
295
        State {
407
296
            name: "AptWork"
408
 
             PropertyChanges { target: apt_label; visible: true; text: "apt扫描完成"}
409
 
             PropertyChanges { target: apt_bitButton; /*hoverimage: "clear-start.png"*/ text:"开始清理"}
 
297
             PropertyChanges { target: apt_bitButton; text:"开始清理"}
410
298
            PropertyChanges { target: root; apt_btn_flag: "apt_work" }
411
 
        },
412
 
 
 
299
            PropertyChanges { target: apt_statusImage; visible: true; iconName: "yellow.png"; text: "未完成"}
 
300
        },
 
301
        State {
 
302
            name: "AptWorkAGAIN"
 
303
            PropertyChanges { target: apt_bitButton; text:"开始扫描" }
 
304
            PropertyChanges { target: root; apt_btn_flag: "apt_scan" }
 
305
            PropertyChanges { target: apt_statusImage; visible: false }
 
306
        },
 
307
        State {
 
308
            name: "AptWorkError"
 
309
            PropertyChanges { target: apt_bitButton; text:"开始扫描" }
 
310
            PropertyChanges { target: root; apt_btn_flag: "apt_scan" }
 
311
            PropertyChanges { target: apt_statusImage; visible: true; iconName: "red.png"; text: "出现异常"}
 
312
        },
413
313
        State {
414
314
            name: "AptWorkFinish"
415
 
            PropertyChanges { target: apt_label; visible: true; text: root.apt_work_result + "清理完毕!" }
416
 
            PropertyChanges { target: apt_bitButton; /*hoverimage: "scan-start.png"*/text:"开始扫描" }
 
315
            PropertyChanges { target: apt_bitButton; text:"开始扫描" }
417
316
            PropertyChanges { target: root; apt_btn_flag: "apt_scan" }
418
 
            PropertyChanges { target: apt_statusImage; iconName: "green.png"; text: "已完成"}
 
317
            PropertyChanges { target: apt_statusImage; visible: true; iconName: "green.png"; text: "已完成"}
419
318
        },
420
319
        State {
421
320
            name: "AptWorkEmpty"
422
 
            PropertyChanges { target: apt_label; visible: true; text: "扫描内容为空,不再执行清理!" }
423
 
            PropertyChanges { target: apt_bitButton; /*hoverimage: "scan-start.png"*/ text:"开始扫描"}
 
321
            PropertyChanges { target: apt_bitButton; text:"开始扫描"}
424
322
            PropertyChanges { target: root; apt_btn_flag: "apt_scan" }
425
 
            PropertyChanges { target: apt_statusImage; iconName: "green.png"; text: "已完成"}
 
323
            PropertyChanges { target: apt_statusImage;  visible: false}
426
324
        }
427
325
    ]
428
326
}