1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +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:
Dmytro Poplavskiy 2012-08-18 11:30:50 +10:00
parent 69bd17c6a8
commit 89023e8c41
3 changed files with 18 additions and 5 deletions

View File

@ -5,6 +5,7 @@ Item {
id: welcomeButton
width: Math.max(116, icon.width)
height: 116
z: 0
property string baseIconName
property alias label : labelText.text
@ -26,18 +27,21 @@ Item {
Image {
id: labelImage
source: "images/button-label.png"
property bool displayBelowButton: false
source: displayBelowButton ? "images/button-label-bottom.png" : "images/button-label.png"
opacity: 0
visible: labelText.text.length > 0 //don't show label bg without text
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: hoveredIcon.top
anchors.bottomMargin: -8
y: displayBelowButton ? parent.height-8 : -height+8
Text {
id: labelText
anchors.baseline: parent.verticalCenter
anchors.baselineOffset: -4
anchors.baseline: parent.bottom
//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
font {
@ -50,8 +54,16 @@ Item {
states: State {
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: 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 {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -9,6 +9,7 @@
<file>qml/images/welcome-news-bg.png</file>
<file>qml/images/welcome-op-logo.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-bg.png</file>
<file>qml/images/flightdata-on.png</file>