Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
edcb9fe6
Commit
edcb9fe6
authored
May 03, 2013
by
Michael Carpenter
Browse files
Change so custom widgets load properly, and realtime plot displays when connected to a MAV
parent
65980cfb
Changes
3
Show whitespace changes
Inline
Side-by-side
src/ui/MainWindow.cc
View file @
edcb9fe6
...
...
@@ -359,7 +359,10 @@ void MainWindow::buildCustomWidget()
QDockWidget
*
dock
=
dynamic_cast
<
QDockWidget
*>
(
tool
->
parentWidget
());
if
(
!
dock
)
{
QDockWidget
*
dock
=
new
QDockWidget
(
tool
->
windowTitle
(),
this
);
QSettings
settings
;
settings
.
beginGroup
(
"QGC_MAINWINDOW"
);
/*QDockWidget* dock = new QDockWidget(tool->windowTitle(), this);
dock->setObjectName(tool->objectName()+"_DOCK");
dock->setWidget(tool);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
...
...
@@ -368,13 +371,36 @@ void MainWindow::buildCustomWidget()
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
widgets.at(i)->setMainMenuAction(showAction);
ui
.
menuTools
->
addAction
(
showAction
);
ui.menuTools->addAction(showAction);
*/
// Load dock widget location (default is bottom)
Qt
::
DockWidgetArea
location
=
static_cast
<
Qt
::
DockWidgetArea
>
(
tool
->
getDockWidgetArea
(
currentView
));
addDockWidget
(
location
,
dock
);
dock
->
hide
();
//addDockWidget(location, dock);
//dock->hide();
int
view
=
settings
.
value
(
QString
(
"TOOL_PARENT_"
)
+
tool
->
objectName
(),
-
1
).
toInt
();
//settings.setValue(QString("TOOL_PARENT_") + "UNNAMED_TOOL_" + QString::number(ui.menuTools->actions().size()),currentView);
settings
.
endGroup
();
switch
(
view
)
{
case
VIEW_ENGINEER
:
createDockWidget
(
dataView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
location
);
break
;
case
VIEW_FLIGHT
:
createDockWidget
(
pilotView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
location
);
break
;
case
VIEW_SIMULATION
:
createDockWidget
(
simView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
location
);
break
;
case
VIEW_MISSION
:
createDockWidget
(
plannerView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
location
);
break
;
default:
createDockWidget
(
centerStack
->
currentWidget
(),
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
location
);
break
;
}
//createDockWidget(0,tool,tool->getTitle(),tool->objectName(),view,location);
}
}
}
...
...
@@ -604,6 +630,10 @@ void MainWindow::addTool(SubMainWindow *parent,VIEW_SECTIONS view,QDockWidget* w
void
MainWindow
::
createDockWidget
(
QWidget
*
parent
,
QWidget
*
child
,
QString
title
,
QString
objectname
,
VIEW_SECTIONS
view
,
Qt
::
DockWidgetArea
area
,
int
minwidth
,
int
minheight
)
{
if
(
child
->
objectName
()
==
""
)
{
child
->
setObjectName
(
objectname
);
}
QDockWidget
*
widget
=
new
QDockWidget
(
title
,
this
);
if
(
!
isAdvancedMode
)
{
...
...
@@ -629,7 +659,7 @@ void MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString title,Q
label
->
installEventFilter
(
new
DockWidgetTitleBarEventFilter
());
label
->
hide
();
}
widget
->
setObjectName
(
object
n
ame
);
widget
->
setObjectName
(
child
->
object
N
ame
()
+
"DOCK"
);
widget
->
setWidget
(
child
);
if
(
minheight
!=
0
||
minwidth
!=
0
)
{
...
...
@@ -826,26 +856,35 @@ void MainWindow::connectCommonWidgets()
void
MainWindow
::
createCustomWidget
()
{
QDockWidget
*
dock
=
new
QDockWidget
(
"Unnamed Tool"
,
this
);
QGCTool
Widget
*
tool
=
new
Q
GCTool
Widget
(
"Unnamed Tool"
,
dock
);
//void MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString title,QString objectname,VIEW_SECTIONS view,Qt::DockWidgetArea area,int minwidth,int minheight)
//QDock
Widget*
dock
= new Q
Dock
Widget("Unnamed Tool",
this
);
if
(
QGCToolWidget
::
instances
()
->
size
()
<
2
)
{
// This is the first widget
ui
.
menuTools
->
addSeparator
();
}
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
"Unnamed Tool "
+
QString
::
number
(
ui
.
menuTools
->
actions
().
size
()));
createDockWidget
(
centerStack
->
currentWidget
(),
tool
,
"Unnamed Tool "
+
QString
::
number
(
ui
.
menuTools
->
actions
().
size
()),
"UNNAMED_TOOL_"
+
QString
::
number
(
ui
.
menuTools
->
actions
().
size
()),
currentView
,
Qt
::
BottomDockWidgetArea
);
//tool->setObjectName("UNNAMED_TOOL_" + QString::number(ui.menuTools->actions().size()));
QSettings
settings
;
settings
.
beginGroup
(
"QGC_MAINWINDOW"
);
settings
.
setValue
(
QString
(
"TOOL_PARENT_"
)
+
tool
->
objectName
(),
currentView
);
settings
.
endGroup
();
connect
(
tool
,
SIGNAL
(
destroyed
()),
dock
,
SLOT
(
deleteLater
()));
dock
->
setWidget
(
tool
);
QAction
*
showAction
=
new
QAction
(
tool
->
getTitle
(),
this
);
showAction
->
setCheckable
(
true
);
connect
(
dock
,
SIGNAL
(
visibilityChanged
(
bool
)),
showAction
,
SLOT
(
setChecked
(
bool
)));
connect
(
showAction
,
SIGNAL
(
triggered
(
bool
)),
dock
,
SLOT
(
setVisible
(
bool
)));
tool
->
setMainMenuAction
(
showAction
);
ui
.
menuTools
->
addAction
(
showAction
);
this
->
addDockWidget
(
Qt
::
BottomDockWidgetArea
,
dock
);
dock
->
setVisible
(
true
);
//connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
//dock->setWidget(tool);
//QAction* showAction = new QAction(tool->getTitle(), this);
//showAction->setCheckable(true);
//connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
//connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
//tool->setMainMenuAction(showAction);
//ui.menuTools->addAction(showAction);
//this->addDockWidget(Qt::BottomDockWidgetArea, dock);
//dock->setVisible(true);
}
void
MainWindow
::
loadCustomWidget
()
...
...
@@ -860,8 +899,35 @@ void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance)
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
""
,
this
);
if
(
tool
->
loadSettings
(
fileName
,
true
)
||
!
singleinstance
)
{
qDebug
()
<<
"Loading custom tool:"
<<
tool
->
getTitle
()
<<
tool
->
objectName
();
QSettings
settings
;
settings
.
beginGroup
(
"QGC_MAINWINDOW"
);
//settings.setValue(QString("TOOL_PARENT_") + "UNNAMED_TOOL_" + QString::number(ui.menuTools->actions().size()),currentView);
int
view
=
settings
.
value
(
QString
(
"TOOL_PARENT_"
)
+
tool
->
objectName
(),
-
1
).
toInt
();
switch
(
view
)
{
case
VIEW_ENGINEER
:
createDockWidget
(
dataView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
Qt
::
LeftDockWidgetArea
);
break
;
case
VIEW_FLIGHT
:
createDockWidget
(
pilotView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
Qt
::
LeftDockWidgetArea
);
break
;
case
VIEW_SIMULATION
:
createDockWidget
(
simView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
Qt
::
LeftDockWidgetArea
);
break
;
case
VIEW_MISSION
:
createDockWidget
(
plannerView
,
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
Qt
::
LeftDockWidgetArea
);
break
;
default:
createDockWidget
(
centerStack
->
currentWidget
(),
tool
,
tool
->
getTitle
(),
tool
->
objectName
(),(
VIEW_SECTIONS
)
view
,
Qt
::
LeftDockWidgetArea
);
break
;
}
settings
.
endGroup
();
// Add widget to UI
QDockWidget
*
dock
=
new
QDockWidget
(
tool
->
getTitle
(),
this
);
/*
QDockWidget* dock = new QDockWidget(tool->getTitle(), this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
dock->setWidget(tool);
tool->setParent(dock);
...
...
@@ -873,7 +939,7 @@ void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance)
tool->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction);
this->addDockWidget(Qt::BottomDockWidgetArea, dock);
dock
->
hide
();
dock->hide();
*/
}
else
{
...
...
@@ -1552,14 +1618,32 @@ void MainWindow::UASCreated(UASInterface* uas)
// HIL
showHILConfigurationWidget
(
uas
);
// Line chart
/*if (!linechartWidget)
if
(
!
linechartWidget
)
{
// Center widgets
linechartWidget
=
new
Linecharts
(
this
);
//linechartWidget->hide();
}
// Line chart
//if (!linechartWidget)
//{
// Center widgets
//linechartWidget->addSystem(uas);
linechartWidget
->
addSource
(
mavlinkDecoder
);
addCentralWidget(linechartWidget, tr("Realtime Plot"));
}*/
//addCentralWidget(linechartWidget, tr("Realtime Plot"));
if
(
dataView
->
centralWidget
()
!=
linechartWidget
)
{
dataView
->
setCentralWidget
(
linechartWidget
);
linechartWidget
->
show
();
}
//dataView->setCentralWidget(linechartWidget);
//linechartWidget->show();
//}
// Load default custom widgets for this autopilot type
loadCustomWidgetsFromDefaults
(
uas
->
getSystemTypeName
(),
uas
->
getAutopilotTypeName
());
...
...
@@ -1755,6 +1839,7 @@ void MainWindow::loadViewState()
{
if
(
widgetname
!=
""
)
{
qDebug
()
<<
"Loading widget:"
<<
widgetname
;
loadDockWidget
(
widgetname
);
}
}
...
...
src/ui/MainWindow.h
View file @
edcb9fe6
...
...
@@ -351,7 +351,7 @@ void createDockWidget(QWidget *parent,QWidget *child,QString title,QString objec
QPointer
<
SubMainWindow
>
simView
;
// Center widgets
//
QPointer<Linecharts> linechartWidget;
QPointer
<
Linecharts
>
linechartWidget
;
//QPointer<HUD> hudWidget;
//QPointer<QGCVehicleConfig> configWidget;
//QPointer<QGCMapTool> mapWidget;
...
...
src/ui/designer/QGCToolWidget.cc
View file @
edcb9fe6
...
...
@@ -117,11 +117,13 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent,
{
settings
->
setArrayIndex
(
i
);
QString
name
=
settings
->
value
(
"TITLE"
,
""
).
toString
();
QString
objname
=
settings
->
value
(
"OBJECT_NAME"
,
""
).
toString
();
if
(
!
instances
()
->
contains
(
name
)
&&
name
.
length
()
!=
0
)
{
//qDebug() << "CREATED WIDGET:" << name;
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
name
,
parent
,
settings
);
tool
->
setObjectName
(
objname
);
newWidgets
.
append
(
tool
);
}
else
if
(
name
.
length
()
==
0
)
...
...
@@ -403,6 +405,7 @@ void QGCToolWidget::storeWidgetsToSettings(QString settingsFile)
{
settings
->
setArrayIndex
(
num
++
);
settings
->
setValue
(
"TITLE"
,
instances
()
->
values
().
at
(
i
)
->
getTitle
());
settings
->
setValue
(
"OBJECT_NAME"
,
instances
()
->
values
().
at
(
i
)
->
objectName
());
//qDebug() << "WRITING TITLE" << instances()->values().at(i)->getTitle();
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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