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
dc3b21fb
Commit
dc3b21fb
authored
Sep 21, 2011
by
LM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed and thoroughly tested custom widgets
parent
5ec5d936
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
120 deletions
+178
-120
MainWindow.cc
src/ui/MainWindow.cc
+83
-53
QGCWaypointListMulti.cc
src/ui/QGCWaypointListMulti.cc
+1
-0
WaypointList.ui
src/ui/WaypointList.ui
+36
-36
QGCToolWidget.cc
src/ui/designer/QGCToolWidget.cc
+57
-30
QGCToolWidget.h
src/ui/designer/QGCToolWidget.h
+1
-1
No files found.
src/ui/MainWindow.cc
View file @
dc3b21fb
...
...
@@ -126,6 +126,9 @@ MainWindow::MainWindow(QWidget *parent):
configureWindowName
();
// Setup corners
setCorner
(
Qt
::
BottomRightCorner
,
Qt
::
RightDockWidgetArea
);
// Setup UI state machines
centerStackActionGroup
.
setExclusive
(
true
);
...
...
@@ -146,28 +149,6 @@ MainWindow::MainWindow(QWidget *parent):
// Create actions
connectCommonActions
();
buildCustomWidget
();
// Restore the window setup
if
(
settings
.
contains
(
getWindowStateKey
()))
{
loadViewState
();
}
// Restore the window position and size
if
(
settings
.
contains
(
getWindowGeometryKey
()))
{
// Restore the window geometry
restoreGeometry
(
settings
.
value
(
getWindowGeometryKey
()).
toByteArray
());
}
else
{
// Adjust the size
adjustSize
();
}
// Populate link menu
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
();
foreach
(
LinkInterface
*
link
,
links
)
...
...
@@ -197,7 +178,33 @@ MainWindow::MainWindow(QWidget *parent):
// Initialize window state
windowStateVal
=
windowState
();
show
();
// Restore the window setup
loadViewState
();
// Restore the window position and size
if
(
settings
.
contains
(
getWindowGeometryKey
()))
{
// Restore the window geometry
restoreGeometry
(
settings
.
value
(
getWindowGeometryKey
()).
toByteArray
());
show
();
}
else
{
// Adjust the size
const
int
screenWidth
=
QApplication
::
desktop
()
->
width
();
const
int
screenHeight
=
QApplication
::
desktop
()
->
height
();
if
(
screenWidth
<
1200
)
{
showFullScreen
();
}
else
{
resize
(
screenWidth
*
0.67
f
,
qMin
(
screenHeight
,
(
int
)(
screenWidth
*
0.67
f
*
0.67
f
)));
show
();
}
}
connect
(
&
windowNameUpdateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
configureWindowName
()));
windowNameUpdateTimer
.
start
(
15000
);
...
...
@@ -381,19 +388,8 @@ void MainWindow::buildCommonWidgets()
acceptList
->
append
(
"-105,pitch deg,deg,+105,s"
);
acceptList
->
append
(
"-105,heading deg,deg,+105,s"
);
acceptList
->
append
(
"-60,rollspeed d/s,deg/s,+60,s"
);
acceptList
->
append
(
"-60,pitchspeed d/s,deg/s,+60,s"
);
acceptList
->
append
(
"-60,yawspeed d/s,deg/s,+60,s"
);
acceptList
->
append
(
"0,airspeed,m/s,30"
);
acceptList
->
append
(
"0,groundspeed,m/s,30"
);
acceptList
->
append
(
"0,climbrate,m/s,30"
);
acceptList
->
append
(
"0,throttle,%,100"
);
//FIXME: memory of acceptList2 will never be freed again
QStringList
*
acceptList2
=
new
QStringList
();
acceptList2
->
append
(
"900,servo #6,us,2100,s"
);
acceptList2
->
append
(
"900,servo #7,us,2100,s"
);
acceptList2
->
append
(
"900,servo #8,us,2100,s"
);
acceptList2
->
append
(
"0,abs pressure,hPa,65500"
);
if
(
!
parametersDockWidget
)
{
...
...
@@ -1059,15 +1055,18 @@ void MainWindow::addLink(LinkInterface *link)
bool
found
=
false
;
foreach
(
QAction
*
act
,
actions
)
{
if
(
act
->
data
().
toInt
()
==
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
link
))
{
foreach
(
QAction
*
act
,
actions
)
{
if
(
act
->
data
().
toInt
()
==
LinkManager
::
instance
()
->
getLinks
().
indexOf
(
link
))
{
found
=
true
;
}
}
UDPLink
*
udp
=
dynamic_cast
<
UDPLink
*>
(
link
);
if
(
!
found
||
udp
)
{
if
(
!
found
||
udp
)
{
CommConfigurationWindow
*
commWidget
=
new
CommConfigurationWindow
(
link
,
mavlink
,
this
);
QAction
*
action
=
commWidget
->
getAction
();
ui
.
menuNetwork
->
addAction
(
action
);
...
...
@@ -1076,7 +1075,8 @@ void MainWindow::addLink(LinkInterface *link)
connect
(
link
,
SIGNAL
(
communicationError
(
QString
,
QString
)),
this
,
SLOT
(
showCriticalMessage
(
QString
,
QString
)),
Qt
::
QueuedConnection
);
// Special case for simulationlink
MAVLinkSimulationLink
*
sim
=
dynamic_cast
<
MAVLinkSimulationLink
*>
(
link
);
if
(
sim
)
{
if
(
sim
)
{
//connect(sim, SIGNAL(valueChanged(int,QString,double,quint64)), linechart, SLOT(appendData(int,QString,double,quint64)));
connect
(
ui
.
actionSimulate
,
SIGNAL
(
triggered
(
bool
)),
sim
,
SLOT
(
connectLink
(
bool
)));
}
...
...
@@ -1093,8 +1093,10 @@ void MainWindow::setActiveUAS(UASInterface* uas)
void
MainWindow
::
UASSpecsChanged
(
int
uas
)
{
UASInterface
*
activeUAS
=
UASManager
::
instance
()
->
getActiveUAS
();
if
(
activeUAS
)
{
if
(
activeUAS
->
getUASID
()
==
uas
)
{
if
(
activeUAS
)
{
if
(
activeUAS
->
getUASID
()
==
uas
)
{
ui
.
menuUnmanned_System
->
setTitle
(
activeUAS
->
getUASName
());
}
}
...
...
@@ -1152,18 +1154,22 @@ void MainWindow::UASCreated(UASInterface* uas)
ui
.
menuConnected_Systems
->
addAction
(
uasAction
);
// FIXME Should be not inside the mainwindow
if
(
debugConsoleDockWidget
)
{
if
(
debugConsoleDockWidget
)
{
DebugConsole
*
debugConsole
=
dynamic_cast
<
DebugConsole
*>
(
debugConsoleDockWidget
->
widget
());
if
(
debugConsole
)
{
if
(
debugConsole
)
{
connect
(
uas
,
SIGNAL
(
textMessageReceived
(
int
,
int
,
int
,
QString
)),
debugConsole
,
SLOT
(
receiveTextMessage
(
int
,
int
,
int
,
QString
)));
}
}
// Health / System status indicator
if
(
infoDockWidget
)
{
if
(
infoDockWidget
)
{
UASInfoWidget
*
infoWidget
=
dynamic_cast
<
UASInfoWidget
*>
(
infoDockWidget
->
widget
());
if
(
infoWidget
)
{
if
(
infoWidget
)
{
infoWidget
->
addUAS
(
uas
);
}
}
...
...
@@ -1202,7 +1208,8 @@ void MainWindow::UASCreated(UASInterface* uas)
addTool
(
detectionDockWidget
,
tr
(
"Object Recognition"
),
Qt
::
RightDockWidgetArea
);
}
if
(
!
watchdogControlDockWidget
)
{
if
(
!
watchdogControlDockWidget
)
{
watchdogControlDockWidget
=
new
QDockWidget
(
tr
(
"Process Control"
),
this
);
watchdogControlDockWidget
->
setWidget
(
new
WatchdogControl
(
this
)
);
watchdogControlDockWidget
->
setObjectName
(
"WATCHDOG_CONTROL_DOCKWIDGET"
);
...
...
@@ -1288,6 +1295,10 @@ void MainWindow::loadViewState()
}
else
{
// Hide custom widgets
if
(
detectionDockWidget
)
detectionDockWidget
->
hide
();
if
(
watchdogControlDockWidget
)
watchdogControlDockWidget
->
hide
();
// Load defaults
switch
(
currentView
)
{
...
...
@@ -1324,7 +1335,7 @@ void MainWindow::loadViewState()
headDown2DockWidget
->
show
();
rcViewDockWidget
->
hide
();
headUpDockWidget
->
hide
();
video1DockWidget
->
show
();
video1DockWidget
->
hide
();
video2DockWidget
->
hide
();
break
;
case
VIEW_MAVLINK
:
...
...
@@ -1346,25 +1357,42 @@ void MainWindow::loadViewState()
video2DockWidget
->
hide
();
break
;
case
VIEW_OPERATOR
:
centerStack
->
setCurrentWidget
(
mapWidget
);
controlDockWidget
->
hide
();
listDockWidget
->
show
();
waypointsDockWidget
->
show
();
infoDockWidget
->
hide
();
debugConsoleDockWidget
->
show
();
logPlayerDockWidget
->
show
();
parametersDockWidget
->
hide
();
hsiDockWidget
->
show
();
headDown1DockWidget
->
hide
();
headDown2DockWidget
->
hide
();
rcViewDockWidget
->
hide
();
headUpDockWidget
->
show
();
video1DockWidget
->
hide
();
video2DockWidget
->
hide
();
mavlinkInspectorWidget
->
hide
();
break
;
case
VIEW_UNCONNECTED
:
case
VIEW_FULL
:
default:
centerStack
->
setCurrentWidget
(
mapWidget
);
controlDockWidget
->
show
();
controlDockWidget
->
hide
();
listDockWidget
->
show
();
waypointsDockWidget
->
show
();
infoDockWidget
->
show
();
waypointsDockWidget
->
hide
();
infoDockWidget
->
hide
();
debugConsoleDockWidget
->
show
();
logPlayerDockWidget
->
show
();
mavlinkInspectorWidget
->
show
();
parametersDockWidget
->
hide
();
hsiDockWidget
->
show
();
hsiDockWidget
->
hide
();
headDown1DockWidget
->
hide
();
headDown2DockWidget
->
hide
();
rcViewDockWidget
->
hide
();
headUpDockWidget
->
show
();
video1DockWidget
->
hide
();
video2DockWidget
->
hide
();
mavlinkInspectorWidget
->
show
();
break
;
}
}
...
...
@@ -1378,7 +1406,8 @@ void MainWindow::loadViewState()
void
MainWindow
::
loadEngineerView
()
{
if
(
currentView
!=
VIEW_ENGINEER
)
{
if
(
currentView
!=
VIEW_ENGINEER
)
{
storeViewState
();
currentView
=
VIEW_ENGINEER
;
ui
.
actionEngineersView
->
setChecked
(
true
);
...
...
@@ -1388,7 +1417,8 @@ void MainWindow::loadEngineerView()
void
MainWindow
::
loadOperatorView
()
{
if
(
currentView
!=
VIEW_OPERATOR
)
{
if
(
currentView
!=
VIEW_OPERATOR
)
{
storeViewState
();
currentView
=
VIEW_OPERATOR
;
ui
.
actionOperatorsView
->
setChecked
(
true
);
...
...
src/ui/QGCWaypointListMulti.cc
View file @
dc3b21fb
...
...
@@ -7,6 +7,7 @@ QGCWaypointListMulti::QGCWaypointListMulti(QWidget *parent) :
ui
(
new
Ui
::
QGCWaypointListMulti
)
{
ui
->
setupUi
(
this
);
setMinimumSize
(
600
,
80
);
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
systemCreated
(
UASInterface
*
)));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
int
)),
this
,
SLOT
(
systemSetActive
(
int
)));
}
...
...
src/ui/WaypointList.ui
View file @
dc3b21fb
...
...
@@ -6,7 +6,7 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
476
</width>
<width>
798
</width>
<height>
218
</height>
</rect>
</property>
...
...
@@ -19,14 +19,14 @@
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
rowstretch=
"100,0,0,0"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
rowstretch=
"100,0,0,0"
columnstretch=
"1,1,5,5,100,10,5,5,5,5,5"
>
<property
name=
"margin"
>
<number>
4
</number>
</property>
<property
name=
"spacing"
>
<number>
4
</number>
</property>
<item
row=
"0"
column=
"0"
colspan=
"1
0
"
>
<item
row=
"0"
column=
"0"
colspan=
"1
1
"
>
<widget
class=
"QScrollArea"
name=
"scrollArea"
>
<property
name=
"widgetResizable"
>
<bool>
true
</bool>
...
...
@@ -36,8 +36,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
464
</width>
<height>
1
58
</height>
<width>
786
</width>
<height>
1
74
</height>
</rect>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
...
...
@@ -64,7 +64,7 @@
</widget>
</widget>
</item>
<item
row=
"2"
column=
"
8
"
>
<item
row=
"2"
column=
"
9
"
>
<widget
class=
"QPushButton"
name=
"readButton"
>
<property
name=
"toolTip"
>
<string>
Read all waypoints from the MAV. Clears the list on this computer.
</string>
...
...
@@ -79,12 +79,12 @@
<string>
Read
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/status/software-update-available.svg
</normaloff>
:/images/status/software-update-available.svg
</iconset>
</property>
</widget>
</item>
<item
row=
"2"
column=
"
9
"
>
<item
row=
"2"
column=
"
10
"
>
<widget
class=
"QPushButton"
name=
"transmitButton"
>
<property
name=
"toolTip"
>
<string>
Transmit all waypoints on this list to the MAV.
</string>
...
...
@@ -99,28 +99,12 @@
<string>
Write
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/devices/network-wireless.svg
</normaloff>
:/images/devices/network-wireless.svg
</iconset>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
colspan=
"10"
>
<widget
class=
"QLabel"
name=
"statusLabel"
>
<property
name=
"toolTip"
>
<string>
The current waypoint transmission status
</string>
</property>
<property
name=
"statusTip"
>
<string>
The current waypoint transmission status
</string>
</property>
<property
name=
"whatsThis"
>
<string>
The current waypoint transmission status
</string>
</property>
<property
name=
"text"
>
<string>
TextLabel
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"6"
>
<item
row=
"2"
column=
"7"
>
<widget
class=
"QToolButton"
name=
"addButton"
>
<property
name=
"toolTip"
>
<string>
Add a new waypoint to this list. Transmit via write to the MAV.
</string>
...
...
@@ -135,7 +119,7 @@
<string>
...
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/actions/list-add.svg
</normaloff>
:/images/actions/list-add.svg
</iconset>
</property>
</widget>
...
...
@@ -172,7 +156,7 @@
</property>
</widget>
</item>
<item
row=
"2"
column=
"
4
"
>
<item
row=
"2"
column=
"
5
"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -185,7 +169,7 @@
</property>
</spacer>
</item>
<item
row=
"2"
column=
"
5
"
>
<item
row=
"2"
column=
"
6
"
>
<widget
class=
"QToolButton"
name=
"positionAddButton"
>
<property
name=
"toolTip"
>
<string>
Set the current vehicle position as new waypoint
</string>
...
...
@@ -200,12 +184,12 @@
<string>
...
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/actions/go-bottom.svg
</normaloff>
:/images/actions/go-bottom.svg
</iconset>
</property>
</widget>
</item>
<item
row=
"2"
column=
"
7
"
>
<item
row=
"2"
column=
"
8
"
>
<widget
class=
"QToolButton"
name=
"clearWPListButton"
>
<property
name=
"toolTip"
>
<string>
Delete all waypoints from this list. You have to click write to clear the list on the MAV as well.
</string>
...
...
@@ -220,15 +204,31 @@
<string>
...
</string>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/actions/process-stop.svg
</normaloff>
:/images/actions/process-stop.svg
</iconset>
</property>
</widget>
</item>
<item
row=
"2"
column=
"4"
>
<widget
class=
"QLabel"
name=
"statusLabel"
>
<property
name=
"toolTip"
>
<string>
The current waypoint transmission status
</string>
</property>
<property
name=
"statusTip"
>
<string>
The current waypoint transmission status
</string>
</property>
<property
name=
"whatsThis"
>
<string>
The current waypoint transmission status
</string>
</property>
<property
name=
"text"
>
<string>
Please add first waypoint.
</string>
</property>
</widget>
</item>
</layout>
<action
name=
"actionAddWaypoint"
>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/actions/list-add.svg
</normaloff>
:/images/actions/list-add.svg
</iconset>
</property>
<property
name=
"text"
>
...
...
@@ -240,7 +240,7 @@
</action>
<action
name=
"actionTransmit"
>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/devices/network-wireless.svg
</normaloff>
:/images/devices/network-wireless.svg
</iconset>
</property>
<property
name=
"text"
>
...
...
@@ -252,7 +252,7 @@
</action>
<action
name=
"actionRead"
>
<property
name=
"icon"
>
<iconset
resource=
"../../
mavground
.qrc"
>
<iconset
resource=
"../../
qgroundcontrol
.qrc"
>
<normaloff>
:/images/status/software-update-available.svg
</normaloff>
:/images/status/software-update-available.svg
</iconset>
</property>
<property
name=
"text"
>
...
...
@@ -261,7 +261,7 @@
</action>
</widget>
<resources>
<include
location=
"../../
mavground
.qrc"
/>
<include
location=
"../../
qgroundcontrol
.qrc"
/>
</resources>
<connections/>
</ui>
src/ui/designer/QGCToolWidget.cc
View file @
dc3b21fb
...
...
@@ -14,20 +14,23 @@
#include "QGCCommandButton.h"
#include "UASManager.h"
QGCToolWidget
::
QGCToolWidget
(
const
QString
&
title
,
QWidget
*
parent
)
:
QGCToolWidget
::
QGCToolWidget
(
const
QString
&
title
,
QWidget
*
parent
,
QSettings
*
settings
)
:
QWidget
(
parent
),
mav
(
NULL
),
mainMenuAction
(
NULL
),
widgetTitle
(
title
),
ui
(
new
Ui
::
QGCToolWidget
)
{
ui
->
setupUi
(
this
);
if
(
settings
)
loadSettings
(
*
settings
);
if
(
title
==
"Unnamed Tool"
)
{
widgetTitle
=
QString
(
"%1 %2"
).
arg
(
title
).
arg
(
QGCToolWidget
::
instances
()
->
count
());
}
qDebug
()
<<
"WidgetTitle"
<<
widgetTitle
;
ui
->
setupUi
(
this
);
setObjectName
(
t
itle
);
setObjectName
(
widgetT
itle
);
createActions
();
toolLayout
=
ui
->
toolLayout
;
toolLayout
->
setAlignment
(
Qt
::
AlignTop
);
...
...
@@ -35,19 +38,18 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent) :
QDockWidget
*
dock
=
dynamic_cast
<
QDockWidget
*>
(
this
->
parentWidget
());
if
(
dock
)
{
dock
->
setWindowTitle
(
t
itle
);
dock
->
setObjectName
(
t
itle
+
"DOCK"
);
dock
->
setWindowTitle
(
widgetT
itle
);
dock
->
setObjectName
(
widgetT
itle
+
"DOCK"
);
}
// Try with parent
dock
=
dynamic_cast
<
QDockWidget
*>
(
parent
);
if
(
dock
)
{
dock
->
setWindowTitle
(
t
itle
);
dock
->
setObjectName
(
t
itle
+
"DOCK"
);
dock
->
setWindowTitle
(
widgetT
itle
);
dock
->
setObjectName
(
widgetT
itle
+
"DOCK"
);
}
this
->
setWindowTitle
(
title
);
this
->
setWindowTitle
(
widgetTitle
);
QList
<
UASInterface
*>
systems
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
uas
,
systems
)
{
...
...
@@ -58,7 +60,11 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent) :
}
}
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
addUAS
(
UASInterface
*
)));
if
(
!
instances
()
->
contains
(
title
))
instances
()
->
insert
(
title
,
this
);
if
(
!
instances
()
->
contains
(
widgetTitle
))
instances
()
->
insert
(
widgetTitle
,
this
);
// Enforce storage if this not loaded from settings
// is MUST NOT BE SAVED if it was loaded from settings!
if
(
!
settings
)
storeWidgetsToSettings
();
}
QGCToolWidget
::~
QGCToolWidget
()
...
...
@@ -106,18 +112,22 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent,
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
settings
->
setArrayIndex
(
i
);
QString
name
=
settings
->
value
(
"TITLE"
,
tr
(
"UNKNOWN WIDGET %1"
).
arg
(
i
)
).
toString
();
QString
name
=
settings
->
value
(
"TITLE"
,
""
).
toString
();
if
(
!
instances
()
->
contains
(
name
))
if
(
!
instances
()
->
contains
(
name
)
&&
name
.
length
()
!=
0
)
{
qDebug
()
<<
"CREATED WIDGET:"
<<
name
;
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
name
,
parent
);
instances
()
->
insert
(
name
,
tool
);
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
name
,
parent
,
settings
);
newWidgets
.
append
(
tool
);
}
else
if
(
name
.
length
()
==
0
)
{
// Silently catch empty widget name - sanity check
// to survive broken settings (e.g. from user manipulation)
}
else
{
qDebug
()
<<
"WIDGET
DID ALREADY EXIST, REJECTING"
;
qDebug
()
<<
"WIDGET
"
<<
name
<<
"
DID ALREADY EXIST, REJECTING"
;
}
}
settings
->
endArray
();
...
...
@@ -145,7 +155,9 @@ bool QGCToolWidget::loadSettings(const QString& settings, bool singleinstance)
{
QString
widgetName
=
groups
.
first
();
if
(
singleinstance
&&
QGCToolWidget
::
instances
()
->
keys
().
contains
(
widgetName
))
return
false
;
setTitle
(
widgetName
);
// Do not use setTitle() here,
// interferes with loading settings
widgetTitle
=
widgetName
;
qDebug
()
<<
"WIDGET TITLE LOADED: "
<<
widgetName
;
loadSettings
(
set
);
return
true
;
...
...
@@ -214,11 +226,24 @@ void QGCToolWidget::storeWidgetsToSettings(QString settingsFile)
qDebug
()
<<
"STORING SETTINGS TO DEFAULT"
<<
settings
->
fileName
();
}
int
preArraySize
=
settings
->
beginReadArray
(
"QGC_TOOL_WIDGET_NAMES"
);
settings
->
endArray
();
settings
->
beginWriteArray
(
"QGC_TOOL_WIDGET_NAMES"
);
for
(
int
i
=
0
;
i
<
instances
()
->
size
(
);
++
i
)
for
(
int
i
=
0
;
i
<
qMax
(
preArraySize
,
instances
()
->
size
()
);
++
i
)
{
settings
->
setArrayIndex
(
i
);
settings
->
setValue
(
"TITLE"
,
instances
()
->
values
().
at
(
i
)
->
getTitle
());
if
(
i
<
instances
()
->
size
())
{
// Updating value
settings
->
setValue
(
"TITLE"
,
instances
()
->
values
().
at
(
i
)
->
getTitle
());
qDebug
()
<<
"WRITING TITLE"
<<
instances
()
->
values
().
at
(
i
)
->
getTitle
();
}
else
{
// Deleting old value
settings
->
remove
(
"TITLE"
);
}
}
settings
->
endArray
();
...
...
@@ -244,8 +269,8 @@ void QGCToolWidget::storeSettings(const QString& settingsFile)
void
QGCToolWidget
::
storeSettings
(
QSettings
&
settings
)
{
QString
widgetName
=
getTitle
()
;
settings
.
beginGroup
(
widget
Nam
e
);
qDebug
()
<<
"WRITING WIDGET"
<<
widgetTitle
<<
"TO SETTINGS"
;
settings
.
beginGroup
(
widget
Titl
e
);
settings
.
beginWriteArray
(
"QGC_TOOL_WIDGET_ITEMS"
);
int
k
=
0
;
// QGCToolItem counter
for
(
int
j
=
0
;
j
<
children
().
size
();
++
j
)
...
...
@@ -254,6 +279,7 @@ void QGCToolWidget::storeSettings(QSettings& settings)
QGCToolWidgetItem
*
item
=
dynamic_cast
<
QGCToolWidgetItem
*>
(
children
().
at
(
j
));
if
(
item
)
{
// Only count actual tool widget item children
settings
.
setArrayIndex
(
k
++
);
// Store the ToolWidgetItem
item
->
writeSettings
(
settings
);
...
...
@@ -424,20 +450,19 @@ void QGCToolWidget::setTitle()
void
QGCToolWidget
::
setWindowTitle
(
const
QString
&
title
)
{
// Sets title and calls setWindowTitle on QWidget
setTitle
(
title
);
widgetTitle
=
title
;
QWidget
::
setWindowTitle
(
title
);
}
void
QGCToolWidget
::
setTitle
(
QString
title
)
{
// Remove references to old title
QDockWidget
*
parent
=
dynamic_cast
<
QDockWidget
*>
(
this
->
parentWidget
());
if
(
parent
)
{
QSettings
settings
;
settings
.
beginGroup
(
widgetTitle
);
settings
.
remove
(
""
);
settings
.
endGroup
();
}
QSettings
settings
;
settings
.
beginGroup
(
widgetTitle
);
settings
.
remove
(
""
);
settings
.
endGroup
();
settings
.
sync
();
if
(
instances
()
->
contains
(
widgetTitle
))
instances
()
->
remove
(
widgetTitle
);
// Switch to new title
...
...
@@ -445,7 +470,10 @@ void QGCToolWidget::setTitle(QString title)
if
(
!
instances
()
->
contains
(
title
))
instances
()
->
insert
(
title
,
this
);
QWidget
::
setWindowTitle
(
title
);
QDockWidget
*
parent
=
dynamic_cast
<
QDockWidget
*>
(
this
->
parentWidget
());
if
(
parent
)
parent
->
setWindowTitle
(
title
);
// Store all widgets
storeWidgetsToSettings
();
emit
titleChanged
(
title
);
if
(
mainMenuAction
)
mainMenuAction
->
setText
(
title
);
...
...
@@ -470,6 +498,5 @@ void QGCToolWidget::deleteWidget()
storeWidgetsToSettings
();
// Delete
mainMenuAction
->
deleteLater
();
this
->
deleteLater
();
}
src/ui/designer/QGCToolWidget.h
View file @
dc3b21fb
...
...
@@ -19,7 +19,7 @@ class QGCToolWidget : public QWidget
Q_OBJECT
public:
explicit
QGCToolWidget
(
const
QString
&
title
=
QString
(
"Unnamed Tool"
),
QWidget
*
parent
=
0
);
explicit
QGCToolWidget
(
const
QString
&
title
=
QString
(
"Unnamed Tool"
),
QWidget
*
parent
=
0
,
QSettings
*
settings
=
0
);
~
QGCToolWidget
();
/** @brief Factory method to instantiate all tool widgets */
...
...
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