mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
Welcome page: display tooltips below buttons if necessary
Useful on low res screen, to ensure tooltips are visible
This commit is contained in:
parent
69bd17c6a8
commit
89023e8c41
@ -5,6 +5,7 @@ Item {
|
|||||||
id: welcomeButton
|
id: welcomeButton
|
||||||
width: Math.max(116, icon.width)
|
width: Math.max(116, icon.width)
|
||||||
height: 116
|
height: 116
|
||||||
|
z: 0
|
||||||
|
|
||||||
property string baseIconName
|
property string baseIconName
|
||||||
property alias label : labelText.text
|
property alias label : labelText.text
|
||||||
@ -26,18 +27,21 @@ Item {
|
|||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: labelImage
|
id: labelImage
|
||||||
source: "images/button-label.png"
|
property bool displayBelowButton: false
|
||||||
|
source: displayBelowButton ? "images/button-label-bottom.png" : "images/button-label.png"
|
||||||
opacity: 0
|
opacity: 0
|
||||||
visible: labelText.text.length > 0 //don't show label bg without text
|
visible: labelText.text.length > 0 //don't show label bg without text
|
||||||
|
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: hoveredIcon.top
|
y: displayBelowButton ? parent.height-8 : -height+8
|
||||||
anchors.bottomMargin: -8
|
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: labelText
|
id: labelText
|
||||||
anchors.baseline: parent.verticalCenter
|
anchors.baseline: parent.bottom
|
||||||
anchors.baselineOffset: -4
|
//text baseline depends on label image orientation,
|
||||||
|
//0.3 and 0.55 constants have to be adjusted when button-label.png is modified
|
||||||
|
anchors.baselineOffset: labelImage.displayBelowButton ? -parent.height*0.3 : -parent.height*0.55
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
font {
|
font {
|
||||||
@ -50,8 +54,16 @@ Item {
|
|||||||
|
|
||||||
states: State {
|
states: State {
|
||||||
name: "hovered"
|
name: "hovered"
|
||||||
|
//update the tooltip position before it's displayed,
|
||||||
|
//since we don't have a property to bind directly
|
||||||
|
StateChangeScript {
|
||||||
|
name: "updateLabelPosition"
|
||||||
|
script: labelImage.displayBelowButton = welcomeButton.mapToItem(null,0,0).y < labelImage.height
|
||||||
|
}
|
||||||
PropertyChanges { target: hoveredIcon; opacity: 1.0 }
|
PropertyChanges { target: hoveredIcon; opacity: 1.0 }
|
||||||
PropertyChanges { target: labelImage; opacity: 1.0 }
|
PropertyChanges { target: labelImage; opacity: 1.0 }
|
||||||
|
//raise this button, so tooltip is not obscured by the next items in the grid
|
||||||
|
PropertyChanges { target: welcomeButton; z: 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
transitions: Transition {
|
transitions: Transition {
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -9,6 +9,7 @@
|
|||||||
<file>qml/images/welcome-news-bg.png</file>
|
<file>qml/images/welcome-news-bg.png</file>
|
||||||
<file>qml/images/welcome-op-logo.png</file>
|
<file>qml/images/welcome-op-logo.png</file>
|
||||||
<file>qml/images/button-label.png</file>
|
<file>qml/images/button-label.png</file>
|
||||||
|
<file>qml/images/button-label-bottom.png</file>
|
||||||
<file>qml/images/welcome-op-bg.png</file>
|
<file>qml/images/welcome-op-bg.png</file>
|
||||||
<file>qml/images/welcome-bg.png</file>
|
<file>qml/images/welcome-bg.png</file>
|
||||||
<file>qml/images/flightdata-on.png</file>
|
<file>qml/images/flightdata-on.png</file>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user