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