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
fb197a75
Commit
fb197a75
authored
Dec 25, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move ui style from MainWindow to QGCApplication
parent
4127e96e
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
175 additions
and
222 deletions
+175
-222
QGCApplication.cc
src/QGCApplication.cc
+62
-1
QGCApplication.h
src/QGCApplication.h
+16
-0
HDDisplay.cc
src/ui/HDDisplay.cc
+7
-14
HSIDisplay.cc
src/ui/HSIDisplay.cc
+22
-24
HUD.cc
src/ui/HUD.cc
+16
-31
HUD.h
src/ui/HUD.h
+1
-1
JoystickWidget.cc
src/ui/JoystickWidget.cc
+7
-7
JoystickWidget.h
src/ui/JoystickWidget.h
+1
-1
MainWindow.cc
src/ui/MainWindow.cc
+0
-56
MainWindow.h
src/ui/MainWindow.h
+0
-20
QGCDataPlot2D.cc
src/ui/QGCDataPlot2D.cc
+1
-2
QGCToolBar.cc
src/ui/QGCToolBar.cc
+10
-24
SettingsDialog.cc
src/ui/SettingsDialog.cc
+2
-3
QGCXYPlot.cc
src/ui/designer/QGCXYPlot.cc
+6
-8
QGCXYPlot.h
src/ui/designer/QGCXYPlot.h
+1
-2
ChartPlot.cc
src/ui/linechart/ChartPlot.cc
+19
-25
ChartPlot.h
src/ui/linechart/ChartPlot.h
+1
-1
LinechartWidget.cc
src/ui/linechart/LinechartWidget.cc
+3
-2
No files found.
src/QGCApplication.cc
View file @
fb197a75
...
...
@@ -69,11 +69,15 @@ const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot";
const
char
*
QGCApplication
::
_settingsVersionKey
=
"SettingsVersion"
;
const
char
*
QGCApplication
::
_savedFilesLocationKey
=
"SavedFilesLocation"
;
const
char
*
QGCApplication
::
_promptFlightDataSave
=
"PromptFLightDataSave"
;
const
char
*
QGCApplication
::
_styleKey
=
"StyleIsDark"
;
const
char
*
QGCApplication
::
_defaultSavedFileDirectoryName
=
"QGroundControl"
;
const
char
*
QGCApplication
::
_savedFileMavlinkLogDirectoryName
=
"FlightData"
;
const
char
*
QGCApplication
::
_savedFileParameterDirectoryName
=
"SavedParameters"
;
const
char
*
QGCApplication
::
_darkStyleFile
=
":files/styles/style-dark.css"
;
const
char
*
QGCApplication
::
_lightStyleFile
=
":files/styles/style-light.css"
;
/**
* @brief Constructor for the main application.
*
...
...
@@ -87,7 +91,8 @@ const char* QGCApplication::_savedFileParameterDirectoryName = "SavedParameters"
QGCApplication
::
QGCApplication
(
int
&
argc
,
char
*
argv
[],
bool
unitTesting
)
:
QApplication
(
argc
,
argv
),
_runningUnitTests
(
unitTesting
)
_runningUnitTests
(
unitTesting
),
_styleIsDark
(
true
)
{
Q_ASSERT
(
_app
==
NULL
);
_app
=
this
;
...
...
@@ -201,6 +206,9 @@ void QGCApplication::_initCommon(void)
"Your saved settings have been reset to defaults."
));
}
_styleIsDark
=
settings
.
value
(
_styleKey
,
_styleIsDark
).
toBool
();
_loadCurrentStyle
();
// Load saved files location and validate
QString
savedFilesLocation
;
...
...
@@ -514,3 +522,56 @@ void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile)
}
QFile
::
remove
(
tempLogfile
);
}
void
QGCApplication
::
setStyle
(
bool
styleIsDark
)
{
QSettings
settings
;
settings
.
setValue
(
_styleKey
,
styleIsDark
);
_styleIsDark
=
styleIsDark
;
_loadCurrentStyle
();
emit
styleChanged
(
_styleIsDark
);
}
void
QGCApplication
::
_loadCurrentStyle
(
void
)
{
bool
success
=
true
;
QString
styles
;
// Signal to the user that the app will pause to apply a new stylesheet
setOverrideCursor
(
Qt
::
WaitCursor
);
// The dark style sheet is the master. Any other selected style sheet just overrides
// the colors of the master sheet.
QFile
masterStyleSheet
(
_darkStyleFile
);
if
(
masterStyleSheet
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
styles
=
masterStyleSheet
.
readAll
();
}
else
{
qDebug
()
<<
"Unable to load master dark style sheet"
;
success
=
false
;
}
if
(
success
&&
!
_styleIsDark
)
{
qDebug
()
<<
"LOADING LIGHT"
;
// Load the slave light stylesheet.
QFile
styleSheet
(
_lightStyleFile
);
if
(
styleSheet
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
styles
+=
styleSheet
.
readAll
();
}
else
{
qDebug
()
<<
"Unable to load slave light sheet:"
;
success
=
false
;
}
}
if
(
!
styles
.
isEmpty
())
{
setStyleSheet
(
styles
);
}
if
(
!
success
)
{
// Fall back to plastique if we can't load our own
setStyle
(
"plastique"
);
}
// Finally restore the cursor before returning.
restoreOverrideCursor
();
}
src/QGCApplication.h
View file @
fb197a75
...
...
@@ -87,6 +87,12 @@ public:
/// @brief Returns truee if unit test are being run
bool
runningUnitTests
(
void
)
{
return
_runningUnitTests
;
}
/// @return true: dark ui style, false: light ui style
bool
styleIsDark
(
void
)
{
return
_styleIsDark
;
}
/// Set the current UI style
void
setStyle
(
bool
styleIsDark
);
public
slots
:
/// You can connect to this slot to show an information message box from a different thread.
void
informationMessageBoxOnMainThread
(
const
QString
&
title
,
const
QString
&
msg
);
...
...
@@ -101,6 +107,10 @@ public slots:
void
saveTempFlightDataLogOnMainThread
(
QString
tempLogfile
);
signals:
/// Signals that the style has changed
/// @param darkStyle true: dark style, false: light style
void
styleChanged
(
bool
darkStyle
);
/// This is connected to MAVLinkProtocol::checkForLostLogFiles. We signal this to ourselves to call the slot
/// on the MAVLinkProtocol thread;
void
checkForLostLogFiles
(
void
);
...
...
@@ -125,11 +135,13 @@ public:
private:
void
_createSingletons
(
void
);
void
_destroySingletons
(
void
);
void
_loadCurrentStyle
(
void
);
static
const
char
*
_settingsVersionKey
;
///< Settings key which hold settings version
static
const
char
*
_deleteAllSettingsKey
;
///< If this settings key is set on boot, all settings will be deleted
static
const
char
*
_savedFilesLocationKey
;
///< Settings key for user visible saved files location
static
const
char
*
_promptFlightDataSave
;
///< Settings key to prompt for saving Flight Data Log for all flights
static
const
char
*
_styleKey
;
///< Settings key for UI style
static
const
char
*
_defaultSavedFileDirectoryName
;
///< Default name for user visible save file directory
static
const
char
*
_savedFileMavlinkLogDirectoryName
;
///< Name of mavlink log subdirectory
...
...
@@ -137,6 +149,10 @@ private:
bool
_runningUnitTests
;
///< true: running unit tests, false: normal app
static
const
char
*
_darkStyleFile
;
static
const
char
*
_lightStyleFile
;
bool
_styleIsDark
;
///< true: dark style, false: light style
/// Unit Test have access to creating and destroying singletons
friend
class
UnitTest
;
};
...
...
src/ui/HDDisplay.cc
View file @
fb197a75
...
...
@@ -24,7 +24,7 @@
#include "ui_HDDisplay.h"
#include "MG.h"
#include "QGC.h"
#include "
MainWindow
.h"
#include "
QGCApplication
.h"
#include <QDebug>
HDDisplay
::
HDDisplay
(
const
QStringList
&
plotList
,
QString
title
,
QWidget
*
parent
)
:
...
...
@@ -440,14 +440,7 @@ void HDDisplay::renderOverlay()
const
float
spacing
=
0.4
f
;
// 40% of width
const
float
gaugeWidth
=
vwidth
/
(((
float
)
columns
)
+
(((
float
)
columns
+
1
)
*
spacing
+
spacing
*
0.5
f
));
QColor
gaugeColor
;
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
gaugeColor
=
QColor
(
0
,
0
,
0
);
}
else
{
gaugeColor
=
QColor
(
255
,
255
,
255
);
}
gaugeColor
=
qgcApp
()
->
styleIsDark
()
?
gaugeColor
=
QColor
(
255
,
255
,
255
)
:
gaugeColor
=
QColor
(
0
,
0
,
0
);
//drawSystemIndicator(10.0f-gaugeWidth/2.0f, 20.0f, 10.0f, 40.0f, 15.0f, &painter);
//drawGauge(15.0f, 15.0f, gaugeWidth/2.0f, 0, 1.0f, "thrust", values.value("thrust", 0.0f), gaugeColor, &painter, qMakePair(0.45f, 0.8f), qMakePair(0.8f, 1.0f), true);
//drawGauge(15.0f+gaugeWidth*1.7f, 15.0f, gaugeWidth/2.0f, 0, 10.0f, "altitude", values.value("altitude", 0.0f), gaugeColor, &painter, qMakePair(1.0f, 2.5f), qMakePair(0.0f, 0.5f), true);
...
...
@@ -582,15 +575,15 @@ void HDDisplay::drawGauge(float xRef, float yRef, float radius, float min, float
// Select color scheme based on light or dark theme.
QColor
valueColor
;
QColor
backgroundColor
;
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
if
(
qgcApp
()
->
styleIsDark
()
)
{
valueColor
=
Q
Color
(
26
,
75
,
95
)
;
backgroundColor
=
QColor
(
246
,
246
,
246
);
valueColor
=
Q
GC
::
colorCyan
;
backgroundColor
=
QColor
(
34
,
34
,
34
);
}
else
{
valueColor
=
Q
GC
::
colorCyan
;
backgroundColor
=
QColor
(
34
,
34
,
34
);
valueColor
=
Q
Color
(
26
,
75
,
95
)
;
backgroundColor
=
QColor
(
246
,
246
,
246
);
}
// Draw the circle
...
...
src/ui/HSIDisplay.cc
View file @
fb197a75
...
...
@@ -35,18 +35,16 @@ This file is part of the QGROUNDCONTROL project
#include <QGraphicsScene>
#include <QHBoxLayout>
#include <QDoubleSpinBox>
#include <QDebug>
#include "UASManager.h"
#include "HSIDisplay.h"
#include "QGC.h"
#include "Waypoint.h"
#include "UASWaypointManager.h"
#include <qmath.h>
//#include "Waypoint2DIcon.h"
#include "MAV2DIcon.h"
#include "MainWindow.h"
#include <QDebug>
#include "QGCApplication.h"
HSIDisplay
::
HSIDisplay
(
QWidget
*
parent
)
:
HDDisplay
(
QStringList
(),
"HSI"
,
parent
),
...
...
@@ -279,26 +277,26 @@ void HSIDisplay::renderOverlay()
QColor
statusColor
;
QColor
waypointLineColor
;
QColor
attitudeColor
;
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
if
(
qgcApp
()
->
styleIsDark
()
)
{
ringColor
=
Q
GC
::
colorBlack
;
ringColor
=
Q
Color
(
255
,
255
,
255
)
;
positionColor
=
QColor
(
20
,
20
,
200
);
setpointColor
=
QColor
(
150
,
250
,
150
);
labelColor
=
Q
Color
(
26
,
75
,
95
)
;
valueColor
=
QColor
(
40
,
40
,
40
);
labelColor
=
Q
GC
::
colorCyan
;
valueColor
=
QColor
(
255
,
255
,
255
);
statusColor
=
QGC
::
colorOrange
;
waypointLineColor
=
QGC
::
color
Dark
Yellow
;
waypointLineColor
=
QGC
::
colorYellow
;
attitudeColor
=
QColor
(
200
,
20
,
20
);
}
else
{
ringColor
=
Q
Color
(
255
,
255
,
255
)
;
ringColor
=
Q
GC
::
colorBlack
;
positionColor
=
QColor
(
20
,
20
,
200
);
setpointColor
=
QColor
(
150
,
250
,
150
);
labelColor
=
Q
GC
::
colorCyan
;
valueColor
=
QColor
(
255
,
255
,
255
);
labelColor
=
Q
Color
(
26
,
75
,
95
)
;
valueColor
=
QColor
(
40
,
40
,
40
);
statusColor
=
QGC
::
colorOrange
;
waypointLineColor
=
QGC
::
colorYellow
;
waypointLineColor
=
QGC
::
color
Dark
Yellow
;
attitudeColor
=
QColor
(
200
,
20
,
20
);
}
...
...
@@ -475,15 +473,15 @@ void HSIDisplay::drawStatusFlag(float x, float y, QString label, bool status, bo
{
QColor
statusColor
;
QColor
labelColor
;
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
if
(
qgcApp
()
->
styleIsDark
()
)
{
statusColor
=
QColor
(
40
,
40
,
4
0
);
labelColor
=
Q
Color
(
26
,
75
,
95
)
;
statusColor
=
QColor
(
250
,
250
,
25
0
);
labelColor
=
Q
GC
::
colorCyan
;
}
else
{
statusColor
=
QColor
(
250
,
250
,
25
0
);
labelColor
=
Q
GC
::
colorCyan
;
statusColor
=
QColor
(
40
,
40
,
4
0
);
labelColor
=
Q
Color
(
26
,
75
,
95
)
;
}
// Draw the label.
...
...
@@ -537,15 +535,15 @@ void HSIDisplay::drawPositionLock(float x, float y, QString label, int status, b
QColor
intermediateStatusColor
(
Qt
::
yellow
);
QColor
posStatusColor
(
20
,
200
,
20
);
QColor
statusColor
;
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
if
(
qgcApp
()
->
styleIsDark
()
)
{
statusColor
=
QColor
(
40
,
40
,
4
0
);
labelColor
=
Q
Color
(
26
,
75
,
95
)
;
statusColor
=
QColor
(
250
,
250
,
25
0
);
labelColor
=
Q
GC
::
colorCyan
;
}
else
{
statusColor
=
QColor
(
250
,
250
,
25
0
);
labelColor
=
Q
GC
::
colorCyan
;
statusColor
=
QColor
(
40
,
40
,
4
0
);
labelColor
=
Q
Color
(
26
,
75
,
95
)
;
}
// Draw the label.
...
...
src/ui/HUD.cc
View file @
fb197a75
...
...
@@ -44,7 +44,7 @@ This file is part of the QGROUNDCONTROL project
#include "UAS.h"
#include "HUD.h"
#include "QGC.h"
#include "
MainWindow
.h"
#include "
QGCApplication
.h"
#include "QGCFileDialog.h"
/**
...
...
@@ -131,7 +131,7 @@ HUD::HUD(int width, int height, QWidget* parent)
// Set up the initial color theme. This can be updated by a styleChanged
// signal from MainWindow.
styleChanged
(
((
MainWindow
*
)
parent
)
->
getStyle
());
styleChanged
(
qgcApp
()
->
styleIsDark
());
// Refresh timer
refreshTimer
->
setInterval
(
updateInterval
);
...
...
@@ -156,8 +156,7 @@ HUD::HUD(int width, int height, QWidget* parent)
// Connect the themeChanged signal from the MainWindow to this widget, so it
// can change it's styling accordingly.
connect
((
MainWindow
*
)
parent
,
SIGNAL
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)),
this
,
SLOT
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)));
connect
(
qgcApp
(),
&
QGCApplication
::
styleChanged
,
this
,
&
HUD
::
styleChanged
);
// Connect with UAS
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
...
...
@@ -177,31 +176,15 @@ QSize HUD::sizeHint() const
return
QSize
(
width
(),
(
width
()
*
3.0
f
)
/
4
);
}
void
HUD
::
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
)
void
HUD
::
styleChanged
(
bool
styleIsDark
)
{
// Generate a background image that's dependent on the current color scheme.
QImage
fill
=
QImage
(
width
(),
height
(),
QImage
::
Format_Indexed8
);
if
(
newTheme
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
fill
.
fill
(
255
);
}
else
{
fill
.
fill
(
0
);
}
fill
.
fill
(
styleIsDark
?
0
:
255
);
glImage
=
QGLWidget
::
convertToGLFormat
(
fill
);
// Now set the other default colors based on the current color scheme.
if
(
newTheme
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
defaultColor
=
QColor
(
0x01
,
0x47
,
0x01
);
setPointColor
=
QColor
(
0x82
,
0x17
,
0x82
);
warningColor
=
Qt
::
darkYellow
;
criticalColor
=
Qt
::
darkRed
;
infoColor
=
QColor
(
0x07
,
0x82
,
0x07
);
fuelColor
=
criticalColor
;
}
else
if
(
styleIsDark
)
{
defaultColor
=
QColor
(
70
,
200
,
70
);
setPointColor
=
QColor
(
200
,
20
,
200
);
...
...
@@ -210,6 +193,15 @@ void HUD::styleChanged(MainWindow::QGC_MAINWINDOW_STYLE newTheme)
infoColor
=
QColor
(
20
,
200
,
20
);
fuelColor
=
criticalColor
;
}
else
{
defaultColor
=
QColor
(
0x01
,
0x47
,
0x01
);
setPointColor
=
QColor
(
0x82
,
0x17
,
0x82
);
warningColor
=
Qt
::
darkYellow
;
criticalColor
=
Qt
::
darkRed
;
infoColor
=
QColor
(
0x07
,
0x82
,
0x07
);
fuelColor
=
criticalColor
;
}
}
void
HUD
::
showEvent
(
QShowEvent
*
event
)
...
...
@@ -1226,14 +1218,7 @@ void HUD::setImageSize(int width, int height, int depth, int channels)
}
// Fill first channel of image with black pixels
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
image
->
fill
(
255
);
}
else
{
image
->
fill
(
0
);
}
image
->
fill
(
qgcApp
()
->
styleIsDark
()
?
0
:
255
);
glImage
=
*
image
;
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"Setting up image"
;
...
...
src/ui/HUD.h
View file @
fb197a75
...
...
@@ -60,7 +60,7 @@ public:
void
resize
(
int
w
,
int
h
);
public
slots
:
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
);
void
styleChanged
(
bool
styleIsDark
);
/** @brief Set the currently monitored UAS */
virtual
void
setActiveUAS
(
UASInterface
*
uas
);
...
...
src/ui/JoystickWidget.cc
View file @
fb197a75
#include "JoystickWidget.h"
#include "
MainWindow
.h"
#include "
QGCApplication
.h"
#include "ui_JoystickWidget.h"
#include "JoystickButton.h"
#include "JoystickAxis.h"
...
...
@@ -42,8 +42,8 @@ JoystickWidget::JoystickWidget(JoystickInput* joystick, QWidget *parent) :
connect
(
m_ui
->
enableCheckBox
,
SIGNAL
(
toggled
(
bool
)),
this
->
joystick
,
SLOT
(
setEnabled
(
bool
)));
// Update the button label colors based on the current theme and watch for future theme changes.
styleChanged
(
MainWindow
::
instance
()
->
getStyle
());
connect
(
MainWindow
::
instance
(),
SIGNAL
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)),
this
,
SLOT
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
))
);
styleChanged
(
qgcApp
()
->
styleIsDark
());
connect
(
qgcApp
(),
&
QGCApplication
::
styleChanged
,
this
,
&
JoystickWidget
::
styleChanged
);
// Display the widget above all other windows.
this
->
raise
();
...
...
@@ -81,15 +81,15 @@ void JoystickWidget::initUI()
}
}
void
JoystickWidget
::
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newStyle
)
void
JoystickWidget
::
styleChanged
(
bool
styleIsDark
)
{
if
(
newStyle
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
if
(
styleIsDark
)
{
buttonLabelColor
=
QColor
(
0x
73
,
0xD9
,
0x5D
);
buttonLabelColor
=
QColor
(
0x
14
,
0xC6
,
0x14
);
}
else
{
buttonLabelColor
=
QColor
(
0x
14
,
0xC6
,
0x14
);
buttonLabelColor
=
QColor
(
0x
73
,
0xD9
,
0x5D
);
}
}
...
...
src/ui/JoystickWidget.h
View file @
fb197a75
...
...
@@ -71,7 +71,7 @@ public slots:
/** @brief Trigger a UI change based on a button being released */
void
joystickButtonReleased
(
int
key
);
/** @brief Update the UI color scheme when the MainWindow theme changes. */
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
);
void
styleChanged
(
bool
styleIsDark
);
/** Update the UI assuming the joystick has stayed the same. */
void
updateUI
();
...
...
src/ui/MainWindow.cc
View file @
fb197a75
...
...
@@ -80,10 +80,6 @@ This file is part of the QGROUNDCONTROL project
static
MainWindow
*
_instance
=
NULL
;
///< @brief MainWindow singleton
// Set up some constants
const
QString
MainWindow
::
defaultDarkStyle
=
":files/styles/style-dark.css"
;
const
QString
MainWindow
::
defaultLightStyle
=
":files/styles/style-light.css"
;
MainWindow
*
MainWindow
::
_create
(
QSplashScreen
*
splashScreen
,
enum
MainWindow
::
CUSTOM_MODE
mode
)
{
Q_ASSERT
(
_instance
==
NULL
);
...
...
@@ -111,7 +107,6 @@ void MainWindow::deleteInstance(void)
/// constructor.
MainWindow
::
MainWindow
(
QSplashScreen
*
splashScreen
,
enum
MainWindow
::
CUSTOM_MODE
mode
)
:
currentView
(
VIEW_FLIGHT
),
currentStyle
(
QGC_MAINWINDOW_STYLE_DARK
),
centerStackActionGroup
(
new
QActionGroup
(
this
)),
autoReconnect
(
false
),
simulationLink
(
NULL
),
...
...
@@ -131,10 +126,6 @@ MainWindow::MainWindow(QSplashScreen* splashScreen, enum MainWindow::CUSTOM_MODE
loadSettings
();
emit
initStatusChanged
(
tr
(
"Loading style"
),
Qt
::
AlignLeft
|
Qt
::
AlignBottom
,
QColor
(
62
,
93
,
141
));
qApp
->
setStyle
(
"plastique"
);
loadStyle
(
currentStyle
);
if
(
settings
.
contains
(
"ADVANCED_MODE"
))
{
menuActionHelper
->
setAdvancedMode
(
settings
.
value
(
"ADVANCED_MODE"
).
toBool
());
...
...
@@ -951,7 +942,6 @@ void MainWindow::loadSettings()
settings
.
beginGroup
(
"QGC_MAINWINDOW"
);
autoReconnect
=
settings
.
value
(
"AUTO_RECONNECT"
,
autoReconnect
).
toBool
();
currentStyle
=
(
QGC_MAINWINDOW_STYLE
)
settings
.
value
(
"CURRENT_STYLE"
,
currentStyle
).
toInt
();
lowPowerMode
=
settings
.
value
(
"LOW_POWER_MODE"
,
lowPowerMode
).
toBool
();
bool
dockWidgetTitleBarEnabled
=
settings
.
value
(
"DOCK_WIDGET_TITLEBARS"
,
menuActionHelper
->
dockWidgetTitleBarsEnabled
()).
toBool
();
settings
.
endGroup
();
...
...
@@ -967,7 +957,6 @@ void MainWindow::storeSettings()
settings
.
beginGroup
(
"QGC_MAINWINDOW"
);
settings
.
setValue
(
"AUTO_RECONNECT"
,
autoReconnect
);
settings
.
setValue
(
"CURRENT_STYLE"
,
currentStyle
);
settings
.
setValue
(
"LOW_POWER_MODE"
,
lowPowerMode
);
settings
.
endGroup
();
...
...
@@ -1055,51 +1044,6 @@ void MainWindow::enableAutoReconnect(bool enabled)
autoReconnect
=
enabled
;
}
bool
MainWindow
::
loadStyle
(
QGC_MAINWINDOW_STYLE
style
)
{
//qDebug() << "LOAD STYLE" << style;
bool
success
=
true
;
QString
styles
;
// Signal to the user that the app will pause to apply a new stylesheet
qApp
->
setOverrideCursor
(
Qt
::
WaitCursor
);
// Store the new style classification.
currentStyle
=
style
;
// The dark style sheet is the master. Any other selected style sheet just overrides
// the colors of the master sheet.
QFile
masterStyleSheet
(
defaultDarkStyle
);
if
(
masterStyleSheet
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
styles
=
masterStyleSheet
.
readAll
();
}
else
{
qDebug
()
<<
"Unable to load master dark style sheet"
;
success
=
false
;
}
if
(
success
&&
style
==
QGC_MAINWINDOW_STYLE_LIGHT
)
{
qDebug
()
<<
"LOADING LIGHT"
;
// Load the slave light stylesheet.
QFile
styleSheet
(
defaultLightStyle
);
if
(
styleSheet
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
styles
+=
styleSheet
.
readAll
();
}
else
{
qDebug
()
<<
"Unable to load slave light sheet:"
;
success
=
false
;
}
}
if
(
!
styles
.
isEmpty
())
{
qApp
->
setStyleSheet
(
styles
);
emit
styleChanged
(
style
);
}
// Finally restore the cursor before returning.
qApp
->
restoreOverrideCursor
();
return
success
;
}
/**
* @brief Create all actions associated to the main window
*
...
...
src/ui/MainWindow.h
View file @
fb197a75
...
...
@@ -111,22 +111,6 @@ public:
~
MainWindow
();
enum
QGC_MAINWINDOW_STYLE
{
QGC_MAINWINDOW_STYLE_DARK
,
QGC_MAINWINDOW_STYLE_LIGHT
};
// Declare default dark and light stylesheets. These should be file-resource
// paths.
static
const
QString
defaultDarkStyle
;
static
const
QString
defaultLightStyle
;
/** @brief Get current visual style */
QGC_MAINWINDOW_STYLE
getStyle
()
const
{
return
currentStyle
;
}
/** @brief Get auto link reconnect setting */
bool
autoReconnectEnabled
()
const
...
...
@@ -215,8 +199,6 @@ public slots:
/** @brief Save power by reducing update rates */
void
enableLowPowerMode
(
bool
enabled
)
{
lowPowerMode
=
enabled
;
}
/** @brief Load the specified style. */
bool
loadStyle
(
QGC_MAINWINDOW_STYLE
style
);
/** @brief Add a custom tool widget */
void
createCustomWidget
();
...
...
@@ -266,7 +248,6 @@ protected slots:
void
normalActionItemCallback
();
signals:
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
);
void
initStatusChanged
(
const
QString
&
message
,
int
alignment
,
const
QColor
&
color
);
/** Emitted when any value changes from any source */
void
valueChanged
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
QVariant
&
value
,
const
quint64
msec
);
...
...
@@ -331,7 +312,6 @@ protected:
/** @brief Keeps track of the current view */
VIEW_SECTIONS
currentView
;
QGC_MAINWINDOW_STYLE
currentStyle
;
void
storeViewState
();
void
loadViewState
();
...
...
src/ui/QGCDataPlot2D.cc
View file @
fb197a75
...
...
@@ -72,8 +72,7 @@ QGCDataPlot2D::QGCDataPlot2D(QWidget *parent) :
connect
(
ui
->
style
,
SIGNAL
(
currentIndexChanged
(
QString
)),
plot
,
SLOT
(
setStyleText
(
QString
)));
// Allow style changes to propagate through this widget
connect
(
MainWindow
::
instance
(),
SIGNAL
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)),
plot
,
SLOT
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)));
connect
(
qgcApp
(),
&
QGCApplication
::
styleChanged
,
plot
,
&
IncrementalPlot
::
styleChanged
);
}
void
QGCDataPlot2D
::
reloadFile
()
...
...
src/ui/QGCToolBar.cc
View file @
fb197a75
...
...
@@ -28,6 +28,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCToolBar.h"
#include "UASManager.h"
#include "MainWindow.h"
#include "QGCApplication.h"
QGCToolBar
::
QGCToolBar
(
QWidget
*
parent
)
:
QToolBar
(
parent
),
...
...
@@ -445,23 +446,13 @@ void QGCToolBar::updateView()
toolBarBatteryBar
->
setValue
(
batteryPercent
);
if
(
batteryPercent
<
30
&&
toolBarBatteryBar
->
value
()
>=
30
)
{
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
toolBarBatteryBar
->
setStyleSheet
(
"QProgressBar {color: #FFF} QProgressBar::chunk { background-color: #008000}"
);
}
else
{
toolBarBatteryBar
->
setStyleSheet
(
"QProgressBar {color: #000} QProgressBar QProgressBar::chunk { background-color: #0F0}"
);
}
toolBarBatteryBar
->
setStyleSheet
(
qgcApp
()
->
styleIsDark
()
?
"QProgressBar {color: #000} QProgressBar QProgressBar::chunk { background-color: #0F0}"
:
"QProgressBar {color: #FFF} QProgressBar::chunk { background-color: #008000}"
);
}
else
if
(
batteryPercent
>=
30
&&
toolBarBatteryBar
->
value
()
<
30
){
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
toolBarBatteryBar
->
setStyleSheet
(
"QProgressBar {color: #FFF} QProgressBar::chunk { background-color: #808000}"
);
}
else
{
toolBarBatteryBar
->
setStyleSheet
(
"QProgressBar {color: #000} QProgressBar QProgressBar::chunk { background-color: #FF0}"
);
}
toolBarBatteryBar
->
setStyleSheet
(
qgcApp
()
->
styleIsDark
()
?
"QProgressBar {color: #000} QProgressBar QProgressBar::chunk { background-color: #FF0}"
:
"QProgressBar {color: #FFF} QProgressBar::chunk { background-color: #808000}"
);
}
}
...
...
@@ -493,14 +484,9 @@ void QGCToolBar::updateView()
}
else
{
if
(
MainWindow
::
instance
()
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
toolBarSafetyLabel
->
setStyleSheet
(
"QLabel {color: #0D820D; font-size: 15pt;}"
);
}
else
{
toolBarSafetyLabel
->
setStyleSheet
(
"QLabel {color: #14C814; font-size: 15pt;}"
);
}
toolBarSafetyLabel
->
setStyleSheet
(
qgcApp
()
->
styleIsDark
()
?
"QLabel {color: #14C814; font-size: 15pt;}"
:
"QLabel {color: #0D820D; font-size: 15pt;}"
);
toolBarSafetyLabel
->
setText
(
tr
(
"DISARMED"
));
}
...
...
src/ui/SettingsDialog.cc
View file @
fb197a75
...
...
@@ -86,8 +86,7 @@ _ui(new Ui::SettingsDialog)
connect
(
_ui
->
customModeComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
selectCustomMode
(
int
)));
// Application color style
MainWindow
::
QGC_MAINWINDOW_STYLE
style
=
_mainWindow
->
getStyle
();
_ui
->
styleChooser
->
setCurrentIndex
(
style
);
_ui
->
styleChooser
->
setCurrentIndex
(
qgcApp
()
->
styleIsDark
()
?
0
:
1
);
_ui
->
savedFilesLocation
->
setText
(
qgcApp
()
->
savedFilesLocation
());
_ui
->
promptFlightDataSave
->
setChecked
(
qgcApp
()
->
promptFlightDataSave
());
...
...
@@ -105,7 +104,7 @@ SettingsDialog::~SettingsDialog()
void
SettingsDialog
::
styleChanged
(
int
index
)
{
_mainWindow
->
loadStyle
((
index
==
1
)
?
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
:
MainWindow
::
QGC_MAINWINDOW_STYLE_DARK
);
qgcApp
()
->
setStyle
(
index
==
0
);
}
void
SettingsDialog
::
selectCustomMode
(
int
mode
)
...
...
src/ui/designer/QGCXYPlot.cc
View file @
fb197a75
...
...
@@ -6,6 +6,8 @@
#include "MAVLinkProtocol.h"
#include "UASManager.h"
#include "IncrementalPlot.h"
#include "QGCApplication.h"
#include <float.h>
#include <qwt_plot.h>
#include <qwt_plot_layout.h>
...
...
@@ -222,9 +224,8 @@ QGCXYPlot::QGCXYPlot(QWidget *parent) :
plot
->
setAutoReplot
();
xycurve
=
new
XYPlotCurve
();
xycurve
->
attach
(
plot
);
styleChanged
(
MainWindow
::
instance
()
->
getStyle
());
connect
(
MainWindow
::
instance
(),
SIGNAL
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)),
this
,
SLOT
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)));
styleChanged
(
qgcApp
()
->
styleIsDark
());
connect
(
qgcApp
(),
&
QGCApplication
::
styleChanged
,
this
,
&
QGCXYPlot
::
styleChanged
);
connect
(
ui
->
minX
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
maxX
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
minY
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
updateMinMaxSettings
()));
...
...
@@ -401,12 +402,9 @@ void QGCXYPlot::appendData(int uasId, const QString& curve, const QString& unit,
}
}
void
QGCXYPlot
::
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
style
)
void
QGCXYPlot
::
styleChanged
(
bool
styleIsDark
)
{
if
(
style
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
xycurve
->
setColor
(
Qt
::
black
);
else
xycurve
->
setColor
(
Qt
::
white
);
xycurve
->
setColor
(
styleIsDark
?
Qt
::
white
:
Qt
::
black
);
}
void
QGCXYPlot
::
updateMinMaxSettings
()
...
...
src/ui/designer/QGCXYPlot.h
View file @
fb197a75
...
...
@@ -2,7 +2,6 @@
#define QGCXYPLOT_H
#include "QGCToolWidgetItem.h"
#include "MainWindow.h"
namespace
Ui
{
...
...
@@ -28,7 +27,7 @@ public slots:
void
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
);
void
appendData
(
int
uasId
,
const
QString
&
curve
,
const
QString
&
unit
,
const
QVariant
&
variant
,
quint64
usec
);
void
clearPlot
();
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
style
);
void
styleChanged
(
bool
styleIsDark
);
void
updateMinMaxSettings
();
...
...
src/ui/linechart/ChartPlot.cc
View file @
fb197a75
#include "ChartPlot.h"
#include "
MainWindow
.h"
#include "
QGCApplication
.h"
const
QColor
ChartPlot
::
baseColors
[
numColors
]
=
{
QColor
(
242
,
255
,
128
),
...
...
@@ -54,7 +54,7 @@ ChartPlot::ChartPlot(QWidget *parent):
}
// Now that all objects have been initialized, color everything.
styleChanged
(
MainWindow
::
instance
()
->
getStyle
());
styleChanged
(
qgcApp
()
->
styleIsDark
());
}
ChartPlot
::~
ChartPlot
()
...
...
@@ -88,47 +88,41 @@ void ChartPlot::shuffleColors()
}
}
void
ChartPlot
::
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
style
)
void
ChartPlot
::
styleChanged
(
bool
styleIsDark
)
{
// Generate a new color list for curves and recolor them.
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
if
(
style
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
colors
[
i
]
=
baseColors
[
i
].
darker
(
150
);
}
else
{
colors
[
i
]
=
baseColors
[
i
].
lighter
(
150
);
}
colors
[
i
]
=
styleIsDark
?
baseColors
[
i
].
lighter
(
150
)
:
baseColors
[
i
].
darker
(
150
);
}
shuffleColors
();
// Configure the rest of the UI colors based on the current theme.
if
(
style
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
if
(
style
IsDark
)
{
// Set the coloring of the area selector for zooming.
zoomer
->
setRubberBandPen
(
QPen
(
QColor
(
0x
37
,
0x9A
,
0xC3
),
zoomerWidth
,
Qt
::
DotLine
));
zoomer
->
setTrackerPen
(
QPen
(
QColor
(
0x
37
,
0x9A
,
0xC3
)));
zoomer
->
setRubberBandPen
(
QPen
(
QColor
(
0x
B8
,
0xD3
,
0xE6
),
zoomerWidth
,
Qt
::
DotLine
));
zoomer
->
setTrackerPen
(
QPen
(
QColor
(
0x
B8
,
0xD3
,
0xE6
)));
// Set canvas background
setCanvasBackground
(
QColor
(
0
xFF
,
0xFF
,
0xFF
));
setCanvasBackground
(
QColor
(
0
,
0
,
0
));
// Configure the plot grid.
grid
->
setMinorPen
(
QPen
(
QColor
(
0x
55
,
0x55
,
0x55
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMajorPen
(
QPen
(
QColor
(
0x
22
,
0x22
,
0x22
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMinorPen
(
QPen
(
QColor
(
0x
AA
,
0xAA
,
0xAA
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMajorPen
(
QPen
(
QColor
(
0x
DD
,
0xDD
,
0xDD
),
gridWidth
,
Qt
::
DotLine
));
}
else
{
// Set the coloring of the area selector for zooming.
zoomer
->
setRubberBandPen
(
QPen
(
QColor
(
0x
B8
,
0xD3
,
0xE6
),
zoomerWidth
,
Qt
::
DotLine
));
zoomer
->
setTrackerPen
(
QPen
(
QColor
(
0x
B8
,
0xD3
,
0xE6
)));
zoomer
->
setRubberBandPen
(
QPen
(
QColor
(
0x
37
,
0x9A
,
0xC3
),
zoomerWidth
,
Qt
::
DotLine
));
zoomer
->
setTrackerPen
(
QPen
(
QColor
(
0x
37
,
0x9A
,
0xC3
)));
// Set canvas background
setCanvasBackground
(
QColor
(
0
,
0
,
0
));
setCanvasBackground
(
QColor
(
0
xFF
,
0xFF
,
0xFF
));
// Configure the plot grid.
grid
->
setMinorPen
(
QPen
(
QColor
(
0x
AA
,
0xAA
,
0xAA
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMajorPen
(
QPen
(
QColor
(
0x
DD
,
0xDD
,
0xDD
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMinorPen
(
QPen
(
QColor
(
0x
55
,
0x55
,
0x55
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMajorPen
(
QPen
(
QColor
(
0x
22
,
0x22
,
0x22
),
gridWidth
,
Qt
::
DotLine
));
}
// And finally refresh the widget to make sure all color changes are redrawn.
...
...
src/ui/linechart/ChartPlot.h
View file @
fb197a75
...
...
@@ -26,7 +26,7 @@ public:
public
slots
:
/** @brief Generate coloring for this plot canvas based on current window theme */
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
style
);
void
styleChanged
(
bool
styleIsDark
);
protected:
const
static
int
numColors
=
20
;
...
...
src/ui/linechart/LinechartWidget.cc
View file @
fb197a75
...
...
@@ -52,6 +52,7 @@ This file is part of the PIXHAWK project
#include "MG.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
#include "QGCApplication.h"
LinechartWidget
::
LinechartWidget
(
int
systemid
,
QWidget
*
parent
)
:
QWidget
(
parent
),
sysid
(
systemid
),
...
...
@@ -140,7 +141,7 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent
createLayout
();
// And make sure we're listening for future style changes
connect
(
MainWindow
::
instance
(),
SIGNAL
(
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
)),
this
,
SLOT
(
recolor
())
);
connect
(
qgcApp
(),
&
QGCApplication
::
styleChanged
,
this
,
&
LinechartWidget
::
recolor
);
updateTimer
->
setInterval
(
updateInterval
);
connect
(
updateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
refresh
()));
...
...
@@ -676,7 +677,7 @@ void LinechartWidget::removeCurve(QString curve)
void
LinechartWidget
::
recolor
()
{
activePlot
->
styleChanged
(
MainWindow
::
instance
()
->
getStyle
());
activePlot
->
styleChanged
(
qgcApp
()
->
styleIsDark
());
foreach
(
QString
key
,
colorIcons
.
keys
())
{
QWidget
*
colorIcon
=
colorIcons
.
value
(
key
,
0
);
...
...
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