From a23da2c6c44c35eb46897e93d08f5559c0b20a8e Mon Sep 17 00:00:00 2001 From: davidsastresas Date: Thu, 5 Oct 2023 01:30:46 +0200 Subject: [PATCH] ToolStripHoverButton.qml: Add some new features --- src/QmlControls/ToolStripHoverButton.qml | 40 ++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/QmlControls/ToolStripHoverButton.qml b/src/QmlControls/ToolStripHoverButton.qml index 510e595..0af34cb 100644 --- a/src/QmlControls/ToolStripHoverButton.qml +++ b/src/QmlControls/ToolStripHoverButton.qml @@ -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) @@ -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 @@ -77,6 +94,23 @@ 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 { @@ -84,6 +118,8 @@ Button { text: control.text color: _currentContentColor anchors.horizontalCenter: parent.horizontalCenter + font.bold: !innerImage.visible && !innerImageColorful.visible + opacity: !innerImage.visible ? 0.8 : 1.0 } } }