Commit 57225710 authored by DonLakeFlyer's avatar DonLakeFlyer

Switch to more generic QmlPageInfo from QGCSettings

Also plugin'ize intrument panel PageView pages
parent 3ebe6b4d
......@@ -390,12 +390,12 @@ FORMS += \
HEADERS += \
src/api/QGCCorePlugin.h \
src/api/QGCOptions.h \
src/api/QGCSettings.h \
src/api/QmlPageInfo.h \
SOURCES += \
src/api/QGCCorePlugin.cc \
src/api/QGCOptions.cc \
src/api/QGCSettings.cc \
src/api/QmlPageInfo.cc \
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
......
......@@ -10,7 +10,7 @@
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include "QGCOptions.h"
#include "QGCSettings.h"
#include "QmlPageInfo.h"
#include "FactMetaData.h"
#include "SettingsManager.h"
#include "AppMessages.h"
......@@ -26,16 +26,20 @@ class QGCCorePlugin_p
{
public:
QGCCorePlugin_p()
: pGeneral(NULL)
, pCommLinks(NULL)
, pOfflineMaps(NULL)
, pMAVLink(NULL)
, pConsole(NULL)
: pGeneral (NULL)
, pCommLinks (NULL)
, pOfflineMaps (NULL)
, pMAVLink (NULL)
, pConsole (NULL)
#if defined(QT_DEBUG)
, pMockLink(NULL)
, pDebug(NULL)
, pMockLink (NULL)
, pDebug (NULL)
#endif
, defaultOptions(NULL)
, defaultOptions (NULL)
, valuesPageWidgetInfo (NULL)
, cameraPageWidgetInfo (NULL)
, healthPageWidgetInfo (NULL)
, vibrationPageWidgetInfo (NULL)
{
}
......@@ -61,17 +65,23 @@ public:
delete defaultOptions;
}
QGCSettings* pGeneral;
QGCSettings* pCommLinks;
QGCSettings* pOfflineMaps;
QGCSettings* pMAVLink;
QGCSettings* pConsole;
QmlPageInfo* pGeneral;
QmlPageInfo* pCommLinks;
QmlPageInfo* pOfflineMaps;
QmlPageInfo* pMAVLink;
QmlPageInfo* pConsole;
#if defined(QT_DEBUG)
QGCSettings* pMockLink;
QGCSettings* pDebug;
QmlPageInfo* pMockLink;
QmlPageInfo* pDebug;
#endif
QVariantList settingsList;
QGCOptions* defaultOptions;
QmlPageInfo* valuesPageWidgetInfo;
QmlPageInfo* cameraPageWidgetInfo;
QmlPageInfo* healthPageWidgetInfo;
QmlPageInfo* vibrationPageWidgetInfo;
QVariantList instrumentPageWidgetList;
};
QGCCorePlugin::~QGCCorePlugin()
......@@ -99,41 +109,55 @@ void QGCCorePlugin::setToolbox(QGCToolbox *toolbox)
QVariantList &QGCCorePlugin::settingsPages()
{
//-- If this hasn't been overridden, create default set of settings
if(!_p->pGeneral) {
//-- Default Settings
_p->pGeneral = new QGCSettings(tr("General"),
_p->pGeneral = new QmlPageInfo(tr("General"),
QUrl::fromUserInput("qrc:/qml/GeneralSettings.qml"),
QUrl::fromUserInput("qrc:/res/gear-white.svg"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pGeneral));
_p->pCommLinks = new QGCSettings(tr("Comm Links"),
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pGeneral));
_p->pCommLinks = new QmlPageInfo(tr("Comm Links"),
QUrl::fromUserInput("qrc:/qml/LinkSettings.qml"),
QUrl::fromUserInput("qrc:/res/waves.svg"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pCommLinks));
_p->pOfflineMaps = new QGCSettings(tr("Offline Maps"),
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pCommLinks));
_p->pOfflineMaps = new QmlPageInfo(tr("Offline Maps"),
QUrl::fromUserInput("qrc:/qml/OfflineMap.qml"),
QUrl::fromUserInput("qrc:/res/waves.svg"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pOfflineMaps));
_p->pMAVLink = new QGCSettings(tr("MAVLink"),
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pOfflineMaps));
_p->pMAVLink = new QmlPageInfo(tr("MAVLink"),
QUrl::fromUserInput("qrc:/qml/MavlinkSettings.qml"),
QUrl::fromUserInput("qrc:/res/waves.svg"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pMAVLink));
_p->pConsole = new QGCSettings(tr("Console"),
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pMAVLink));
_p->pConsole = new QmlPageInfo(tr("Console"),
QUrl::fromUserInput("qrc:/qml/QGroundControl/Controls/AppMessages.qml"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pConsole));
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pConsole));
#if defined(QT_DEBUG)
//-- These are always present on Debug builds
_p->pMockLink = new QGCSettings(tr("Mock Link"),
_p->pMockLink = new QmlPageInfo(tr("Mock Link"),
QUrl::fromUserInput("qrc:/qml/MockLink.qml"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pMockLink));
_p->pDebug = new QGCSettings(tr("Debug"),
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pMockLink));
_p->pDebug = new QmlPageInfo(tr("Debug"),
QUrl::fromUserInput("qrc:/qml/DebugWindow.qml"));
_p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pDebug));
_p->settingsList.append(QVariant::fromValue((QmlPageInfo*)_p->pDebug));
#endif
}
return _p->settingsList;
}
QVariantList& QGCCorePlugin::instrumentPages(void)
{
if (!_p->valuesPageWidgetInfo) {
_p->valuesPageWidgetInfo = new QmlPageInfo(tr("Values"), QUrl::fromUserInput("qrc:/qml/ValuePageWidget.qml"));
_p->cameraPageWidgetInfo = new QmlPageInfo(tr("Camera"), QUrl::fromUserInput("qrc:/qml/CameraPageWidget.qml"));
_p->healthPageWidgetInfo = new QmlPageInfo(tr("Health"), QUrl::fromUserInput("qrc:/qml/HealthPageWidget.qml"));
_p->vibrationPageWidgetInfo = new QmlPageInfo(tr("Vibration"), QUrl::fromUserInput("qrc:/qml/VibrationPageWidget.qml"));
_p->instrumentPageWidgetList.append(QVariant::fromValue(_p->valuesPageWidgetInfo));
_p->instrumentPageWidgetList.append(QVariant::fromValue(_p->cameraPageWidgetInfo));
_p->instrumentPageWidgetList.append(QVariant::fromValue(_p->healthPageWidgetInfo));
_p->instrumentPageWidgetList.append(QVariant::fromValue(_p->vibrationPageWidgetInfo));
}
return _p->instrumentPageWidgetList;
}
int QGCCorePlugin::defaultSettings()
{
return 0;
......
......@@ -40,6 +40,7 @@ public:
~QGCCorePlugin();
Q_PROPERTY(QVariantList settingsPages READ settingsPages NOTIFY settingsPagesChanged)
Q_PROPERTY(QVariantList instrumentPages READ instrumentPages NOTIFY instrumentPagesChanged)
Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT)
Q_PROPERTY(QGCOptions* options READ options CONSTANT)
......@@ -54,6 +55,10 @@ public:
/// @return A list of QGCSettings
virtual QVariantList& settingsPages(void);
/// The list of PageWidget pages shown in the instrument panel
/// @return A list of QmlPageInfo
virtual QVariantList& instrumentPages(void);
/// The default settings panel to show
/// @return The settings index
virtual int defaultSettings(void);
......@@ -107,6 +112,7 @@ public:
signals:
void settingsPagesChanged (void);
void instrumentPagesChanged (void);
void showTouchAreasChanged (bool showTouchAreas);
void showAdvancedUIChanged (bool showAdvancedUI);
......
......@@ -7,15 +7,13 @@
*
****************************************************************************/
#include "QGCSettings.h"
#include "QmlPageInfo.h"
/// @file
/// @brief Core Plugin Interface for QGroundControl. Settings element.
/// @author Gus Grubba <mavlink@grubba.com>
QGCSettings::QGCSettings(QString title, QUrl url, QUrl icon)
: _title(title)
, _url(url)
, _icon(icon)
QmlPageInfo::QmlPageInfo(QString title, QUrl url, QUrl icon, QObject* parent)
: QObject (parent)
, _title (title)
, _url (url)
, _icon (icon)
{
}
......@@ -12,23 +12,21 @@
#include <QObject>
#include <QUrl>
/// @file
/// @brief Core Plugin Interface for QGroundControl. Settings element.
/// @author Gus Grubba <mavlink@grubba.com>
class QGCSettings : public QObject
/// Represents a
class QmlPageInfo : public QObject
{
Q_OBJECT
public:
QGCSettings(QString title, QUrl url, QUrl icon = QUrl());
QmlPageInfo(QString title, QUrl url, QUrl icon = QUrl(), QObject* parent = NULL);
Q_PROPERTY(QString title READ title CONSTANT)
Q_PROPERTY(QUrl url READ url CONSTANT)
Q_PROPERTY(QUrl icon READ icon CONSTANT)
Q_PROPERTY(QString title READ title CONSTANT) ///< Title for page
Q_PROPERTY(QUrl url READ url CONSTANT) ///< Qml source code
Q_PROPERTY(QUrl icon READ icon CONSTANT) ///< Icon for page
virtual QString title () { return _title; }
virtual QUrl url () { return _url; }
virtual QUrl icon () { return _icon; }
virtual QString title () { return _title; }
virtual QUrl url () { return _url; }
virtual QUrl icon () { return _icon; }
protected:
QString _title;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment