aboutsummaryrefslogtreecommitdiffstats
path: root/qml/ImageButton.qml
blob: 7aaba27375d477ad507271be97e50081331b33ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

 Rectangle {
     id: container

     property string text: "Button"
     property string image: ""

     signal clicked

     width: buttonLabel.width + 5
     height: buttonLabel.height + buttonImage.height + 5
     //width: 60
     //height: 60
     //border { width: 1; color: Qt.darker(activePalette.button) }
     //smooth: true
     radius: 8
     color: ffffff;

     /*gradient: Gradient {
         GradientStop {
             position: 0.0
             color: !mouseArea.pressed ? activePalette.light : activePalette.button
         }
         GradientStop {
             position: 1.0
             color: !mouseArea.pressed ? activePalette.button : activePalette.dark
         }
     }*/

     SystemPalette { id: activePalette }
//     // color the button with a gradient
//     gradient: Gradient {
//         GradientStop {
//             position: 0.0
//             color: {
//                 if (mouseArea.pressed)
//                     return activePalette.dark
//                 else
//                     return activePalette.light
//             }
//         }
//         GradientStop { position: 1.0; color: activePalette.button }
//     }

     MouseArea {
         id: mouseArea
         anchors.fill: parent
         onClicked: container.clicked();
     }

     Image {
         id: buttonImage
         y: 5
         source: container.image
         height: 30
         width: 30
         anchors.horizontalCenter: parent.horizontalCenter
         //anchors.fill: parent
     }

     Text {
         id: buttonLabel
         //anchors.centerIn: container
         anchors { top: buttonImage.bottom; horizontalCenter: parent.horizontalCenter }
         color: activePalette.buttonText
         text: container.text
         horizontalAlignment: Text.AlignLeft
     }
 }