From f27e3b7a2e6ae96f0714d2f0a7a7a470aa58cbf3 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Thu, 8 Sep 2011 13:49:32 +0200 Subject: [PATCH] Fixed custom widgets, now working as expected with default config --- .../widgets/pixhawk-widget.qgw | 14 +++++ qgroundcontrol.pri | 12 +++++ src/ui/MainWindow.cc | 29 ++++------- src/ui/MainWindow.ui | 52 +++++++++---------- src/ui/designer/QGCToolWidget.cc | 19 ++++--- 5 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 files/mav_type_quadrotor/mav_autopilot_pixhawk/widgets/pixhawk-widget.qgw diff --git a/files/mav_type_quadrotor/mav_autopilot_pixhawk/widgets/pixhawk-widget.qgw b/files/mav_type_quadrotor/mav_autopilot_pixhawk/widgets/pixhawk-widget.qgw new file mode 100644 index 000000000..6add259e9 --- /dev/null +++ b/files/mav_type_quadrotor/mav_autopilot_pixhawk/widgets/pixhawk-widget.qgw @@ -0,0 +1,14 @@ +[PIXHAWK%20Quadrotor%20Commands] +QGC_TOOL_WIDGET_ITEMS\1\TYPE=BUTTON +QGC_TOOL_WIDGET_ITEMS\1\QGC_ACTION_BUTTON_DESCRIPTION=CALIBRATE GYRO +QGC_TOOL_WIDGET_ITEMS\1\QGC_ACTION_BUTTON_BUTTONTEXT=Calibrate +QGC_TOOL_WIDGET_ITEMS\1\QGC_ACTION_BUTTON_ACTIONID=17 +QGC_TOOL_WIDGET_ITEMS\2\TYPE=BUTTON +QGC_TOOL_WIDGET_ITEMS\2\QGC_ACTION_BUTTON_DESCRIPTION=Record logfile and images +QGC_TOOL_WIDGET_ITEMS\2\QGC_ACTION_BUTTON_BUTTONTEXT=Start +QGC_TOOL_WIDGET_ITEMS\2\QGC_ACTION_BUTTON_ACTIONID=21 +QGC_TOOL_WIDGET_ITEMS\3\TYPE=BUTTON +QGC_TOOL_WIDGET_ITEMS\3\QGC_ACTION_BUTTON_DESCRIPTION=Stop recording +QGC_TOOL_WIDGET_ITEMS\3\QGC_ACTION_BUTTON_BUTTONTEXT=Stop +QGC_TOOL_WIDGET_ITEMS\3\QGC_ACTION_BUTTON_ACTIONID=23 +QGC_TOOL_WIDGET_ITEMS\size=3 diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index d0c54457b..ce04a4559 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -84,6 +84,8 @@ macx { # Copy audio files if needed QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOS + # Copy contributed files + QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/qgroundcontrol.app/Contents/MacOS # Copy google earth starter file QMAKE_POST_LINK += && cp -f $$BASEDIR/images/earth.html $$TARGETDIR/qgroundcontrol.app/Contents/MacOS # Copy CSS stylesheets @@ -219,6 +221,10 @@ message("Compiling for linux 32") DEFINES += QGC_LIBFREENECT_ENABLED } + # Validated copy commands + QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$DESTDIR + QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$DESTDIR + QMAKE_POST_LINK += && cp -rf $$BASEDIR/models $$DESTDIR QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$DESTDIR QMAKE_POST_LINK += && mkdir -p $$DESTDIR/images @@ -293,6 +299,10 @@ linux-g++-64 { DEFINES += QGC_LIBFREENECT_ENABLED } + # Validated copy commands + QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$DESTDIR + QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$DESTDIR + QMAKE_POST_LINK += && cp -rf $$BASEDIR/models $$DESTDIR QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$DESTDIR QMAKE_POST_LINK += && mkdir -p $$DESTDIR/images @@ -369,6 +379,7 @@ DEFINES += QGC_OSG_ENABLED exists($$TARGETDIR/debug) { QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN\\debug"$$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\audio" "$$TARGETDIR_WIN\\debug\\audio" /E /I $$escape_expand(\\n)) + QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\files" "$$TARGETDIR_WIN\\debug\\files" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\models" "$$TARGETDIR_WIN\\debug\\models" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\images\\earth.html" "$$TARGETDIR_WIN\\debug"$$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$(QTDIR)\\plugins" "$$TARGETDIR_WIN\\debug" /E /I /EXCLUDE:copydebug.txt $$escape_expand(\\n)) @@ -388,6 +399,7 @@ DEFINES += QGC_OSG_ENABLED exists($$TARGETDIR/release) { QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN\\release"$$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\audio" "$$TARGETDIR_WIN\\release\\audio" /E /I $$escape_expand(\\n)) + QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\files" "$$TARGETDIR_WIN\\release\\files" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$BASEDIR_WIN\\models" "$$TARGETDIR_WIN\\release\\models" /E /I $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(copy /Y "$$BASEDIR_WIN\\images\\earth.html" "$$TARGETDIR_WIN\\release\\earth.html" $$escape_expand(\\n)) QMAKE_POST_LINK += $$quote(xcopy /Y "$$(QTDIR)\\plugins" "$$TARGETDIR_WIN\\release" /E /I /EXCLUDE:copyrelease.txt $$escape_expand(\\n)) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 7db7f1780..26b2cdd1b 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -326,9 +326,6 @@ void MainWindow::buildCustomWidget() // Show custom widgets only if UAS is connected if (UASManager::instance()->getActiveUAS() != NULL) { - // Enable custom widgets - ui.actionNewCustomWidget->setEnabled(true); - // Create custom widgets QList widgets = QGCToolWidget::createWidgetsFromSettings(this); @@ -355,9 +352,6 @@ void MainWindow::buildCustomWidget() widgets.at(i)->setMainMenuAction(showAction); ui.menuTools->addAction(showAction); -// // Load visibility for view (default is off) -// dock->setVisible(tool->isVisible(currentView)); - // Load dock widget location (default is bottom) Qt::DockWidgetArea location = static_cast (tool->getDockWidgetArea(currentView)); @@ -685,7 +679,7 @@ 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)); - loadCustomWidget(fileName); + if (fileName != "") loadCustomWidget(fileName); } void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance) @@ -699,7 +693,7 @@ void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance) dock->setWidget(tool); tool->setParent(dock); - QAction* showAction = new QAction("Show Unnamed Tool", this); + 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))); @@ -734,7 +728,8 @@ void MainWindow::loadCustomWidgetsFromDefaults(const QString& systemType, const { // Will only be loaded if not already a custom widget with // the same name is present - loadCustomWidget(file, true); + qDebug() << "Tried to load file: " << file; + loadCustomWidget(defaultsDir+"/"+file, true); } } } @@ -776,9 +771,11 @@ void MainWindow::configureWindowName() windowname.append(" (" + QHostInfo::localHostName() + ": "); - for (int i = 0; i < hostAddresses.size(); i++) { + for (int i = 0; i < hostAddresses.size(); i++) + { // Exclude loopback IPv4 and all IPv6 addresses - if (hostAddresses.at(i) != QHostAddress("127.0.0.1") && !hostAddresses.at(i).toString().contains(":")) { + if (hostAddresses.at(i) != QHostAddress("127.0.0.1") && !hostAddresses.at(i).toString().contains(":")) + { if(prevAddr) windowname.append("/"); windowname.append(hostAddresses.at(i).toString()); prevAddr = true; @@ -823,7 +820,8 @@ void MainWindow::saveScreen() QPixmap window = QPixmap::grabWindow(this->winId()); QString format = "bmp"; - if (!screenFileName.isEmpty()) { + if (!screenFileName.isEmpty()) + { window.save(screenFileName, format.toAscii()); } } @@ -969,8 +967,6 @@ void MainWindow::showInfoMessage(const QString& title, const QString& message) **/ void MainWindow::connectCommonActions() { - ui.actionNewCustomWidget->setEnabled(false); - // Bind together the perspective actions QActionGroup* perspectives = new QActionGroup(ui.menuPerspectives); perspectives->addAction(ui.actionEngineersView); @@ -987,11 +983,6 @@ void MainWindow::connectCommonActions() if (currentView == VIEW_OPERATOR) ui.actionOperatorsView->setChecked(true); if (currentView == VIEW_UNCONNECTED) ui.actionUnconnectedView->setChecked(true); - // The pilot, engineer and operator view are not available on startup - // since they only make sense with a system connected. - ui.actionPilotsView->setEnabled(false); - ui.actionOperatorsView->setEnabled(false); - ui.actionEngineersView->setEnabled(false); // The UAS actions are not enabled without connection to system ui.actionLiftoff->setEnabled(false); ui.actionLand->setEnabled(false); diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index ce2b6e402..1c71db90e 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -51,7 +51,7 @@ 0 0 800 - 22 + 25 @@ -152,7 +152,7 @@ - + :/images/actions/system-log-out.svg:/images/actions/system-log-out.svg @@ -167,7 +167,7 @@ true - + :/images/control/launch.svg :/images/control/launch.svg:/images/control/launch.svg @@ -177,7 +177,7 @@ - + :/images/control/land.svg:/images/control/land.svg @@ -186,7 +186,7 @@ - + :/images/actions/process-stop.svg:/images/actions/process-stop.svg @@ -198,7 +198,7 @@ - + :/images/actions/process-stop.svg:/images/actions/process-stop.svg @@ -210,7 +210,7 @@ - + :/images/actions/list-add.svg:/images/actions/list-add.svg @@ -219,7 +219,7 @@ - + :/images/categories/applications-system.svg:/images/categories/applications-system.svg @@ -231,7 +231,7 @@ - + :/images/devices/input-gaming.svg:/images/devices/input-gaming.svg @@ -246,7 +246,7 @@ true - + :/images/control/launch.svg:/images/control/launch.svg @@ -258,7 +258,7 @@ - + :/images/contrib/slugs.png:/images/contrib/slugs.png @@ -267,7 +267,7 @@ - + :/images/devices/input-gaming.svg:/images/devices/input-gaming.svg @@ -279,7 +279,7 @@ - + :/images/apps/utilities-system-monitor.svg:/images/apps/utilities-system-monitor.svg @@ -288,7 +288,7 @@ - + :/images/status/software-update-available.svg:/images/status/software-update-available.svg @@ -297,7 +297,7 @@ - + :/images/categories/preferences-system.svg:/images/categories/preferences-system.svg @@ -309,7 +309,7 @@ true - + :/images/status/weather-overcast.svg:/images/status/weather-overcast.svg @@ -324,7 +324,7 @@ true - + :/images/apps/utilities-system-monitor.svg:/images/apps/utilities-system-monitor.svg @@ -339,7 +339,7 @@ true - + :/images/devices/network-wired.svg:/images/devices/network-wired.svg @@ -351,7 +351,7 @@ - + :/images/categories/applications-internet.svg:/images/categories/applications-internet.svg @@ -363,7 +363,7 @@ true - + :/images/status/network-wireless-encrypted.svg:/images/status/network-wireless-encrypted.svg @@ -375,7 +375,7 @@ - + :/images/apps/utilities-system-monitor.svg:/images/apps/utilities-system-monitor.svg @@ -387,7 +387,7 @@ true - + :/images/status/audio-volume-high.svg :/images/status/audio-volume-muted.svg :/images/status/audio-volume-muted.svg @@ -403,7 +403,7 @@ true - + :/images/devices/network-wireless.svg:/images/devices/network-wireless.svg @@ -415,7 +415,7 @@ - + :/images/actions/system-log-out.svg:/images/actions/system-log-out.svg @@ -459,7 +459,7 @@ - + :/images/status/folder-drag-accept.svg:/images/status/folder-drag-accept.svg @@ -469,7 +469,7 @@ - + diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index ea4374885..673b1388c 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -116,12 +116,19 @@ bool QGCToolWidget::loadSettings(const QString& settings, bool singleinstance) { QSettings set(settings, QSettings::IniFormat); QStringList groups = set.childGroups(); - QString widgetName = groups.first(); - if (singleinstance && QGCToolWidget::instances()->keys().contains(widgetName)) return false; - setTitle(widgetName); - qDebug() << "WIDGET TITLE LOADED: " << widgetName; - loadSettings(set); - return true; + if (groups.length() > 0) + { + QString widgetName = groups.first(); + if (singleinstance && QGCToolWidget::instances()->keys().contains(widgetName)) return false; + setTitle(widgetName); + qDebug() << "WIDGET TITLE LOADED: " << widgetName; + loadSettings(set); + return true; + } + else + { + return false; + } } void QGCToolWidget::loadSettings(QSettings& settings) -- 2.22.0