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
3d1a54df
Commit
3d1a54df
authored
Jun 02, 2013
by
Bryant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The HUD now responds to changes in the MainWindow theme.
parent
fc3080e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
47 deletions
+51
-47
HUD.cc
src/ui/HUD.cc
+44
-45
HUD.h
src/ui/HUD.h
+2
-1
MainWindow.cc
src/ui/MainWindow.cc
+4
-0
MainWindow.h
src/ui/MainWindow.h
+1
-1
No files found.
src/ui/HUD.cc
View file @
3d1a54df
...
...
@@ -34,8 +34,8 @@ This file is part of the QGROUNDCONTROL project
#include <QMenu>
#include <QDesktopServices>
#include <QFileDialog>
#include <QDebug>
#include <cmath>
#include <qmath.h>
#include <limits>
...
...
@@ -130,42 +130,9 @@ HUD::HUD(int width, int height, QWidget* parent)
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
);
scalingFactor
=
this
->
width
()
/
vwidth
;
// Generate a background image that's dependent on the current color scheme.
QImage
fill
=
QImage
(
width
,
height
,
QImage
::
Format_Indexed8
);
if
(((
MainWindow
*
)
parent
)
->
getStyle
()
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
fill
.
fill
(
255
);
}
else
{
fill
.
fill
(
0
);
}
glImage
=
QGLWidget
::
convertToGLFormat
(
fill
);
// Now set the other default colors based on the current color scheme.
if
(((
MainWindow
*
)
parent
)
->
getStyle
()
==
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
{
defaultColor
=
QColor
(
70
,
200
,
70
);
setPointColor
=
QColor
(
200
,
20
,
200
);
warningColor
=
Qt
::
yellow
;
criticalColor
=
Qt
::
red
;
infoColor
=
QColor
(
20
,
200
,
20
);
fuelColor
=
criticalColor
;
}
//QString imagePath = "/Users/user/Desktop/frame0000.png";
//qDebug() << __FILE__ << __LINE__ << "template image:" << imagePath;
//fill = QImage(imagePath);
// Set up the initial color theme. This can be updated by a styleChanged
// signal from MainWindow.
styleChanged
(((
MainWindow
*
)
parent
)
->
getStyle
());
// Refresh timer
refreshTimer
->
setInterval
(
updateInterval
);
...
...
@@ -173,14 +140,6 @@ HUD::HUD(int width, int height, QWidget* parent)
// Resize to correct size and fill with image
resize
(
this
->
width
(),
this
->
height
());
//glDrawPixels(glImage.width(), glImage.height(), GL_RGBA, GL_UNSIGNED_BYTE, glImage.bits());
// Set size once
//setFixedSize(fill.size());
//setMinimumSize(fill.size());
//setMaximumSize(fill.size());
// Lock down the size
//setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
fontDatabase
=
QFontDatabase
();
const
QString
fontFileName
=
":/general/vera.ttf"
;
///< Font file is part of the QRC file and compiled into the app
...
...
@@ -196,6 +155,11 @@ HUD::HUD(int width, int height, QWidget* parent)
if
(
font
.
family
()
!=
fontFamilyName
)
qDebug
()
<<
"ERROR! WRONG FONT LOADED: "
<<
fontFamilyName
;
}
// 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 with UAS
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
...
...
@@ -214,6 +178,41 @@ QSize HUD::sizeHint() const
return
QSize
(
width
(),
(
width
()
*
3.0
f
)
/
4
);
}
void
HUD
::
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
)
{
// 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
);
}
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
{
defaultColor
=
QColor
(
70
,
200
,
70
);
setPointColor
=
QColor
(
200
,
20
,
200
);
warningColor
=
Qt
::
yellow
;
criticalColor
=
Qt
::
red
;
infoColor
=
QColor
(
20
,
200
,
20
);
fuelColor
=
criticalColor
;
}
}
void
HUD
::
showEvent
(
QShowEvent
*
event
)
{
// React only to internal (pre-display)
...
...
src/ui/HUD.h
View file @
3d1a54df
...
...
@@ -39,6 +39,7 @@ This file is part of the QGROUNDCONTROL project
#include <QTimer>
#include <QVector3D>
#include "UASInterface.h"
#include "MainWindow.h"
/**
* @brief Displays a Head Up Display (HUD)
...
...
@@ -59,7 +60,7 @@ public:
public
slots
:
void
initializeGL
();
//void paintGL(
);
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
);
/** @brief Set the currently monitored UAS */
virtual
void
setActiveUAS
(
UASInterface
*
uas
);
...
...
src/ui/MainWindow.cc
View file @
3d1a54df
...
...
@@ -1260,6 +1260,10 @@ bool MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style, QString cssFile)
darkStyleFileName
=
cssFile
;
}
// And trigger any changes to other UI elements that are watching for
// theme changes.
emit
styleChanged
(
style
);
// Finally restore the cursor before returning.
qApp
->
restoreOverrideCursor
();
return
true
;
...
...
src/ui/MainWindow.h
View file @
3d1a54df
...
...
@@ -51,7 +51,6 @@ This file is part of the QGROUNDCONTROL project
#include "MAVLinkProtocol.h"
#include "MAVLinkSimulationLink.h"
#include "ObjectDetectionView.h"
#include "HUD.h"
#include "submainwindow.h"
#include "JoystickWidget.h"
#include "input/JoystickInput.h"
...
...
@@ -257,6 +256,7 @@ public slots:
void
configureWindowName
();
signals:
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
);
void
initStatusChanged
(
const
QString
&
message
);
#ifdef MOUSE_ENABLED_LINUX
/** @brief Forward X11Event to catch 3DMouse inputs */
...
...
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