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