Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
130e7ff3
Commit
130e7ff3
authored
Apr 25, 2017
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All core plugin to override palette
parent
540ffbc5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
59 deletions
+92
-59
MissionItemEditor.qml
src/PlanView/MissionItemEditor.qml
+1
-1
QGCPalette.cc
src/QGCPalette.cc
+43
-31
QGCPalette.h
src/QGCPalette.h
+34
-23
QGCToolBarButton.qml
src/QmlControls/QGCToolBarButton.qml
+3
-3
QGCCorePlugin.cc
src/api/QGCCorePlugin.cc
+6
-0
QGCCorePlugin.h
src/api/QGCCorePlugin.h
+5
-1
No files found.
src/PlanView/MissionItemEditor.qml
View file @
130e7ff3
...
...
@@ -16,7 +16,7 @@ import QGroundControl.Palette 1.0
Rectangle
{
id
:
_root
height
:
editorLoader
.
y
+
editorLoader
.
height
+
(
_margin
*
2
)
color
:
_currentItem
?
qgcPal
.
primaryButton
:
qgcPal
.
windowShade
color
:
_currentItem
?
qgcPal
.
missionItemEditor
:
qgcPal
.
windowShade
radius
:
_radius
property
var
map
///< Map control
...
...
src/QGCPalette.cc
View file @
130e7ff3
...
...
@@ -12,6 +12,8 @@
/// @author Don Gagne <don@thegagnes.com>
#include "QGCPalette.h"
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include <QApplication>
#include <QPalette>
...
...
@@ -20,42 +22,16 @@ QList<QGCPalette*> QGCPalette::_paletteObjects;
QGCPalette
::
Theme
QGCPalette
::
_theme
=
QGCPalette
::
Dark
;
// Light Dark
// Disabled Enabled Disabled Enabled
DECLARE_QGC_COLOR
(
window
,
"#ffffff"
,
"#ffffff"
,
"#222222"
,
"#222222"
)
DECLARE_QGC_COLOR
(
windowShade
,
"#d9d9d9"
,
"#d9d9d9"
,
"#333333"
,
"#333333"
)
DECLARE_QGC_COLOR
(
windowShadeDark
,
"#bdbdbd"
,
"#bdbdbd"
,
"#282828"
,
"#282828"
)
DECLARE_QGC_COLOR
(
text
,
"#9d9d9d"
,
"#000000"
,
"#a0a0a0"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
warningText
,
"#cc0808"
,
"#cc0808"
,
"#f85761"
,
"#f85761"
)
DECLARE_QGC_COLOR
(
button
,
"#ffffff"
,
"#ffffff"
,
"#707070"
,
"#626270"
)
DECLARE_QGC_COLOR
(
buttonText
,
"#9d9d9d"
,
"#000000"
,
"#202020"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
buttonHighlight
,
"#e4e4e4"
,
"#946120"
,
"#3a3a3a"
,
"#fff291"
)
DECLARE_QGC_COLOR
(
buttonHighlightText
,
"#2c2c2c"
,
"#ffffff"
,
"#2c2c2c"
,
"#000000"
)
DECLARE_QGC_COLOR
(
primaryButton
,
"#585858"
,
"#8cb3be"
,
"#585858"
,
"#8cb3be"
)
DECLARE_QGC_COLOR
(
primaryButtonText
,
"#2c2c2c"
,
"#000000"
,
"#2c2c2c"
,
"#000000"
)
DECLARE_QGC_COLOR
(
textField
,
"#ffffff"
,
"#ffffff"
,
"#585858"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
textFieldText
,
"#dedede"
,
"#000000"
,
"#2c2c2c"
,
"#000000"
)
DECLARE_QGC_COLOR
(
mapButton
,
"#585858"
,
"#000000"
,
"#585858"
,
"#000000"
)
DECLARE_QGC_COLOR
(
mapButtonHighlight
,
"#585858"
,
"#be781c"
,
"#585858"
,
"#be781c"
)
DECLARE_QGC_COLOR
(
colorGreen
,
"#009431"
,
"#009431"
,
"#00e04b"
,
"#00e04b"
)
DECLARE_QGC_COLOR
(
colorOrange
,
"#b95604"
,
"#b95604"
,
"#de8500"
,
"#de8500"
)
DECLARE_QGC_COLOR
(
colorRed
,
"#ed3939"
,
"#ed3939"
,
"#f32836"
,
"#f32836"
)
DECLARE_QGC_COLOR
(
colorGrey
,
"#808080"
,
"#808080"
,
"#bfbfbf"
,
"#bfbfbf"
)
DECLARE_QGC_COLOR
(
colorBlue
,
"#1a72ff"
,
"#1a72ff"
,
"#536dff"
,
"#536dff"
)
DECLARE_QGC_COLOR
(
alertBackground
,
"#eecc44"
,
"#eecc44"
,
"#eecc44"
,
"#eecc44"
)
DECLARE_QGC_COLOR
(
alertBorder
,
"#808080"
,
"#808080"
,
"#808080"
,
"#808080"
)
DECLARE_QGC_COLOR
(
alertText
,
"#000000"
,
"#000000"
,
"#000000"
,
"#000000"
)
// Colors are not affecting by theming
DECLARE_QGC_COLOR
(
mapWidgetBorderLight
,
"#ffffff"
,
"#ffffff"
,
"#ffffff"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
mapWidgetBorderDark
,
"#000000"
,
"#000000"
,
"#000000"
,
"#000000"
)
DECLARE_QGC_COLOR
(
brandingPurple
,
"#4A2C6D"
,
"#4A2C6D"
,
"#4A2C6D"
,
"#4A2C6D"
)
DECLARE_QGC_COLOR
(
brandingBlue
,
"#48D6FF"
,
"#48D6FF"
,
"#48D6FF"
,
"#48D6FF"
)
QMap
<
int
,
QMap
<
int
,
QMap
<
QString
,
QColor
>>>
QGCPalette
::
_colorInfoMap
;
QGCPalette
::
QGCPalette
(
QObject
*
parent
)
:
QObject
(
parent
),
_colorGroupEnabled
(
true
)
{
if
(
_colorInfoMap
.
isEmpty
())
{
_buildMap
();
}
// We have to keep track of all QGCPalette objects in the system so we can signal theme change to all of them
_paletteObjects
+=
this
;
}
...
...
@@ -67,6 +43,42 @@ QGCPalette::~QGCPalette()
Q_UNUSED
(
fSuccess
);
}
void
QGCPalette
::
_buildMap
(
void
)
{
// Light Dark
// Disabled Enabled Disabled Enabled
DECLARE_QGC_COLOR
(
window
,
"#ffffff"
,
"#ffffff"
,
"#222222"
,
"#222222"
)
DECLARE_QGC_COLOR
(
windowShade
,
"#d9d9d9"
,
"#d9d9d9"
,
"#333333"
,
"#333333"
)
DECLARE_QGC_COLOR
(
windowShadeDark
,
"#bdbdbd"
,
"#bdbdbd"
,
"#282828"
,
"#282828"
)
DECLARE_QGC_COLOR
(
text
,
"#9d9d9d"
,
"#000000"
,
"#a0a0a0"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
warningText
,
"#cc0808"
,
"#cc0808"
,
"#f85761"
,
"#f85761"
)
DECLARE_QGC_COLOR
(
button
,
"#ffffff"
,
"#ffffff"
,
"#707070"
,
"#626270"
)
DECLARE_QGC_COLOR
(
buttonText
,
"#9d9d9d"
,
"#000000"
,
"#202020"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
buttonHighlight
,
"#e4e4e4"
,
"#946120"
,
"#3a3a3a"
,
"#fff291"
)
DECLARE_QGC_COLOR
(
buttonHighlightText
,
"#2c2c2c"
,
"#ffffff"
,
"#2c2c2c"
,
"#000000"
)
DECLARE_QGC_COLOR
(
primaryButton
,
"#585858"
,
"#8cb3be"
,
"#585858"
,
"#8cb3be"
)
DECLARE_QGC_COLOR
(
primaryButtonText
,
"#2c2c2c"
,
"#000000"
,
"#2c2c2c"
,
"#000000"
)
DECLARE_QGC_COLOR
(
textField
,
"#ffffff"
,
"#ffffff"
,
"#585858"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
textFieldText
,
"#dedede"
,
"#000000"
,
"#2c2c2c"
,
"#000000"
)
DECLARE_QGC_COLOR
(
mapButton
,
"#585858"
,
"#000000"
,
"#585858"
,
"#000000"
)
DECLARE_QGC_COLOR
(
mapButtonHighlight
,
"#585858"
,
"#be781c"
,
"#585858"
,
"#be781c"
)
DECLARE_QGC_COLOR
(
colorGreen
,
"#009431"
,
"#009431"
,
"#00e04b"
,
"#00e04b"
)
DECLARE_QGC_COLOR
(
colorOrange
,
"#b95604"
,
"#b95604"
,
"#de8500"
,
"#de8500"
)
DECLARE_QGC_COLOR
(
colorRed
,
"#ed3939"
,
"#ed3939"
,
"#f32836"
,
"#f32836"
)
DECLARE_QGC_COLOR
(
colorGrey
,
"#808080"
,
"#808080"
,
"#bfbfbf"
,
"#bfbfbf"
)
DECLARE_QGC_COLOR
(
colorBlue
,
"#1a72ff"
,
"#1a72ff"
,
"#536dff"
,
"#536dff"
)
DECLARE_QGC_COLOR
(
alertBackground
,
"#eecc44"
,
"#eecc44"
,
"#eecc44"
,
"#eecc44"
)
DECLARE_QGC_COLOR
(
alertBorder
,
"#808080"
,
"#808080"
,
"#808080"
,
"#808080"
)
DECLARE_QGC_COLOR
(
alertText
,
"#000000"
,
"#000000"
,
"#000000"
,
"#000000"
)
DECLARE_QGC_COLOR
(
missionItemEditor
,
"#585858"
,
"#8cb3be"
,
"#585858"
,
"#8cb3be"
)
// Colors are not affecting by theming
DECLARE_QGC_COLOR
(
mapWidgetBorderLight
,
"#ffffff"
,
"#ffffff"
,
"#ffffff"
,
"#ffffff"
)
DECLARE_QGC_COLOR
(
mapWidgetBorderDark
,
"#000000"
,
"#000000"
,
"#000000"
,
"#000000"
)
DECLARE_QGC_COLOR
(
brandingPurple
,
"#4A2C6D"
,
"#4A2C6D"
,
"#4A2C6D"
,
"#4A2C6D"
)
DECLARE_QGC_COLOR
(
brandingBlue
,
"#48D6FF"
,
"#48D6FF"
,
"#48D6FF"
,
"#48D6FF"
)
}
void
QGCPalette
::
setColorGroupEnabled
(
bool
enabled
)
{
_colorGroupEnabled
=
enabled
;
...
...
src/QGCPalette.h
View file @
130e7ff3
...
...
@@ -12,22 +12,25 @@
#include <QObject>
#include <QColor>
#define QGCColorThemes 2
#define QGCColorGroups 2
#define DECLARE_QGC_COLOR(name, lightEnabled, lightDisabled, darkEnabled, darkDisabled) \
QColor QGCPalette::_##name[QGCColorThemes][QGCColorGroups] = { \
{ QColor(lightEnabled), QColor(lightDisabled) }, \
{ QColor(darkEnabled), QColor(darkDisabled) }, \
};
#include <QMap>
#define DECLARE_QGC_COLOR(name, lightDisabled, lightEnabled, darkDisabled, darkEnabled) \
{ \
PaletteColorInfo_t colorInfo = { \
{ QColor(lightDisabled), QColor(lightEnabled) }, \
{ QColor(darkDisabled), QColor(darkEnabled) } \
}; \
qgcApp()->toolbox()->corePlugin()->paletteOverride(#name, colorInfo); \
_colorInfoMap[Light][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupEnabled]; \
_colorInfoMap[Light][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupDisabled]; \
_colorInfoMap[Dark][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupEnabled]; \
_colorInfoMap[Dark][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupDisabled]; \
}
#define DEFINE_QGC_COLOR(name, setName) \
Q_PROPERTY(QColor name READ name WRITE setName NOTIFY paletteChanged) \
QColor name() const { return _##name[_theme][_colorGroupEnabled ? 1 : 0]; } \
void setName(QColor& color) { _##name[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } \
static QColor _##name[QGCColorThemes][QGCColorGroups];
QColor name() const { return _colorInfoMap[_theme][_colorGroupEnabled ? ColorGroupEnabled : ColorGroupDisabled][QStringLiteral(#name)]; } \
void setName(QColor& color) { _colorInfoMap[_theme][_colorGroupEnabled ? ColorGroupEnabled : ColorGroupDisabled][QStringLiteral(#name)] = color; _signalPaletteChangeToAll(); }
/*!
QGCPalette is used in QML ui to expose color properties for the QGC palette. There are two
...
...
@@ -50,20 +53,24 @@
class
QGCPalette
:
public
QObject
{
Q_OBJECT
Q_ENUMS
(
Theme
)
public:
enum
ColorGroup
{
Disabled
=
0
,
Enabled
ColorGroupDisabled
=
0
,
ColorGroupEnabled
,
cMaxColorGroup
};
enum
Theme
{
Light
=
0
,
Dark
Dark
,
cMaxTheme
};
typedef
QColor
PaletteColorInfo_t
[
cMaxTheme
][
cMaxColorGroup
];
Q_PROPERTY
(
Theme
globalTheme
READ
globalTheme
WRITE
setGlobalTheme
NOTIFY
paletteChanged
)
Q_PROPERTY
(
bool
colorGroupEnabled
READ
colorGroupEnabled
WRITE
setColorGroupEnabled
NOTIFY
paletteChanged
)
...
...
@@ -94,26 +101,30 @@ public:
DEFINE_QGC_COLOR
(
alertBackground
,
setAlertBackground
)
DEFINE_QGC_COLOR
(
alertBorder
,
setAlertBorder
)
DEFINE_QGC_COLOR
(
alertText
,
setAlertText
)
DEFINE_QGC_COLOR
(
missionItemEditor
,
setMissionItemEditor
)
QGCPalette
(
QObject
*
parent
=
NULL
);
~
QGCPalette
();
bool
colorGroupEnabled
()
const
{
return
_colorGroupEnabled
;
}
bool
colorGroupEnabled
(
void
)
const
{
return
_colorGroupEnabled
;
}
void
setColorGroupEnabled
(
bool
enabled
);
static
Theme
globalTheme
()
{
return
_theme
;
}
static
Theme
globalTheme
(
void
)
{
return
_theme
;
}
static
void
setGlobalTheme
(
Theme
newTheme
);
signals:
void
paletteChanged
();
private:
static
void
_signalPaletteChangeToAll
();
void
_signalPaletteChanged
();
void
_themeChanged
();
static
void
_buildMap
(
void
);
static
void
_signalPaletteChangeToAll
(
void
);
void
_signalPaletteChanged
(
void
);
void
_themeChanged
(
void
);
static
Theme
_theme
;
///< There is a single theme for all palettes
bool
_colorGroupEnabled
;
///< Currently selected ColorGroup. true: enabled, false: disabled
static
QMap
<
int
,
QMap
<
int
,
QMap
<
QString
,
QColor
>>>
_colorInfoMap
;
// theme -> colorGroup -> color name -> color
static
QList
<
QGCPalette
*>
_paletteObjects
;
///< List of all active QGCPalette objects
};
...
...
src/QmlControls/QGCToolBarButton.qml
View file @
130e7ff3
...
...
@@ -26,10 +26,10 @@ Item {
property
bool
logo
:
false
property
ExclusiveGroup
exclusiveGroup
:
null
readonly
property
real
_topBottomMargins
:
ScreenTools
.
defaultFontPixelHeight
/
2
signal
clicked
()
readonly
property
real
_topBottomMargins
:
ScreenTools
.
defaultFontPixelHeight
/
2
onExclusiveGroupChanged
:
{
if
(
exclusiveGroup
)
{
exclusiveGroup
.
bindCheckable
(
_root
)
...
...
@@ -41,7 +41,7 @@ Item {
Rectangle
{
anchors.fill
:
parent
visible
:
logo
color
:
"
#4A2C6D
"
color
:
qgcPal
.
brandingPurple
}
QGCColoredImage
{
...
...
src/api/QGCCorePlugin.cc
View file @
130e7ff3
...
...
@@ -184,3 +184,9 @@ void QGCCorePlugin::setShowAdvancedUI(bool show)
emit
showAdvancedUIChanged
(
show
);
}
}
void
QGCCorePlugin
::
paletteOverride
(
QString
colorName
,
QGCPalette
::
PaletteColorInfo_t
&
colorInfo
)
{
Q_UNUSED
(
colorName
);
Q_UNUSED
(
colorInfo
);
}
src/api/QGCCorePlugin.h
View file @
130e7ff3
...
...
@@ -10,6 +10,7 @@
#pragma once
#include "QGCToolbox.h"
#include "QGCPalette.h"
#include <QObject>
#include <QVariantList>
...
...
@@ -78,7 +79,10 @@ public:
"You should do so only if instructed by customer support. Are you sure you want to enable Advanced Mode?"
);
}
/// @return An instance of an alternate postion source (or NULL if not available)
virtual
QGeoPositionInfoSource
*
createPositionSource
(
QObject
*
parent
)
{
Q_UNUSED
(
parent
);
return
NULL
;
}
virtual
QGeoPositionInfoSource
*
createPositionSource
(
QObject
*
parent
)
{
Q_UNUSED
(
parent
);
return
NULL
;
}
/// Allows a plugin to override the specified color name from the palette
virtual
void
paletteOverride
(
QString
colorName
,
QGCPalette
::
PaletteColorInfo_t
&
colorInfo
);
bool
showTouchAreas
(
void
)
const
{
return
_showTouchAreas
;
}
bool
showAdvancedUI
(
void
)
const
{
return
_showAdvancedUI
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment