Commit 44afaa86 authored by Gus Grubba's avatar Gus Grubba

Moving QmtTest to the Settings Panel (in debug builds only). This used to be a separate "QtWidget".

parent 1d0a02d2
...@@ -187,6 +187,7 @@ ...@@ -187,6 +187,7 @@
<file alias="QGroundControl/FlightMap/VehicleMapItem.qml">src/FlightMap/MapItems/VehicleMapItem.qml</file> <file alias="QGroundControl/FlightMap/VehicleMapItem.qml">src/FlightMap/MapItems/VehicleMapItem.qml</file>
<file alias="QGroundControl/ScreenTools/qmldir">src/QmlControls/QGroundControl.ScreenTools.qmldir</file> <file alias="QGroundControl/ScreenTools/qmldir">src/QmlControls/QGroundControl.ScreenTools.qmldir</file>
<file alias="QGroundControl/ScreenTools/ScreenTools.qml">src/QmlControls/ScreenTools.qml</file> <file alias="QGroundControl/ScreenTools/ScreenTools.qml">src/QmlControls/ScreenTools.qml</file>
<file alias="QGroundControl/Controls/QGCHoverButton.qml">src/QmlControls/QGCHoverButton.qml</file>
<file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file> <file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file>
<file alias="RadioComponent.qml">src/AutoPilotPlugins/Common/RadioComponent.qml</file> <file alias="RadioComponent.qml">src/AutoPilotPlugins/Common/RadioComponent.qml</file>
<file alias="SerialSettings.qml">src/ui/preferences/SerialSettings.qml</file> <file alias="SerialSettings.qml">src/ui/preferences/SerialSettings.qml</file>
......
import QtQuick 2.3
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
// TODO: Use QT styles. Use default button style + custom style entries
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Button {
id: button
width: columnItem.contentWidth + contentLayoutItem.margins * 2
height: width
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 alias radius: buttonBkRect.radius
property alias fontPointSize: innerText.font.pointSize
property alias imageSource: innerImage.source
property alias contentWidth: innerText.contentWidth
property real imageScale: 0.8
property real borderWidth: 0
property real contentMargins: innerText.height * 0.1
property color _currentColor: checked ? pressedColor : color
property color _currentContentColor: contentColor
QGCPalette { id: qgcPal }
QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false }
// Initial state
state: "Default"
// Update state on status changed
onEnabledChanged: state = "Default"
property real _contentVDist: innerImage.height/innerText.contentHeight
// Content Icon + Text
contentItem: Item {
id: contentLayoutItem
anchors.fill: parent
anchors.margins: contentMargins
Column {
id: columnItem
anchors.fill: parent
Item {
width: parent.width
height: (contentLayoutItem.height - innerText.height)
Image {
id: innerImage
anchors.centerIn: parent
height: parent.height * imageScale
width: parent.width * imageScale
visible: false
smooth: true
antialiasing: true
mipmap: true
fillMode: Image.PreserveAspectFit
sourceSize.height: height
sourceSize.width: width
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
}
ColorOverlay {
id: imageOverlay
anchors.fill: innerImage
source: innerImage
color: _currentContentColor
}
}
Text {
id: innerText
text: button.text
color: _currentContentColor
width: parent.width
font.pointSize: ScreenTools.defaultFontPointSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
} // Column - content
} // Item - content
background: Rectangle {
id: buttonBkRect
anchors.fill: parent
color: _currentColor
border.width: borderWidth
border.color: borderColor
}
// Change the aspect of the content in differen button states
states: [
State {
name: "Hovering"
PropertyChanges {
target: button;
_currentColor: pressed || checked ? pressedColor : hoverColor
_currentContentColor: pressed || checked ? contentPressedColor : contentColor
}
},
State {
name: "Default"
PropertyChanges {
target: button;
_currentColor: enabled ? ((checked || pressed) ? pressedColor : color) : disabledColor
_currentContentColor: contentColor
}
}
]
transitions: [
Transition {
from: ""; to: "Hovering"
ColorAnimation { duration: 200 }
},
Transition {
from: "*"; to: "Pressed"
ColorAnimation { duration: 10 }
}
]
// Process hover events
MouseArea {
enabled: !ScreenTools.isMobile
hoverEnabled: true
propagateComposedEvents: true
preventStealing: true
anchors.fill: button
onEntered: { button.state = 'Hovering'; }
onExited: { button.state = 'Default'; }
// Propagate events down
onClicked: { mouse.accepted = false; }
onDoubleClicked: { mouse.accepted = false; }
onPositionChanged: { mouse.accepted = false; }
onPressAndHold: { mouse.accepted = false; }
onPressed: { mouse.accepted = false }
onReleased: { mouse.accepted = false }
}
}
...@@ -77,3 +77,4 @@ ToolStrip 1.0 ToolStrip.qml ...@@ -77,3 +77,4 @@ ToolStrip 1.0 ToolStrip.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml ViewWidget 1.0 ViewWidget.qml
QGCHoverButton 1.0 QGCHoverButton.qml
...@@ -8,12 +8,11 @@ import QGroundControl.Controls 1.0 ...@@ -8,12 +8,11 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
Rectangle { Rectangle {
anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
QGCPalette { id: qgcPal; colorGroupEnabled: enabled } color: "white"
property var palette: QGCPalette { colorGroupEnabled: true } property var palette: QGCPalette { colorGroupEnabled: true }
color: "white"
Component { Component {
id: arbBox id: arbBox
...@@ -83,7 +82,14 @@ Rectangle { ...@@ -83,7 +82,14 @@ Rectangle {
} }
} }
QGCFlickable {
anchors.fill: parent
contentWidth: _rootCol.width
contentHeight: _rootCol.height
clip: true
Column { Column {
id: _rootCol
Rectangle { Rectangle {
width: parent.width width: parent.width
...@@ -118,6 +124,7 @@ Rectangle { ...@@ -118,6 +124,7 @@ Rectangle {
Row { Row {
spacing: 30 spacing: 30
// Theme preview
Grid { Grid {
columns: 5 columns: 5
spacing: 5 spacing: 5
...@@ -844,7 +851,7 @@ Rectangle { ...@@ -844,7 +851,7 @@ Rectangle {
// missionItemEditor // missionItemEditor
Loader { Loader {
sourceComponent: rowHeader sourceComponent: rowHeader
property var text: "missionItemEditor" property string text: "missionItemEditor"
} }
ClickableColor { ClickableColor {
property var palette: QGCPalette { colorGroupEnabled: false } property var palette: QGCPalette { colorGroupEnabled: false }
...@@ -873,45 +880,57 @@ Rectangle { ...@@ -873,45 +880,57 @@ Rectangle {
text: palette.missionItemEditor text: palette.missionItemEditor
} }
} } // Theme preview
// QGC controls preview
Column { Column {
id: ctlPrevColumn
property real _width: ScreenTools.defaultFontPointSize * 18
property real _height: _width*0.15
property color _bkColor: qgcPal.window
spacing: 10 spacing: 10
width: leftGrid.width width: previewGrid.width
Grid { Grid {
id: leftGrid id: previewGrid
columns: 3 columns: 3
spacing: 10 spacing: 10
Component { Component {
id: ctlRowHeader id: ctlRowHeader
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: "white"
Text { Text {
width: 120 anchors.fill: parent
height: 20
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: "black" color: "black"
text: parent.text
text: parent.parent.text
}
} }
} }
// Header row // Header row
Loader { Text {
sourceComponent: ctlRowHeader width: ctlPrevColumn._width
property string text: "" height: ctlPrevColumn._height
color: "black"
horizontalAlignment: Text.AlignHCenter
text: qsTr("QGC name")
} }
Text { Text {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
color: "black" color: "black"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: qsTr("Enabled") text: qsTr("Enabled")
} }
Text { Text {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
color: "black" color: "black"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: qsTr("Disabled") text: qsTr("Disabled")
...@@ -922,17 +941,27 @@ Rectangle { ...@@ -922,17 +941,27 @@ Rectangle {
sourceComponent: ctlRowHeader sourceComponent: ctlRowHeader
property string text: "QGCLabel" property string text: "QGCLabel"
} }
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: ctlPrevColumn._bkColor
QGCLabel { QGCLabel {
width: 100 anchors.fill: parent
height: 20 anchors.margins: 5
text: qsTr("Label") text: qsTr("Label")
} }
}
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: ctlPrevColumn._bkColor
QGCLabel { QGCLabel {
width: 100 anchors.fill: parent
height: 20 anchors.margins: 5
text: qsTr("Label") text: qsTr("Label")
enabled: false enabled: false
} }
}
// QGCButton // QGCButton
Loader { Loader {
...@@ -940,13 +969,13 @@ Rectangle { ...@@ -940,13 +969,13 @@ Rectangle {
property string text: "QGCButton" property string text: "QGCButton"
} }
QGCButton { QGCButton {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: qsTr("Button") text: qsTr("Button")
} }
QGCButton { QGCButton {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: qsTr("Button") text: qsTr("Button")
enabled: false enabled: false
} }
...@@ -957,19 +986,40 @@ Rectangle { ...@@ -957,19 +986,40 @@ Rectangle {
property string text: "QGCButton(primary)" property string text: "QGCButton(primary)"
} }
QGCButton { QGCButton {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
primary: true primary: true
text: qsTr("Button") text: qsTr("Button")
} }
QGCButton { QGCButton {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: qsTr("Button") text: qsTr("Button")
primary: true primary: true
enabled: false enabled: false
} }
// QGCHoverButton
Loader {
sourceComponent: ctlRowHeader
property string text: "QGCHoverButton"
}
QGCHoverButton {
width: ctlPrevColumn._width
height: ctlPrevColumn._height * 2
text: qsTr("Hover Button")
radius: ScreenTools.defaultFontPointSize
imageSource: "/qmlimages/Gears.svg"
}
QGCHoverButton {
width: ctlPrevColumn._width
height: ctlPrevColumn._height * 2
text: qsTr("Hover Button")
radius: ScreenTools.defaultFontPointSize
imageSource: "/qmlimages/Gears.svg"
enabled: false
}
// QGCButton - menu // QGCButton - menu
Loader { Loader {
sourceComponent: ctlRowHeader sourceComponent: ctlRowHeader
...@@ -988,14 +1038,14 @@ Rectangle { ...@@ -988,14 +1038,14 @@ Rectangle {
} }
} }
QGCButton { QGCButton {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: qsTr("Button") text: qsTr("Button")
menu: buttonMenu menu: buttonMenu
} }
QGCButton { QGCButton {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: qsTr("Button") text: qsTr("Button")
enabled: false enabled: false
menu: buttonMenu menu: buttonMenu
...@@ -1006,34 +1056,54 @@ Rectangle { ...@@ -1006,34 +1056,54 @@ Rectangle {
sourceComponent: ctlRowHeader sourceComponent: ctlRowHeader
property string text: "QGCRadioButton" property string text: "QGCRadioButton"
} }
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: ctlPrevColumn._bkColor
QGCRadioButton { QGCRadioButton {
width: 100 anchors.fill: parent
height: 20 anchors.margins: 5
text: qsTr("Radio") text: qsTr("Radio")
} }
}
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: ctlPrevColumn._bkColor
QGCRadioButton { QGCRadioButton {
width: 100 anchors.fill: parent
height: 20 anchors.margins: 5
text: qsTr("Radio") text: qsTr("Radio")
enabled: false enabled: false
} }
}
// QGCCheckBox // QGCCheckBox
Loader { Loader {
sourceComponent: ctlRowHeader sourceComponent: ctlRowHeader
property string text: "QGCCheckBox" property string text: "QGCCheckBox"
} }
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: ctlPrevColumn._bkColor
QGCCheckBox { QGCCheckBox {
width: 100 anchors.fill: parent
height: 20 anchors.margins: 5
text: qsTr("Check Box") text: qsTr("Check Box")
} }
}
Rectangle {
width: ctlPrevColumn._width
height: ctlPrevColumn._height
color: ctlPrevColumn._bkColor
QGCCheckBox { QGCCheckBox {
width: 100 anchors.fill: parent
height: 20 anchors.margins: 5
text: qsTr("Check Box") text: qsTr("Check Box")
enabled: false enabled: false
} }
}
// QGCTextField // QGCTextField
Loader { Loader {
...@@ -1041,13 +1111,13 @@ Rectangle { ...@@ -1041,13 +1111,13 @@ Rectangle {
property string text: "QGCTextField" property string text: "QGCTextField"
} }
QGCTextField { QGCTextField {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: "QGCTextField" text: "QGCTextField"
} }
QGCTextField { QGCTextField {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
text: "QGCTextField" text: "QGCTextField"
enabled: false enabled: false
} }
...@@ -1058,13 +1128,13 @@ Rectangle { ...@@ -1058,13 +1128,13 @@ Rectangle {
property string text: "QGCComboBox" property string text: "QGCComboBox"
} }
QGCComboBox { QGCComboBox {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ] model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ]
} }
QGCComboBox { QGCComboBox {
width: 100 width: ctlPrevColumn._width
height: 20 height: ctlPrevColumn._height
model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ] model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ]
enabled: false enabled: false
} }
...@@ -1075,19 +1145,19 @@ Rectangle { ...@@ -1075,19 +1145,19 @@ Rectangle {
property string text: "SubMenuButton" property string text: "SubMenuButton"
} }
SubMenuButton { SubMenuButton {
width: 100 width: ctlPrevColumn._width
height: 100 height: ctlPrevColumn._width/3
text: qsTr("SUB MENU") text: qsTr("SUB MENU")
} }
SubMenuButton { SubMenuButton {
width: 100 width: ctlPrevColumn._width
height: 100 height: ctlPrevColumn._width/3
text: qsTr("SUB MENU") text: qsTr("SUB MENU")
enabled: false enabled: false
} }
} }
Rectangle { Rectangle {
width: leftGrid.width width: previewGrid.width
height: 60 height: 60
radius: 3 radius: 3
color: palette.alertBackground color: palette.alertBackground
...@@ -1099,7 +1169,7 @@ Rectangle { ...@@ -1099,7 +1169,7 @@ Rectangle {
anchors.centerIn: parent anchors.centerIn: parent
} }
} }
} } // QGC controls preview
} }
Item{ Item{
...@@ -1125,4 +1195,6 @@ Rectangle { ...@@ -1125,4 +1195,6 @@ Rectangle {
} }
} }
}
} }
...@@ -61,6 +61,8 @@ public: ...@@ -61,6 +61,8 @@ public:
delete pMockLink; delete pMockLink;
if(pDebug) if(pDebug)
delete pDebug; delete pDebug;
if(pQmlTest)
delete pQmlTest;
#endif #endif
if(defaultOptions) if(defaultOptions)
delete defaultOptions; delete defaultOptions;
...@@ -84,6 +86,7 @@ public: ...@@ -84,6 +86,7 @@ public:
#if defined(QT_DEBUG) #if defined(QT_DEBUG)
QmlComponentInfo* pMockLink = nullptr; QmlComponentInfo* pMockLink = nullptr;
QmlComponentInfo* pDebug = nullptr; QmlComponentInfo* pDebug = nullptr;
QmlComponentInfo* pQmlTest = nullptr;
#endif #endif
QmlComponentInfo* valuesPageWidgetInfo = nullptr; QmlComponentInfo* valuesPageWidgetInfo = nullptr;
...@@ -173,6 +176,9 @@ QVariantList &QGCCorePlugin::settingsPages() ...@@ -173,6 +176,9 @@ QVariantList &QGCCorePlugin::settingsPages()
_p->pDebug = new QmlComponentInfo(tr("Debug"), _p->pDebug = new QmlComponentInfo(tr("Debug"),
QUrl::fromUserInput("qrc:/qml/DebugWindow.qml")); QUrl::fromUserInput("qrc:/qml/DebugWindow.qml"));
_p->settingsList.append(QVariant::fromValue(reinterpret_cast<QmlComponentInfo*>(_p->pDebug))); _p->settingsList.append(QVariant::fromValue(reinterpret_cast<QmlComponentInfo*>(_p->pDebug)));
_p->pQmlTest = new QmlComponentInfo(tr("Palette Test"),
QUrl::fromUserInput("qrc:/qml/QmlTest.qml"));
_p->settingsList.append(QVariant::fromValue(reinterpret_cast<QmlComponentInfo*>(_p->pQmlTest)));
#endif #endif
} }
return _p->settingsList; return _p->settingsList;
......
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