Commit ad5cde3b authored by Don Gagne's avatar Don Gagne

Updated palette and control implementation

parent b1a9d302
...@@ -247,11 +247,12 @@ ...@@ -247,11 +247,12 @@
<file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file> <file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file>
<file alias="QGroundControl/Controls/qmldir">src/QmlControls/qmldir</file> <file alias="QGroundControl/Controls/qmldir">src/QmlControls/qmldir</file>
<file alias="QGroundControl/Controls/SetupButton.qml">src/QmlControls/SetupButton.qml</file> <file alias="QGroundControl/Controls/SubMenuButton.qml">src/QmlControls/SubMenuButton.qml</file>
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file> <file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file> <file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file>
<file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file> <file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file>
<file alias="QGroundControl/Controls/QGCLabel.qml">src/QmlControls/QGCLabel.qml</file> <file alias="QGroundControl/Controls/QGCLabel.qml">src/QmlControls/QGCLabel.qml</file>
<file alias="QGroundControl/Controls/QGCTextField.qml">src/QmlControls/QGCTextField.qml</file>
<file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file> <file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file>
<file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file> <file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file>
...@@ -268,7 +269,7 @@ ...@@ -268,7 +269,7 @@
<file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file> <file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file>
<file alias="AirframeComponentSummary.qml">src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml</file> <file alias="AirframeComponentSummary.qml">src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml</file>
<file alias="QGroundControl/Controls/setupButtonImage.png">files/Setup/cogwheels.png</file> <file alias="QGroundControl/Controls/subMenuButtonImage.png">files/Setup/cogwheels.png</file>
<file alias="QGroundControl/Controls/SensorsComponentIcon.png">src/AutoPilotPlugins/PX4/SensorsComponentIcon.png</file> <file alias="QGroundControl/Controls/SensorsComponentIcon.png">src/AutoPilotPlugins/PX4/SensorsComponentIcon.png</file>
<file alias="QGroundControl/Controls/RadioComponentIcon.png">src/AutoPilotPlugins/PX4/RadioComponentIcon.png</file> <file alias="QGroundControl/Controls/RadioComponentIcon.png">src/AutoPilotPlugins/PX4/RadioComponentIcon.png</file>
<file alias="QGroundControl/Controls/FlightModesComponentIcon.png">src/AutoPilotPlugins/PX4/FlightModesComponentIcon.png</file> <file alias="QGroundControl/Controls/FlightModesComponentIcon.png">src/AutoPilotPlugins/PX4/FlightModesComponentIcon.png</file>
......
...@@ -51,7 +51,7 @@ QString SafetyComponent::description(void) const ...@@ -51,7 +51,7 @@ QString SafetyComponent::description(void) const
QString SafetyComponent::iconResource(void) const QString SafetyComponent::iconResource(void) const
{ {
// FIXME: Need real icon // FIXME: Need real icon
return "setupButtonImage.png"; return "subMenuButtonImage.png";
} }
bool SafetyComponent::requiresSetup(void) const bool SafetyComponent::requiresSetup(void) const
......
...@@ -7,7 +7,7 @@ import QGroundControl.FactControls 1.0 ...@@ -7,7 +7,7 @@ import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Rectangle { Rectangle {
QGCPalette { id: palette; colorGroup: QGCPalette.Active } QGCPalette { id: palette; colorGroupEnabled: true }
width: 600 width: 600
height: 600 height: 600
...@@ -21,12 +21,12 @@ Rectangle { ...@@ -21,12 +21,12 @@ Rectangle {
//-- Return Home Triggers //-- Return Home Triggers
Column { Column {
spacing: 18 spacing: 18
Label { text: "Triggers For Return Home"; color: palette.windowText; font.pointSize: 20 } Label { text: "Triggers For Return Home"; color: palette.text; font.pointSize: 20 }
Row { Row {
Label { Label {
width: leftColWidth width: leftColWidth
text: "RC Transmitter Signal Loss - Return Home After" text: "RC Transmitter Signal Loss - Return Home After"
color: palette.windowText color: palette.text
anchors.baseline: rcLossField.baseline anchors.baseline: rcLossField.baseline
} }
FactTextField { FactTextField {
...@@ -56,12 +56,12 @@ Rectangle { ...@@ -56,12 +56,12 @@ Rectangle {
//-- Return Home Options //-- Return Home Options
Column { Column {
spacing: 18 spacing: 18
Label { text: "Return Home Options"; color: palette.windowText; font.pointSize: 20 } Label { text: "Return Home Options"; color: palette.text; font.pointSize: 20 }
Row { Row {
Label { Label {
width: leftColWidth width: leftColWidth
text: "Climb to minimum altitude of " text: "Climb to minimum altitude of "
color: palette.windowText color: palette.text
anchors.baseline: climbField.baseline anchors.baseline: climbField.baseline
} }
FactTextField { FactTextField {
...@@ -82,7 +82,7 @@ Rectangle { ...@@ -82,7 +82,7 @@ Rectangle {
} }
style: CheckBoxStyle { style: CheckBoxStyle {
label: Text { label: Text {
color: palette.windowText color: palette.text
text: control.text text: control.text
} }
} }
...@@ -102,7 +102,7 @@ Rectangle { ...@@ -102,7 +102,7 @@ Rectangle {
Label { Label {
width: leftColWidth; width: leftColWidth;
text: "When Home is reached, loiter at an altitude of "; text: "When Home is reached, loiter at an altitude of ";
color: palette.windowText; color: palette.text;
anchors.baseline: descendField.baseline anchors.baseline: descendField.baseline
visible: homeLoiterCheckbox.checked == true visible: homeLoiterCheckbox.checked == true
} }
...@@ -120,7 +120,7 @@ Rectangle { ...@@ -120,7 +120,7 @@ Rectangle {
font.pointSize: 14 font.pointSize: 14
text: "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply."; text: "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.";
visible: autopilot.parameters["NAV_RCL_OBC"].value != 0 visible: autopilot.parameters["NAV_RCL_OBC"].value != 0
color: palette.windowText color: palette.text
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
Text { Text {
...@@ -128,7 +128,7 @@ Rectangle { ...@@ -128,7 +128,7 @@ Rectangle {
font.pointSize: 14 font.pointSize: 14
text: "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply."; text: "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.";
visible: autopilot.parameters["NAV_DLL_OBC"].value != 0 visible: autopilot.parameters["NAV_DLL_OBC"].value != 0
color: palette.windowText color: palette.text
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
} }
......
...@@ -66,36 +66,52 @@ QString Fact::valueString(void) const ...@@ -66,36 +66,52 @@ QString Fact::valueString(void) const
QVariant Fact::defaultValue(void) QVariant Fact::defaultValue(void)
{ {
Q_ASSERT(_metaData);
return _metaData->defaultValue; return _metaData->defaultValue;
} }
FactMetaData::ValueType_t Fact::type(void) FactMetaData::ValueType_t Fact::type(void)
{ {
Q_ASSERT(_metaData);
return _metaData->type; return _metaData->type;
} }
QString Fact::shortDescription(void) QString Fact::shortDescription(void)
{ {
return _metaData->shortDescription; if (_metaData) {
return _metaData->shortDescription;
} else {
return QString();
}
} }
QString Fact::longDescription(void) QString Fact::longDescription(void)
{ {
return _metaData->longDescription; if (_metaData) {
return _metaData->longDescription;
} else {
return QString();
}
} }
QString Fact::units(void) QString Fact::units(void)
{ {
return _metaData->units; if (_metaData) {
return _metaData->units;
} else {
return QString();
}
} }
QVariant Fact::min(void) QVariant Fact::min(void)
{ {
Q_ASSERT(_metaData);
return _metaData->min; return _metaData->min;
} }
QVariant Fact::max(void) QVariant Fact::max(void)
{ {
Q_ASSERT(_metaData);
return _metaData->max; return _metaData->max;
} }
......
...@@ -33,59 +33,69 @@ QList<QGCPalette*> QGCPalette::_paletteObjects; ...@@ -33,59 +33,69 @@ QList<QGCPalette*> QGCPalette::_paletteObjects;
QGCPalette::Theme QGCPalette::_theme = QGCPalette::Dark; QGCPalette::Theme QGCPalette::_theme = QGCPalette::Dark;
QColor QGCPalette::_alternateBase[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_window[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6) }, { QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6) },
{ QColor(2, 2, 2), QColor(2, 2, 2), QColor(2, 2, 2) } { QColor(0x22, 0x22, 0x22), QColor(0x22, 0x22, 0x22) }
};
QColor QGCPalette::_windowShade[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(255, 235, 211), QColor(255, 235, 211) },
{ QColor(51, 51, 51), QColor(51, 51, 51) }
};
QColor QGCPalette::_windowShadeDark[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(216, 216, 216), QColor(216, 216, 216) },
{ QColor(40, 40, 40), QColor(40, 40, 40) }
}; };
QColor QGCPalette::_base[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_text[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6) }, { QColor(0x58, 0x58, 0x58), QColor(0, 0, 0) },
{ QColor(2, 2, 2), QColor(2, 2, 2), QColor(2, 2, 2) } { QColor(0x58, 0x58, 0x58), QColor(0xFF, 0xFF, 0xFF) }
}; };
QColor QGCPalette::_button[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_button[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0x58, 0x58, 0x58), QColor(0x1b, 0x6f, 0xad), QColor(0x1b, 0x6f, 0xad) }, { QColor(0x58, 0x58, 0x58), QColor(0x1b, 0x6f, 0xad) },
{ QColor(0x58, 0x58, 0x58), QColor(0x1b, 0x6f, 0xad), QColor(0x1b, 0x6f, 0xad) }, { QColor(0x58, 0x58, 0x58), QColor(98, 98, 100) },
}; };
QColor QGCPalette::_buttonText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_buttonText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0x2c, 0x2c, 0x2c), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) }, { QColor(0x2c, 0x2c, 0x2c), 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 QGCPalette::_text[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_buttonHighlight[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0x58, 0x58, 0x58), QColor(0, 0, 0), QColor(0, 0, 0) }, { QColor(0x58, 0x58, 0x58), QColor(237, 235, 51) },
{ QColor(0x58, 0x58, 0x58), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) } { QColor(0x58, 0x58, 0x58), QColor(237, 235, 51) },
}; };
QColor QGCPalette::_window[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_buttonHighlightText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6), QColor(0xF6, 0xF6, 0xF6) }, { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) },
{ QColor(0x22, 0x22, 0x22), QColor(0x22, 0x22, 0x22), QColor(0x22, 0x22, 0x22) } { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) },
}; };
QColor QGCPalette::_windowShade[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_primaryButton[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(255, 235, 211), QColor(255, 235, 211), QColor(255, 235, 211) }, { QColor(0x58, 0x58, 0x58), QColor(152, 255, 252) },
{ QColor(51, 51, 51), QColor(51, 51, 51), QColor(51, 51, 51) } { QColor(0x58, 0x58, 0x58), QColor(152, 255, 252) },
}; };
QColor QGCPalette::_windowShadeDark[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_primaryButtonText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(216, 216, 216), QColor(216, 216, 216), QColor(216, 216, 216) }, { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) },
{ QColor(40, 40, 40), QColor(40, 40, 40), QColor(40, 40, 40) } { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) },
}; };
QColor QGCPalette::_windowText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_textField[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0x58, 0x58, 0x58), QColor(0, 0, 0), QColor(0, 0, 0) }, { QColor(0x58, 0x58, 0x58), QColor(255, 255, 255) },
{ QColor(0x58, 0x58, 0x58), QColor(0xFF, 0xFF, 0xFF), QColor(0xFF, 0xFF, 0xFF) } { QColor(0x58, 0x58, 0x58), QColor(255, 255, 255) },
}; };
QColor QGCPalette::_buttonHighlight[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { QColor QGCPalette::_textFieldText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = {
{ QColor(0x58, 0x58, 0x58), QColor(238, 227, 51), QColor(238, 227, 51) }, { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) },
{ QColor(0x58, 0x58, 0x58), QColor(238, 227, 51), QColor(238, 227, 51) }, { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) },
}; };
QGCPalette::QGCPalette(QObject* parent) : QGCPalette::QGCPalette(QObject* parent) :
QObject(parent), QObject(parent),
_colorGroup(Active) _colorGroupEnabled(true)
{ {
// We have to keep track of all QGCPalette objects in the system so we can signal theme change to all of them // We have to keep track of all QGCPalette objects in the system so we can signal theme change to all of them
_paletteObjects += this; _paletteObjects += this;
...@@ -98,9 +108,9 @@ QGCPalette::~QGCPalette() ...@@ -98,9 +108,9 @@ QGCPalette::~QGCPalette()
Q_UNUSED(fSuccess); Q_UNUSED(fSuccess);
} }
void QGCPalette::setColorGroup(ColorGroup colorGroup) void QGCPalette::setColorGroupEnabled(bool enabled)
{ {
_colorGroup = colorGroup; _colorGroupEnabled = enabled;
emit paletteChanged(); emit paletteChanged();
} }
......
...@@ -39,34 +39,54 @@ class QGCPalette : public QObject ...@@ -39,34 +39,54 @@ class QGCPalette : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(ColorGroup) Q_ENUMS(Theme)
Q_PROPERTY(ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) Q_PROPERTY(Theme globalTheme READ globalTheme WRITE setGlobalTheme NOTIFY paletteChanged)
Q_PROPERTY(bool colorGroupEnabled READ colorGroupEnabled WRITE setColorGroupEnabled NOTIFY paletteChanged)
Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) /// Background color for windows
Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
/// Color for shaded areas within a window. The windowShade color should be a color somewhere between window and button.
Q_PROPERTY(QColor windowShade READ windowShade NOTIFY paletteChanged)
/// Color for darker shared areas within a window. The windowShadeDark color should be a color somewhere between window and windowShade.
Q_PROPERTY(QColor windowShadeDark READ windowShadeDark NOTIFY paletteChanged)
/// Standard text color for label text
Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
/// Background color for buttons
Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
/// Text color for buttons
Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
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. /// Background color for button in selected or hover state
Q_PROPERTY(QColor buttonHighlight READ buttonHighlight NOTIFY paletteChanged) Q_PROPERTY(QColor buttonHighlight READ buttonHighlight NOTIFY paletteChanged)
/// Text color for button in selected or hover state
Q_PROPERTY(QColor buttonHighlightText READ buttonHighlightText NOTIFY paletteChanged)
/// The windowShade color should be a color somewhere between window and button. It is used to shade window /// Background color for primary buttons. A primary button is the button which would be the
/// areas. /// normal default button to press. For example in an Ok/Cancel situation where Ok would normally
Q_PROPERTY(QColor windowShade READ windowShade NOTIFY paletteChanged) /// be pressed, Ok is the primary button.
Q_PROPERTY(QColor primaryButton READ primaryButton NOTIFY paletteChanged)
/// The windowShadeDark color should be a color somewhere between window and windowShade. It is used to shade window /// Text color for buttons
/// darker areas. Q_PROPERTY(QColor primaryButtonText READ primaryButtonText NOTIFY paletteChanged)
Q_PROPERTY(QColor windowShadeDark READ windowShadeDark NOTIFY paletteChanged)
// Background color for TextFields
Q_PROPERTY(QColor textField READ textField NOTIFY paletteChanged)
// Text color for TextFields
Q_PROPERTY(QColor textFieldText READ textFieldText NOTIFY paletteChanged)
public: public:
enum ColorGroup { enum ColorGroup {
Disabled = 0, Disabled = 0,
Active, Enabled
Inactive
}; };
enum Theme { enum Theme {
...@@ -77,19 +97,25 @@ public: ...@@ -77,19 +97,25 @@ public:
QGCPalette(QObject* parent = NULL); QGCPalette(QObject* parent = NULL);
~QGCPalette(); ~QGCPalette();
ColorGroup colorGroup(void) const { return _colorGroup; } bool colorGroupEnabled(void) const { return _colorGroupEnabled; }
void setColorGroup(ColorGroup colorGroup); void setColorGroupEnabled(bool enabled);
QColor window(void) const { return _window[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor windowShade(void) const { return _windowShade[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor windowShadeDark(void) const { return _windowShadeDark[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor text(void) const { return _text[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor button(void) const { return _button[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor buttonText(void) const { return _buttonText[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor buttonHighlight(void) const { return _buttonHighlight[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor buttonHighlightText(void) const { return _buttonHighlightText[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor alternateBase(void) const { return _alternateBase[_theme][_colorGroup]; } QColor primaryButton(void) const { return _primaryButton[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor base(void) const { return _base[_theme][_colorGroup]; } QColor primaryButtonText(void) const { return _primaryButtonText[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor button(void) const { return _button[_theme][_colorGroup]; }
QColor buttonText(void) const { return _buttonText[_theme][_colorGroup]; } QColor textField(void) const { return _textField[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor text(void) const { return _text[_theme][_colorGroup]; } QColor textFieldText(void) const { return _textFieldText[_theme][_colorGroupEnabled ? 1 : 0]; }
QColor window(void) const { return _window[_theme][_colorGroup]; }
QColor windowShade(void) const { return _windowShade[_theme][_colorGroup]; }
QColor windowShadeDark(void) const { return _windowShadeDark[_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 Theme globalTheme(void) { return _theme; }
static void setGlobalTheme(Theme newTheme); static void setGlobalTheme(Theme newTheme);
...@@ -98,22 +124,30 @@ signals: ...@@ -98,22 +124,30 @@ signals:
void paletteChanged(void); void paletteChanged(void);
private: private:
static Theme _theme; ///< There is a single theme for all palettes static Theme _theme; ///< There is a single theme for all palettes
ColorGroup _colorGroup; ///< Currently selected ColorGroup bool _colorGroupEnabled; ///< Currently selected ColorGroup. true: enabled, false: disabled
static const int _cThemes = 2; static const int _cThemes = 2;
static const int _cColorGroups = 3; static const int _cColorGroups = 2;
static QColor _alternateBase[_cThemes][_cColorGroups];
static QColor _base[_cThemes][_cColorGroups];
static QColor _button[_cThemes][_cColorGroups];
static QColor _buttonText[_cThemes][_cColorGroups];
static QColor _text[_cThemes][_cColorGroups];
static QColor _window[_cThemes][_cColorGroups]; static QColor _window[_cThemes][_cColorGroups];
static QColor _windowShade[_cThemes][_cColorGroups]; static QColor _windowShade[_cThemes][_cColorGroups];
static QColor _windowShadeDark[_cThemes][_cColorGroups]; static QColor _windowShadeDark[_cThemes][_cColorGroups];
static QColor _windowText[_cThemes][_cColorGroups];
static QColor _text[_cThemes][_cColorGroups];
static QColor _button[_cThemes][_cColorGroups];
static QColor _buttonText[_cThemes][_cColorGroups];
static QColor _buttonHighlight[_cThemes][_cColorGroups]; static QColor _buttonHighlight[_cThemes][_cColorGroups];
static QColor _buttonHighlightText[_cThemes][_cColorGroups];
static QColor _primaryButton[_cThemes][_cColorGroups];
static QColor _primaryButtonText[_cThemes][_cColorGroups];
static QColor _primaryButtonHighlight[_cThemes][_cColorGroups];
static QColor _primaryButtonHighlightText[_cThemes][_cColorGroups];
static QColor _textField[_cThemes][_cColorGroups];
static QColor _textFieldText[_cThemes][_cColorGroups];
void _themeChanged(void); void _themeChanged(void);
......
...@@ -5,13 +5,20 @@ import QtQuick.Controls.Styles 1.2 ...@@ -5,13 +5,20 @@ import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Button { Button {
property var __qgcPal: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } // primary: true - this is the primary button for this group of buttons
property bool primary: false
property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
property bool __showHighlight: pressed | hovered | checked
style: ButtonStyle { style: ButtonStyle {
background: Rectangle { background: Rectangle {
implicitWidth: 100 implicitWidth: 100
implicitHeight: 25 implicitHeight: 25
color: control.pressed ? control.__qgcPal.buttonHighlight : control.__qgcPal.button color: __showHighlight ?
control.__qgcPal.buttonHighlight :
(primary ? control.__qgcPal.primaryButton : control.__qgcPal.button)
} }
label: Text { label: Text {
...@@ -22,7 +29,9 @@ Button { ...@@ -22,7 +29,9 @@ Button {
horizontalAlignment: TextEdit.AlignHCenter horizontalAlignment: TextEdit.AlignHCenter
text: control.text text: control.text
color: control.__qgcPal.buttonText color: __showHighlight ?
control.__qgcPal.buttonHighlightText :
(primary ? control.__qgcPal.primaryButtonText : control.__qgcPal.buttonText)
} }
} }
} }
...@@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.2 ...@@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
CheckBox { CheckBox {
property var __qgcPal: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
style: CheckBoxStyle { style: CheckBoxStyle {
label: Item { label: Item {
...@@ -28,7 +28,7 @@ CheckBox { ...@@ -28,7 +28,7 @@ CheckBox {
id: text id: text
text: control.text text: control.text
anchors.centerIn: parent anchors.centerIn: parent
color: control.__qgcPal.windowText color: control.__qgcPal.text
} }
} }
} }
......
...@@ -5,8 +5,8 @@ import QtQuick.Controls.Styles 1.2 ...@@ -5,8 +5,8 @@ import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Text { Text {
property var __palette: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } property var __palette: QGCPalette { colorGroupEnabled: enabled }
property bool enabled: true property bool enabled: true
color: __palette.windowText color: __palette.text
} }
...@@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.2 ...@@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
RadioButton { RadioButton {
property var __qgcPal: QGCPalette { colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
style: RadioButtonStyle { style: RadioButtonStyle {
label: Item { label: Item {
...@@ -28,7 +28,7 @@ RadioButton { ...@@ -28,7 +28,7 @@ RadioButton {
id: text id: text
text: control.text text: control.text
anchors.centerIn: parent anchors.centerIn: parent
color: control.__qgcPal.windowText color: control.__qgcPal.text
} }
} }
} }
......
...@@ -2,21 +2,19 @@ import QtQuick 2.2 ...@@ -2,21 +2,19 @@ import QtQuick 2.2
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2 import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
TextField { TextField {
property Fact fact: Fact { value: 0 }
property bool showUnits: false property bool showUnits: false
property string unitsLabel: ""
property var __qgcpal: QGCPalette { colorGroup: QGCPalette.Active } property var __qgcPal: QGCPalette { colorGroupEnabled: true }
text: fact.valueString textColor: __qgcPal.textFieldText
textColor: __qgcpal.text
Label { Label {
id: unitsLabelWidthGenerator id: unitsLabelWidthGenerator
text: parent.fact.units text: unitsLabel
width: contentWidth + ((parent.__contentHeight/3)*2) width: contentWidth + ((parent.__contentHeight/3)*2)
visible: false visible: false
} }
...@@ -35,7 +33,7 @@ TextField { ...@@ -35,7 +33,7 @@ TextField {
anchors.fill: parent anchors.fill: parent
border.color: control.activeFocus ? "#47b" : "#999" border.color: control.activeFocus ? "#47b" : "#999"
color: __qgcpal.base color: __qgcPal.textField
} }
Text { Text {
...@@ -50,7 +48,7 @@ TextField { ...@@ -50,7 +48,7 @@ TextField {
x: parent.width - width x: parent.width - width
width: unitsLabelWidthGenerator.width width: unitsLabelWidthGenerator.width
text: control.fact.units text: control.unitsLabel
color: control.textColor color: control.textColor
visible: control.showUnits visible: control.showUnits
} }
...@@ -58,6 +56,4 @@ TextField { ...@@ -58,6 +56,4 @@ TextField {
padding.right: control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight/3 padding.right: control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight/3
} }
onEditingFinished: fact.value = text
} }
This diff is collapsed.
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
QmlTestWidget::QmlTestWidget(void) QmlTestWidget::QmlTestWidget(void)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
resize(500, 500); resize(900, 500);
setVisible(true); setVisible(true);
setSource(QUrl::fromUserInput("qrc:qml/QmlTest.qml")); setSource(QUrl::fromUserInput("qrc:qml/QmlTest.qml"));
} }
...@@ -12,20 +12,22 @@ Button { ...@@ -12,20 +12,22 @@ Button {
text: "Button" text: "Button"
property bool setupComplete: true property bool setupComplete: true
property bool setupIndicator: true property bool setupIndicator: true
property string imageResource: "setupButtonImage.png" property string imageResource: "subMenuButtonImage.png"
style: ButtonStyle { style: ButtonStyle {
id: buttonStyle id: buttonStyle
property var __qgcPal: QGCPalette { property var __qgcPal: QGCPalette {
colorGroup: control.enabled ? QGCPalette.Active : QGCPalette.Disabled colorGroupEnabled: control.enabled
} }
property bool __showHighlight: control.pressed | control.checked
background: Rectangle { background: Rectangle {
id: innerRect id: innerRect
readonly property real titleHeight: 20 readonly property real titleHeight: 20
color: control.pressed ? __qgcPal.buttonHighlight : (control.checked ? __qgcPal.buttonHighlight : __qgcPal.button) color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
Text { Text {
id: titleBar id: titleBar
...@@ -38,7 +40,7 @@ Button { ...@@ -38,7 +40,7 @@ Button {
text: control.text text: control.text
font.pixelSize: 12 font.pixelSize: 12
color: __qgcPal.buttonText color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
Rectangle { Rectangle {
id: setupIndicator id: setupIndicator
...@@ -76,7 +78,7 @@ Button { ...@@ -76,7 +78,7 @@ Button {
ColorOverlay { ColorOverlay {
anchors.fill: buttonImage anchors.fill: buttonImage
source: buttonImage source: buttonImage
color: control.pressed ? __qgcPal.buttonHighlight : (control.checked ? __qgcPal.buttonHighlight : __qgcPal.button) color: __showHighlight ? __qgcPal.buttonHighlight : __qgcPal.button
} }
} }
} }
......
Module QGroundControl.Controls Module QGroundControl.Controls
SetupButton 1.0 SetupButton.qml SubMenuButton 1.0 SubMenuButton.qml
QGCLabel 1.0 QGCLabel.qml QGCLabel 1.0 QGCLabel.qml
QGCButton 1.0 QGCButton.qml QGCButton 1.0 QGCButton.qml
QGCRadioButton 1.0 QGCRadioButton.qml QGCRadioButton 1.0 QGCRadioButton.qml
QGCCheckBox 1.0 QGCCheckBox.qml QGCCheckBox 1.0 QGCCheckBox.qml
QGCTextField 1.0 QGCTextField.qml
...@@ -11,7 +11,7 @@ Rectangle { ...@@ -11,7 +11,7 @@ Rectangle {
width: 600 width: 600
height: 600 height: 600
property var qgcPal: QGCPalette { colorGroup: QGCPalette.Active } property var qgcPal: QGCPalette { colorGroupEnabled: true }
property FirmwareUpgradeController controller: FirmwareUpgradeController { property FirmwareUpgradeController controller: FirmwareUpgradeController {
upgradeButton: upgradeButton upgradeButton: upgradeButton
statusLog: statusTextArea statusLog: statusTextArea
...@@ -25,7 +25,7 @@ Rectangle { ...@@ -25,7 +25,7 @@ Rectangle {
Text { Text {
text: "FIRMWARE UPDATE" text: "FIRMWARE UPDATE"
color: qgcPal.windowText color: qgcPal.text
font.pointSize: 20 font.pointSize: 20
} }
...@@ -97,7 +97,7 @@ Rectangle { ...@@ -97,7 +97,7 @@ Rectangle {
readOnly: true readOnly: true
frameVisible: false frameVisible: false
style: TextAreaStyle { style: TextAreaStyle {
textColor: qgcPal.windowText textColor: qgcPal.text
backgroundColor: qgcPal.windowShade backgroundColor: qgcPal.windowShade
} }
} }
......
...@@ -10,7 +10,7 @@ import QGroundControl.Controls 1.0 ...@@ -10,7 +10,7 @@ import QGroundControl.Controls 1.0
Rectangle { Rectangle {
id: topLevel id: topLevel
QGCPalette { id: palette; colorGroup: QGCPalette.Active } QGCPalette { id: palette; colorGroupEnabled: true }
color: palette.window color: palette.window
ExclusiveGroup { id: setupButtonGroup } ExclusiveGroup { id: setupButtonGroup }
...@@ -21,7 +21,7 @@ Rectangle { ...@@ -21,7 +21,7 @@ Rectangle {
Column { Column {
anchors.fill: parent anchors.fill: parent
SetupButton { SubMenuButton {
id: firmwareButton; objectName: "firmwareButton" id: firmwareButton; objectName: "firmwareButton"
width: parent.width width: parent.width
text: "FIRMWARE" text: "FIRMWARE"
...@@ -39,7 +39,7 @@ Rectangle { ...@@ -39,7 +39,7 @@ Rectangle {
Column { Column {
anchors.fill: parent anchors.fill: parent
SetupButton { SubMenuButton {
id: summaryButton; objectName: "summaryButton" id: summaryButton; objectName: "summaryButton"
width: parent.width width: parent.width
text: "SUMMARY" text: "SUMMARY"
...@@ -49,7 +49,7 @@ Rectangle { ...@@ -49,7 +49,7 @@ Rectangle {
onClicked: controller.summaryButtonClicked() onClicked: controller.summaryButtonClicked()
} }
SetupButton { SubMenuButton {
id: firmwareButton; objectName: "firmwareButton" id: firmwareButton; objectName: "firmwareButton"
width: parent.width width: parent.width
text: "FIRMWARE" text: "FIRMWARE"
...@@ -62,7 +62,7 @@ Rectangle { ...@@ -62,7 +62,7 @@ Rectangle {
Repeater { Repeater {
model: autopilot.components model: autopilot.components
SetupButton { SubMenuButton {
width: parent.width width: parent.width
text: modelData.name.toUpperCase() text: modelData.name.toUpperCase()
imageResource: modelData.iconResource imageResource: modelData.iconResource
...@@ -72,7 +72,7 @@ Rectangle { ...@@ -72,7 +72,7 @@ Rectangle {
} }
} }
SetupButton { SubMenuButton {
width: parent.width width: parent.width
text: "PARAMETERS" text: "PARAMETERS"
setupIndicator: false setupIndicator: false
......
...@@ -9,7 +9,7 @@ Rectangle { ...@@ -9,7 +9,7 @@ Rectangle {
width: 600 width: 600
height: 400 height: 400
property var qgcPal: QGCPalette { id: palette; colorGroup: QGCPalette.Active } property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
id: topLevel id: topLevel
objectName: "topLevel" objectName: "topLevel"
......
...@@ -7,10 +7,10 @@ import QGroundControl.Palette 1.0 ...@@ -7,10 +7,10 @@ import QGroundControl.Palette 1.0
Rectangle { Rectangle {
QGCPalette { id: palette; colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } QGCPalette { id: palette; colorGroupEnabled: enabled }
width: 100 width: 100
height: 100 height: 100
color: "#e43f3f" color: "#e43f3f"
// palette.windowText // palette.text
} }
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