~ubuntu-branches/ubuntu/utopic/youker-assistant/utopic-proposed

« back to all changes in this revision

Viewing changes to qml/MonitorBall.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:
1
 
import QtQuick 1.1
2
 
import SystemType 0.1
3
 
import "./func/common" as Common
4
 
Rectangle {
5
 
    id:sfloat
6
 
    width: 83
7
 
    height: 48
8
 
    color: "transparent"
9
 
    radius: 5
10
 
    property string up_speed: "0"
11
 
    property string down_speed: "0"
12
 
    property double memory_ratio: 0.0
13
 
    signal send_signal_to_large;
14
 
 
15
 
 
16
 
    function receive_data(value, up, down) {
17
 
        sfloat.memory_ratio = value;
18
 
        sfloat.up_speed = up;
19
 
        sfloat.down_speed = down;
20
 
    }
21
 
 
22
 
    Component.onCompleted: {
23
 
        sfloat.memory_ratio = systemdispatcher.get_used_memory_qt()/systemdispatcher.get_total_memory_qt();
24
 
        sfloat.memory_ratio = Math.round(sfloat.memory_ratio*100)/100 * 100
25
 
    }
26
 
    SystemDispatcher {
27
 
        id: systemdispatcher
28
 
    }
29
 
 
30
 
    function show_float_frame() {
31
 
        if (sfloat.visible == true)
32
 
            sfloat.visible = false;
33
 
        else if (sfloat.visible == false)
34
 
            sfloat.visible = true;
35
 
    }
36
 
    Image {
37
 
        id: background
38
 
        source: "./img/skin/accelerate-bg0.png"
39
 
    }
40
 
    Column{
41
 
        anchors{
42
 
            bottom:parent.bottom
43
 
            bottomMargin: 6
44
 
            left: parent.left
45
 
            leftMargin: 22
46
 
        }
47
 
        spacing: 3
48
 
        Text {
49
 
            id:upload
50
 
            text: sfloat.up_speed + "K/s"
51
 
            font.pixelSize: 10
52
 
            color: "#7a7a7a"
53
 
        }
54
 
        Text {
55
 
            id:download
56
 
            text: sfloat.down_speed + "K/s"
57
 
            font.pixelSize: 10
58
 
            color: "#7a7a7a"
59
 
        }
60
 
    }
61
 
    Rectangle{
62
 
        id:ball
63
 
        width: 31;height: 31
64
 
//        border.color: "grey"
65
 
        radius:2
66
 
        z:1
67
 
        smooth:true
68
 
        anchors{
69
 
            right: parent.right
70
 
            rightMargin: 1
71
 
            bottom:parent.bottom
72
 
            bottomMargin: 2
73
 
        }
74
 
        Image {
75
 
            source: "./img/skin/blister-small.png"
76
 
        }
77
 
        Text {
78
 
            id: cpu
79
 
            text: sfloat.memory_ratio + "%";
80
 
            font.pointSize: 8
81
 
            anchors.centerIn: parent
82
 
        }
83
 
        gradient: Gradient{
84
 
            GradientStop{position: 0.0; color: (sfloat.memory_ratio == 100) ? "#ff2400" : "transparent"}
85
 
 
86
 
            GradientStop{position: 1.0 - sfloat.memory_ratio * 0.01; color: (sfloat.memory_ratio == 100) ? "#ff2400" : "transparent"}
87
 
            GradientStop{position: (sfloat.memory_ratio <= 0) ? 0.0 : (1.0 - sfloat.memory_ratio * 0.01 + 0.01);
88
 
                color: {
89
 
                    if(sfloat.memory_ratio > 60)
90
 
                        "#ff2400"
91
 
                    else if (sfloat.memory_ratio == 0)
92
 
                        "transparent"
93
 
                    else
94
 
                        "#0084ff"
95
 
                }
96
 
            }
97
 
            GradientStop{position: 1.0; color: {
98
 
                    if (sfloat.memory_ratio == 0)
99
 
                        "transparent"
100
 
                    else if (sfloat.memory_ratio > 60)
101
 
                        "#ff2400"
102
 
                    else
103
 
                        "#0084ff"
104
 
                }
105
 
            }
106
 
        }
107
 
        MouseArea{
108
 
            anchors.fill: parent
109
 
            onClicked: {
110
 
                send_signal_to_large();
111
 
            }
112
 
        }
113
 
    }
114
 
 
115
 
    MouseArea {
116
 
        anchors.fill: sfloat
117
 
        acceptedButtons : Qt.RightButton
118
 
        onClicked: {
119
 
            if (sfloat.visible == true)
120
 
                sfloat.visible = false;
121
 
            sfloat.focus = false;
122
 
        }
123
 
    }
124
 
    MouseArea {
125
 
        anchors.fill: sfloat
126
 
        property variant clickPos: "1,1"
127
 
        onPressed: {
128
 
            clickPos  = Qt.point(mouse.x,mouse.y)
129
 
        }
130
 
        onPositionChanged: {
131
 
            var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
132
 
            smallwindow.pos = Qt.point(smallwindow.pos.x+delta.x,
133
 
                              smallwindow.pos.y+delta.y)
134
 
        }
135
 
    }
136
 
}