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

« back to all changes in this revision

Viewing changes to qml/func/settings/FcitxConfigtool.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:
 
1
import QtQuick 1.1
 
2
import SystemType 0.1
 
3
import SessionType 0.1
 
4
import FcitxCfgWizard 0.1
 
5
import "../common" as Common
 
6
import "../bars" as Bars
 
7
import "../../func"  as Func
 
8
 
 
9
Rectangle {
 
10
 
 
11
    id:fcitxconfigtool
 
12
    width: parent.width
 
13
    height: 475
 
14
    property string actiontitle: "小企鹅输入法配置"
 
15
    property string actiontext: "可以设置自己喜欢的输入方式,点击"下一步"继续设置,点击"取消"取消当前设置并返回。"
 
16
    property string selectedimage: ""
 
17
    property int leftFcitxModelindex: 0
 
18
    property int rightFcitxModelindex: 0
 
19
    property int leftScrollbar_z:-1    //设置滑动条是否隐藏
 
20
    property int rightScrollbar_z:0
 
21
    property int scrollbar_z: -1
 
22
    property int leftNum: 0
 
23
    property int rightNum:0
 
24
    property string m_separator: "<5|13)"
 
25
    signal emitFcitxRefresh;
 
26
    //背景
 
27
    Image {
 
28
        source: "../../img/skin/bg-left.png"
 
29
        anchors.fill: parent
 
30
    }
 
31
 
 
32
    //温馨提示
 
33
    Column {
 
34
        spacing: 10
 
35
        anchors.top: parent.top
 
36
        anchors.topMargin: 44
 
37
        anchors.left: parent.left
 
38
        anchors.leftMargin: 80
 
39
        Text {
 
40
             text: fcitxconfigtool.actiontitle
 
41
             font.bold: true
 
42
             font.pixelSize: 14
 
43
             color: "#383838"
 
44
         }
 
45
         Text {
 
46
             text: fcitxconfigtool.actiontext
 
47
             font.pixelSize: 12
 
48
             color: "#7a7a7a"
 
49
         }
 
50
    }
 
51
 
 
52
    function returnUnneed_data()
 
53
    {
 
54
        var returnUnneed_list = new Array
 
55
        leftFcitxModelindex =0;
 
56
        rightFcitxModelindex = 0;
 
57
        for(var i=0;i<leftNum;i++)
 
58
        {
 
59
            returnUnneed_list.push(leftFcitxModel.get(leftFcitxModelindex).itemTitle+m_separator+
 
60
                                   leftFcitxModel.get(leftFcitxModelindex).uniqueName+m_separator+
 
61
                                   leftFcitxModel.get(leftFcitxModelindex).langClde+m_separator+"true")
 
62
 
 
63
          leftFcitxModelindex++;
 
64
        }
 
65
        for(var i=0;i<rightNum;i++)
 
66
        {
 
67
            returnUnneed_list.push(rightFcitxModel.get(rightFcitxModelindex).itemTitle+m_separator+
 
68
                                   rightFcitxModel.get(rightFcitxModelindex).uniqueName+m_separator+
 
69
                                   rightFcitxModel.get(rightFcitxModelindex).langClde+m_separator+"flase")
 
70
              rightFcitxModelindex++;
 
71
        }
 
72
        console.log(leftNum+rightNum);//524
 
73
        return returnUnneed_list;
 
74
 
 
75
    }
 
76
 
 
77
    function refreshFcitxtool(){
 
78
        leftFcitxModel.clear();
 
79
        rightFcitxModel.clear();
 
80
        leftFcitxModelindex = 0;
 
81
        rightFcitxModelindex = 0;
 
82
        if(leftNum >= 2)
 
83
            downBtn.enabled =true;
 
84
        leftNum = 0;
 
85
        rightNum = 0;
 
86
        var unneed_data = fcitxcfgwizard.get_im_list();
 
87
        for (var i=0; i< unneed_data.length; i++) {
 
88
            var chooseList = unneed_data[i].split(m_separator);
 
89
            if(chooseList[3]=="true")
 
90
            {
 
91
                leftNum++;
 
92
                leftFcitxModel.append({"itemTitle": chooseList[0],"uniqueName":chooseList[1],"langClde":chooseList[2]});
 
93
            }
 
94
            else{
 
95
 
 
96
                rightNum++;
 
97
                rightFcitxModel.append({"itemTitle": chooseList[0],"uniqueName":chooseList[1],"langClde":chooseList[2]});
 
98
            }
 
99
        }
 
100
 
 
101
     pageStack.push(functioncollection);
 
102
}
 
103
    Connections {
 
104
            target: fcitxcfgwizard
 
105
            onRefreshFcitxSig: {
 
106
                refreshFcitxtool();
 
107
            }
 
108
        }
 
109
    Component.onCompleted: {
 
110
        leftFcitxModel.clear();
 
111
        rightFcitxModel.clear();
 
112
        leftFcitxModelindex = 0;
 
113
        rightFcitxModelindex = 0;
 
114
        var unneed_data = fcitxcfgwizard.get_im_list();
 
115
        if (unneed_data == "" || unneed_data.length == 0)
 
116
            unneed_data = fcitxcfgwizard.get_im_list();
 
117
        for (var i=0; i< unneed_data.length; i++) {
 
118
            var chooseList = unneed_data[i].split(m_separator);
 
119
            if(chooseList[3]=="true")
 
120
            {
 
121
                leftNum++;
 
122
                leftFcitxModel.append({"itemTitle": chooseList[0],"uniqueName":chooseList[1],"langClde":chooseList[2]});
 
123
            }
 
124
            else{
 
125
                rightNum++;
 
126
                rightFcitxModel.append({"itemTitle": chooseList[0],"uniqueName":chooseList[1],"langClde":chooseList[2]});
 
127
            }
 
128
        }
 
129
    }
 
130
 
 
131
    Text {
 
132
        id:currentMethod
 
133
        anchors {
 
134
            top: parent.top
 
135
            topMargin: 100
 
136
            left: parent.left
 
137
            leftMargin: 80
 
138
        }
 
139
        text: "当前的输入法"
 
140
        font.bold: true
 
141
        font.pixelSize: 12
 
142
        color: "#7a7a7a"
 
143
    }
 
144
    Text {
 
145
        id:choseMethod
 
146
        anchors {
 
147
            top: parent.top
 
148
            topMargin: 100
 
149
            left: parent.left
 
150
            leftMargin: 475
 
151
        }
 
152
        text: "可用的输入法"
 
153
        font.bold: true
 
154
        font.pixelSize: 12
 
155
        color: "#7a7a7a"
 
156
    }
 
157
 
 
158
    ListModel {
 
159
        id: leftFcitxModel
 
160
        ListElement {
 
161
            itemTitle: "";
 
162
            uniqueName:"";
 
163
            langClde:""
 
164
        }
 
165
    }
 
166
 
 
167
 
 
168
    ListModel {
 
169
        id: rightFcitxModel
 
170
        ListElement {
 
171
            itemTitle: "";
 
172
            uniqueName:"";
 
173
            langClde:""
 
174
        }
 
175
    }
 
176
    //左边框
 
177
    Rectangle{
 
178
        id:leftRectangle
 
179
        border.color: "#b9c5cc"
 
180
        width: 350; height: 240
 
181
        clip:true    //?
 
182
        anchors {
 
183
            top: parent.top
 
184
            topMargin: 120
 
185
            left: parent.left
 
186
            leftMargin: 80
 
187
        }
 
188
        Component{
 
189
            id:leftDelegat
 
190
            Item{
 
191
                id:wrapper
 
192
                width:350; height: 30
 
193
                Text{
 
194
                    id:listtext
 
195
                    anchors {
 
196
                        left: parent.left
 
197
                        leftMargin: 10
 
198
                        verticalCenter: parent.verticalCenter
 
199
                    }
 
200
                    font.pixelSize: 12
 
201
                    color: "#7a7a7a"
 
202
                    text:itemTitle
 
203
                }
 
204
                Text{
 
205
                    id:listtext2
 
206
                    anchors {
 
207
                        left: listtext.right
 
208
                        leftMargin: 10
 
209
                        verticalCenter: parent.verticalCenter
 
210
                    }
 
211
                    font.pixelSize: 12
 
212
                    color: "#7a7a7a"
 
213
                    text:uniqueName
 
214
                }
 
215
                Text{
 
216
                    id:listtext3
 
217
                    anchors {
 
218
                        left: listtext2.right
 
219
                        leftMargin: 10
 
220
                        verticalCenter: parent.verticalCenter
 
221
                    }
 
222
                    font.pixelSize: 12
 
223
                    color: "#7a7a7a"
 
224
                    text:langClde
 
225
                }
 
226
                MouseArea{
 
227
                    anchors.fill:parent
 
228
                    hoverEnabled: true
 
229
                    onClicked: {
 
230
                        upBtn.enabled = true
 
231
                      wrapper.ListView.view.currentIndex = index; //?
 
232
                        leftFcitxModelindex = wrapper.ListView.view.currentIndex;
 
233
                        if(leftFcitxModelindex==0)
 
234
                        {
 
235
                             upBtn.enabled = false;
 
236
                        }
 
237
                        else
 
238
                        {
 
239
                             upBtn.enabled = true;
 
240
                        }
 
241
                        if(leftFcitxModelindex==leftNum-1)
 
242
                        {
 
243
                            downBtn.enabled = false;
 
244
                        }
 
245
                        else
 
246
                        {
 
247
                            downBtn.enabled = true;
 
248
                        }
 
249
                    }
 
250
                }
 
251
 
 
252
            }
 
253
        }
 
254
        ListView{
 
255
            id:leftLisv
 
256
            anchors.fill: parent
 
257
            model: leftFcitxModel
 
258
            delegate: leftDelegat
 
259
            highlight: Rectangle{width: 340;height: 30 ; color: "lightsteelblue"}
 
260
            focus:true
 
261
        }
 
262
 
 
263
        Rectangle{
 
264
            id:leftScrollbar
 
265
            anchors.right: parent.right
 
266
            anchors.rightMargin: -1
 
267
            height: parent.height
 
268
//            z:scrollbar_z
 
269
            width:11
 
270
            color: "lightgrey"
 
271
        }
 
272
        Rectangle{
 
273
            id: leftButton
 
274
            anchors.right: parent.right
 
275
            anchors.rightMargin: 0
 
276
            width: 10
 
277
            y: leftLisv.visibleArea.yPosition * leftScrollbar.height    //?
 
278
            height: leftLisv.visibleArea.heightRatio * leftScrollbar.height; //?
 
279
            radius: 3
 
280
            smooth: true
 
281
            color: "white"
 
282
            border.color: "lightgrey"
 
283
            Column{
 
284
                anchors.verticalCenter: parent.verticalCenter
 
285
                anchors.horizontalCenter: parent.horizontalCenter
 
286
                spacing: 2
 
287
                Rectangle{
 
288
                    width: 8;height: 1
 
289
                    color: "lightgrey"
 
290
                }
 
291
                Rectangle{
 
292
                    width: 8;height: 1
 
293
                    color: "lightgrey"
 
294
                }
 
295
                Rectangle{
 
296
                    width: 8;height: 1
 
297
                    color: "lightgrey"
 
298
                }
 
299
            }
 
300
            MouseArea {
 
301
                id: mousearea
 
302
                anchors.fill: leftButton
 
303
                drag.target: leftButton
 
304
                drag.axis: Drag.YAxis
 
305
                drag.minimumY: 0
 
306
                drag.maximumY: leftScrollbar.height - leftButton.height
 
307
                onMouseYChanged: {
 
308
                    leftLisv.contentY = leftButton.y / leftScrollbar.height * leftLisv.contentHeight //?
 
309
                }
 
310
            }
 
311
        }
 
312
    }
 
313
 
 
314
    //右边框
 
315
    Column{
 
316
        id:rightColum
 
317
        anchors {
 
318
            top: parent.top
 
319
            topMargin: 120
 
320
            left: parent.left
 
321
            leftMargin: 475
 
322
        }
 
323
        spacing: 10
 
324
        Rectangle{
 
325
            id:rightRectangle
 
326
            border.color: "#b9c5cc"
 
327
            width: 350; height: 240
 
328
            clip:true
 
329
            Component{
 
330
                id:rightDelegat
 
331
                Item{
 
332
                    id:wrapper
 
333
                    state: "transparentColor"
 
334
                    width: 280; height: 30
 
335
                    Text{
 
336
                        id:listtext
 
337
                        anchors {
 
338
                            left: parent.left
 
339
                            leftMargin: 10
 
340
                            verticalCenter: parent.verticalCenter
 
341
                        }
 
342
                        font.pixelSize: 12
 
343
                        color: "#7a7a7a"
 
344
                        text:itemTitle
 
345
                    }
 
346
                    Text{
 
347
                        id:listtext2
 
348
                        anchors {
 
349
                            left: listtext.right
 
350
                            leftMargin: 10
 
351
                            verticalCenter: parent.verticalCenter
 
352
                        }
 
353
                        font.pixelSize: 12
 
354
                        color: "#7a7a7a"
 
355
                        text:uniqueName
 
356
                    }
 
357
                    Text{
 
358
                        width: 20
 
359
                        id:listtext3
 
360
                        anchors {
 
361
                            left: listtext2.right
 
362
                            leftMargin: 10
 
363
                            verticalCenter: parent.verticalCenter
 
364
                        }
 
365
                        font.pixelSize: 12
 
366
                        color: "#7a7a7a"
 
367
                        text:langClde
 
368
                    }
 
369
                    MouseArea{
 
370
                        anchors.fill:parent
 
371
                        hoverEnabled: true
 
372
                        onClicked: {
 
373
//                            okBtn.enabled = true;
 
374
//                            okBtn.hoverimage = "list_item_active.png";
 
375
                            wrapper.ListView.view.currentIndex = index; //?
 
376
                            state = "lightsteelblueColor";
 
377
                            rightFcitxModelindex = index;
 
378
 
 
379
                        }
 
380
                    }
 
381
                }
 
382
            }
 
383
            ListView{
 
384
                id:rightLisv
 
385
                anchors.fill: parent
 
386
                model: rightFcitxModel
 
387
                delegate: rightDelegat
 
388
                highlightMoveSpeed: 9999999
 
389
                highlight: Rectangle{width: 350;height: 30 ; color: "lightsteelblue"}
 
390
                    
 
391
            }
 
392
 
 
393
            Rectangle{
 
394
                id:rightscrollbar
 
395
                anchors.right: parent.right
 
396
                anchors.rightMargin: -1
 
397
                height: parent.height
 
398
//                z:scrollbar_z
 
399
                width:11
 
400
                color: "lightgrey"
 
401
            }
 
402
            Rectangle{
 
403
                id: rightbutton
 
404
                anchors.right: parent.right
 
405
                anchors.rightMargin: 0
 
406
                width: 10
 
407
                y: rightLisv.visibleArea.yPosition * rightscrollbar.height    //?
 
408
                height: 10*(rightLisv.visibleArea.heightRatio * rightscrollbar.height); //?
 
409
//                height:20
 
410
                radius: 3
 
411
                smooth: true
 
412
                color: "white"
 
413
                border.color: "lightgrey"
 
414
                Column{
 
415
                    anchors.verticalCenter: parent.verticalCenter
 
416
                    anchors.horizontalCenter: parent.horizontalCenter
 
417
                    spacing: 2
 
418
                    Rectangle{
 
419
                        width: 8;height: 1
 
420
                        color: "lightgrey"
 
421
                    }
 
422
                    Rectangle{
 
423
                        width: 8;height: 1
 
424
                        color: "lightgrey"
 
425
                    }
 
426
                    Rectangle{
 
427
                        width: 8;height: 1
 
428
                        color: "lightgrey"
 
429
                    }
 
430
                }
 
431
                MouseArea {
 
432
                    id: rightmousearea
 
433
                    anchors.fill: rightbutton
 
434
                    drag.target: rightbutton
 
435
                    drag.axis: Drag.YAxis
 
436
                    drag.minimumY: 0
 
437
                    drag.maximumY: rightscrollbar.height - rightbutton.height/10
 
438
                    onMouseYChanged: {
 
439
                        rightLisv.contentY = rightbutton.y / rightscrollbar.height * rightLisv.contentHeight //?
 
440
                    }
 
441
                }
 
442
            }
 
443
        }
 
444
    }
 
445
        //提示
 
446
        Text {
 
447
            id:prompt
 
448
            anchors {
 
449
                top: parent.top
 
450
                topMargin: 400
 
451
                left: parent.left
 
452
                leftMargin: 80
 
453
            }
 
454
            text: qsTr("提示:'+'可以将可用输入法加入当前输入法,'-'删除当前选中输入法,'▲'和'▼'改变选中输入法的位置")
 
455
            font.bold: true
 
456
            font.pixelSize: 12
 
457
            color: "#7a7a7a"
 
458
        }
 
459
        Row{
 
460
            spacing: 5
 
461
            anchors{
 
462
        //     top:parent.top
 
463
        //     topMargin: 190
 
464
        //     left: parent.left
 
465
        //     leftMargin:410
 
466
                left: parent.left
 
467
                leftMargin: 80;
 
468
                top:leftRectangle.bottom
 
469
                topMargin: 10
 
470
 
 
471
            }
 
472
        Common.Button{
 
473
            id:addBtn
 
474
            width:60
 
475
            height:20
 
476
            //hoverimage: "list_item_active.png"
 
477
            text:"+"
 
478
            onClicked: {
 
479
                leftFcitxModel.append({"itemTitle":rightFcitxModel.get(rightFcitxModelindex).itemTitle,
 
480
                                       "uniqueName" :rightFcitxModel.get(rightFcitxModelindex).uniqueName,
 
481
                                       "langClde" :rightFcitxModel.get(rightFcitxModelindex).langClde})
 
482
                rightFcitxModel.remove(rightFcitxModelindex);
 
483
                leftNum++;
 
484
                rightNum--;
 
485
 
 
486
                cutBtn.enabled = true;
 
487
                if((leftFcitxModelindex==0)&&(leftNum>1))
 
488
                downBtn.enabled = true;
 
489
 
 
490
            }
 
491
        }
 
492
        Common.Button{
 
493
            id:cutBtn
 
494
            width:60
 
495
            height:20
 
496
            text: "-"
 
497
            onClicked: {
 
498
                rightFcitxModel.append({"itemTitle":leftFcitxModel.get(leftFcitxModelindex).itemTitle,
 
499
                                       "uniqueName" :leftFcitxModel.get(leftFcitxModelindex).uniqueName,
 
500
                                        "langClde" :leftFcitxModel.get(leftFcitxModelindex).langClde})
 
501
                leftFcitxModel.remove(leftFcitxModelindex);
 
502
                leftNum--;
 
503
                rightNum++;
 
504
 
 
505
                if((leftFcitxModelindex==leftNum)&&(leftFcitxModelindex!=0))
 
506
                {
 
507
                    leftFcitxModelindex--;
 
508
                }
 
509
                if(leftFcitxModelindex==0)
 
510
                {
 
511
                    leftFcitxModelindex =0;
 
512
                }
 
513
                if(leftNum==0)
 
514
                {
 
515
                    cutBtn.enabled = false;
 
516
                    upBtn.enabled = false;
 
517
                    downBtn.enabled = false;
 
518
                }
 
519
            }
 
520
        }
 
521
        Common.Button{
 
522
            id:upBtn
 
523
            width:60
 
524
            height:20
 
525
            enabled: false
 
526
            text:"▲"
 
527
            onClicked: {
 
528
                if(leftFcitxModelindex==0)
 
529
                {
 
530
                    upBtn.enabled = false
 
531
                }
 
532
                if(leftFcitxModelindex>0)
 
533
                {
 
534
                    downBtn.enabled = true
 
535
                    leftFcitxModel.move(leftFcitxModelindex,leftFcitxModelindex-1,1)
 
536
                    leftFcitxModelindex=leftFcitxModelindex-1;
 
537
                    if((leftFcitxModelindex==0)||(leftNum == 0))
 
538
                    {
 
539
                        upBtn.enabled = false
 
540
                    }
 
541
 
 
542
                }
 
543
 
 
544
            }
 
545
        }
 
546
        Common.Button{
 
547
            id:downBtn
 
548
            width:60
 
549
            height:20
 
550
            text: "▼"
 
551
            onClicked: {
 
552
                if((leftFcitxModelindex==leftNum-1)||(leftNum==0))
 
553
                {
 
554
                    downBtn.enabled = false;
 
555
                }
 
556
                if(leftFcitxModelindex<leftNum-1)
 
557
                {
 
558
                    upBtn.enabled = true;
 
559
                    leftFcitxModel.move(leftFcitxModelindex,leftFcitxModelindex+1,1)
 
560
                    leftFcitxModelindex=leftFcitxModelindex+1;
 
561
 
 
562
                    if((leftFcitxModelindex==leftNum-1)||(leftNum==0))
 
563
                    {
 
564
                        downBtn.enabled = false
 
565
 
 
566
                    }
 
567
                }
 
568
            }
 
569
        }
 
570
    }
 
571
    //顶层工具栏
 
572
    Bars.TopBar {
 
573
        id: topBar
 
574
        width: 28
 
575
        height: 26
 
576
        anchors.top: parent.top
 
577
        anchors.topMargin: 40
 
578
        anchors.left: parent.left
 
579
        anchors.leftMargin: 40
 
580
        opacity: 0.9
 
581
        onButtonClicked: {
 
582
            var num = sessiondispatcher.get_page_num();
 
583
            if (num == 0)
 
584
                pageStack.push(homepage)
 
585
            else if (num == 3)
 
586
                pageStack.push(systemset)
 
587
            else if (num == 4)
 
588
                pageStack.push(functioncollection)
 
589
        }
 
590
    }
 
591
 
 
592
    //底层工具栏
 
593
    Bars.FcitxBar{
 
594
        id: toolBar
 
595
        height: 50; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
 
596
//            button1Label: qsTr("取消")
 
597
//            button2Label: qsTr("上一步")
 
598
//            button3Label: qsTr("下一步")
 
599
        onCancelBtnClicked: {
 
600
            fcitxcfgwizard.send_fcitx_ok_warn();
 
601
        }
 
602
        onGobackBtnClicked: {
 
603
                pageStack.push(functioncollection)
 
604
        }
 
605
        onContinueBtnClicked: {         
 
606
            pageStack.push(fcitxConfigtoolFontpage);//静态添加页
 
607
            fcitxcfgwizard.set_im_list(returnUnneed_data(),false);
 
608
 
 
609
        }
 
610
    }
 
611
}
 
612