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

« back to all changes in this revision

Viewing changes to qml/func/settings/MousePointer.qml

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2014-03-24 15:52:37 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140324155237-3kod0m3wr2a2ag39
Tags: 1.0.1-0ubuntu1
* New upstream release (LP: #1294936).
* Modify display mode of weather forecast and system settings.
* Add file manager and font style settings.
* Improve system settings and restoring default settings.
* Cache user account (not password).
* Change the position of window control buttons.
* Add configuration for Kingsoft KuaiPan cloud client.
* Add the instruction of Youker Assistant.
* Open related folders when scanning items got double-clicked.
* Notify users when operating the Kingsoft disk cloud configuration.
* Modify Dbus starting method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import "../bars" as Bars
20
20
Rectangle {
21
21
    id: mousepointerpage
22
 
    property bool on: true
23
22
    width: parent.width
24
23
    height: 475
25
 
    property string fontName: "Helvetica"
26
 
    property int fontSize: 12
27
 
    property color fontColor: "black"
 
24
 
28
25
    property int cursor_size: 24
29
 
    property string selected_cursor_theme: ""//存放用户选择确认后的主题
30
 
 
31
26
    property int current_index//当前主题的索引
32
27
    property int default_index//系统默认主题的索引
33
 
 
34
28
    property string actiontitle: qsTr("Mouse Settings")//鼠标设置
35
29
    property string actiontext: qsTr("Replace the theme and size of the mouse pointer,  then click the 'OK' button to confirm. Also, theme change need to restart system.")//更换鼠标指针主题和大小,更改设置后点击"确定"按钮进行确认。主题更改需要重新系统才能生效。
 
30
 
 
31
    ListModel { id: choices }
 
32
 
36
33
    //背景
37
34
    Image {
38
35
        source: "../../img/skin/bg-middle.png"
40
37
    }
41
38
    Component.onCompleted: {
42
39
        mousepointerpage.cursor_size = sessiondispatcher.get_cursor_size_qt();
43
 
//        sessiondispatcher.write_default_configure_to_qsetting_file("theme", "cursorsize", mousepointerpage.cursor_size);
44
40
        var cursorlist = sessiondispatcher.get_cursor_themes_qt();
45
 
        var default_theme = sessiondispatcher.get_default_theme_sring_qt("mousetheme");
46
 
        //系统默认值可能在获取列表的时候没有该值,所以需要在这里添加进去。
47
 
        var flag = false;
48
 
        for(var i=0; i < cursorlist.length; i++) {
49
 
            if(cursorlist[i] == default_theme) {
50
 
                flag = true;
51
 
            }
52
 
        }
53
 
        if(flag) {
54
 
            flag = false;
55
 
        }
56
 
        else {
57
 
            var len = cursorlist.length;
58
 
            cursorlist.push(default_theme);
59
 
        }
60
 
 
61
 
 
62
41
        var current_cursor_theme = sessiondispatcher.get_cursor_theme_qt();
63
 
        //将系统初始的图标主题写入QSetting配置文件
64
 
//        sessiondispatcher.write_default_configure_to_qsetting_file("theme", "cursortheme", current_cursor_theme);
65
 
        showText.text = qsTr("[ Current Cursor Theme: ") + current_cursor_theme + " ]";//[ 当前光标主题是:
66
 
        mousepointerpage.selected_cursor_theme = current_cursor_theme;
67
 
//        cursorlist.unshift(current_cursor_theme);
68
 
 
69
 
 
70
 
//        console.log("default_theme->");
71
 
//        console.log(default_theme);
72
 
 
 
42
        var default_theme = "DMZ-White";//sessiondispatcher.get_default_theme_sring_qt("mousetheme");
73
43
        choices.clear();
74
 
        for(var k=0; k < cursorlist.length; k++) {
75
 
            choices.append({"text": cursorlist[k]});
76
 
            if (cursorlist[k] == current_cursor_theme) {
77
 
                mousepointerpage.current_index = k;
78
 
            }
79
 
        }
80
 
//        var flag = false;
81
 
//        var k;
82
 
//        for(k=0; k < cursorlist.length; k++) {
83
 
//            choices.append({"text": cursorlist[k]});
84
 
////            if (k!=0 && cursorlist[k] == current_cursor_theme)
85
 
////                choices.remove(k);
86
 
//            if (cursorlist[k] == current_cursor_theme) {
87
 
//                mousepointerpage.current_index = k;
88
 
//            }
89
 
//            else if (cursorlist[k] == default_theme) {
90
 
//                mousepointerpage.default_index = k;
91
 
//                flag = true;
92
 
////                console.log("aaaaaaaaaa->");
93
 
////                console.log()
94
 
//            }
95
 
//        }
96
 
//        if(flag) {
97
 
//            flag = false;
98
 
//        }
99
 
//        else {
100
 
//            choices.append({"text": default_theme});
101
 
//            mousepointerpage.default_index = cursorlist.length - 1;
102
 
//        }
103
 
 
 
44
        if(current_cursor_theme == default_theme) {
 
45
            for(var i=0; i < cursorlist.length; i++) {
 
46
                choices.append({"text": cursorlist[i]});
 
47
                if (cursorlist[i] == current_cursor_theme) {
 
48
                    mousepointerpage.current_index = i;
 
49
                    mousepointerpage.default_index = i;
 
50
                }
 
51
            }
 
52
        }
 
53
        else {
 
54
            for(var j=0; j < cursorlist.length; j++) {
 
55
                choices.append({"text": cursorlist[j]});
 
56
                if (cursorlist[j] == current_cursor_theme) {
 
57
                    mousepointerpage.current_index = j;
 
58
                }
 
59
                else if (cursorlist[j] == default_theme) {
 
60
                    mousepointerpage.default_index = j;
 
61
                }
 
62
            }
 
63
        }
104
64
        cursorcombo.selectedIndex = mousepointerpage.current_index;
105
 
 
106
65
    }
107
66
 
108
67
    Column {
111
70
        anchors.topMargin: 44
112
71
        anchors.left: parent.left
113
72
        anchors.leftMargin: 80
114
 
        Row {
115
 
            spacing: 50
116
 
            Text {
117
 
                 text: mousepointerpage.actiontitle
118
 
                 font.bold: true
119
 
                 font.pixelSize: 14
120
 
                 color: "#383838"
121
 
             }
122
 
            Text {
123
 
                id: showText
124
 
                text: ""
125
 
                font.pixelSize: 14
126
 
                color: "#318d11"
127
 
            }
128
 
            //status picture
129
 
            Common.StatusImage {
130
 
                id: statusImage
131
 
                visible: false
132
 
                iconName: "green.png"
133
 
                text: qsTr("Completed")//已完成
134
 
                anchors.verticalCenter: parent.verticalCenter
135
 
            }
136
 
        }
137
 
         Text {
138
 
             text: mousepointerpage.actiontext
139
 
             font.pixelSize: 12
140
 
             color: "#7a7a7a"
141
 
         }
 
73
        Text {
 
74
            text: mousepointerpage.actiontitle
 
75
            font.bold: true
 
76
            font.pixelSize: 14
 
77
            color: "#383838"
 
78
        }
 
79
        Text {
 
80
            text: mousepointerpage.actiontext
 
81
            font.pixelSize: 12
 
82
            color: "#7a7a7a"
 
83
        }
142
84
    }
143
85
 
144
 
    ListModel { id: choices }
145
 
 
146
86
    Row {
147
87
        id: settitle
148
88
        anchors{
150
90
            leftMargin: 40
151
91
            top: parent.top
152
92
            topMargin: 120
153
 
 
154
93
        }
155
94
        Text{
156
95
            id: mousetitle
174
113
            topMargin: 10
175
114
        }
176
115
        spacing: 20
 
116
        z: 11
177
117
        Row {
178
 
            spacing: 135
 
118
            spacing: 314 - 16 - 20
179
119
            Row {
180
120
                spacing: 20
 
121
                Common.TipLabel {
 
122
                    anchors.verticalCenter: parent.verticalCenter
 
123
                    kflag: "no"
 
124
                    showImage: "../../img/icons/cloud-gray.png"
 
125
                }
181
126
                Text {
182
127
                    id: cursorthemelabel
183
 
                    text: qsTr("Mouse Pointer Theme")//鼠标指针主题
 
128
                    width: 160
 
129
                    text: qsTr("Mouse Pointer Theme:")//鼠标指针主题:
184
130
                    font.pixelSize: 12
185
131
                    color: "#7a7a7a"
186
132
                    anchors.verticalCenter: parent.verticalCenter
187
133
                }
188
 
 
189
134
                Common.ComboBox {
190
135
                    id: cursorcombo
191
136
                    model: choices
192
 
                    width: 150
193
 
        //            width: cursorthemelabel.width
194
 
                    onSelectedTextChanged: {/*console.log(selectedText)*/}
 
137
                    width: cursorthemelabel.width
 
138
                    onSelectedTextChanged: {
 
139
                        sessiondispatcher.set_cursor_theme_qt(cursorcombo.selectedText);
 
140
                        systemdispatcher.set_cursor_theme_with_root_qt(cursorcombo.selectedText);
 
141
                    }
195
142
                    anchors.verticalCenter: parent.verticalCenter
196
143
                }
197
 
                Common.Button {
198
 
                    id: okBtn
199
 
                    width: 94;height: 29
200
 
                    fontsize: 13
201
 
                    hoverimage: "green.png"
202
 
                    text: qsTr("OK")//确定
203
 
                    onClicked: {
204
 
                        if (mousepointerpage.selected_cursor_theme != cursorcombo.selectedText) {
205
 
                            mousepointerpage.selected_cursor_theme = cursorcombo.selectedText;
206
 
                            sessiondispatcher.set_cursor_theme_qt(cursorcombo.selectedText);
207
 
                            systemdispatcher.set_cursor_theme_with_root_qt(cursorcombo.selectedText);
208
 
                            showText.text = qsTr("[ Current Cursor Theme: ") + cursorcombo.selectedText + " ]";//[ 当前光标主题是:
209
 
                            statusImage.visible = true;
210
 
                        }
211
 
                    }
212
 
                }
213
144
            }
214
145
            Common.Button {
215
146
                hoverimage: "blue.png"
218
149
                height: 29
219
150
                fontsize: 13
220
151
                onClicked: {
221
 
                    sessiondispatcher.set_default_theme_qt("mousetheme");
222
 
                    var defaulttheme = sessiondispatcher.get_cursor_theme_qt();
223
 
//                    console.log(defaulttheme);
224
 
                    systemdispatcher.set_cursor_theme_with_root_qt(defaulttheme);
225
 
                    cursorcombo.selectedText = defaulttheme;
226
 
//                    cursorcombo.selectedIndex = mousepointerpage.default_index;
227
 
                    showText.text = qsTr("[ Current Cursor Theme: ") + cursorcombo.selectedText + " ]";//[ 当前光标主题是:
228
 
                    statusImage.visible = true;
 
152
                    //Attention:配置文件的系统默认值为:DMZ-White,而通过gsetting方法得到的默认值为:Adwaita
 
153
                    //这里我们使用配置自带的系统默认值DMZ-White
 
154
                    sessiondispatcher.set_cursor_theme_qt("DMZ-White");
 
155
                    systemdispatcher.set_cursor_theme_with_root_qt("DMZ-White");
 
156
                    cursorcombo.selectedIndex = mousepointerpage.default_index;
229
157
                }
230
158
            }
231
159
        }
232
160
 
233
 
//        Row {
234
 
//            spacing: 135
235
161
        Row {
236
 
            spacing: 20
237
 
            Text {
238
 
                id: trashlabel
239
 
                text: qsTr("Cursor Pointer Size")//光标指针大小
240
 
                font.pixelSize: 12
241
 
                color: "#7a7a7a"
242
 
                anchors.verticalCenter: parent.verticalCenter
 
162
            spacing: 314 - 16 - 20
 
163
 
 
164
            Row {
 
165
                spacing: 20
 
166
                Common.TipLabel {
 
167
                    anchors.verticalCenter: parent.verticalCenter
 
168
                    kflag: "no"
 
169
                    showImage: "../../img/icons/cloud-gray.png"
 
170
                }
 
171
                Text {
 
172
                    id: trashlabel
 
173
                    width: 160
 
174
                    text: qsTr("Cursor Pointer Size:")//光标指针大小:
 
175
                    font.pixelSize: 12
 
176
                    color: "#7a7a7a"
 
177
                    anchors.verticalCenter: parent.verticalCenter
 
178
                }
 
179
 
 
180
                Common.ButtonRow {
 
181
                    exclusive: true//控制是否联动
 
182
                    spacing: 134
 
183
                    Common.CheckBox {
 
184
                        id: smallstyle
 
185
                        checked: (mousepointerpage.cursor_size == 24) ? true : false
 
186
                        titleName: qsTr("Small Size")//24   小号
 
187
                        flag: "radio"
 
188
                        onClicked: {
 
189
                            if(smallstyle.checked == true) {
 
190
                                if(mousepointerpage.cursor_size != 24) {
 
191
                                    sessiondispatcher.set_cursor_size_qt(24);
 
192
                                    mousepointerpage.cursor_size = 24;
 
193
                                }
 
194
                            }
 
195
                        }
 
196
                    }
 
197
                    Common.CheckBox {
 
198
                        id: bigstyle
 
199
                        checked: (mousepointerpage.cursor_size == 48) ? true : false
 
200
                        titleName: qsTr("Big Size")//48    大号
 
201
                        flag: "radio"
 
202
                        onClicked: {
 
203
                            if(bigstyle.checked == true) {
 
204
                                if(mousepointerpage.cursor_size != 48) {
 
205
                                    sessiondispatcher.set_cursor_size_qt(48);
 
206
                                    mousepointerpage.cursor_size = 48;
 
207
                                }
 
208
                            }
 
209
                        }
 
210
                    }
 
211
                }
243
212
            }
244
 
 
245
 
            Common.ButtonRow {
246
 
                exclusive: true//控制是否联动
247
 
                spacing: 60
248
 
                Common.CheckBox {
249
 
                    id: smallstyle
250
 
                    checked: (mousepointerpage.cursor_size == 24) ? true : false
251
 
                    titleName: qsTr("Small Size")//24   小号
252
 
                    flag: "radio"
253
 
                    onClicked: {
254
 
                        if(smallstyle.checked == true) {
255
 
                            if(mousepointerpage.cursor_size != 24) {
256
 
                                sessiondispatcher.set_cursor_size_qt(24);
257
 
                                mousepointerpage.cursor_size = 24;
258
 
                                statusImage.visible = true;
259
 
                            }
260
 
                        }
 
213
            Common.Button {
 
214
                hoverimage: "blue.png"
 
215
                text: qsTr("Restore")//恢复默认
 
216
                width: 94
 
217
                height: 29
 
218
                fontsize: 13
 
219
                onClicked: {
 
220
                    sessiondispatcher.set_default_theme_qt("cursorsize");
 
221
                    var default_value = sessiondispatcher.get_cursor_size_qt();
 
222
                    if(default_value == 24) {
 
223
                        smallstyle.checked = true;
261
224
                    }
262
 
                }
263
 
                Common.CheckBox {
264
 
                    id: bigstyle
265
 
                    checked: (mousepointerpage.cursor_size == 36) ? true : false
266
 
                    titleName: qsTr("Big Size")//36     大号
267
 
                    flag: "radio"
268
 
                    onClicked: {
269
 
                        if(bigstyle.checked == true) {
270
 
                            if(mousepointerpage.cursor_size != 36) {
271
 
                                sessiondispatcher.set_cursor_size_qt(36);
272
 
                                mousepointerpage.cursor_size = 36;
273
 
                                statusImage.visible = true;
274
 
                            }
275
 
                        }
 
225
                    else if(default_type == 48) {
 
226
                        bigstyle.checked = true;
276
227
                    }
277
228
                }
278
229
            }
279
230
        }
280
 
//            Common.Button {
281
 
//                hoverimage: "blue.png"
282
 
//                text: qsTr("Restore")//恢复默认
283
 
//                width: 94
284
 
//                height: 29
285
 
//                fontsize: 13
286
 
//                onClicked: {
287
 
 
288
 
//                }
289
 
//            }
290
 
//        }
291
231
    }
292
232
    //顶层工具栏
293
233
    Bars.TopBar {
316
256
    Bars.ToolBar {
317
257
        id: toolBar
318
258
        showok: false
319
 
//        showrestore: true
320
259
        height: 50; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
321
260
        onQuitBtnClicked: {
322
261
            var num = sessiondispatcher.get_page_num();
330
269
                pageStack.push(functioncollection);
331
270
            }
332
271
        }
333
 
//        onRestoreBtnClicked: {
334
 
            //20140219
335
 
//            sessiondispatcher.set_default_theme_qt("mousetheme");
336
 
//            var defaulttheme = sessiondispatcher.get_cursor_theme_qt();
337
 
//            systemdispatcher.set_cursor_theme_with_root_qt(defaulttheme);
338
 
//            showText.text = qsTr("[ Current Cursor Theme: ") + defaulttheme + " ]";//[ 当前光标主题是:
339
 
//            statusImage.visible = true;
340
 
//            var defaulttheme = sessiondispatcher.read_default_configure_from_qsetting_file("theme", "cursortheme");
341
 
//            var defaultsize = sessiondispatcher.read_default_configure_from_qsetting_file("theme", "cursorsize");
342
 
 
343
 
//            if((defaulttheme == mousepointerpage.selected_cursor_theme) && (defaultsize == mousepointerpage.cursor_size)) {
344
 
//                sessiondispatcher.showWarningDialog(qsTr("Tips: "), qsTr("Cursor configure is the default configuration!"), mainwindow.pos.x, mainwindow.pos.y);//友情提示://光标配置已经为默认设置!
345
 
//            }
346
 
//            else {
347
 
//                if(defaulttheme != mousepointerpage.selected_cursor_theme) {
348
 
//                    sessiondispatcher.set_cursor_theme_qt(defaulttheme);
349
 
//                    systemdispatcher.set_cursor_theme_with_root_qt(defaulttheme);
350
 
//                    mousepointerpage.selected_cursor_theme = defaulttheme;
351
 
//                    showText.text = qsTr("[ Current Cursor Theme: ") + defaulttheme + " ]";//[ 当前光标主题是:
352
 
//                    cursorcombo.selectedIndex = 0;
353
 
//                }
354
 
//                if(defaultsize != mousepointerpage.cursor_size) {
355
 
//                    sessiondispatcher.set_cursor_size_qt(defaultsize);
356
 
//                    mousepointerpage.cursor_size = defaultsize;
357
 
//                    if(defaultsize == 24) {
358
 
//                        smallstyle.checked = true;
359
 
//                    }
360
 
//                    else if(defaultsize == 36) {
361
 
//                        bigstyle.checked = true;
362
 
//                    }
363
 
//                }
364
 
//                statusImage.visible = true;
365
 
//            }
366
 
//        }
367
 
        Timer {
368
 
             interval: 5000; running: true; repeat: true
369
 
             onTriggered: statusImage.visible = false
370
 
        }
371
272
    }
372
273
}