Skip to content

Commit

Permalink
ToolStripHoverButton.qml: Add some new features
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidsastresas authored and julianoes committed Apr 11, 2024
1 parent e01a83f commit a23da2c
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/QmlControls/ToolStripHoverButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ Button {
property alias imageSource: innerImage.source
property alias contentWidth: innerText.contentWidth

property real imageScale: 0.6
property real contentMargins: innerText.height * 0.1
property bool forceImageScale11: false
property real imageScale: forceImageScale11 && (text == "") ? 0.8 : 0.6
property real contentMargins: innerText.height * 0.1

property color _currentContentColor: (checked || pressed) ? qgcPal.buttonHighlightText : qgcPal.buttonText
property color _currentContentColorSecondary: (checked || pressed) ? qgcPal.buttonText : qgcPal.buttonHighlight

signal dropped(int index)

Expand Down Expand Up @@ -65,6 +67,21 @@ Button {
anchors.centerIn: parent
spacing: contentMargins * 2

Image {
id: innerImageColorful
height: contentLayoutItem.height * imageScale
width: contentLayoutItem.width * imageScale
smooth: true
mipmap: true
fillMode: Image.PreserveAspectFit
antialiasing: true
sourceSize.height: height
sourceSize.width: width
anchors.horizontalCenter: parent.horizontalCenter
source: control.imageSource
visible: source != "" && modelData.fullColorIcon
}

QGCColoredImage {
id: innerImage
height: contentLayoutItem.height * imageScale
Expand All @@ -77,13 +94,32 @@ Button {
sourceSize.height: height
sourceSize.width: width
anchors.horizontalCenter: parent.horizontalCenter
visible: source != "" && !modelData.fullColorIcon

QGCColoredImage {
id: innerImageSecondColor
source: modelData.alternateIconSource
height: contentLayoutItem.height * imageScale
width: contentLayoutItem.width * imageScale
smooth: true
mipmap: true
color: _currentContentColorSecondary
fillMode: Image.PreserveAspectFit
antialiasing: true
sourceSize.height: height
sourceSize.width: width
anchors.horizontalCenter: parent.horizontalCenter
visible: source != "" && modelData.biColorIcon
}
}

QGCLabel {
id: innerText
text: control.text
color: _currentContentColor
anchors.horizontalCenter: parent.horizontalCenter
font.bold: !innerImage.visible && !innerImageColorful.visible
opacity: !innerImage.visible ? 0.8 : 1.0
}
}
}
Expand Down

0 comments on commit a23da2c

Please sign in to comment.