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

« back to all changes in this revision

Viewing changes to qml/func/SoftwareCruft.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:
36
36
    property int sof_num:sof_sub_num
37
37
    property bool sof_null_flag: false
38
38
    property bool sof_check_flag:true
39
 
 
40
 
 
 
39
    property int deleget_arrow :0
41
40
 
42
41
    function remove_last_name(str)
43
42
    {
52
51
            //get data of cookies
53
52
//            var software_data = systemdispatcher.scan_softwarecenter_cruft_qt();
54
53
            var software_data = sessiondispatcher.scan_softwarecenter_cruft_qt();
55
 
            if (software_data == "")
 
54
            if (software_data == "") {
56
55
                root.sof_null_flag = true;
57
 
            else
 
56
                if(sof_statusImage.visible == true)
 
57
                    sof_statusImage.visible = false;
 
58
            }
 
59
            else {
58
60
                root.sof_null_flag = false;
 
61
                sof_statusImage.visible == true
 
62
            }
59
63
            root.sof_sub_num = software_data.length;
60
64
            systemdispatcher.clear_software_args();
61
65
            sof_subModel.clear();
67
71
                    num++;
68
72
                }
69
73
                else {
70
 
                    sof_subModel.append({"itemTitle": splitlist[0], "desc": "","number": splitlist[1] + "字节"});
 
74
                    sof_subModel.append({"itemTitle": splitlist[0], "desc": "","number": splitlist[1]});
71
75
                    systemdispatcher.set_software_args(splitlist[0]);
72
76
                }
73
77
            }
74
78
            root.sof_sub_num -= num;
75
 
            sof_num=sof_sub_num
 
79
            sof_num = sof_sub_num;
76
80
            if(sof_num!=0)
77
81
                sof_check_flag=true;
78
82
            sof_mainModel.clear();
79
83
            sof_mainModel.append({"itemTitle": "软件中心缓存清理",
80
84
                             "picture": "../img/toolWidget/software-min.png",
81
 
                                 "detailstr": "用户可以根据扫描结果选择性地清理软件中心缓存,缓存路径为:" + sessiondispatcher.get_home_path() + "/.cache/software-center/",
 
85
                                 "detailstr": "用户可以根据扫描结果选择性地清理软件中心缓存,缓存路径为:" + sessiondispatcher.getHomePath() + "/.cache/software-center/",
82
86
                             "flags": "clear_software",
83
87
                            "attributes":
84
88
                                 [{"subItemTitle": "Cookies1"},
121
125
        //             }
122
126
 
123
127
//         }
 
128
        onFinishCleanWorkError: {
 
129
            if (sof_btn_flag == "software_work") {
 
130
                if (msg == "software") {
 
131
                    root.sof_work_result = msg;
 
132
                    root.state = "SoftwareWorkError";
 
133
                    toolkits.alertMSG("清理出现异常!", mainwindow.pos.x, mainwindow.pos.y);
 
134
                }
 
135
            }
 
136
         }
124
137
        onFinishCleanWork: {
125
138
            if (sof_btn_flag == "software_work") {
126
 
                if (msg == "software") {
 
139
                if (msg == "") {
 
140
                    resetBtn.visible = true;
 
141
                }
 
142
                else if (msg == "software") {
127
143
                    root.sof_work_result = msg;
128
144
                    root.state = "SoftwareWorkFinish";
 
145
                    toolkits.alertMSG("清理完毕!", mainwindow.pos.x, mainwindow.pos.y);
 
146
                    software_signal("SoftwareWork");
129
147
                }
130
148
            }
131
149
        }
144
162
        spacing: 20
145
163
        width: parent.width
146
164
//        height: 50
147
 
        anchors { top: parent.top; topMargin: 20; left: parent.left; leftMargin: 20 }
 
165
        anchors { top: parent.top; topMargin: 20; left: parent.left; leftMargin: 27 }
148
166
        Image {
149
167
            id: refreshArrow
150
168
            source: "../img/toolWidget/software-max.png"
170
188
        anchors { top: parent.top; topMargin: 30;right: parent.right ; rightMargin: 40 }
171
189
        spacing: 20
172
190
 
173
 
        //status picture
174
 
//        Image {
175
 
//            id: sof_statusImage
176
 
//            source: "../img/toolWidget/unfinish.png"
177
 
//            fillMode: "PreserveAspectFit"
178
 
//            smooth: true
179
 
//            anchors.verticalCenter: parent.verticalCenter
180
 
//        }
181
191
        Common.StatusImage {
182
192
            id: sof_statusImage
 
193
            visible: false
183
194
            iconName: "yellow.png"
184
195
            text: "未完成"
185
196
            anchors.verticalCenter: parent.verticalCenter
186
197
        }
187
 
 
188
 
        Common.Label {
189
 
            id: sof_label
190
 
            visible: false
191
 
            text: ""
192
 
            anchors.verticalCenter: parent.verticalCenter
193
 
        }
194
 
 
195
 
 
196
198
        Common.Button {
197
199
            id: sof_bitButton
198
200
            width: 120
199
201
            height: 39
200
202
            hoverimage: "green1.png"
201
203
            text: root.btn_text
 
204
            fontsize: 15
202
205
            anchors.verticalCenter: parent.verticalCenter
203
206
            onClicked: {
 
207
                resetBtn.visible = false;
204
208
                if(root.sof_check_flag)
205
209
                {
206
210
                //software cruft
208
212
                     software_signal("SoftwareWork");
209
213
                     if(root.sof_null_flag == true) {
210
214
                        root.state = "SoftwareWorkEmpty";
211
 
                         sessiondispatcher.send_warningdialog_msg("友情提示:","扫描内容为空,不再执行清理!");
 
215
                         deleget_arrow=0;
 
216
                         sessiondispatcher.showWarningDialog("友情提示:","扫描内容为空,不再执行清理!", mainwindow.pos.x, mainwindow.pos.y);
212
217
                     }
213
218
                     else if(root.sof_null_flag == false)
 
219
                     {
214
220
                        root.state = "SoftwareWork";
 
221
                         deleget_arrow=1;
 
222
                         toolkits.alertMSG("扫描完成!", mainwindow.pos.x, mainwindow.pos.y);
 
223
                     }
215
224
                 }
216
225
                 else if (sof_btn_flag == "software_work") {
217
226
                     systemdispatcher.clean_file_cruft_qt(systemdispatcher.get_software_args(), "software");
 
227
                     deleget_arrow=1;
218
228
                 }
219
229
                }
220
230
                else
221
 
                    sessiondispatcher.send_warningdialog_msg("友情提示:","对不起,您没有选择需要清理的项,请确认!");
222
 
            }
223
 
        }
224
 
//        Common.Button {
225
 
//            id: sof_bitButton
226
 
//            width: 120
227
 
//            height: 39
228
 
////            hoverimage: "scan-start.png"
229
 
//            text:"开始扫描"
230
 
//            bold:true
231
 
//            textsize: 12
232
 
//            anchors.verticalCenter: parent.verticalCenter
233
 
//            onClicked: {
234
 
//                if(root.sof_check_flag)
235
 
//                {
236
 
//                //software cruft
237
 
//                 if (sof_btn_flag == "software_scan") {
238
 
//                     software_signal("SoftwareWork");
239
 
//                     if(root.sof_null_flag == true) {
240
 
//                        root.state = "SoftwareWorkEmpty";
241
 
//                         sessiondispatcher.send_warningdialog_msg("友情提示:","扫描内容为空,不再执行清理!");
242
 
//                     }
243
 
//                     else if(root.sof_null_flag == false)
244
 
//                        root.state = "SoftwareWork";
245
 
//                 }
246
 
//                 else if (sof_btn_flag == "software_work") {
247
 
//                     systemdispatcher.clean_file_cruft_qt(systemdispatcher.get_software_args(), "software");
248
 
////                     sessiondispatcher.clean_file_cruft_qt(systemdispatcher.get_software_args(), "software");
249
 
//                 }
250
 
//                }
251
 
//                else
252
 
//                    sessiondispatcher.send_warningdialog_msg("友情提示:","对不起,您没有选择需要清理的项,请确认!");
253
 
//            }
254
 
//        }
 
231
                    sessiondispatcher.showWarningDialog("友情提示:","对不起,您没有选择需要清理的项,请确认!", mainwindow.pos.x, mainwindow.pos.y);
 
232
            }
 
233
        }
 
234
        SetBtn {
 
235
            id: resetBtn
 
236
            width: 12
 
237
            height: 15
 
238
            iconName: "revoke.png"
 
239
            visible: false
 
240
            anchors.verticalCenter: parent.verticalCenter
 
241
            onClicked: {
 
242
                resetBtn.visible = false;
 
243
                sof_subModel.clear();
 
244
                root.state = "SoftwareWorkAGAIN";
 
245
            }
 
246
        }
255
247
    }
256
248
    //分割条
257
249
    Rectangle {
264
256
        }
265
257
        width: parent.width - 4
266
258
        height: 1
267
 
        color: "#b9c5cc"
 
259
        color: "#d8e0e6"
268
260
    }
269
 
 
270
 
//    Component {
271
 
//        id: listViewDelegate
272
 
//        Item {
273
 
//            id: delegate
274
 
//            property alias expandedItemCount: subItemRepeater.count
275
 
//            x: 5; y: 2
276
 
//            width: root.width
277
 
//            height: headerItemRect.height + subItemsRect.height
278
 
 
279
 
//            //母项
280
 
//            //checkbox, picture and words
281
 
//            Row {
282
 
//                id: headerItemRect
283
 
//                x: 5; y: 2
284
 
//                width: root.width
285
 
//                height: root.itemHeight
286
 
//                spacing: 170
287
 
//                Row{
288
 
//                    spacing: 15
289
 
//                    Image {
290
 
//                        id: clearImage
291
 
//                        fillMode: "PreserveAspectFit"
292
 
//                        height: parent.height*0.9
293
 
//                        source: picture
294
 
//                        smooth: true
295
 
//                    }
296
 
 
297
 
//                    Column {
298
 
//                        id: status_update_content
299
 
//                        spacing: 5
300
 
//                        anchors.verticalCenter: parent.verticalCenter
301
 
//                        Text {
302
 
//                            text: itemTitle
303
 
//                            font.pointSize: 11
304
 
//                            color: "black"
305
 
//                        }
306
 
//                        Text {
307
 
//                            text: detailstr
308
 
//                            font.pointSize: 9
309
 
//                            color: "gray"
310
 
//                        }
311
 
//                    }
312
 
//                }
313
 
 
314
 
//            }//母项Row
315
 
//            Image {
316
 
//                id: arrow
317
 
//                fillMode: "PreserveAspectFit"
318
 
////                    height: parent.height*0.3
319
 
//                height: 28
320
 
//                width: 26
321
 
//                x:740
322
 
//                y:15
323
 
//                source: root.arrow
324
 
//                //当鼠标点击后,箭头图片旋转90度
325
 
////                    rotation: expanded ? 90 : 0
326
 
//                rotation: expanded ? 0 : -180
327
 
//                smooth: true
328
 
//                MouseArea {
329
 
//                    id: mouseRegion
330
 
//                    anchors.fill: parent
331
 
//                    onPressed: {
332
 
//                        expanded = !expanded
333
 
//                    }
334
 
//                }
335
 
//            }
336
 
 
337
 
//            //子项
338
 
//            Item {
339
 
//                id: subItemsRect
340
 
//                property int itemHeight: root.itemHeight
341
 
//                y: headerItemRect.height
342
 
//                width: root.width
343
 
//                //当高度需要扩展时,根据expandedItemCount数目和itemHeight高度去扩展
344
 
//                height: expanded ? delegate.expandedItemCount * itemHeight : 0
345
 
//                clip: true
346
 
//                opacity: 1
347
 
//                Behavior on height {
348
 
//                    SequentialAnimation {
349
 
//                        NumberAnimation { duration: 100; easing.type: Easing.InOutQuad }
350
 
//                    }
351
 
//                }
352
 
 
353
 
//                Column {
354
 
//                    width: root.width
355
 
//                    Repeater {
356
 
//                        id: subItemRepeater
357
 
//                        model: sof_subModel
358
 
//                        width: subItemsRect.width
359
 
//                        ListItem {
360
 
//                            id: subListItem
361
 
//                            split_status: true
362
 
//                            width: root.width
363
 
//                            height: subItemsRect.itemHeight
364
 
////                            text: subItemTitle
365
 
//                            text: itemTitle
366
 
//                            descript: desc
367
 
//                            size_num: number
368
 
//                            checkbox_status: root.sof_check_flag
369
 
////                            bgImage: "../../img/icons/list_subitem.png"
370
 
//                            bgImage: ""
371
 
//                            fontName: root.subItemFontName
372
 
//                            fontSize: root.subItemFontSize
373
 
//                            fontColor: root.subItemFontColor
374
 
//                            textIndent: 20
375
 
 
376
 
//                            btn_flag: root.sof_btn_flag
377
 
 
378
 
//                            onClicked: {}
379
 
//                        }
380
 
 
381
 
//                    }//Repeater
382
 
//                }//Column
383
 
//            }//子项Item
384
 
//        }
385
 
//    }//Component
386
 
 
387
 
 
388
261
    Common.ScrollArea {
389
262
        frame:false
390
263
        anchors.top: sof_titlebar.bottom
391
 
        anchors.topMargin: 30
392
 
        height: root.height -sof_titlebar.height - 50
393
 
        width: parent.width
 
264
        anchors.topMargin: 20//30
 
265
        anchors.left:parent.left
 
266
        anchors.leftMargin: 27
 
267
        height: root.height -sof_titlebar.height - 37//50
 
268
        width: parent.width - 27 -2
394
269
        Item {
395
270
            width: parent.width
396
271
            height: (root.sof_num + 1) * 40 //450 + //this height must be higher than root.height, then the slidebar can display
400
275
                height: parent.height
401
276
                model: sof_mainModel
402
277
                delegate: Cleardelegate{
403
 
                    sub_num: sof_sub_num;sub_model: sof_subModel;btn_flag: sof_btn_flag
 
278
                    sub_num: sof_sub_num;sub_model: sof_subModel;btn_flag: sof_btn_flag;arrow_display:deleget_arrow;
404
279
                    delegate_flag: true
405
280
                    onSubpressed: {root.sof_num=hMark}
406
281
                    onCheckchanged: {root.sof_check_flag=checkchange}
421
296
    states: [
422
297
        State {
423
298
            name: "SoftwareWork"
424
 
             PropertyChanges { target: sof_label; visible: true; text: "software扫描完成"}
425
 
             PropertyChanges { target: sof_bitButton; /*hoverimage: "clear-start.png"*/text:"开始清理" }
 
299
             PropertyChanges { target: sof_bitButton; text:"开始清理" }
426
300
            PropertyChanges { target: root; sof_btn_flag: "software_work" }
 
301
            PropertyChanges { target: sof_statusImage; visible: true; iconName: "yellow.png"; text: "未完成"}
 
302
        },
 
303
        State {
 
304
            name: "SoftwareWorkAGAIN"
 
305
            PropertyChanges { target: sof_bitButton; text:"开始扫描" }
 
306
            PropertyChanges { target: root; sof_btn_flag: "software_scan" }
 
307
            PropertyChanges { target: sof_statusImage; visible: false }
 
308
        },
 
309
        State {
 
310
            name: "SoftwareWorkError"
 
311
            PropertyChanges { target: sof_bitButton; text:"开始扫描" }
 
312
            PropertyChanges { target: root; sof_btn_flag: "software_scan" }
 
313
            PropertyChanges { target: sof_statusImage; visible: true; iconName: "red.png"; text: "出现异常"}
427
314
        },
428
315
        State {
429
316
            name: "SoftwareWorkFinish"
430
 
            PropertyChanges { target: sof_label; visible: true; text: root.sof_work_result + "清理完毕!" }
431
 
            PropertyChanges { target: sof_bitButton; /*hoverimage: "scan-start.png"*/text:"开始扫描" }
 
317
            PropertyChanges { target: sof_bitButton; text:"开始扫描" }
432
318
            PropertyChanges { target: root; sof_btn_flag: "software_scan" }
433
 
            PropertyChanges { target: sof_statusImage; iconName: "green.png"; text: "已完成"}
 
319
            PropertyChanges { target: sof_statusImage; visible: true; iconName: "green.png"; text: "已完成"}
434
320
        },
435
321
        State {
436
322
            name: "SoftwareWorkEmpty"
437
 
            PropertyChanges { target: sof_label; visible: true; text: "扫描内容为空,不再执行清理!" }
438
 
            PropertyChanges { target: sof_bitButton; /*hoverimage: "scan-start.png"*/text:"开始扫描" }
 
323
            PropertyChanges { target: sof_bitButton; text:"开始扫描" }
439
324
            PropertyChanges { target: root; sof_btn_flag: "software_scan" }
440
 
            PropertyChanges { target: sof_statusImage; iconName: "green.png"; text: "已完成"}
 
325
            PropertyChanges { target: sof_statusImage; visible: false}
441
326
        }
442
327
    ]
443
328
}