Commit 20606a57 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Help text for toolbar buttons (#3711)

parent 7736e244
...@@ -16,17 +16,22 @@ import QGroundControl.Palette 1.0 ...@@ -16,17 +16,22 @@ import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
Item { Item {
id: _root id: _root
state: "HelpShown"
clip: true
property alias source: icon.source property alias text: helpText.text
property bool checked: false property alias source: icon.source
property bool checked: false
property bool logo: false
property ExclusiveGroup exclusiveGroup: null property ExclusiveGroup exclusiveGroup: null
readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight / 2
signal clicked() signal clicked()
QGCPalette { id: qgcPal } readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight / 2
property real _helpTextBottomMargin: 0
property real _imageBottomMargin: 0
onExclusiveGroupChanged: { onExclusiveGroupChanged: {
if (exclusiveGroup) { if (exclusiveGroup) {
...@@ -34,17 +39,62 @@ Item { ...@@ -34,17 +39,62 @@ Item {
} }
} }
QGCPalette { id: qgcPal }
states: [
State {
name: "HelpShown"
},
State {
name: "HelpHidden"
PropertyChanges { target: imageAnimation; running: true }
PropertyChanges { target: helpTextAnimation; running: true }
}
]
PropertyAnimation {
id: imageAnimation
target: _root
property: "_imageBottomMargin"
duration: 1000
easing.type: Easing.InOutQuad
to: _topBottomMargins
from: 0
}
PropertyAnimation {
id: helpTextAnimation
target: _root
property: "_helpTextBottomMargin"
duration: 1000
easing.type: Easing.InOutQuad
to: -helpText.height
from: 0
}
Timer {
interval: 10000
running: true
onTriggered: _root.state = "HelpHidden"
}
Rectangle {
anchors.fill: parent
visible: logo
color: "#4A2C6D"
}
QGCColoredImage { QGCColoredImage {
id: icon id: icon
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: _topBottomMargins anchors.topMargin: _topBottomMargins
anchors.bottomMargin: _topBottomMargins
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottomMargin: _imageBottomMargin
anchors.bottom: helpText.top
sourceSize.height: parent.height sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
color: checked ? qgcPal.buttonHighlight : qgcPal.buttonText color: logo ? "white" : (checked ? qgcPal.buttonHighlight : qgcPal.buttonText)
} }
Rectangle { Rectangle {
...@@ -56,6 +106,16 @@ Item { ...@@ -56,6 +106,16 @@ Item {
visible: checked visible: checked
} }
QGCLabel {
id: helpText
anchors.left: parent.left
anchors.right: parent.right
anchors.bottomMargin: _helpTextBottomMargin
anchors.bottom: parent.bottom
horizontalAlignment: Text.AlignHCenter
color: logo ? "white" : qgcPal.buttonText
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
......
...@@ -107,6 +107,7 @@ Item { ...@@ -107,6 +107,7 @@ Item {
setupViewLoader.visible = false setupViewLoader.visible = false
planViewLoader.visible = false planViewLoader.visible = false
preferencesPanel.visible = true preferencesPanel.visible = true
toolBar.checkPreferencesButton()
} }
// The following are use for unit testing only // The following are use for unit testing only
......
...@@ -52,6 +52,10 @@ Rectangle { ...@@ -52,6 +52,10 @@ Rectangle {
MainToolBarController { id: _controller } MainToolBarController { id: _controller }
function checkPreferencesButton() {
preferencesButton.checked = true
}
function checkSetupButton() { function checkSetupButton() {
setupButton.checked = true setupButton.checked = true
} }
...@@ -307,53 +311,31 @@ Rectangle { ...@@ -307,53 +311,31 @@ Rectangle {
visible: qgcPal.globalTheme == QGCPalette.Light visible: qgcPal.globalTheme == QGCPalette.Light
} }
//---------------------------------------------
// Logo (Preferences Button)
Rectangle {
id: preferencesButton
width: mainWindow.tbButtonWidth * 1.25
height: parent.height
anchors.top: parent.top
anchors.left: parent.left
color: "#4A2C6D"
Image {
height: mainWindow.tbCellHeight
anchors.centerIn: parent
source: "/res/QGCLogoWhite"
fillMode: Image.PreserveAspectFit
smooth: true
mipmap: true
antialiasing: true
}
/* Experimenting with a white/black divider
Rectangle {
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.15) : Qt.rgba(1,1,1,0.15)
height: parent.height
width: 1
anchors.right: parent.right
anchors.top: parent.top
}
*/
MouseArea {
anchors.fill: parent
onClicked: toolBar.showPreferences()
}
}
//--------------------------------------------- //---------------------------------------------
// Toolbar Row // Toolbar Row
Row { Row {
id: viewRow id: viewRow
height: mainWindow.tbCellHeight height: mainWindow.tbCellHeight
spacing: mainWindow.tbSpacing spacing: mainWindow.tbSpacing
anchors.left: preferencesButton.right anchors.left: parent.left
anchors.leftMargin: mainWindow.tbSpacing
anchors.bottomMargin: 1 anchors.bottomMargin: 1
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
ExclusiveGroup { id: mainActionGroup } ExclusiveGroup { id: mainActionGroup }
QGCToolBarButton {
id: preferencesButton
width: mainWindow.tbButtonWidth
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/res/QGCLogoWhite"
logo: true
text: "Settings"
onClicked: toolBar.showPreferences()
}
QGCToolBarButton { QGCToolBarButton {
id: setupButton id: setupButton
width: mainWindow.tbButtonWidth width: mainWindow.tbButtonWidth
...@@ -361,6 +343,7 @@ Rectangle { ...@@ -361,6 +343,7 @@ Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup exclusiveGroup: mainActionGroup
source: "/qmlimages/Gears.svg" source: "/qmlimages/Gears.svg"
text: "Setup"
onClicked: toolBar.showSetupView() onClicked: toolBar.showSetupView()
} }
...@@ -371,6 +354,7 @@ Rectangle { ...@@ -371,6 +354,7 @@ Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup exclusiveGroup: mainActionGroup
source: "/qmlimages/Plan.svg" source: "/qmlimages/Plan.svg"
text: "Plan"
onClicked: toolBar.showPlanView() onClicked: toolBar.showPlanView()
} }
...@@ -381,6 +365,7 @@ Rectangle { ...@@ -381,6 +365,7 @@ Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup exclusiveGroup: mainActionGroup
source: "/qmlimages/PaperPlane.svg" source: "/qmlimages/PaperPlane.svg"
text: "Fly"
onClicked: toolBar.showFlyView() onClicked: toolBar.showFlyView()
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment