Commit 3ec958c2 authored by Stefan Dunca's avatar Stefan Dunca

Toolstrip and QmlTest tweaks

parent b4b57bc1
...@@ -6,19 +6,13 @@ import QtGraphicalEffects 1.0 ...@@ -6,19 +6,13 @@ import QtGraphicalEffects 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
// TODO: use QT palette
Button { Button {
id: button id: button
width: columnItem.contentWidth + contentLayoutItem.margins * 2 width: columnItem.contentWidth + contentLayoutItem.margins * 2
height: width height: width
flat: true flat: true
property color color: qgcPal.button
property color disabledColor: qgcPalDisabled.button
property color pressedColor: qgcPal.buttonHighlight
// TODO: remove after we add it to the palette
property color hoverColor: qgcPal.hoverColor
property color contentColor: qgcPal.buttonText
property color contentPressedColor: qgcPal.buttonHighlightText
property color borderColor: qgcPal.windowShadeDark property color borderColor: qgcPal.windowShadeDark
property alias radius: buttonBkRect.radius property alias radius: buttonBkRect.radius
...@@ -30,8 +24,8 @@ Button { ...@@ -30,8 +24,8 @@ Button {
property real borderWidth: 0 property real borderWidth: 0
property real contentMargins: innerText.height * 0.1 property real contentMargins: innerText.height * 0.1
property color _currentColor: checked ? pressedColor : color property color _currentColor: qgcPal.button
property color _currentContentColor: contentColor property color _currentContentColor: qgcPal.buttonText
QGCPalette { id: qgcPal } QGCPalette { id: qgcPal }
QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false } QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false }
...@@ -102,27 +96,36 @@ Button { ...@@ -102,27 +96,36 @@ Button {
id: buttonBkRect id: buttonBkRect
anchors.fill: parent anchors.fill: parent
color: _currentColor color: _currentColor
visible: !flat
border.width: borderWidth border.width: borderWidth
border.color: borderColor border.color: borderColor
} }
// Change the aspect of the content in differen button states // Change the colors based on button states
states: [ states: [
State { State {
name: "Hovering" name: "Hovering"
PropertyChanges { PropertyChanges {
target: button; target: button;
_currentColor: pressed || checked ? pressedColor : hoverColor _currentColor: (checked || pressed) ? qgcPal.buttonHighlight : qgcPal.hoverColor
_currentContentColor: pressed || checked ? contentPressedColor : contentColor _currentContentColor: qgcPal.buttonHighlightText
}
PropertyChanges {
target: buttonBkRect
visible: true
} }
}, },
State { State {
name: "Default" name: "Default"
PropertyChanges { PropertyChanges {
target: button; target: button;
_currentColor: enabled ? ((checked || pressed) ? pressedColor : color) : disabledColor _currentColor: enabled ? ((checked || pressed) ? qgcPal.buttonHighlight : qgcPal.button) : qgcPalDisabled.button
_currentContentColor: contentColor _currentContentColor: enabled ? ((checked || pressed) ? qgcPal.buttonHighlightText : qgcPal.buttonHighlight) : qgcPalDisabled.buttonText
}
PropertyChanges {
target: buttonBkRect
visible: !flat || (checked || pressed)
} }
} }
] ]
......
This diff is collapsed.
...@@ -32,7 +32,7 @@ Rectangle { ...@@ -32,7 +32,7 @@ Rectangle {
property AbstractButton lastClickedButton: null property AbstractButton lastClickedButton: null
// Ensure we don't get lower than // Ensure we don't get lower than
property real _idealWidth: (ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 10) + toolStripColumn.anchors.margins * 2 property real _idealWidth: (ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 8) + toolStripColumn.anchors.margins * 2
signal clicked(int index, bool checked) signal clicked(int index, bool checked)
...@@ -44,7 +44,7 @@ Rectangle { ...@@ -44,7 +44,7 @@ Rectangle {
Column { Column {
id: toolStripColumn id: toolStripColumn
anchors.margins: ScreenTools.defaultFontPixelWidth * 0.8 anchors.margins: ScreenTools.defaultFontPixelWidth * 0.4
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -55,13 +55,11 @@ Rectangle { ...@@ -55,13 +55,11 @@ Rectangle {
QGCHoverButton { QGCHoverButton {
id: buttonTemplate id: buttonTemplate
color: _root.color
anchors.left: toolStripColumn.left anchors.left: toolStripColumn.left
anchors.right: toolStripColumn.right anchors.right: toolStripColumn.right
height: width height: width
radius: ScreenTools.defaultFontPixelWidth / 2 radius: ScreenTools.defaultFontPixelWidth / 2
fontPointSize: ScreenTools.isMobile ? ScreenTools.smallFontPointSize : ScreenTools.mediumFontPointSize fontPointSize: ScreenTools.isMobile ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
enabled: _root.buttonEnabled ? _root.buttonEnabled[index] : true enabled: _root.buttonEnabled ? _root.buttonEnabled[index] : true
visible: _root.buttonVisible ? _root.buttonVisible[index] : true visible: _root.buttonVisible ? _root.buttonVisible[index] : true
......
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