|
|
@ -8,26 +8,25 @@ import QGroundControl.Palette 1.0 |
|
|
|
|
|
|
|
|
|
|
|
// TODO: use QT palette |
|
|
|
// TODO: use QT palette |
|
|
|
Button { |
|
|
|
Button { |
|
|
|
id: button |
|
|
|
id: button |
|
|
|
width: columnItem.contentWidth + contentLayoutItem.margins * 2 |
|
|
|
width: contentLayoutItem.contentWidth + (contentMargins * 2) |
|
|
|
height: width |
|
|
|
height: width |
|
|
|
flat: true |
|
|
|
flat: true |
|
|
|
|
|
|
|
|
|
|
|
property color borderColor: qgcPal.windowShadeDark |
|
|
|
property color borderColor: qgcPal.windowShadeDark |
|
|
|
|
|
|
|
|
|
|
|
property alias radius: buttonBkRect.radius |
|
|
|
property alias radius: buttonBkRect.radius |
|
|
|
property alias fontPointSize: innerText.font.pointSize |
|
|
|
property alias fontPointSize: innerText.font.pointSize |
|
|
|
property alias imageSource: innerImage.source |
|
|
|
property alias imageSource: innerImage.source |
|
|
|
property alias contentWidth: innerText.contentWidth |
|
|
|
property alias contentWidth: innerText.contentWidth |
|
|
|
|
|
|
|
|
|
|
|
property real imageScale: 0.8 |
|
|
|
property real imageScale: 0.6 |
|
|
|
property real borderWidth: 0 |
|
|
|
property real borderWidth: 0 |
|
|
|
property real contentMargins: innerText.height * 0.1 |
|
|
|
property real contentMargins: innerText.height * 0.1 |
|
|
|
|
|
|
|
|
|
|
|
property color _currentColor: qgcPal.button |
|
|
|
property color _currentColor: qgcPal.button |
|
|
|
property color _currentContentColor: qgcPal.buttonText |
|
|
|
property color _currentContentColor: qgcPal.buttonText |
|
|
|
|
|
|
|
|
|
|
|
QGCPalette { id: qgcPal } |
|
|
|
|
|
|
|
QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false } |
|
|
|
QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false } |
|
|
|
|
|
|
|
|
|
|
|
// Initial state |
|
|
|
// Initial state |
|
|
@ -35,70 +34,43 @@ Button { |
|
|
|
// Update state on status changed |
|
|
|
// Update state on status changed |
|
|
|
onEnabledChanged: state = "Default" |
|
|
|
onEnabledChanged: state = "Default" |
|
|
|
|
|
|
|
|
|
|
|
property real _contentVDist: innerImage.height/innerText.contentHeight |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Content Icon + Text |
|
|
|
// Content Icon + Text |
|
|
|
contentItem: Item { |
|
|
|
contentItem: Item { |
|
|
|
id: contentLayoutItem |
|
|
|
id: contentLayoutItem |
|
|
|
anchors.fill: parent |
|
|
|
anchors.fill: parent |
|
|
|
anchors.margins: contentMargins |
|
|
|
anchors.margins: contentMargins |
|
|
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
Column { |
|
|
|
id: columnItem |
|
|
|
anchors.centerIn: parent |
|
|
|
anchors.fill: parent |
|
|
|
spacing: contentMargins * 2 |
|
|
|
|
|
|
|
QGCColoredImage { |
|
|
|
Item { |
|
|
|
id: innerImage |
|
|
|
width: parent.width |
|
|
|
height: contentLayoutItem.height * imageScale |
|
|
|
height: (contentLayoutItem.height - innerText.height) |
|
|
|
width: contentLayoutItem.width * imageScale |
|
|
|
Image { |
|
|
|
smooth: true |
|
|
|
id: innerImage |
|
|
|
mipmap: true |
|
|
|
|
|
|
|
color: _currentContentColor |
|
|
|
anchors.centerIn: parent |
|
|
|
fillMode: Image.PreserveAspectFit |
|
|
|
|
|
|
|
antialiasing: true |
|
|
|
height: parent.height * imageScale |
|
|
|
sourceSize.height: height |
|
|
|
width: parent.width * imageScale |
|
|
|
sourceSize.width: width |
|
|
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
|
visible: false |
|
|
|
|
|
|
|
smooth: true |
|
|
|
|
|
|
|
antialiasing: true |
|
|
|
|
|
|
|
mipmap: true |
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectFit |
|
|
|
|
|
|
|
sourceSize.height: height |
|
|
|
|
|
|
|
sourceSize.width: width |
|
|
|
|
|
|
|
horizontalAlignment: Image.AlignHCenter |
|
|
|
|
|
|
|
verticalAlignment: Image.AlignVCenter |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ColorOverlay { |
|
|
|
|
|
|
|
id: imageOverlay |
|
|
|
|
|
|
|
anchors.fill: innerImage |
|
|
|
|
|
|
|
source: innerImage |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
color: _currentContentColor |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
QGCLabel { |
|
|
|
Text { |
|
|
|
id: innerText |
|
|
|
id: innerText |
|
|
|
text: button.text |
|
|
|
text: button.text |
|
|
|
color: _currentContentColor |
|
|
|
color: _currentContentColor |
|
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
|
width: parent.width |
|
|
|
|
|
|
|
font.family: ScreenTools.normalFontFamily |
|
|
|
|
|
|
|
font.pointSize: ScreenTools.defaultFontPointSize |
|
|
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter |
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} // Column - content |
|
|
|
} |
|
|
|
} // Item - content |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
background: Rectangle { |
|
|
|
background: Rectangle { |
|
|
|
id: buttonBkRect |
|
|
|
id: buttonBkRect |
|
|
|
anchors.fill: parent |
|
|
|
color: _currentColor |
|
|
|
color: _currentColor |
|
|
|
visible: !flat |
|
|
|
visible: !flat |
|
|
|
border.width: borderWidth |
|
|
|
|
|
|
|
border.color: borderColor |
|
|
|
border.width: borderWidth |
|
|
|
anchors.fill: parent |
|
|
|
border.color: borderColor |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Change the colors based on button states |
|
|
|
// Change the colors based on button states |
|
|
@ -142,11 +114,11 @@ Button { |
|
|
|
|
|
|
|
|
|
|
|
// Process hover events |
|
|
|
// Process hover events |
|
|
|
MouseArea { |
|
|
|
MouseArea { |
|
|
|
enabled: !ScreenTools.isMobile |
|
|
|
enabled: !ScreenTools.isMobile |
|
|
|
hoverEnabled: true |
|
|
|
hoverEnabled: true |
|
|
|
propagateComposedEvents: true |
|
|
|
propagateComposedEvents: true |
|
|
|
preventStealing: true |
|
|
|
preventStealing: true |
|
|
|
anchors.fill: button |
|
|
|
anchors.fill: button |
|
|
|
onEntered: { button.state = 'Hovering'; } |
|
|
|
onEntered: { button.state = 'Hovering'; } |
|
|
|
onExited: { button.state = 'Default'; } |
|
|
|
onExited: { button.state = 'Default'; } |
|
|
|
// Propagate events down |
|
|
|
// Propagate events down |
|
|
|