~ubuntu-branches/ubuntu/vivid/muon/vivid-proposed

« back to all changes in this revision

Viewing changes to discover/qml/InstallApplicationButton.qml

Tags: upstream-1.3.65
ImportĀ upstreamĀ versionĀ 1.3.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 1.1
 
2
import org.kde.plasma.components 0.1
 
3
import org.kde.qtextracomponents 0.1
 
4
import org.kde.muon 1.0
 
5
 
 
6
Item {
 
7
    id: item
 
8
    property alias application: transactions.application
 
9
    property bool canHide: parent.state=="idle"
 
10
    property bool preferUpgrade: false
 
11
    property alias isInstalling: transactions.isActive
 
12
    width: 100
 
13
    height: 30
 
14
    
 
15
    TransactionListener {
 
16
        id: transactions
 
17
        backend: app.appBackend
 
18
    }
 
19
    
 
20
    Button {
 
21
        id: button
 
22
        visible: parent.state=="idle"
 
23
        width: parent.width
 
24
        anchors.fill: parent
 
25
        
 
26
        onClicked: {
 
27
            switch(state) {
 
28
                case "willupgrade":
 
29
                case "willinstall": app.appBackend.installApplication(application); break;
 
30
                case "willremove":  app.appBackend.removeApplication(application); break;
 
31
            }
 
32
        }
 
33
        
 
34
        states: [
 
35
            State {
 
36
                name: "willupgrade"
 
37
                when: application.canUpgrade && item.preferUpgrade
 
38
                PropertyChanges { target: button;  text: i18n("Upgrade") }
 
39
            },
 
40
            State {
 
41
                name: "willinstall"
 
42
                when: !application.isInstalled
 
43
                PropertyChanges { target: button;  text: i18n("Install") }
 
44
            },
 
45
            State {
 
46
                name: "willremove"
 
47
                when: application.isInstalled
 
48
                PropertyChanges { target: button;  text: i18n("Remove") }
 
49
            }
 
50
        ]
 
51
    }
 
52
    
 
53
    Item {
 
54
        visible: parent.state=="working"
 
55
        anchors.fill: parent
 
56
        height: workingCancelButton.height
 
57
        
 
58
        Label {
 
59
            id: workingLabel
 
60
            anchors {
 
61
                verticalCenter: parent.verticalCenter
 
62
                left: parent.left
 
63
                right: workingCancelButton.left
 
64
            }
 
65
            text: transactions.comment
 
66
        }
 
67
        
 
68
        Button {
 
69
            id: workingCancelButton
 
70
            anchors.verticalCenter: parent.verticalCenter
 
71
            anchors.right: parent.right
 
72
            iconSource: "dialog-cancel"
 
73
            enabled: transactions.isDownloading
 
74
            onClicked: app.appBackend.cancelTransaction(application)
 
75
        }
 
76
    }
 
77
    
 
78
    states: [
 
79
        State {
 
80
            name: "idle"
 
81
            when: !transactions.isActive
 
82
        },
 
83
        State {
 
84
            name: "working"
 
85
            when: transactions.isActive
 
86
        }
 
87
    ]
 
88
}
 
 
b'\\ No newline at end of file'