diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 30889e548faa0d17b8fc50df5f8aed5d72a66c5a..65b6242a426bcc5f826ff3cc8c7e4ee175484aa1 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -208,8 +208,6 @@ ReleaseBuild { } } -QML_IMPORT_PATH = $$BASEDIR/qml - # qextserialport should not be used by general QGroundControl code. Use QSerialPort instead. This is only # here to support special case Firmware Upgrade code. include(libs/qextserialport/src/qextserialport.pri) @@ -681,7 +679,8 @@ HEADERS += \ src/qgcunittest/MavlinkLogTest.h \ src/FactSystem/FactSystemTestBase.h \ src/FactSystem/FactSystemTestPX4.h \ - src/FactSystem/FactSystemTestGeneric.h + src/FactSystem/FactSystemTestGeneric.h \ + src/QmlControls/QmlTestWidget.h \ SOURCES += \ src/qgcunittest/UnitTest.cc \ @@ -705,7 +704,9 @@ SOURCES += \ src/qgcunittest/MavlinkLogTest.cc \ src/FactSystem/FactSystemTestBase.cc \ src/FactSystem/FactSystemTestPX4.cc \ - src/FactSystem/FactSystemTestGeneric.cc + src/FactSystem/FactSystemTestGeneric.cc \ + src/QmlControls/QmlTestWidget.cc \ + } # diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 7069cad514579c0c351fd34465d47b5cd3593095..aa035643df86e13fdad12a86a149f902555929f3 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -239,20 +239,26 @@ src/test.qml + src/QmlControls/QmlTest.qml - qml/QGroundControl/FactControls/qmldir - qml/QGroundControl/FactControls/FactLabel.qml - qml/QGroundControl/FactControls/FactTextField.qml - qml/QGroundControl/FactControls/FactCheckBox.qml + src/FactSystem/FactControls/qmldir + src/FactSystem/FactControls/FactLabel.qml + src/FactSystem/FactControls/FactTextField.qml + src/FactSystem/FactControls/FactCheckBox.qml - qml/QGroundControl/Controls/qmldir - qml/QGroundControl/Controls/SetupButton.qml + src/QmlControls/qmldir + src/QmlControls/SetupButton.qml + src/QmlControls/QGCButton.qml + src/QmlControls/QGCRadioButton.qml + src/QmlControls/QGCCheckBox.qml + src/QmlControls/QGCLabel.qml files/images/px4/airframes/octo_x.png files/images/px4/boards/px4fmu_2.x.png src/VehicleSetup/SetupViewButtons.qml src/VehicleSetup/VehicleSummary.qml + src/VehicleSetup/FirmwareUpgrade.qml src/AutoPilotPlugins/PX4/SafetyComponent.qml diff --git a/qml/QGroundControl/Controls/qmldir b/qml/QGroundControl/Controls/qmldir deleted file mode 100644 index 48c30e1a22cd9102044264d669dbeaa8ea8af635..0000000000000000000000000000000000000000 --- a/qml/QGroundControl/Controls/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Module QGroundControl.Controls -SetupButton 1.0 SetupButton.qml \ No newline at end of file diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml index f6187dc100b931a6784978356206ab3086e9381f..4a4d3bbbe51a5f33df2d91ca3ce8fb18968033fd 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -1,8 +1,10 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 + import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 Rectangle { QGCPalette { id: palette; colorGroup: QGCPalette.Active } diff --git a/qml/QGroundControl/FactControls/FactCheckBox.qml b/src/FactSystem/FactControls/FactCheckBox.qml similarity index 95% rename from qml/QGroundControl/FactControls/FactCheckBox.qml rename to src/FactSystem/FactControls/FactCheckBox.qml index 82a29a71393c033280179720f41de25bc2975885..84d0834f3f3a5465c5066f8336435a3a9b208cad 100644 --- a/qml/QGroundControl/FactControls/FactCheckBox.qml +++ b/src/FactSystem/FactControls/FactCheckBox.qml @@ -1,7 +1,9 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 + import QGroundControl.FactSystem 1.0 +import QGroundControl.Palette 1.0 CheckBox { property Fact fact: Fact { value: 0 } diff --git a/qml/QGroundControl/FactControls/FactLabel.qml b/src/FactSystem/FactControls/FactLabel.qml similarity index 90% rename from qml/QGroundControl/FactControls/FactLabel.qml rename to src/FactSystem/FactControls/FactLabel.qml index 25bcf809927d217caebcfcea3967afb7b0c30447..b9fe43c8a1076e6e1349b4d8902d08457868b70d 100644 --- a/qml/QGroundControl/FactControls/FactLabel.qml +++ b/src/FactSystem/FactControls/FactLabel.qml @@ -1,7 +1,9 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 + import QGroundControl.FactSystem 1.0 +import QGroundControl.Palette 1.0 Label { property Fact fact: Fact { value: "FactLabel" } diff --git a/qml/QGroundControl/FactControls/FactTextField.qml b/src/FactSystem/FactControls/FactTextField.qml similarity index 97% rename from qml/QGroundControl/FactControls/FactTextField.qml rename to src/FactSystem/FactControls/FactTextField.qml index be0e68e66a7e7df0403660617c501dbf274c05db..6ff1b484f90b2b7cf4d147c85f6c704a9c742387 100644 --- a/qml/QGroundControl/FactControls/FactTextField.qml +++ b/src/FactSystem/FactControls/FactTextField.qml @@ -1,7 +1,9 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 + import QGroundControl.FactSystem 1.0 +import QGroundControl.Palette 1.0 TextField { property Fact fact: Fact { value: 0 } diff --git a/qml/QGroundControl/FactControls/qmldir b/src/FactSystem/FactControls/qmldir similarity index 100% rename from qml/QGroundControl/FactControls/qmldir rename to src/FactSystem/FactControls/qmldir diff --git a/src/FactSystem/FactSystem.cc b/src/FactSystem/FactSystem.cc index 0fe30b35f893689b1b86f1c3ba08c93a1f0c29ee..650166b21d06788757b28852bc5aa4fd097aa295 100644 --- a/src/FactSystem/FactSystem.cc +++ b/src/FactSystem/FactSystem.cc @@ -28,7 +28,6 @@ #include "UASManager.h" #include "QGCApplication.h" #include "VehicleComponent.h" -#include "QGCPalette.h" #include @@ -44,7 +43,6 @@ FactSystem::FactSystem(QObject* parent) : // FIXME: Where should these go? qmlRegisterUncreatableType(_factSystemQmlUri, 1, 0, "VehicleComponent", "Can only reference VehicleComponent"); - qmlRegisterType(_factSystemQmlUri, 1, 0, "QGCPalette"); } FactSystem::~FactSystem() diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index f383226e6aa7f248bad906f8ae11abab347fee31..70370c2ce8a532ff74f402ebf4a33dc0b86f3fc7 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -247,6 +247,9 @@ void QGCApplication::_initCommon(void) // Avoid Using setFont(). In the Qt docu you can read the following: // "Warning: Do not use this function in conjunction with Qt Style Sheets." // setFont(fontDatabase.font(fontFamilyName, "Roman", 12)); + + // Register our Qml palette before anyone tries to use it + qmlRegisterType("QGroundControl.Palette", 1, 0, "QGCPalette"); } bool QGCApplication::_initForNormalAppBoot(void) diff --git a/src/QGCPalette.cc b/src/QGCPalette.cc index 46f54bda1cfc6e39de9f6e4962f3782171560471..3ae331467a06afec1c0302bcba0198fa5aec25cb 100644 --- a/src/QGCPalette.cc +++ b/src/QGCPalette.cc @@ -49,13 +49,13 @@ QColor QGCPalette::_button[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { }; QColor QGCPalette::_buttonText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0, 0, 0), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) }, - { QColor(0, 0, 0), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) }, + { QColor(0x2c, 0x2c, 0x2c), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) }, + { QColor(0x2c, 0x2c, 0x2c), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) }, }; QColor QGCPalette::_text[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0, 0, 0), QColor(0, 0, 0), QColor(0, 0, 0) }, - { QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) } + { QColor(0x58, 0x58, 0x58), QColor(0, 0, 0), QColor(0, 0, 0) }, + { QColor(0x58, 0x58, 0x58), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) } }; QColor QGCPalette::_window[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { @@ -64,8 +64,13 @@ QColor QGCPalette::_window[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { }; QColor QGCPalette::_windowText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0, 0, 0), QColor(0, 0, 0), QColor(0, 0, 0) }, - { QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) } + { QColor(0x58, 0x58, 0x58), QColor(0, 0, 0), QColor(0, 0, 0) }, + { QColor(0x58, 0x58, 0x58), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) } +}; + +QColor QGCPalette::_buttonHighlight[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { + { QColor(0x58, 0x58, 0x58), QColor(0xee, 0xe3, 0x33), QColor(0xee, 0xe3, 0x33) }, + { QColor(0x58, 0x58, 0x58), QColor(0xee, 0xe3, 0x33), QColor(0xee, 0xe3, 0x33) }, }; QGCPalette::QGCPalette(QObject* parent) : diff --git a/src/QGCPalette.h b/src/QGCPalette.h index 61b2a9ebde587891726d612c0ae3f71bf494cca4..85b7e142709be8edafe619a26565bfeda0d5335d 100644 --- a/src/QGCPalette.h +++ b/src/QGCPalette.h @@ -50,6 +50,9 @@ class QGCPalette : public QObject Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) + + /// The buttonHighlight color identifies the button background color when hovered or selected. + Q_PROPERTY(QColor buttonHighlight READ buttonHighlight NOTIFY paletteChanged) public: enum ColorGroup { @@ -76,6 +79,7 @@ public: QColor text(void) const { return _text[_theme][_colorGroup]; } QColor window(void) const { return _window[_theme][_colorGroup]; } QColor windowText(void) const { return _windowText[_theme][_colorGroup]; } + QColor buttonHighlight(void) const { return _buttonHighlight[_theme][_colorGroup]; } static Theme globalTheme(void) { return _theme; } static void setGlobalTheme(Theme newTheme); @@ -97,6 +101,7 @@ private: static QColor _text[_cThemes][_cColorGroups]; static QColor _window[_cThemes][_cColorGroups]; static QColor _windowText[_cThemes][_cColorGroups]; + static QColor _buttonHighlight[_cThemes][_cColorGroups]; void _themeChanged(void); diff --git a/src/QmlControls/QGCButton.qml b/src/QmlControls/QGCButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..d60b06b0cf696fae493c4ebb184270d025db4357 --- /dev/null +++ b/src/QmlControls/QGCButton.qml @@ -0,0 +1,28 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Palette 1.0 + +Button { + property var __qgcPal: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } + + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 25 + color: control.hovered ? control.__qgcPal.buttonHighlight : control.__qgcPal.button + } + + label: Text { + width: parent.width + height: parent.height + + verticalAlignment: TextEdit.AlignVCenter + horizontalAlignment: TextEdit.AlignHCenter + + text: control.text + color: control.__qgcPal.buttonText + } + } +} diff --git a/src/QmlControls/QGCCheckBox.qml b/src/QmlControls/QGCCheckBox.qml new file mode 100644 index 0000000000000000000000000000000000000000..85af8269320b86bbf603306f7bd6e52f7b2c5351 --- /dev/null +++ b/src/QmlControls/QGCCheckBox.qml @@ -0,0 +1,35 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Palette 1.0 + +CheckBox { + property var __qgcPal: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } + + style: CheckBoxStyle { + label: Item { + implicitWidth: text.implicitWidth + 2 + implicitHeight: text.implicitHeight + baselineOffset: text.baselineOffset + Rectangle { + anchors.fill: text + anchors.margins: -1 + anchors.leftMargin: -3 + anchors.rightMargin: -3 + visible: control.activeFocus + height: 6 + radius: 3 + color: "#224f9fef" + border.color: "#47b" + opacity: 0.6 + } + Text { + id: text + text: control.text + anchors.centerIn: parent + color: control.__qgcPal.windowText + } + } + } +} diff --git a/src/QmlControls/QGCLabel.qml b/src/QmlControls/QGCLabel.qml new file mode 100644 index 0000000000000000000000000000000000000000..7ddcda552187a4579df18ce697eecb5a7c8d5e9c --- /dev/null +++ b/src/QmlControls/QGCLabel.qml @@ -0,0 +1,12 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Palette 1.0 + +Text { + property var __palette: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } + property bool enabled: true + + color: __palette.windowText +} diff --git a/src/QmlControls/QGCRadioButton.qml b/src/QmlControls/QGCRadioButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..27901baf81c68560f8f08e15fc9ece66ae70fa69 --- /dev/null +++ b/src/QmlControls/QGCRadioButton.qml @@ -0,0 +1,35 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Palette 1.0 + +RadioButton { + property var __qgcPal: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } + + style: RadioButtonStyle { + label: Item { + implicitWidth: text.implicitWidth + 2 + implicitHeight: text.implicitHeight + baselineOffset: text.y + text.baselineOffset + Rectangle { + anchors.fill: text + anchors.margins: -1 + anchors.leftMargin: -3 + anchors.rightMargin: -3 + visible: control.activeFocus + height: 6 + radius: 3 + color: "#224f9fef" + border.color: "#47b" + opacity: 0.6 + } + Text { + id: text + text: control.text + anchors.centerIn: parent + color: control.__qgcPal.windowText + } + } + } +} diff --git a/src/QmlControls/QmlTest.qml b/src/QmlControls/QmlTest.qml new file mode 100644 index 0000000000000000000000000000000000000000..627341bbba13712506fab297024fce17286b699e --- /dev/null +++ b/src/QmlControls/QmlTest.qml @@ -0,0 +1,344 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 + +Rectangle { + + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + color: palette.window + + Column { + spacing: 10 + + Grid { + columns: 4 + spacing: 5 + + Component { + id: colorSquare + + Rectangle { + width: 80 + height: 20 + border.width: 1 + border.color: "white" + color: parent.color + } + } + + Component { + id: rowHeader + + Text { + width: 120 + height: 20 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + color: palette.windowText + text: parent.text + } + } + + + // Header row + Loader { + sourceComponent: rowHeader + property var text: "" + } + Text { + width: 80 + height: 20 + color: palette.windowText + horizontalAlignment: Text.AlignHCenter + text: "Disabled" + } + Text { + width: 80 + height: 20 + color: palette.windowText + horizontalAlignment: Text.AlignHCenter + text: "Active" + } + Text { + width: 80 + height: 20 + color: palette.windowText + horizontalAlignment: Text.AlignHCenter + text: "Inactive" + } + + Loader { + sourceComponent: rowHeader + property var text: "alternateBase" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.alternateBase + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.alternateBase + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.alternateBase + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "base" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.base + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.base + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.base + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "button" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.button + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.button + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.button + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "buttonHighlight" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.buttonHighlight + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.buttonHighlight + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.buttonHighlight + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "buttonText" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.buttonText + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.buttonText + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.buttonText + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "text" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.text + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.text + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.text + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "window" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.window + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.window + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.window + sourceComponent: colorSquare + } + + Loader { + sourceComponent: rowHeader + property var text: "windowText" + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Disabled } + property var color: palette.windowText + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Active } + property var color: palette.windowText + sourceComponent: colorSquare + } + Loader { + property var palette: QGCPalette { colorGroup: QGCPalette.Inactive } + property var color: palette.windowText + sourceComponent: colorSquare + } + + } + + Item { + width: parent.width + height: 30 + } + + Grid { + columns: 3 + spacing: 5 + + Component { + id: ctlRowHeader + + Text { + width: 120 + height: 20 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + color: palette.windowText + text: parent.text + } + } + + + // Header row + Loader { + sourceComponent: ctlRowHeader + property var text: "" + } + Text { + width: 100 + height: 20 + color: palette.windowText + horizontalAlignment: Text.AlignHCenter + text: "Enabled" + } + Text { + width: 100 + height: 20 + color: palette.windowText + horizontalAlignment: Text.AlignHCenter + text: "Disabled" + } + + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCLabel" + } + QGCLabel { + width: 100 + height: 20 + text: "Label" + } + QGCLabel { + width: 100 + height: 20 + text: "Label" + enabled: false + } + + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCButton" + } + QGCButton { + width: 100 + height: 20 + text: "Button" + } + QGCButton { + width: 100 + height: 20 + text: "Button" + enabled: false + } + + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCRadioButton" + } + QGCRadioButton { + width: 100 + height: 20 + text: "Radio" + } + QGCRadioButton { + width: 100 + height: 20 + text: "Radio" + enabled: false + } + + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCCheckBox" + } + QGCCheckBox { + width: 100 + height: 20 + text: "Check Box" + } + QGCCheckBox { + width: 100 + height: 20 + text: "Check Box" + enabled: false + } + + } + } +} diff --git a/src/QmlControls/QmlTestWidget.cc b/src/QmlControls/QmlTestWidget.cc new file mode 100644 index 0000000000000000000000000000000000000000..f9f404c3f362cc02d6b5f688ad832479506b5769 --- /dev/null +++ b/src/QmlControls/QmlTestWidget.cc @@ -0,0 +1,35 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +/// @file +/// @author Don Gagne + +#include "QmlTestWidget.h" + +QmlTestWidget::QmlTestWidget(void) +{ + setAttribute(Qt::WA_DeleteOnClose); + resize(500, 500); + setVisible(true); + setSource(QUrl::fromUserInput("qrc:qml/QmlTest.qml")); +} diff --git a/src/QmlControls/QmlTestWidget.h b/src/QmlControls/QmlTestWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..4fc6d602710a072d633725b33032489c74b17ce3 --- /dev/null +++ b/src/QmlControls/QmlTestWidget.h @@ -0,0 +1,42 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +#ifndef QmlTestWidget_h +#define QmlTestWidget_h + +/// @file +/// @author Don Gagne + +#include "QGCQmlWidgetHolder.h" + +/// This is used to create widgets which are implemented in QML. + +class QmlTestWidget : public QGCQmlWidgetHolder +{ + Q_OBJECT + +public: + QmlTestWidget(void); +}; + +#endif diff --git a/qml/QGroundControl/Controls/SetupButton.qml b/src/QmlControls/SetupButton.qml similarity index 98% rename from qml/QGroundControl/Controls/SetupButton.qml rename to src/QmlControls/SetupButton.qml index 64b720663f0ceada7a297eecd818768ab4816569..cefc33421102d01d8e46c49f5c62d00c4bde08fd 100644 --- a/qml/QGroundControl/Controls/SetupButton.qml +++ b/src/QmlControls/SetupButton.qml @@ -2,7 +2,8 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 import QtGraphicalEffects 1.0 -import QGroundControl.FactSystem 1.0 + +import QGroundControl.Palette 1.0 Button { checkable: true diff --git a/src/QmlControls/qmldir b/src/QmlControls/qmldir new file mode 100644 index 0000000000000000000000000000000000000000..c617f80c6ec8ca310efb15effd9d231c6f762041 --- /dev/null +++ b/src/QmlControls/qmldir @@ -0,0 +1,6 @@ +Module QGroundControl.Controls +SetupButton 1.0 SetupButton.qml +QGCLabel 1.0 QGCLabel.qml +QGCButton 1.0 QGCButton.qml +QGCRadioButton 1.0 QGCRadioButton.qml +QGCCheckBox 1.0 QGCCheckBox.qml diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml new file mode 100644 index 0000000000000000000000000000000000000000..1dcbdcefb7f874dee047c53c510a9a57601f4be1 --- /dev/null +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -0,0 +1,37 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.Controls 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 + +Rectangle { + width: 600 + height: 400 + + property var qgcPal: QGCPalette { colorGroup: QGCPalette.Active } + + color: qgcPal.window + + Text { + text: "FIRMWARE UPDATE" + color: qgcPal.windowText + font.pointSize: 20 + } + + Column { + QGCRadioButton { + text: qsTr("Standard Version (stable)") + } + QGCRadioButton { + text: qsTr("Beta Testing (beta)") + } + QGCRadioButton { + text: qsTr("Developer Build (master)") + } + QGCRadioButton { + text: qsTr("Custom firmware file...") + } + } +} diff --git a/src/VehicleSetup/SetupView.cc b/src/VehicleSetup/SetupView.cc index fd13f54e78b954762ff6c68e518d1c59ae781a78..c4c4db7d11793c3807fac761fa7281edf9753fb2 100644 --- a/src/VehicleSetup/SetupView.cc +++ b/src/VehicleSetup/SetupView.cc @@ -132,8 +132,17 @@ void SetupView::_firmwareButtonClicked(void) QGCMessageBox::warning("Setup", "Firmware Update cannot be performed while vehicle is armed."); return; } - + +#if 1 PX4FirmwareUpgrade* setup = new PX4FirmwareUpgrade(this); +#else + // NYI + QGCQmlWidgetHolder* setup = new QGCQmlWidgetHolder; + Q_CHECK_PTR(setup); + + //setup->setAutoPilot(_autoPilotPlugin); + setup->setSource(QUrl::fromUserInput("qrc:/qml/FirmwareUpgrade.qml")); +#endif _changeSetupWidget(setup); } diff --git a/src/VehicleSetup/SetupViewButtons.qml b/src/VehicleSetup/SetupViewButtons.qml index 8d8aa34a7d8f7fa15a28845c0f48c02825ed3899..b0e1e3066309ade647a3c2bf983e9e3805a42130 100644 --- a/src/VehicleSetup/SetupViewButtons.qml +++ b/src/VehicleSetup/SetupViewButtons.qml @@ -2,6 +2,9 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 import QGroundControl.FactSystem 1.0 +import QtGraphicalEffects 1.0 + +import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 Rectangle { diff --git a/src/VehicleSetup/VehicleSummary.qml b/src/VehicleSetup/VehicleSummary.qml index 8569e290c37ad150b15a8f7c2577c18be7c76a4f..acc4d5da4f720f47efeea3571b6f6e2fe4dcc2a5 100644 --- a/src/VehicleSetup/VehicleSummary.qml +++ b/src/VehicleSetup/VehicleSummary.qml @@ -1,7 +1,9 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 + import QGroundControl.FactSystem 1.0 +import QGroundControl.Palette 1.0 Rectangle { width: 600 diff --git a/src/test.qml b/src/test.qml index fa45fe27200c03b3736a1d3782293286efcaea7d..7016fe38abc3f270c64ab2b36531ea07d547d09d 100644 --- a/src/test.qml +++ b/src/test.qml @@ -1,7 +1,9 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 + import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 Rectangle { diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index d5bc4f960c6a0cb17285754bdd3e3db37a667a93..acddb2bc3620a3f4df52599b802fe6204909932d 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -71,6 +71,10 @@ This file is part of the QGROUNDCONTROL project #include "QGCMessageBox.h" #include "QGCDockWidget.h" +#ifdef UNITTEST_BUILD +#include "QmlControls/QmlTestWidget.h" +#endif + #ifdef QGC_OSG_ENABLED #include "Q3DWidgetFactory.h" #endif @@ -186,6 +190,12 @@ MainWindow::MainWindow(QSplashScreen* splashScreen) : #ifdef Q_OS_LINUX menuBar()->setNativeMenuBar(false); #endif + +#ifdef UNITTEST_BUILD + QAction* qmlTestAction = new QAction("Test QML palette and controls", NULL); + connect(qmlTestAction, &QAction::triggered, this, &MainWindow::_showQmlTestWidget); + ui.menuTools->addAction(qmlTestAction); +#endif // Setup UI state machines centerStackActionGroup->setExclusive(true); @@ -338,7 +348,7 @@ MainWindow::MainWindow(QSplashScreen* splashScreen) : connect(&windowNameUpdateTimer, SIGNAL(timeout()), this, SLOT(configureWindowName())); windowNameUpdateTimer.start(15000); emit initStatusChanged(tr("Done"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); - + if (!qgcApp()->runningUnitTests()) { show(); } @@ -1519,3 +1529,11 @@ bool MainWindow::x11Event(XEvent *event) return false; } #endif // QGC_MOUSE_ENABLED_LINUX + +#ifdef UNITTEST_BUILD +void MainWindow::_showQmlTestWidget(void) +{ + new QmlTestWidget(); +} +#endif + diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index b10ea3fa24552b4a9a97d995033e6bcdfc52f253..7ebd2fc34c935fa57082b139020cd6e469577fef 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -294,7 +294,10 @@ private slots: void _showDockWidgetAction(bool show); void _loadCustomWidgetFromFile(void); void _createNewCustomWidget(void); - +#ifdef UNITTEST_BUILD + void _showQmlTestWidget(void); +#endif + private: /// Constructor is private since all creation should be through MainWindow::_create MainWindow(QSplashScreen* splashScreen);