Commit 0af3f517 authored by pixhawk's avatar pixhawk

Merge branch 'master' of github.com:pixhawk/qgroundcontrol into dev

parents 0aad802f 30573ed0
......@@ -937,17 +937,45 @@ void MainWindow::connectCommonWidgets()
void MainWindow::createCustomWidget()
{
QGCToolWidget* tool = new QGCToolWidget("Unnamed Tool", this);
QDockWidget* dock = new QDockWidget("Unnamed Tool", this);
QGCToolWidget* tool = new QGCToolWidget("Unnamed Tool", dock);
if (QGCToolWidget::instances()->size() < 2) {
// This is the first widget
ui.menuTools->addSeparator();
}
QDockWidget* dock = new QDockWidget("Unnamed Tool", this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
dock->setWidget(tool);
QAction* showAction = new QAction(tool->getTitle(), this);
showAction->setCheckable(true);
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
tool->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction);
this->addDockWidget(Qt::BottomDockWidgetArea, dock);
dock->setVisible(true);
}
void MainWindow::loadCustomWidget()
{
QString widgetFileExtension(".qgw");
QString fileName = QFileDialog::getOpenFileName(this, tr("Specify Widget File Name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("QGroundControl Widget (*%1);;").arg(widgetFileExtension));
QGCToolWidget* tool = new QGCToolWidget("", this);
tool->loadSettings(fileName);
if (QGCToolWidget::instances()->size() < 2) {
// This is the first widget
ui.menuTools->addSeparator();
}
// Add widget to UI
QDockWidget* dock = new QDockWidget(tool->getTitle(), this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
dock->setWidget(tool);
tool->setParent(dock);
QAction* showAction = new QAction("Show Unnamed Tool", this);
showAction->setCheckable(true);
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
......@@ -1332,6 +1360,7 @@ void MainWindow::connectCommonActions()
// Custom widget actions
connect(ui.actionNewCustomWidget, SIGNAL(triggered()), this, SLOT(createCustomWidget()));
connect(ui.actionLoadCustomWidgetFile, SIGNAL(triggered()), this, SLOT(loadCustomWidget()));
// Audio output
ui.actionMuteAudioOutput->setChecked(GAudioOutput::instance()->isMuted());
......
......@@ -181,6 +181,9 @@ public slots:
/** @brief Add a custom tool widget */
void createCustomWidget();
/** @brief Load a custom tool widget from a file */
void loadCustomWidget();
void closeEvent(QCloseEvent* event);
/** @brief Load data view, allowing to plot flight data */
......
......@@ -111,6 +111,7 @@
<string>Widgets</string>
</property>
<addaction name="actionNewCustomWidget"/>
<addaction name="actionLoadCustomWidgetFile"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
......@@ -456,6 +457,15 @@
<string>Esc</string>
</property>
</action>
<action name="actionLoadCustomWidgetFile">
<property name="icon">
<iconset resource="../../mavground.qrc">
<normaloff>:/images/status/folder-drag-accept.svg</normaloff>:/images/status/folder-drag-accept.svg</iconset>
</property>
<property name="text">
<string>Load Custom Widget File</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
......
......@@ -87,7 +87,7 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
void QGCParamSlider::requestParameter()
{
if (parameterIndex != -1) {
if (parameterIndex != -1 && uas) {
uas->requestParameter(this->component, this->parameterIndex);
}
}
......
This diff is collapsed.
......@@ -23,11 +23,13 @@ public:
~QGCToolWidget();
/** @brief Factory method to instantiate all tool widgets */
static QList<QGCToolWidget*> createWidgetsFromSettings(QWidget* parent);
static QList<QGCToolWidget*> createWidgetsFromSettings(QWidget* parent, QString settingsFile=QString());
/** @Give the tool widget a reference to its action in the main menu */
void setMainMenuAction(QAction* action);
/** @brief All instances of this class */
static QMap<QString, QGCToolWidget*>* instances();
/** @brief Get title of widget */
const QString getTitle();
int isVisible(int view) { return viewVisible.value(view, false); }
Qt::DockWidgetArea getDockWidgetArea(int view) { return dockWidgetArea.value(view, Qt::BottomDockWidgetArea); }
......@@ -39,9 +41,17 @@ public slots:
/** @brief Export this widget to a file */
void exportWidget();
/** @brief Import settings for this widget from a file */
void importWidget(const QString& fileName);
void importWidget();
/** @brief Store all widgets of this type to QSettings */
static void storeWidgetsToSettings();
static void storeWidgetsToSettings(QString settingsFile=QString());
/** @brief Load this widget from a QSettings object */
void loadSettings(QSettings& settings);
/** @brief Load this widget from a settings file */
void loadSettings(const QString& settings);
/** @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 the view id and dock widget area */
void setViewVisibilityAndDockWidgetArea(int view, bool visible, Qt::DockWidgetArea area);
......@@ -65,7 +75,6 @@ protected:
void contextMenuEvent(QContextMenuEvent* event);
void createActions();
QList<QGCToolWidgetItem* >* itemList();
const QString getTitle();
/** @brief Add an existing tool widget */
void addToolWidget(QGCToolWidgetItem* widget);
......@@ -77,6 +86,7 @@ protected slots:
void addAction();
void addCommand();
void setTitle();
void setTitle(QString title);
private:
......
......@@ -449,7 +449,7 @@ void LinechartWidget::startLogging()
}
// Let user select the log file name
QDate date(QDate::currentDate());
//QDate date(QDate::currentDate());
// QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log")
QString fileName = QFileDialog::getSaveFileName(this, tr("Specify log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("Logfile (*.csv *.txt);;"));
......
......@@ -42,11 +42,11 @@ public:
protected:
mapcontrol::OPMapWidget* parent; ///< Parent widget
int radius; ///< Radius / diameter of the icon in pixels
Waypoint* waypoint; ///< Waypoint data container this icon represents
QColor color;
int radius; ///< Radius / diameter of the icon in pixels
bool showAcceptanceRadius;
bool showOrbit;
QColor color;
// QSize size;
};
......
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