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
9ac8b1c3
Commit
9ac8b1c3
authored
Oct 31, 2013
by
Lorenz Meier
Browse files
Merge branch 'master' of github.com:mavlink/qgroundcontrol
parents
0700a1e7
483f6293
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
qgroundcontrol.pro
View file @
9ac8b1c3
...
...
@@ -301,7 +301,8 @@ FORMS += src/ui/MainWindow.ui \
src
/
ui
/
configuration
/
ApmFirmwareConfig
.
ui
\
src
/
ui
/
px4_configuration
/
QGCPX4AirframeConfig
.
ui
\
src
/
ui
/
px4_configuration
/
QGCPX4MulticopterConfig
.
ui
\
src
/
ui
/
px4_configuration
/
QGCPX4SensorCalibration
.
ui
src
/
ui
/
px4_configuration
/
QGCPX4SensorCalibration
.
ui
\
src
/
ui
/
designer
/
QGCXYPlot
.
ui
INCLUDEPATH
+=
src
\
src
/
ui
\
...
...
@@ -449,7 +450,6 @@ HEADERS += src/MG.h \
src
/
ui
/
designer
/
QGCComboBox
.
h
\
src
/
ui
/
designer
/
QGCTextLabel
.
h
\
src
/
ui
/
submainwindow
.
h
\
src
/
ui
/
dockwidgettitlebareventfilter
.
h
\
src
/
ui
/
uas
/
UASQuickView
.
h
\
src
/
ui
/
uas
/
UASQuickViewItem
.
h
\
src
/
ui
/
linechart
/
ChartPlot
.
h
\
...
...
@@ -507,7 +507,8 @@ HEADERS += src/MG.h \
src
/
ui
/
QGCBaseParamWidget
.
h
\
src
/
ui
/
px4_configuration
/
QGCPX4MulticopterConfig
.
h
\
src
/
ui
/
px4_configuration
/
QGCPX4SensorCalibration
.
h
\
src
/
ui
/
dockwidgeteventfilter
.
h
src
/
ui
/
designer
/
QGCXYPlot
.
h
\
src
/
ui
/
menuactionhelper
.
h
#
Google
Earth
is
only
supported
on
Mac
OS
and
Windows
with
Visual
Studio
Compiler
macx
|
macx
-
g
++
|
macx
-
g
++
42
|
win32
-
msvc2008
|
win32
-
msvc2010
|
win32
-
msvc2012
::
HEADERS
+=
src
/
ui
/
map3D
/
QGCGoogleEarthView
.
h
...
...
@@ -672,7 +673,6 @@ SOURCES += src/main.cc \
src
/
ui
/
designer
/
QGCComboBox
.
cc
\
src
/
ui
/
designer
/
QGCTextLabel
.
cc
\
src
/
ui
/
submainwindow
.
cpp
\
src
/
ui
/
dockwidgettitlebareventfilter
.
cpp
\
src
/
ui
/
uas
/
UASQuickViewItem
.
cc
\
src
/
ui
/
uas
/
UASQuickView
.
cc
\
src
/
ui
/
linechart
/
ChartPlot
.
cc
\
...
...
@@ -730,7 +730,8 @@ SOURCES += src/main.cc \
src
/
ui
/
QGCBaseParamWidget
.
cc
\
src
/
ui
/
px4_configuration
/
QGCPX4MulticopterConfig
.
cc
\
src
/
ui
/
px4_configuration
/
QGCPX4SensorCalibration
.
cc
\
src
/
ui
/
dockwidgeteventfilter
.
cpp
src
/
ui
/
designer
/
QGCXYPlot
.
cc
\
src
/
ui
/
menuactionhelper
.
cpp
#
Enable
Google
Earth
only
on
Mac
OS
and
Windows
with
Visual
Studio
compiler
macx
|
macx
-
g
++
|
macx
-
g
++
42
|
win32
-
msvc2008
|
win32
-
msvc2010
|
win32
-
msvc2012
::
SOURCES
+=
src
/
ui
/
map3D
/
QGCGoogleEarthView
.
cc
...
...
src/ui/HDDisplay.cc
View file @
9ac8b1c3
...
...
@@ -27,7 +27,7 @@
#include
"MainWindow.h"
#include
<QDebug>
HDDisplay
::
HDDisplay
(
QStringList
*
plotList
,
QString
title
,
QWidget
*
parent
)
:
HDDisplay
::
HDDisplay
(
const
QStringList
&
plotList
,
QString
title
,
QWidget
*
parent
)
:
QGraphicsView
(
parent
),
uas
(
NULL
),
xCenterOffset
(
0.0
f
),
...
...
@@ -60,11 +60,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QString title, QWidget *parent) :
setAutoFillBackground
(
true
);
// Add all items in accept list to gauge
if
(
plotList
)
{
for
(
int
i
=
0
;
i
<
plotList
->
length
();
++
i
)
{
addGauge
(
plotList
->
at
(
i
));
}
}
for
(
int
i
=
0
;
i
<
plotList
.
length
();
++
i
)
addGauge
(
plotList
.
at
(
i
));
restoreState
();
// Set preferred size
...
...
src/ui/HDDisplay.h
View file @
9ac8b1c3
...
...
@@ -60,7 +60,7 @@ class HDDisplay : public QGraphicsView
{
Q_OBJECT
public:
HDDisplay
(
QStringList
*
plotList
,
QString
title
=
""
,
QWidget
*
parent
=
0
);
HDDisplay
(
const
QStringList
&
plotList
,
QString
title
=
""
,
QWidget
*
parent
=
0
);
~
HDDisplay
();
public
slots
:
...
...
src/ui/HSIDisplay.cc
View file @
9ac8b1c3
...
...
@@ -49,7 +49,7 @@ This file is part of the QGROUNDCONTROL project
HSIDisplay
::
HSIDisplay
(
QWidget
*
parent
)
:
HDDisplay
(
NULL
,
"HSI"
,
parent
),
HDDisplay
(
QStringList
()
,
"HSI"
,
parent
),
dragStarted
(
false
),
leftDragStarted
(
false
),
mouseHasMoved
(
false
),
...
...
src/ui/MainWindow.cc
View file @
9ac8b1c3
This diff is collapsed.
Click to expand it.
src/ui/MainWindow.h
View file @
9ac8b1c3
...
...
@@ -86,6 +86,7 @@ class QGCStatusBar;
class
Linecharts
;
class
QGCDataPlot2D
;
class
JoystickWidget
;
class
MenuActionHelper
;
/**
* @brief Main Application Window
...
...
@@ -142,41 +143,38 @@ public:
static
const
QString
defaultLightStyle
;
/** @brief Get current visual style */
QGC_MAINWINDOW_STYLE
getStyle
()
QGC_MAINWINDOW_STYLE
getStyle
()
const
{
return
currentStyle
;
}
/** @brief Get current light visual stylesheet */
QString
getLightStyleSheet
()
QString
getLightStyleSheet
()
const
{
return
lightStyleFileName
;
}
/** @brief Get current dark visual stylesheet */
QString
getDarkStyleSheet
()
QString
getDarkStyleSheet
()
const
{
return
darkStyleFileName
;
}
/** @brief Get auto link reconnect setting */
bool
autoReconnectEnabled
()
bool
autoReconnectEnabled
()
const
{
return
autoReconnect
;
}
/** @brief Get title bar mode setting */
bool
dockWidgetTitleBarsEnabled
()
{
return
dockWidgetTitleBarEnabled
;
}
bool
dockWidgetTitleBarsEnabled
()
const
;
/** @brief Get low power mode setting */
bool
lowPowerModeEnabled
()
bool
lowPowerModeEnabled
()
const
{
return
lowPowerMode
;
}
void
setCustomMode
(
enum
MainWindow
::
CUSTOM_MODE
mode
)
void
setCustomMode
(
MainWindow
::
CUSTOM_MODE
mode
)
{
if
(
mode
!=
CUSTOM_MODE_UNCHANGED
)
{
...
...
@@ -184,12 +182,12 @@ public:
}
}
enum
MainWindow
::
CUSTOM_MODE
getCustomMode
()
MainWindow
::
CUSTOM_MODE
getCustomMode
()
const
{
return
customMode
;
}
QList
<
QAction
*>
listLinkMenuActions
(
void
);
QList
<
QAction
*>
listLinkMenuActions
();
public
slots
:
/** @brief Shows a status message on the bottom status bar */
...
...
@@ -224,7 +222,7 @@ public slots:
void
saveScreen
();
/** @brief Sets advanced mode, allowing for editing of tool widget locations */
void
setAdvancedMode
();
void
setAdvancedMode
(
bool
isAdvancedMode
);
/** @brief Load configuration views */
void
loadHardwareConfigView
();
void
loadSoftwareConfigView
();
...
...
@@ -283,16 +281,6 @@ public slots:
/** @brief Load data view, allowing to plot flight data */
// void loadDataView(QString fileName);
/**
* @brief Shows a Docked Widget based on the action sender
*
* This slot is written to be used in conjunction with the addTool() function
* It shows the QDockedWidget based on the action sender
*
*/
void
showTool
(
bool
visible
);
/**
* @brief Shows a Widget from the center stack based on the action sender
*
...
...
@@ -308,13 +296,14 @@ public slots:
void
commsWidgetDestroyed
(
QObject
*
obj
);
protected
slots
:
/** @brief Called by a dock widget when it is has been deleted */
void
dockWidgetDestroyed
();
void
showDockWidget
(
const
QString
&
name
,
bool
show
);
signals:
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
newTheme
);
void
styleChanged
();
void
initStatusChanged
(
const
QString
&
message
,
int
alignment
,
const
QColor
&
color
);
/** Emitted when any value changes from any source */
void
valueChanged
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
QVariant
&
value
,
const
quint64
msec
);
#ifdef MOUSE_ENABLED_LINUX
/** @brief Forward X11Event to catch 3DMouse inputs */
void
x11EventOccured
(
XEvent
*
event
);
...
...
@@ -362,8 +351,9 @@ protected:
* @param location The default location for the QDockedWidget in case there is no previous key in the settings
*/
void
addTool
(
SubMainWindow
*
parent
,
VIEW_SECTIONS
view
,
QDockWidget
*
widget
,
const
QString
&
title
,
Qt
::
DockWidgetArea
area
);
void
loadDockWidget
(
QString
name
);
QDockWidget
*
createDockWidget
(
QWidget
*
parent
,
QWidget
*
child
,
QString
title
,
QString
objectname
,
VIEW_SECTIONS
view
,
Qt
::
DockWidgetArea
area
,
int
minwidth
=
0
,
int
minheight
=
0
);
void
loadDockWidget
(
const
QString
&
name
);
QDockWidget
*
createDockWidget
(
QWidget
*
subMainWindowParent
,
QWidget
*
child
,
const
QString
&
title
,
const
QString
&
objectname
,
VIEW_SECTIONS
view
,
Qt
::
DockWidgetArea
area
,
const
QSize
&
minSize
=
QSize
());
/**
* @brief Adds an already instantiated QWidget to the center stack
*
...
...
@@ -514,11 +504,7 @@ protected:
private:
QList
<
QObject
*>
commsWidgetList
;
QMap
<
QString
,
QString
>
customWidgetNameToFilenameMap
;
QMap
<
QAction
*
,
QString
>
menuToDockNameMap
;
QList
<
QDockWidget
*>
dockWidgets
;
QMap
<
VIEW_SECTIONS
,
QMap
<
QString
,
QWidget
*>
>
centralWidgetToDockWidgetsMap
;
bool
isAdvancedMode
;
///< If enabled dock widgets can be moved and floated.
bool
dockWidgetTitleBarEnabled
;
///< If enabled, dock widget titlebars are displayed when NOT in advanced mode.
MenuActionHelper
*
menuActionHelper
;
Ui
::
MainWindow
ui
;
/** @brief Set the appropriate titlebar for a given dock widget.
...
...
@@ -529,6 +515,7 @@ private:
QString
getWindowStateKey
();
QString
getWindowGeometryKey
();
friend
class
MenuActionHelper
;
//For VIEW_SECTIONS
};
#endif
/* _MAINWINDOW_H_ */
src/ui/QGCPX4VehicleConfig.cc
View file @
9ac8b1c3
...
...
@@ -576,7 +576,7 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
QWidget
*
parent
=
left
?
ui
->
generalLeftContents
:
ui
->
generalRightContents
;
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
""
,
""
,
parent
);
if
(
tool
->
loadSettings
(
generaldir
.
absoluteFilePath
(
file
),
false
))
{
toolWidgets
.
append
(
tool
);
...
...
@@ -651,7 +651,7 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
foreach
(
QString
file
,
newdir
.
entryList
(
QDir
::
Files
|
QDir
::
NoDotAndDotDot
))
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
tool
=
new
QGCToolWidget
(
""
,
tab
);
tool
=
new
QGCToolWidget
(
""
,
""
,
tab
);
if
(
tool
->
loadSettings
(
newdir
.
absoluteFilePath
(
file
),
false
))
{
toolWidgets
.
append
(
tool
);
...
...
@@ -698,7 +698,7 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
foreach
(
QString
file
,
newdir
.
entryList
(
QDir
::
Files
|
QDir
::
NoDotAndDotDot
))
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
tool
=
new
QGCToolWidget
(
""
,
tab
);
tool
=
new
QGCToolWidget
(
""
,
""
,
tab
);
tool
->
addUAS
(
mav
);
if
(
tool
->
loadSettings
(
newdir
.
absoluteFilePath
(
file
),
false
))
{
...
...
@@ -953,10 +953,8 @@ void QGCPX4VehicleConfig::loadConfig()
{
parent
=
ui
->
generalRightContents
;
}
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
parametersname
,
parametersname
,
parent
);
tool
->
addUAS
(
mav
);
tool
->
setTitle
(
parametersname
);
tool
->
setObjectName
(
parametersname
);
tool
->
setSettings
(
genset
);
QList
<
QString
>
paramlist
=
tool
->
getParamList
();
for
(
int
i
=
0
;
i
<
paramlist
.
size
();
i
++
)
...
...
@@ -1007,10 +1005,8 @@ void QGCPX4VehicleConfig::loadConfig()
{
parent
=
ui
->
generalRightContents
;
}
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
parametersname
,
parametersname
,
parent
);
tool
->
addUAS
(
mav
);
tool
->
setTitle
(
parametersname
);
tool
->
setObjectName
(
parametersname
);
tool
->
setSettings
(
advset
);
QList
<
QString
>
paramlist
=
tool
->
getParamList
();
for
(
int
i
=
0
;
i
<
paramlist
.
size
();
i
++
)
...
...
src/ui/QGCVehicleConfig.cc
View file @
9ac8b1c3
...
...
@@ -261,7 +261,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary)
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
QWidget
*
parent
=
left
?
ui
->
generalLeftContents
:
ui
->
generalRightContents
;
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
""
,
""
,
parent
);
if
(
tool
->
loadSettings
(
generaldir
.
absoluteFilePath
(
file
),
false
))
{
toolWidgets
.
append
(
tool
);
...
...
@@ -291,7 +291,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary)
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
QWidget
*
parent
=
left
?
ui
->
advancedLeftContents
:
ui
->
advancedRightContents
;
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
""
,
""
,
parent
);
if
(
tool
->
loadSettings
(
vehicledir
.
absoluteFilePath
(
file
),
false
))
{
toolWidgets
.
append
(
tool
);
...
...
@@ -342,7 +342,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary)
foreach
(
QString
file
,
newdir
.
entryList
(
QDir
::
Files
|
QDir
::
NoDotAndDotDot
))
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
tool
=
new
QGCToolWidget
(
""
,
tab
);
tool
=
new
QGCToolWidget
(
""
,
""
,
tab
);
if
(
tool
->
loadSettings
(
newdir
.
absoluteFilePath
(
file
),
false
))
{
toolWidgets
.
append
(
tool
);
...
...
@@ -389,7 +389,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary)
foreach
(
QString
file
,
newdir
.
entryList
(
QDir
::
Files
|
QDir
::
NoDotAndDotDot
))
{
if
(
file
.
toLower
().
endsWith
(
".qgw"
))
{
tool
=
new
QGCToolWidget
(
""
,
tab
);
tool
=
new
QGCToolWidget
(
""
,
""
,
tab
);
tool
->
addUAS
(
mav
);
if
(
tool
->
loadSettings
(
newdir
.
absoluteFilePath
(
file
),
false
))
{
...
...
@@ -411,7 +411,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary)
// Load general calibration for autopilot
//TODO: Handle this more gracefully, maybe have it scan the directory for multiple calibration entries?
tool
=
new
QGCToolWidget
(
""
,
ui
->
sensorContents
);
tool
=
new
QGCToolWidget
(
""
,
""
,
ui
->
sensorContents
);
tool
->
addUAS
(
mav
);
if
(
tool
->
loadSettings
(
autopilotdir
.
absolutePath
()
+
"/general/calibration/calibration.qgw"
,
false
))
{
...
...
@@ -426,7 +426,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary)
}
// Load vehicle-specific autopilot configuration
tool
=
new
QGCToolWidget
(
""
,
ui
->
sensorContents
);
tool
=
new
QGCToolWidget
(
""
,
""
,
ui
->
sensorContents
);
tool
->
addUAS
(
mav
);
if
(
tool
->
loadSettings
(
autopilotdir
.
absolutePath
()
+
"/"
+
mav
->
getSystemTypeName
().
toLower
()
+
"/calibration/calibration.qgw"
,
false
))
{
...
...
@@ -681,10 +681,8 @@ void QGCVehicleConfig::loadConfig()
{
parent
=
ui
->
generalRightContents
;
}
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
parametersname
,
parametersname
,
parent
);
tool
->
addUAS
(
mav
);
tool
->
setTitle
(
parametersname
);
tool
->
setObjectName
(
parametersname
);
tool
->
setSettings
(
genset
);
QList
<
QString
>
paramlist
=
tool
->
getParamList
();
for
(
int
i
=
0
;
i
<
paramlist
.
size
();
i
++
)
...
...
@@ -735,10 +733,8 @@ void QGCVehicleConfig::loadConfig()
{
parent
=
ui
->
generalRightContents
;
}
tool
=
new
QGCToolWidget
(
""
,
parent
);
tool
=
new
QGCToolWidget
(
parametersname
,
parametersname
,
parent
);
tool
->
addUAS
(
mav
);
tool
->
setTitle
(
parametersname
);
tool
->
setObjectName
(
parametersname
);
tool
->
setSettings
(
advset
);
QList
<
QString
>
paramlist
=
tool
->
getParamList
();
for
(
int
i
=
0
;
i
<
paramlist
.
size
();
i
++
)
...
...
@@ -1175,14 +1171,12 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
}
// Create the tool, attaching it to the QGroupBox
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
""
,
parent
);
QString
tooltitle
=
parameterName
;
if
(
parameterName
.
split
(
"_"
).
size
()
>
1
)
{
tooltitle
=
parameterName
.
split
(
"_"
)[
0
]
+
"_"
;
}
tool
->
setTitle
(
tooltitle
);
tool
->
setObjectName
(
tooltitle
);
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
tooltitle
,
tooltitle
,
parent
);
//tool->setSettings(set);
libParamToWidgetMap
.
insert
(
parameterName
,
tool
);
toolWidgets
.
append
(
tool
);
...
...
src/ui/designer/QGCComboBox.cc
View file @
9ac8b1c3
...
...
@@ -167,70 +167,42 @@ void QGCComboBox::selectParameter(int paramIndex)
}
}
void
QGCComboBox
::
s
tar
tEditMode
()
void
QGCComboBox
::
s
e
tEditMode
(
bool
editMode
)
{
ui
->
nameLabel
->
hide
();
ui
->
writeButton
->
hide
();
ui
->
readButton
->
hide
();
ui
->
editInfoCheckBox
->
show
();
ui
->
editDoneButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editRefreshParamsButton
->
show
();
ui
->
editSelectParamComboBox
->
show
();
ui
->
editSelectComponentComboBox
->
show
();
ui
->
editStatusLabel
->
show
();
ui
->
writeButton
->
hide
();
ui
->
readButton
->
hide
();
ui
->
editLine1
->
show
();
ui
->
editLine2
->
show
();
ui
->
editAddItemButton
->
show
();
ui
->
editRemoveItemButton
->
show
();
ui
->
editItemValueSpinBox
->
show
();
ui
->
editItemNameLabel
->
show
();
ui
->
itemValueLabel
->
show
();
ui
->
itemNameLabel
->
show
();
if
(
isDisabled
)
{
ui
->
editOptionComboBox
->
setEnabled
(
true
);
if
(
!
editMode
)
{
// Store component id
selectComponent
(
ui
->
editSelectComponentComboBox
->
currentIndex
());
// Store parameter name and id
selectParameter
(
ui
->
editSelectParamComboBox
->
currentIndex
());
}
isInEditMode
=
true
;
}
void
QGCComboBox
::
endEditMode
()
{
// Store component id
selectComponent
(
ui
->
editSelectComponentComboBox
->
currentIndex
());
// Store parameter name and id
selectParameter
(
ui
->
editSelectParamComboBox
->
currentIndex
());
// Min/max
ui
->
editInfoCheckBox
->
hide
();
ui
->
editDoneButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editRefreshParamsButton
->
hide
();
ui
->
editSelectParamComboBox
->
hide
();
ui
->
editSelectComponentComboBox
->
hide
();
ui
->
editStatusLabel
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine2
->
hide
();
ui
->
writeButton
->
show
();
ui
->
readButton
->
show
();
ui
->
editAddItemButton
->
hide
();
ui
->
editRemoveItemButton
->
hide
();
ui
->
editItemValueSpinBox
->
hide
();
ui
->
editItemNameLabel
->
hide
();
ui
->
itemValueLabel
->
hide
();
ui
->
itemNameLabel
->
hide
();
ui
->
nameLabel
->
show
();
ui
->
nameLabel
->
setVisible
(
!
editMode
);
ui
->
writeButton
->
setVisible
(
!
editMode
);
ui
->
readButton
->
setVisible
(
!
editMode
);
ui
->
editInfoCheckBox
->
setVisible
(
editMode
);
ui
->
editDoneButton
->
setVisible
(
editMode
);
ui
->
editNameLabel
->
setVisible
(
editMode
);
ui
->
editRefreshParamsButton
->
setVisible
(
editMode
);
ui
->
editSelectParamComboBox
->
setVisible
(
editMode
);
ui
->
editSelectComponentComboBox
->
setVisible
(
editMode
);
ui
->
editStatusLabel
->
setVisible
(
editMode
);
ui
->
writeButton
->
setVisible
(
!
editMode
);
ui
->
readButton
->
setVisible
(
!
editMode
);
ui
->
editLine1
->
setVisible
(
editMode
);
ui
->
editLine2
->
setVisible
(
editMode
);
ui
->
editAddItemButton
->
setVisible
(
editMode
);
ui
->
editRemoveItemButton
->
setVisible
(
editMode
);
ui
->
editItemValueSpinBox
->
setVisible
(
editMode
);
ui
->
editItemNameLabel
->
setVisible
(
editMode
);
ui
->
itemValueLabel
->
setVisible
(
editMode
);
ui
->
itemNameLabel
->
setVisible
(
editMode
);
if
(
isDisabled
)
{
ui
->
editOptionComboBox
->
setEnabled
(
fals
e
);
ui
->
editOptionComboBox
->
setEnabled
(
editMod
e
);
}
isInEditMode
=
false
;
emit
editingFinished
(
);
QGCToolWidgetItem
::
setEditMode
(
editMode
);
}
void
QGCComboBox
::
setParamPending
()
...
...
src/ui/designer/QGCComboBox.h
View file @
9ac8b1c3
...
...
@@ -22,9 +22,9 @@ public:
explicit
QGCComboBox
(
QWidget
*
parent
=
0
);
~
QGCComboBox
();
virtual
void
setEditMode
(
bool
editMode
)
override
;
public
slots
:
void
startEditMode
();
void
endEditMode
();
/** @brief Queue parameter for sending to the MAV (add to pending list)*/
void
setParamPending
();
/** @brief Update the UI with the new parameter value */
...
...
src/ui/designer/QGCCommandButton.cc
View file @
9ac8b1c3
...
...
@@ -159,93 +159,33 @@ void QGCCommandButton::setCommandButtonName(QString text)
ui
->
commandButton
->
setText
(
text
);
}
void
QGCCommandButton
::
s
tar
tEditMode
()
void
QGCCommandButton
::
s
e
tEditMode
(
bool
editMode
)
{
// Hide elements
ui
->
commandButton
->
hide
();
ui
->
nameLabel
->
hide
();
ui
->
editCommandComboBox
->
blockSignals
(
false
);
ui
->
editCommandComboBox
->
show
();
ui
->
editFinishButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editButtonName
->
show
();
ui
->
editConfirmationCheckBox
->
show
();
ui
->
editComponentSpinBox
->
show
();
ui
->
editParamsVisibleCheckBox
->
show
();
ui
->
editParam1SpinBox
->
show
();
ui
->
editParam2SpinBox
->
show
();
ui
->
editParam3SpinBox
->
show
();
ui
->
editParam4SpinBox
->
show
();
ui
->
editParam5SpinBox
->
show
();
ui
->
editParam6SpinBox
->
show
();
ui
->
editParam7SpinBox
->
show
();
ui
->
editLine1
->
show
();
ui
->
editLine2
->
show
();
// Attempt to undock the dock widget
QWidget
*
p
=
this
;
QDockWidget
*
dock
;
do
{
p
=
p
->
parentWidget
();
dock
=
dynamic_cast
<
QDockWidget
*>
(
p
);
if
(
dock
)
{
dock
->
setFloating
(
true
);
break
;
}
}
while
(
p
&&
!
dock
);
isInEditMode
=
true
;
}
void
QGCCommandButton
::
endEditMode
()
{
ui
->
editCommandComboBox
->
blockSignals
(
true
);
ui
->
editCommandComboBox
->
hide
();
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editButtonName
->
hide
();
ui
->
editConfirmationCheckBox
->
hide
();
ui
->
editComponentSpinBox
->
hide
();
ui
->
editParamsVisibleCheckBox
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine2
->
hide
();
if
(
!
ui
->
editParamsVisibleCheckBox
->
isChecked
())
{
ui
->
editParam1SpinBox
->
hide
();
ui
->
editParam2SpinBox
->
hide
();
ui
->
editParam3SpinBox
->
hide
();
ui
->
editParam4SpinBox
->
hide
();
ui
->
editParam5SpinBox
->
hide
();
ui
->
editParam6SpinBox
->
hide
();
ui
->
editParam7SpinBox
->
hide
();
}
ui
->
commandButton
->
show
();
ui
->
nameLabel
->
show
();
// Write to settings
emit
editingFinished
();
// Attempt to dock the dock widget
QWidget
*
p
=
this
;
QDockWidget
*
dock
;
do
{
p
=
p
->
parentWidget
();
dock
=
dynamic_cast
<
QDockWidget
*>
(
p
);
if
(
dock
)
{
dock
->
setFloating
(
false
);
break
;
}
}
while
(
p
&&
!
dock
);
isInEditMode
=
false
;
ui
->
commandButton
->
setVisible
(
!
editMode
);
ui
->
nameLabel
->
setVisible
(
!
editMode
);
ui
->
editCommandComboBox
->
blockSignals
(
!
editMode
);
ui
->
editCommandComboBox
->
setVisible
(
editMode
);
ui
->
editFinishButton
->
setVisible
(
editMode
);
ui
->
editNameLabel
->
setVisible
(
editMode
);
ui
->
editButtonName
->
setVisible
(
editMode
);
ui
->
editConfirmationCheckBox
->
setVisible
(
editMode
);
ui
->
editComponentSpinBox
->
setVisible
(
editMode
);
ui
->
editParamsVisibleCheckBox
->
setVisible
(
editMode
);
bool
showParams
=
editMode
||
ui
->
editParamsVisibleCheckBox
->
isChecked
();
ui
->
editParam1SpinBox
->
setVisible
(
showParams
);
ui
->
editParam2SpinBox
->
setVisible
(
showParams
);
ui
->
editParam3SpinBox
->
setVisible
(
showParams
);
ui
->
editParam4SpinBox
->
setVisible
(
showParams
);
ui
->
editParam5SpinBox
->
setVisible
(
showParams
);
ui
->
editParam6SpinBox
->
setVisible
(
showParams
);
ui
->
editParam7SpinBox
->
setVisible
(
showParams
);
ui
->
editLine1
->
setVisible
(
editMode
);
ui
->
editLine2
->
setVisible
(
editMode
);
QGCToolWidgetItem
::
setEditMode
(
editMode
);
}
void
QGCCommandButton
::
writeSettings
(
QSettings
&
settings
)
...
...
src/ui/designer/QGCCommandButton.h
View file @
9ac8b1c3
...
...
@@ -18,11 +18,11 @@ public:
explicit
QGCCommandButton
(
QWidget
*
parent
=
0
);
~
QGCCommandButton
();
virtual
void
setEditMode
(
bool
editMode
)
override
;
public
slots
:
void
sendCommand
();
void
setCommandButtonName
(
QString
text
);
void
startEditMode
();
void
endEditMode
();
void
writeSettings
(
QSettings
&
settings
);
void
readSettings
(
const
QSettings
&
settings
);
void
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
);
...
...
src/ui/designer/QGCParamSlider.cc
View file @
9ac8b1c3
...
...
@@ -207,74 +207,57 @@ void QGCParamSlider::selectParameter(int paramIndex)
}
}
void
QGCParamSlider
::
s
tar
tEditMode
()
void
QGCParamSlider
::
s
e
tEditMode
(
bool
editMode
)
{
ui
->
valueSlider
->
hide
();
ui
->
doubleValueSpinBox
->
hide
();
ui
->
intValueSpinBox
->
hide
();
ui
->
nameLabel
->
hide
();
ui
->
writeButton
->
hide
();
ui
->
readButton
->
hide
();
ui
->
editInfoCheckBox
->
show
();
ui
->
editDoneButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editRefreshParamsButton
->
show
();
ui
->
editSelectParamComboBox
->
show
();
ui
->
editSelectComponentComboBox
->
show
();
ui
->
editStatusLabel
->
show
();
ui
->
editMinSpinBox
->
show
();
ui
->
editMaxSpinBox
->
show
();
ui
->
writeButton
->
hide
();
ui
->
readButton
->
hide
();
ui
->
editLine1
->
show
();
ui
->
editLine2
->
show
();
isInEditMode
=
true
;
}
if
(
!
editMode
)
{
// Store component id
selectComponent
(
ui
->
editSelectComponentComboBox
->
currentIndex
());
void
QGCParamSlider
::
endEditMode
()
{
// Store component id
selectComponent
(
ui
->
editSelectComponentComboBox
->
currentIndex
());
// Store parameter name and id
selectParameter
(
ui
->
editSelectParamComboBox
->
currentIndex
());
// Store parameter name and id
selectParameter
(
ui
->
editSelectParamComboBox
->
currentIndex
());
// Min/max
parameterMin
=
ui
->
editMinSpinBox
->
value
();
parameterMax
=
ui
->
editMaxSpinBox
->
value
();
// Min/max
parameterMin
=
ui
->
editMinSpinBox
->
value
();
parameterMax
=
ui
->
editMaxSpinBox
->
value
();
ui
->
editInfoCheckBox
->
hide
();
ui
->
editDoneButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editRefreshParamsButton
->
hide
();
ui
->
editSelectParamComboBox
->
hide
();
ui
->
editSelectComponentComboBox
->
hide
();
ui
->
editStatusLabel
->
hide
();
ui
->
editMinSpinBox
->
hide
();
ui
->
editMaxSpinBox
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine2
->
hide
();
ui
->
writeButton
->
show
();
ui
->
readButton
->
show
();
ui
->
valueSlider
->
show
();
switch
((
int
)
parameterValue
.
type
())
{
case
QVariant
::
Char
:
case
QVariant
::
Int
:
case
QVariant
::
UInt
:
ui
->
intValueSpinBox
->
show
();
break
;
case
QMetaType
::
Float
:
ui
->
doubleValueSpinBox
->
show
();
break
;
default:
qCritical
()
<<
"ERROR: NO VALID PARAM TYPE"
;
return
;
switch
((
int
)
parameterValue
.
type
())
{
case
QVariant
::
Char
:
case
QVariant
::
Int
:
case
QVariant
::
UInt
:
ui
->
intValueSpinBox
->
show
();
break
;
case
QMetaType
::
Float
:
ui
->
doubleValueSpinBox
->
show
();
break
;
default:
qCritical
()
<<
"ERROR: NO VALID PARAM TYPE"
;
return
;
}
}
else
{
ui
->
doubleValueSpinBox
->
hide
();
ui
->
intValueSpinBox
->
hide
();
}
ui
->
nameLabel
->
show
();
isInEditMode
=
false
;
emit
editingFinished
();
ui
->
valueSlider
->
setVisible
(
!
editMode
);
ui
->
nameLabel
->
setVisible
(
!
editMode
);
ui
->
writeButton
->
setVisible
(
!
editMode
);
ui
->
readButton
->
setVisible
(
!
editMode
);
ui
->
editInfoCheckBox
->
setVisible
(
editMode
);
ui
->
editDoneButton
->
setVisible
(
editMode
);
ui
->
editNameLabel
->
setVisible
(
editMode
);
ui
->
editRefreshParamsButton
->
setVisible
(
editMode
);
ui
->
editSelectParamComboBox
->
setVisible
(
editMode
);
ui
->
editSelectComponentComboBox
->
setVisible
(
editMode
);
ui
->
editStatusLabel
->
setVisible
(
editMode
);
ui
->
editMinSpinBox
->
setVisible
(
editMode
);
ui
->
editMaxSpinBox
->
setVisible
(
editMode
);
ui
->
writeButton
->
setVisible
(
!
editMode
);
ui
->
readButton
->
setVisible
(
!
editMode
);
ui
->
editLine1
->
setVisible
(
editMode
);
ui
->
editLine2
->
setVisible
(
editMode
);
QGCToolWidgetItem
::
setEditMode
(
editMode
);
}
void
QGCParamSlider
::
setParamPending
()
...
...
src/ui/designer/QGCParamSlider.h
View file @
9ac8b1c3
...
...
@@ -20,9 +20,9 @@ public:
explicit
QGCParamSlider
(
QWidget
*
parent
=
0
);
~
QGCParamSlider
();
virtual
void
setEditMode
(
bool
editMode
)
override
;
public
slots
:
void
startEditMode
();
void
endEditMode
();
/** @brief Queue parameter for sending to the MAV (add to pending list)*/
void
setParamPending
();
/** @brief Set the slider value as parameter value */
...
...
src/ui/designer/QGCRadioChannelDisplay.h
View file @
9ac8b1c3
...
...
@@ -20,6 +20,7 @@ public:
int
value
()
{
return
m_value
;
}
int
min
()
{
return
m_min
;
}
int
max
()
{
return
m_max
;
}
protected:
void
paintEvent
(
QPaintEvent
*
event
);
private:
...
...
src/ui/designer/QGCTextLabel.cc
View file @
9ac8b1c3
...
...
@@ -31,61 +31,17 @@ QGCTextLabel::~QGCTextLabel()
delete
ui
;
}
void
QGCTextLabel
::
s
tar
tEditMode
()
void
QGCTextLabel
::
s
e
tEditMode
(
bool
editMode
)
{
// Hide elements
ui
->
editFinishButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editLine1
->
show
();
ui
->
editLine2
->
show
();
ui
->
isMavCommand
->
show
();
// Attempt to undock the dock widget
QWidget
*
p
=
this
;
QDockWidget
*
dock
;
do
{
p
=
p
->
parentWidget
();
dock
=
dynamic_cast
<
QDockWidget
*>
(
p
);
if
(
dock
)
{
dock
->
setFloating
(
true
);
break
;
}
}
while
(
p
&&
!
dock
);
isInEditMode
=
true
;
}
void
QGCTextLabel
::
endEditMode
()
{
update_isMavCommand
();
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editLine1
->
hide
();
ui
->
editLine2
->
hide
();
ui
->
isMavCommand
->
hide
();
// Write to settings
emit
editingFinished
();
// Attempt to dock the dock widget
QWidget
*
p
=
this
;
QDockWidget
*
dock
;
do
{
p
=
p
->
parentWidget
();
dock
=
dynamic_cast
<
QDockWidget
*>
(
p
);
if
(
dock
)
{
dock
->
setFloating
(
false
);
break
;
}
}
while
(
p
&&
!
dock
);
isInEditMode
=
false
;
if
(
!
editMode
)
update_isMavCommand
();
ui
->
editFinishButton
->
setVisible
(
editMode
);
ui
->
editNameLabel
->
setVisible
(
editMode
);
ui
->
editLine1
->
setVisible
(
editMode
);
ui
->
editLine2
->
setVisible
(
editMode
);
ui
->
isMavCommand
->
setVisible
(
editMode
);
QGCToolWidgetItem
::
setEditMode
(
editMode
);
}
void
QGCTextLabel
::
writeSettings
(
QSettings
&
settings
)
...
...
src/ui/designer/QGCTextLabel.h
View file @
9ac8b1c3
...
...
@@ -19,9 +19,8 @@ public:
~
QGCTextLabel
();
void
setActiveUAS
(
UASInterface
*
uas
);
void
enableText
(
int
num
);
virtual
void
setEditMode
(
bool
editMode
)
override
;
public
slots
:
void
startEditMode
();
void
endEditMode
();
void
writeSettings
(
QSettings
&
settings
);
void
readSettings
(
const
QSettings
&
settings
);
void
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
);
...
...
src/ui/designer/QGCToolWidget.cc
View file @
9ac8b1c3
...
...
@@ -13,10 +13,11 @@
#include
"QGCParamSlider.h"
#include
"QGCComboBox.h"
#include
"QGCTextLabel.h"
#include
"QGCXYPlot.h"
#include
"QGCCommandButton.h"
#include
"UASManager.h"
QGCToolWidget
::
QGCToolWidget
(
const
QString
&
title
,
QWidget
*
parent
,
QSettings
*
settings
)
:
QGCToolWidget
::
QGCToolWidget
(
const
QString
&
objectName
,
const
QString
&
title
,
QWidget
*
parent
,
QSettings
*
settings
)
:
QWidget
(
parent
),
mav
(
NULL
),
mainMenuAction
(
NULL
),
...
...
@@ -27,12 +28,6 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent, QSettings* s
ui
->
setupUi
(
this
);
if
(
settings
)
loadSettings
(
*
settings
);
if
(
title
==
"Unnamed Tool"
)
{
widgetTitle
=
QString
(
"%1 %2"
).
arg
(
title
).
arg
(
QGCToolWidget
::
instances
()
->
count
());
}
//qDebug() << "WidgetTitle" << widgetTitle;
createActions
();
toolLayout
=
ui
->
toolLayout
;
toolLayout
->
setAlignment
(
Qt
::
AlignTop
);
...
...
@@ -50,15 +45,16 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent, QSettings* s
}
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
addUAS
(
UASInterface
*
)));
// Enforce storage if this not loaded from settings
// is MUST NOT BE SAVED if it was loaded from settings!
//if (!settings) storeWidgetsToSettings();
if
(
!
objectName
.
isEmpty
())
{
instances
()
->
insert
(
objectName
,
this
);
setObjectName
(
objectName
);
}
//Otherwise we must call loadSettings() immediately to set the object name
}
QGCToolWidget
::~
QGCToolWidget
()
{
if
(
mainMenuAction
)
mainMenuAction
->
deleteLater
();
if
(
QGCToolWidget
::
instances
())
QGCToolWidget
::
instances
()
->
remove
(
widgetTitle
);
if
(
QGCToolWidget
::
instances
())
QGCToolWidget
::
instances
()
->
remove
(
objectName
()
);
delete
ui
;
}
...
...
@@ -98,11 +94,10 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent,
QString
name
=
settings
->
value
(
"TITLE"
,
""
).
toString
();
QString
objname
=
settings
->
value
(
"OBJECT_NAME"
,
""
).
toString
();
if
(
!
instances
()
->
contains
(
name
)
&&
name
.
length
()
!=
0
)
if
(
!
instances
()
->
contains
(
obj
name
)
&&
!
obj
name
.
isEmpty
()
)
{
//qDebug() << "CREATED WIDGET:" << name;
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
name
,
parent
,
settings
);
tool
->
setObjectName
(
objname
);
QGCToolWidget
*
tool
=
new
QGCToolWidget
(
objname
,
name
,
parent
,
settings
);
newWidgets
.
append
(
tool
);
}
else
if
(
name
.
length
()
==
0
)
...
...
@@ -154,12 +149,13 @@ bool QGCToolWidget::loadSettings(const QString& settings, bool singleinstance)
QStringList
groups
=
set
.
childGroups
();
if
(
groups
.
length
()
>
0
)
{
QString
widgetName
=
groups
.
first
();
this
->
setObjectName
(
widgetName
);
if
(
singleinstance
&&
QGCToolWidget
::
instances
()
->
keys
().
contains
(
widgetName
))
return
false
;
QString
objectName
=
groups
.
first
();
setObjectName
(
objectName
);
if
(
singleinstance
&&
QGCToolWidget
::
instances
()
->
contains
(
objectName
))
return
false
;
instances
()
->
insert
(
objectName
,
this
);
// Do not use setTitle() here,
// interferes with loading settings
widgetTitle
=
widge
tName
;
widgetTitle
=
objec
tName
;
//qDebug() << "WIDGET TITLE LOADED: " << widgetName;
loadSettings
(
set
);
return
true
;
...
...
@@ -277,6 +273,11 @@ void QGCToolWidget::loadSettings(QVariantMap& settings)
item
=
new
QGCComboBox
(
this
);
//qDebug() << "CREATED COMBOBOX";
}
else
if
(
type
==
"XYPLOT"
)
{
item
=
new
QGCXYPlot
(
this
);
//qDebug() << "CREATED XYPlot";
}
if
(
item
)
{
// Configure and add to layout
...
...
@@ -335,6 +336,11 @@ void QGCToolWidget::loadSettings(QSettings& settings)
item
->
setObjectName
(
settings
.
value
(
"QGC_TEXT_ID"
).
toString
());
item
->
setActiveUAS
(
mav
);
}
else
if
(
type
==
"XYPLOT"
)
{
item
=
new
QGCXYPlot
(
this
);
item
->
setActiveUAS
(
mav
);
}
if
(
item
)
{
...
...
@@ -354,26 +360,13 @@ void QGCToolWidget::loadSettings(QSettings& settings)
settings
.
endGroup
();
}
void
QGCToolWidget
::
storeWidgetsToSettings
(
QS
tring
settingsFile
)
void
QGCToolWidget
::
storeWidgetsToSettings
(
QS
ettings
&
settings
)
//static
{
// Store list of widgets
QSettings
*
settings
;
if
(
!
settingsFile
.
isEmpty
())
{
settings
=
new
QSettings
(
settingsFile
,
QSettings
::
IniFormat
);
//qDebug() << "STORING SETTINGS TO" << settings->fileName();
}
else
{
settings
=
new
QSettings
();
//qDebug() << "STORING SETTINGS TO DEFAULT" << settings->fileName();
}
settings
->
beginGroup
(
"Custom_Tool_Widgets"
);
int
preArraySize
=
settings
->
beginReadArray
(
"QGC_TOOL_WIDGET_NAMES"
);
settings
->
endArray
();
settings
.
beginGroup
(
"Custom_Tool_Widgets"
);
int
preArraySize
=
settings
.
beginReadArray
(
"QGC_TOOL_WIDGET_NAMES"
);
settings
.
endArray
();
settings
->
beginWriteArray
(
"QGC_TOOL_WIDGET_NAMES"
);
settings
.
beginWriteArray
(
"QGC_TOOL_WIDGET_NAMES"
);
int
num
=
0
;
for
(
int
i
=
0
;
i
<
qMax
(
preArraySize
,
instances
()
->
size
());
++
i
)
{
...
...
@@ -382,44 +375,34 @@ void QGCToolWidget::storeWidgetsToSettings(QString settingsFile)
// Updating value
if
(
!
instances
()
->
values
().
at
(
i
)
->
fromMetaData
())
{
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();
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
()
<<
"object:"
<<
instances
()
->
values
().
at
(
i
)
->
objectName
()
;
}
}
else
{
// Deleting old value
settings
->
remove
(
"TITLE"
);
settings
.
remove
(
"TITLE"
);
}
}
settings
->
endArray
();
settings
.
endArray
();
// Store individual widget items
for
(
int
i
=
0
;
i
<
instances
()
->
size
();
++
i
)
{
instances
()
->
values
().
at
(
i
)
->
storeSettings
(
*
settings
);
instances
()
->
values
().
at
(
i
)
->
storeSettings
(
settings
);
}
settings
->
endGroup
();
settings
->
sync
();
delete
settings
;
}
void
QGCToolWidget
::
storeSettings
()
{
QSettings
settings
;
storeSettings
(
settings
);
}
void
QGCToolWidget
::
storeSettings
(
const
QString
&
settingsFile
)
{
QSettings
settings
(
settingsFile
,
QSettings
::
IniFormat
);
storeSettings
(
settings
);
settings
.
endGroup
();
settings
.
sync
();
}
void
QGCToolWidget
::
storeSettings
(
QSettings
&
settings
)
{
/* This function should be called from storeWidgetsToSettings() which sets up the group etc */
Q_ASSERT
(
settings
.
group
()
==
"Custom_Tool_Widgets"
);
if
(
isFromMetaData
)
{
//Refuse to store if this is loaded from metadata or dynamically generated.
...
...
@@ -429,17 +412,11 @@ void QGCToolWidget::storeSettings(QSettings& settings)
settings
.
beginGroup
(
widgetTitle
);
settings
.
beginWriteArray
(
"QGC_TOOL_WIDGET_ITEMS"
);
int
k
=
0
;
// QGCToolItem counter
for
(
int
j
=
0
;
j
<
children
().
size
();
++
j
)
{
// Store only QGCToolWidgetItems
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
);
}
foreach
(
QGCToolWidgetItem
*
item
,
toolItemList
)
{
// Only count actual tool widget item children
settings
.
setArrayIndex
(
k
++
);
// Store the ToolWidgetItem
item
->
writeSettings
(
settings
);
}
//qDebug() << "WROTE" << k << "SUB-WIDGETS TO SETTINGS";
settings
.
endArray
();
...
...
@@ -462,6 +439,7 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
menu
.
addAction
(
addParamAction
);
menu
.
addAction
(
addCommandAction
);
menu
.
addAction
(
addLabelAction
);
menu
.
addAction
(
addPlotAction
);
menu
.
addSeparator
();
menu
.
addAction
(
setTitleAction
);
menu
.
addAction
(
exportAction
);
...
...
@@ -501,6 +479,10 @@ void QGCToolWidget::createActions()
addLabelAction
->
setStatusTip
(
tr
(
"Add a new label to the tool"
));
connect
(
addLabelAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addLabel
()));
addPlotAction
=
new
QAction
(
tr
(
"New &XY Plot"
),
this
);
addPlotAction
->
setStatusTip
(
tr
(
"Add a XY Plot to the tool"
));
connect
(
addPlotAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
addPlot
()));
setTitleAction
=
new
QAction
(
tr
(
"Set Widget Title"
),
this
);
setTitleAction
->
setStatusTip
(
tr
(
"Set the title caption of this tool widget"
));
connect
(
setTitleAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
setTitle
()));
...
...
@@ -525,66 +507,39 @@ QMap<QString, QGCToolWidget*>* QGCToolWidget::instances()
return
instances
;
}
QList
<
QGCToolWidgetItem
*>*
QGCToolWidget
::
itemList
()
{
static
QList
<
QGCToolWidgetItem
*>*
instances
;
if
(
!
instances
)
instances
=
new
QList
<
QGCToolWidgetItem
*>
();
return
instances
;
}
void
QGCToolWidget
::
addParam
(
int
uas
,
int
component
,
QString
paramname
,
QVariant
value
)
{
isFromMetaData
=
true
;
QGCParamSlider
*
slider
=
new
QGCParamSlider
(
this
);
connect
(
slider
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
storeSettings
()));
if
(
ui
->
hintLabel
)
{
ui
->
hintLabel
->
deleteLater
();
ui
->
hintLabel
=
NULL
;
}
toolLayout
->
addWidget
(
slider
);
addToolWidget
(
slider
);
slider
->
setActiveUAS
(
mav
);
slider
->
setParameterValue
(
uas
,
component
,
0
,
-
1
,
paramname
,
value
);
}
void
QGCToolWidget
::
addParam
()
{
QGCParamSlider
*
slider
=
new
QGCParamSlider
(
this
);
connect
(
slider
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
storeSettings
()));
if
(
ui
->
hintLabel
)
{
ui
->
hintLabel
->
deleteLater
();
ui
->
hintLabel
=
NULL
;
}
toolLayout
->
addWidget
(
slider
);
slider
->
startEditMode
();
addToolWidgetAndEdit
(
new
QGCParamSlider
(
this
));
}
void
QGCToolWidget
::
addCommand
()
{
QGCCommandButton
*
button
=
new
QGCCommandButton
(
this
);
connect
(
button
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
storeSettings
()));
if
(
ui
->
hintLabel
)
{
ui
->
hintLabel
->
deleteLater
();
ui
->
hintLabel
=
NULL
;
}
toolLayout
->
addWidget
(
button
);
button
->
startEditMode
();
addToolWidgetAndEdit
(
new
QGCCommandButton
(
this
));
}
void
QGCToolWidget
::
addLabel
()
{
QGCTextLabel
*
label
=
new
QGCTextLabel
(
this
);
connect
(
label
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
storeSettings
()));
if
(
ui
->
hintLabel
)
{
ui
->
hintLabel
->
deleteLater
();
ui
->
hintLabel
=
NULL
;
}
toolLayout
->
addWidget
(
label
);
label
->
startEditMode
();
addToolWidgetAndEdit
(
new
QGCTextLabel
(
this
));
}
void
QGCToolWidget
::
addPlot
()
{
addToolWidgetAndEdit
(
new
QGCXYPlot
(
this
));
}
void
QGCToolWidget
::
addToolWidgetAndEdit
(
QGCToolWidgetItem
*
widget
)
{
addToolWidget
(
widget
);
widget
->
startEditMode
();
}
void
QGCToolWidget
::
addToolWidget
(
QGCToolWidgetItem
*
widget
)
...
...
@@ -594,11 +549,21 @@ void QGCToolWidget::addToolWidget(QGCToolWidgetItem* widget)
ui
->
hintLabel
->
deleteLater
();
ui
->
hintLabel
=
NULL
;
}
connect
(
widget
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
storeSettings
()));
connect
(
widget
,
SIGNAL
(
editingFinished
()),
this
,
SLOT
(
storeWidgetsToSettings
()));
connect
(
widget
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
widgetRemoved
()));
toolLayout
->
addWidget
(
widget
);
toolItemList
.
append
(
widget
);
}
void
QGCToolWidget
::
widgetRemoved
()
{
//Must static cast and not dynamic cast since the object is in the destructor
//and we only want to use it as a pointer value
QGCToolWidgetItem
*
widget
=
static_cast
<
QGCToolWidgetItem
*>
(
QObject
::
sender
());
toolItemList
.
removeAll
(
widget
);
storeWidgetsToSettings
();
}
void
QGCToolWidget
::
exportWidget
()
{
const
QString
widgetFileExtension
(
".qgw"
);
...
...
@@ -607,7 +572,8 @@ void QGCToolWidget::exportWidget()
{
fileName
=
fileName
.
append
(
widgetFileExtension
);
}
storeSettings
(
fileName
);
QSettings
settings
(
fileName
,
QSettings
::
IniFormat
);
storeSettings
(
settings
);
}
void
QGCToolWidget
::
importWidget
()
...
...
@@ -617,7 +583,7 @@ void QGCToolWidget::importWidget()
loadSettings
(
fileName
);
}
const
QString
QGCToolWidget
::
getTitle
()
QString
QGCToolWidget
::
getTitle
()
const
{
return
widgetTitle
;
}
...
...
@@ -640,20 +606,18 @@ void QGCToolWidget::setTitle()
void
QGCToolWidget
::
setTitle
(
const
QString
&
title
)
{
if
(
instances
()
->
contains
(
widgetTitle
))
instances
()
->
remove
(
widgetTitle
);
if
(
!
instances
()
->
contains
(
title
))
instances
()
->
insert
(
title
,
this
);
// Sets title and calls setWindowTitle on QWidget
widgetTitle
=
title
;
QWidget
::
setWindowTitle
(
title
);
setObjectName
(
widgetTitle
);
QDockWidget
*
dock
=
dynamic_cast
<
QDockWidget
*>
(
this
->
parentWidget
());
if
(
dock
)
{
if
(
dock
)
dock
->
setWindowTitle
(
widgetTitle
);
dock
->
setObjectName
(
widgetTitle
+
"DOCK"
);
}
emit
titleChanged
(
title
);
if
(
mainMenuAction
)
mainMenuAction
->
setText
(
title
);
//Do not save the settings here, because this function might be
//called while loading, and thus saving here could end up clobbering
//all of the other widgets
}
void
QGCToolWidget
::
setMainMenuAction
(
QAction
*
action
)
...
...
@@ -667,7 +631,7 @@ void QGCToolWidget::deleteWidget()
// Hide
this
->
hide
();
instances
()
->
remove
(
getTitl
e
());
instances
()
->
remove
(
objectNam
e
());
QSettings
settings
;
settings
.
beginGroup
(
"QGC_MAINWINDOW"
);
...
...
src/ui/designer/QGCToolWidget.h
View file @
9ac8b1c3
...
...
@@ -19,7 +19,7 @@ class QGCToolWidget : public QWidget
Q_OBJECT
public:
explicit
QGCToolWidget
(
const
QString
&
title
=
QString
(
"Unnamed Tool"
)
,
QWidget
*
parent
=
0
,
QSettings
*
settings
=
0
);
explicit
QGCToolWidget
(
const
QString
&
objectName
,
const
QString
&
title
,
QWidget
*
parent
=
0
,
QSettings
*
settings
=
0
);
~
QGCToolWidget
();
/** @brief Factory method to instantiate all tool widgets */
...
...
@@ -29,12 +29,15 @@ public:
/** @brief All instances of this class */
static
QMap
<
QString
,
QGCToolWidget
*>*
instances
();
/** @brief Get title of widget */
const
QString
getTitle
();
QString
getTitle
()
const
;
int
isVisible
(
int
view
)
{
return
viewVisible
.
value
(
view
,
false
);
}
int
isVisible
(
int
view
)
const
{
return
viewVisible
.
value
(
view
,
false
);
}
Qt
::
DockWidgetArea
getDockWidgetArea
(
int
view
)
{
return
dockWidgetArea
.
value
(
view
,
Qt
::
BottomDockWidgetArea
);
}
void
setParent
(
QWidget
*
parent
);
/** @brief Store all widgets of this type to QSettings */
static
void
storeWidgetsToSettings
(
QSettings
&
settingsFile
);
public
slots
:
void
addUAS
(
UASInterface
*
uas
);
/** @brief Delete this widget */
...
...
@@ -44,27 +47,24 @@ public slots:
/** @brief Import settings for this widget from a file */
void
importWidget
();
/** @brief Store all widgets of this type to QSettings */
static
void
storeWidgetsToSettings
(
QString
settingsFile
=
QString
());
void
storeWidgetsToSettings
()
{
QSettings
settings
;
QGCToolWidget
::
storeWidgetsToSettings
(
settings
);
}
public:
void
loadSettings
(
QVariantMap
&
settings
);
/** @brief Load this widget from a QSettings object */
void
loadSettings
(
QSettings
&
settings
);
/** @brief Load this widget from a settings file */
bool
loadSettings
(
const
QString
&
settings
,
bool
singleinstance
=
false
);
/** @brief Store this widget to a QSettings object */
void
storeSettings
(
QSettings
&
settings
);
/** @brief Store this widget to a settings file */
void
storeSettings
(
const
QString
&
settingsFile
);
/** @brief Store this widget to a settings file */
void
storeSettings
();
/** @brief Store the view id and dock widget area */
void
setViewVisibilityAndDockWidgetArea
(
int
view
,
bool
visible
,
Qt
::
DockWidgetArea
area
);
void
setSettings
(
QVariantMap
&
settings
);
QList
<
QString
>
getParamList
();
void
setParameterValue
(
int
uas
,
int
component
,
QString
parameterName
,
const
QVariant
value
);
bool
fromMetaData
()
{
return
isFromMetaData
;
}
bool
fromMetaData
()
const
{
return
isFromMetaData
;
}
void
showLabel
(
QString
name
,
int
num
);
signals:
void
titleChanged
(
QString
);
void
titleChanged
(
const
QString
&
title
);
protected:
bool
isFromMetaData
;
...
...
@@ -74,6 +74,7 @@ protected:
QVariantMap
settingsMap
;
QAction
*
addParamAction
;
QAction
*
addCommandAction
;
QAction
*
addPlotAction
;
QAction
*
addLabelAction
;
QAction
*
setTitleAction
;
QAction
*
deleteAction
;
...
...
@@ -85,13 +86,13 @@ protected:
QMap
<
int
,
Qt
::
DockWidgetArea
>
dockWidgetArea
;
///< Dock widget area desired by this widget
QMap
<
int
,
bool
>
viewVisible
;
///< Visibility in one view
QString
widgetTitle
;
static
int
instanceCount
;
///< Number of instances around
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
void
createActions
();
QList
<
QGCToolWidgetItem
*
>*
itemList
();
/** @brief Add an existing tool widget */
void
addToolWidget
(
QGCToolWidgetItem
*
widget
);
/** @brief Add an existing tool widget and set it to edit mode */
void
addToolWidgetAndEdit
(
QGCToolWidgetItem
*
widget
);
void
hideEvent
(
QHideEvent
*
event
);
public
slots
:
...
...
@@ -100,10 +101,21 @@ public slots:
protected
slots
:
void
addParam
();
void
addCommand
();
void
addPlot
();
void
addLabel
();
void
setTitle
();
void
widgetRemoved
();
private:
/** Do not use this from outside the class to set the object name,
* because we cannot track changes to the object name, and the
* QObject::setObjectName() function is not virtual. Instead only
* pass in the object name to the constructor, or use the , then
* never change it again. */
void
setObjectName
(
const
QString
&
name
)
{
QWidget
::
setObjectName
(
name
);
}
/** Helper for storeWidgetsToSettings() */
void
storeSettings
(
QSettings
&
settings
);
Ui
::
QGCToolWidget
*
ui
;
};
...
...
src/ui/designer/QGCToolWidgetItem.cc
View file @
9ac8b1c3
...
...
@@ -5,12 +5,13 @@
#include
"QGCToolWidget.h"
#include
"UASManager.h"
#include
<QDockWidget>
QGCToolWidgetItem
::
QGCToolWidgetItem
(
const
QString
&
name
,
QWidget
*
parent
)
:
QWidget
(
parent
),
uas
(
NULL
),
isInEditMode
(
false
),
qgcToolWidgetItemName
(
name
),
uas
(
NULL
),
_component
(
-
1
)
{
startEditAction
=
new
QAction
(
tr
(
"Edit %1"
).
arg
(
qgcToolWidgetItemName
),
this
);
...
...
@@ -20,11 +21,6 @@ QGCToolWidgetItem::QGCToolWidgetItem(const QString& name, QWidget *parent) :
deleteAction
=
new
QAction
(
tr
(
"Delete %1"
).
arg
(
qgcToolWidgetItemName
),
this
);
connect
(
deleteAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
deleteLater
()));
QGCToolWidget
*
tool
=
dynamic_cast
<
QGCToolWidget
*>
(
parent
);
if
(
tool
)
{
connect
(
this
,
SIGNAL
(
editingFinished
()),
tool
,
SLOT
(
storeWidgetsToSettings
()));
}
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
// Set first UAS if it exists
...
...
@@ -54,3 +50,25 @@ void QGCToolWidgetItem::setActiveUAS(UASInterface *uas)
{
this
->
uas
=
uas
;
}
void
QGCToolWidgetItem
::
setEditMode
(
bool
editMode
)
{
isInEditMode
=
editMode
;
// Attempt to undock the dock widget
QWidget
*
p
=
this
;
QDockWidget
*
dock
;
do
{
p
=
p
->
parentWidget
();
dock
=
dynamic_cast
<
QDockWidget
*>
(
p
);
if
(
dock
)
{
dock
->
setFloating
(
editMode
);
break
;
}
}
while
(
p
&&
!
dock
);
emit
editingFinished
();
}
Prev
1
2
Next
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