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
85485285
Commit
85485285
authored
Sep 06, 2013
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed toolbar fun when disconnected
parent
baca1f38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
52 deletions
+71
-52
QGCToolBar.cc
src/ui/QGCToolBar.cc
+67
-52
QGCToolBar.h
src/ui/QGCToolBar.h
+4
-0
No files found.
src/ui/QGCToolBar.cc
View file @
85485285
...
...
@@ -77,8 +77,7 @@ void QGCToolBar::heartbeatTimeout(bool timeout, unsigned int ms)
}
toolBarTimeoutLabel
->
setText
(
tr
(
"CONNECTION LOST: %1 s"
).
arg
((
ms
/
1000.0
f
),
2
,
'f'
,
1
,
' '
));
toolBarTimeoutAction
->
setVisible
(
true
);
toolBarMessageLabel
->
hide
();
toolBarMessageAction
->
setVisible
(
false
);
}
else
{
...
...
@@ -86,8 +85,7 @@ void QGCToolBar::heartbeatTimeout(bool timeout, unsigned int ms)
if
(
toolBarTimeoutAction
->
isVisible
())
{
toolBarTimeoutAction
->
setVisible
(
false
);
toolBarMessageLabel
->
show
();
toolBarMessageAction
->
setVisible
(
true
);
}
}
}
...
...
@@ -124,11 +122,11 @@ void QGCToolBar::createUI()
toolBarModeLabel
->
setAlignment
(
Qt
::
AlignCenter
);
addWidget
(
toolBarModeLabel
);
toolBarStateLabel
=
new
QLabel
(
this
);
toolBarStateLabel
->
setToolTip
(
tr
(
"Vehicle state"
));
toolBarStateLabel
->
setObjectName
(
"toolBarStateLabel"
);
toolBarStateLabel
->
setAlignment
(
Qt
::
AlignCenter
);
addWidget
(
toolBarStateLabel
);
//
toolBarStateLabel = new QLabel(this);
//
toolBarStateLabel->setToolTip(tr("Vehicle state"));
//
toolBarStateLabel->setObjectName("toolBarStateLabel");
//
toolBarStateLabel->setAlignment(Qt::AlignCenter);
//
addWidget(toolBarStateLabel);
toolBarBatteryBar
=
new
QProgressBar
(
this
);
toolBarBatteryBar
->
setMinimum
(
0
);
...
...
@@ -150,12 +148,12 @@ void QGCToolBar::createUI()
toolBarWpLabel
->
setToolTip
(
tr
(
"Current waypoint"
));
toolBarWpLabel
->
setObjectName
(
"toolBarWpLabel"
);
toolBarWpLabel
->
setAlignment
(
Qt
::
AlignCenter
);
addWidget
(
toolBarWpLabel
);
toolBarWpAction
=
addWidget
(
toolBarWpLabel
);
toolBarMessageLabel
=
new
QLabel
(
this
);
toolBarMessageLabel
->
setToolTip
(
tr
(
"Most recent system message"
));
toolBarMessageLabel
->
setObjectName
(
"toolBarMessageLabel"
);
addWidget
(
toolBarMessageLabel
);
toolBarMessageAction
=
addWidget
(
toolBarMessageLabel
);
QWidget
*
spacer
=
new
QWidget
();
spacer
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
);
...
...
@@ -165,7 +163,7 @@ void QGCToolBar::createUI()
portComboBox
->
setToolTip
(
tr
(
"Choose the COM port to use"
));
portComboBox
->
setEnabled
(
true
);
portComboBox
->
setMinimumWidth
(
100
);
addWidget
(
portComboBox
);
toolBarPortAction
=
addWidget
(
portComboBox
);
baudcomboBox
=
new
QComboBox
(
this
);
baudcomboBox
->
setToolTip
(
tr
(
"Choose what baud rate to use"
));
...
...
@@ -181,7 +179,7 @@ void QGCToolBar::createUI()
baudcomboBox
->
addItem
(
"460800"
,
460800
);
baudcomboBox
->
addItem
(
"921600"
,
921600
);
baudcomboBox
->
setCurrentIndex
(
baudcomboBox
->
findData
(
57600
));
addWidget
(
baudcomboBox
);
toolBarBaudAction
=
addWidget
(
baudcomboBox
);
connect
(
baudcomboBox
,
SIGNAL
(
activated
(
int
)),
this
,
SLOT
(
baudSelected
(
int
)));
connect
(
portComboBox
,
SIGNAL
(
activated
(
int
)),
this
,
SLOT
(
portSelected
(
int
)));
...
...
@@ -206,8 +204,8 @@ void QGCToolBar::createUI()
// Update label if required
if
(
LinkManager
::
instance
()
->
getSerialLinks
().
count
()
<
1
)
{
connectButton
->
setText
(
tr
(
"New Serial Link"
));
baudcomboBox
->
hide
(
);
portComboBox
->
hide
(
);
toolBarPortAction
->
setVisible
(
false
);
toolBarBaudAction
->
setVisible
(
false
);
}
else
{
QList
<
SerialLink
*>
links
=
LinkManager
::
instance
()
->
getSerialLinks
();
...
...
@@ -241,7 +239,7 @@ void QGCToolBar::resetToolbarUI()
//toolBarTimeoutLabel->show();
toolBarSafetyLabel
->
setText
(
"----"
);
toolBarModeLabel
->
setText
(
"------"
);
toolBarStateLabel
->
setText
(
"------"
);
//
toolBarStateLabel->setText("------");
toolBarBatteryBar
->
setValue
(
0
);
toolBarBatteryBar
->
setDisabled
(
true
);
toolBarBatteryVoltageLabel
->
setText
(
"xx.x V"
);
...
...
@@ -401,11 +399,14 @@ void QGCToolBar::setActiveUAS(UASInterface* active)
// Update all values once
systemName
=
mav
->
getUASName
();
systemArmed
=
mav
->
isArmed
();
toolBarNameLabel
->
setText
(
mav
->
getUASName
());
toolBarNameLabel
->
setText
(
mav
->
getUASName
()
.
replace
(
"MAV"
,
""
)
);
toolBarNameLabel
->
setStyleSheet
(
QString
(
"QLabel {color: %1;}"
).
arg
(
mav
->
getColor
().
name
()));
symbolLabel
->
setStyleSheet
(
QString
(
"QWidget {background-color: %1;}"
).
arg
(
mav
->
getColor
().
name
()));
toolBarModeLabel
->
setText
(
mav
->
getShortMode
());
toolBarStateLabel
->
setText
(
mav
->
getShortState
());
QString
shortMode
=
mav
->
getShortMode
();
shortMode
=
shortMode
.
replace
(
"D|"
,
""
);
shortMode
=
shortMode
.
replace
(
"A|"
,
""
);
toolBarModeLabel
->
setText
(
shortMode
);
// toolBarStateLabel->setText(mav->getShortState());
toolBarTimeoutAction
->
setVisible
(
false
);
toolBarMessageLabel
->
clear
();
lastSystemMessageTimeMs
=
0
;
...
...
@@ -430,37 +431,47 @@ void QGCToolBar::updateArmingState(bool armed)
void
QGCToolBar
::
updateView
()
{
if
(
!
changed
)
return
;
toolBarWpLabel
->
setText
(
tr
(
"WP%1"
).
arg
(
wpId
));
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}"
);
}
}
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}"
);
if
(
toolBarWpLabel
->
isVisible
())
toolBarWpLabel
->
setText
(
tr
(
"WP%1"
).
arg
(
wpId
));
if
(
toolBarBatteryBar
->
isVisible
())
{
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}"
);
}
}
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}"
);
}
}
toolBarBatteryVoltageLabel
->
setText
(
tr
(
"%1 V"
).
arg
(
batteryVoltage
,
4
,
'f'
,
1
,
' '
));
}
toolBarBatteryVoltageLabel
->
setText
(
tr
(
"%1 V"
).
arg
(
batteryVoltage
,
4
,
'f'
,
1
,
' '
));
toolBarStateLabel
->
setText
(
QString
(
"%1"
).
arg
(
state
));
//
toolBarStateLabel->setText(QString("%1").arg(state));
toolBarModeLabel
->
setText
(
QString
(
"%1"
).
arg
(
mode
));
toolBarNameLabel
->
setText
(
systemName
);
// expire after 15 seconds
if
(
QGC
::
groundTimeMilliseconds
()
-
lastSystemMessageTimeMs
<
15000
)
{
toolBarMessageLabel
->
setText
(
QString
(
"%1"
).
arg
(
lastSystemMessage
));
}
else
{
toolBarMessageLabel
->
clear
();
if
(
toolBarMessageLabel
->
isVisible
())
{
if
(
QGC
::
groundTimeMilliseconds
()
-
lastSystemMessageTimeMs
<
15000
)
{
toolBarMessageLabel
->
setText
(
QString
(
"%1"
).
arg
(
lastSystemMessage
));
}
else
{
toolBarMessageLabel
->
clear
();
}
}
// Display the system armed state with a red-on-yellow background if armed or green text if safe.
...
...
@@ -627,8 +638,8 @@ void QGCToolBar::addLink(LinkInterface* link)
if
(
serial
&&
!
currentLink
)
{
baudcomboBox
->
show
(
);
portComboBox
->
show
(
);
toolBarPortAction
->
setVisible
(
true
);
toolBarBaudAction
->
setVisible
(
true
);
currentLink
=
link
;
connect
(
currentLink
,
SIGNAL
(
connected
(
bool
)),
this
,
SLOT
(
updateLinkState
(
bool
)));
...
...
@@ -664,7 +675,7 @@ void QGCToolBar::removeLink(LinkInterface* link)
}
void
QGCToolBar
::
updateComboBox
()
{
if
(
currentLink
)
if
(
currentLink
&&
!
currentLink
->
isConnected
()
)
{
// Do not update if not visible
if
(
!
portComboBox
->
isVisible
())
...
...
@@ -713,14 +724,16 @@ void QGCToolBar::updateComboBox()
void
QGCToolBar
::
updateLinkState
(
bool
connected
)
{
Q_UNUSED
(
connected
);
if
(
currentLink
&&
currentLink
->
isConnected
())
if
(
currentLink
&&
currentLink
->
isConnected
()
&&
portComboBox
->
isVisible
()
)
{
connectButton
->
setText
(
tr
(
"Disconnect"
));
connectButton
->
blockSignals
(
true
);
connectButton
->
setChecked
(
true
);
connectButton
->
blockSignals
(
false
);
portComboBox
->
hide
();
baudcomboBox
->
hide
();
toolBarPortAction
->
setVisible
(
false
);
toolBarBaudAction
->
setVisible
(
false
);
toolBarMessageAction
->
setVisible
(
true
);
toolBarWpAction
->
setVisible
(
true
);
}
else
{
...
...
@@ -728,8 +741,10 @@ void QGCToolBar::updateLinkState(bool connected)
connectButton
->
blockSignals
(
true
);
connectButton
->
setChecked
(
false
);
connectButton
->
blockSignals
(
false
);
portComboBox
->
show
();
baudcomboBox
->
show
();
toolBarPortAction
->
setVisible
(
true
);
toolBarBaudAction
->
setVisible
(
true
);
toolBarMessageAction
->
setVisible
(
false
);
toolBarWpAction
->
setVisible
(
false
);
}
}
...
...
src/ui/QGCToolBar.h
View file @
85485285
...
...
@@ -109,6 +109,10 @@ protected:
QLabel
*
toolBarNameLabel
;
QLabel
*
toolBarTimeoutLabel
;
QAction
*
toolBarTimeoutAction
;
///< Needed to set label (in)visible.
QAction
*
toolBarMessageAction
;
QAction
*
toolBarPortAction
;
QAction
*
toolBarBaudAction
;
QAction
*
toolBarWpAction
;
QLabel
*
toolBarSafetyLabel
;
QLabel
*
toolBarModeLabel
;
QLabel
*
toolBarStateLabel
;
...
...
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