| 1 |
import QtQuick 2.0 |
| 2 |
import FlightGear 1.0 |
| 3 |
|
| 4 |
Rectangle { |
| 5 |
id: root |
| 6 |
radius: Style.roundRadius |
| 7 |
border.width: 1 |
| 8 |
border.color: Style.themeColor |
| 9 |
width: height |
| 10 |
height: Style.baseFontPixelSize + Style.margin * 2 |
| 11 |
color: mouse.containsMouse ? Style.minorFrameColor : Style.backgroundColor |
| 12 |
|
| 13 |
property bool gridMode: false |
| 14 |
|
| 15 |
signal clicked(); |
| 16 |
|
| 17 |
Image { |
| 18 |
id: icon |
| 19 |
width: parent.width - Style.margin |
| 20 |
height: parent.height - Style.margin |
| 21 |
anchors.centerIn: parent |
| 22 |
|
| 23 |
readonly property string __iconSuffix: mouse.containsMouse ? "?theme" : "?text" |
| 24 |
source: (root.gridMode ? "image://colored-icon/grid-view" |
| 25 |
: "image://colored-icon/list-view") + __iconSuffix |
| 26 |
} |
| 27 |
|
| 28 |
MouseArea { |
| 29 |
id: mouse |
| 30 |
hoverEnabled: true |
| 31 |
onClicked: root.clicked(); |
| 32 |
anchors.fill: parent |
| 33 |
} |
| 34 |
|
| 35 |
Text { |
| 36 |
anchors.left: root.right |
| 37 |
anchors.leftMargin: Style.margin |
| 38 |
anchors.verticalCenter: root.verticalCenter |
| 39 |
visible: mouse.containsMouse |
| 40 |
color: Style.baseTextColor |
| 41 |
font.pixelSize: Style.baseFontPixelSize |
| 42 |
text: root.gridMode ? qsTr("Switch to grid view") |
| 43 |
: qsTr("Switch to list view") |
| 44 |
} |
| 45 |
} |