diff --git a/dongfang_qgroundcontrol_notes.txt b/dongfang_qgroundcontrol_notes.txt deleted file mode 100644 index 40fcc46d076944deeac1b1ee22c165f4cfa56651..0000000000000000000000000000000000000000 --- a/dongfang_qgroundcontrol_notes.txt +++ /dev/null @@ -1,90 +0,0 @@ -From where is the 3D mouse used? - - -Comm folder: -============ - -LinkInterface is a QThread. Appears to describe an interface on the host system (TCP port, serial port, ....). - Does it suppport multiple connections? -SerialLinkInterface: Extension of above -SerialLink: Implementation - -XBeeLinkInterface: Extension of LinkInterface (but without other serial stuff than baudrate, is the rest assumed?) -XBeeLink: Implementation (with address resetting probably it's Series 1) - -UDPLink: UDP implementation. Port is defaulted. - -MAVLinkSimulationLink: Simulation/dummy implementation of LinkInterface. Does some file IO. -MAVLinkSimulationUAV: Simulation/dummy basic (remote) UAV state (minus mission state) for MAVLinkSimulationLink. -MAVLinkSimulationWaypointPlanner: imulation/dummy basic (remote) UAV mission state for MAVLinkSimulationLink. - - -ProtocolInterface describes a protocol. Major method: - virtual void receiveBytes(LinkInterface *link, QByteArray b) = 0; - -MavlinkProtocol: MAVLink implementation of ProtocolInterface - - -Parameter: Identity of a parameter (the value types are not handled here. Oddly there is no type metainfo either) -ParameterList: Is pretty much what the name impiles. -QGCParamID: Wrapper if parameter text IDs, conversion to byte* and back - -QGCHilLink: Link to a HIL external system - QCGFlightGearLink, QGCJSBSimLink, QGCXPlaneLink : Implementations of QGCHilLink - - -QGCMAVLink: Nothing more than in include to raw mavlink.h - - -input folder: -============= -Some exotic input devices - - - -uas folder: -=========== -UAS.h: Local UAV model. Claims to support some sort of RPC. Uses some properties with notifications. Assumes MAVLink. -Some methods: - int getUASID() const; // the systemId - QList* getLinks(); // it knows its links - - virtual void receiveMessage(LinkInterface* link, mavlink_message_t message); - - float receiveDropRate; ///< Percentage of packets that were dropped on the MAV's receiving link (from GCS and other MAVs) - float sendDropRate; ///< Percentage of packets that were not received from the MAV by the GCS - -Some fields: - bool positionLock; ///< Status if position information is available or not - double localX; // (what is this?) - double localY; - double localZ; - double latitude; ///< Global latitude as estimated by position estimator - double longitude; ///< Global longitude as estimated by position estimator - double altitude; ///< Global altitude as estimated by position estimator - double satelliteCount; ///< Number of satellites visible to raw GPS - bool globalEstimatorActive; ///< Global position estimator present, do not fall back to GPS raw for position - double latitude_gps; ///< Global latitude as estimated by raw GPS - double longitude_gps; ///< Global longitude as estimated by raw GPS - double altitude_gps; ///< Global altitude as estimated by raw GPS - - and lots ans lots more... - - -*MAV.h: Implementations of UAS - - -QGCUASParamManager.h: A mixture of a widget and a parameter up/download state machine. Has a reference to its associated UAV. - -UASWaypointManager: API to waypoint / mission control. Not a widget. Has a reference to its associated UAV. - -UASManager.h: Singleton interface to all UASs on all interfaces. Maintains a single selected/active UAS. - -Ideas to do -TCPLink -XBee Series2 implementation -Less stress on uplink -Get rid of hardcoded SystemId of 255 -Quick View should print all altitudes (GPS, mix, ground and/or home), letting user see errors. -Console debugging is hopefully removed? - diff --git a/dongfang_qgroundcontrol_wishlist.txt b/dongfang_qgroundcontrol_wishlist.txt deleted file mode 100644 index f55ba1dc24dcc2a8f367946a436e72672ac7bec3..0000000000000000000000000000000000000000 --- a/dongfang_qgroundcontrol_wishlist.txt +++ /dev/null @@ -1,23 +0,0 @@ -Major -1) Absolute altitude should absolutely work. Also in face of bad GPS init. - How does the mission planning part work with that, how is alt. stored in waypoints? - When is home altitude stored in the UAV? - -2) Some people have worse datalinks than average - eg. slow or noisy telemetry. GPRS data also easily gets - flooded. All data rates should be configurable and uplinks eased off a little. - -3) Some streams should be sent always even if not in use. For example using RC override and then stopping - using it: If the UAV does not received the final RC override message with zero values for all channels, - it will not get out of RC override. A solution is to make the message non final, repeating it every - now and then. - -Minor -1) I would like to see initial dummy values for eg. battery voltage go away and be replaced by "unknown". - Dummy values confuse, you won't know if your sensors and link are working or not. - -2) Suggestion if the DO_JUMP behavior of APM today (where DO_JUMP requires a waypoint command after it): - Modify APM code so DO_JUMP is regarded a navigation command. Make non navigation commands appear in - planning as sub commands of navigation commands (indent them). Easier to understand. - -3) Old style audio with signals/bells/beeps / Morse may be prefered by some. Maybe add slots'n'signals for - all audio and different implementation types (speech, beep, ...). Or a generic operator messaging thing. diff --git a/files/images/actions/qgroundcontrol-apm.svg b/files/images/actions/qgroundcontrol-apm.svg new file mode 100644 index 0000000000000000000000000000000000000000..d8ff8dee5a9bccad567dc48f4cc09e85e808a0da --- /dev/null +++ b/files/images/actions/qgroundcontrol-apm.svg @@ -0,0 +1,4931 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/images/actions/qgroundcontrol-ardrone.svg b/files/images/actions/qgroundcontrol-ardrone.svg new file mode 100644 index 0000000000000000000000000000000000000000..9933b10fef67fcc4066b3365aa84b3f8cad3c26a --- /dev/null +++ b/files/images/actions/qgroundcontrol-ardrone.svg @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/images/actions/qgroundcontrol-generic.svg b/files/images/actions/qgroundcontrol-generic.svg new file mode 100644 index 0000000000000000000000000000000000000000..92b3d0e7faf3cb254816b74aa423c70d9b1320f5 --- /dev/null +++ b/files/images/actions/qgroundcontrol-generic.svg @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/files/images/actions/qgroundcontrol-px4.svg b/files/images/actions/qgroundcontrol-px4.svg new file mode 100644 index 0000000000000000000000000000000000000000..b264ca567425a285072e8ded8a4881ef78fdeadd --- /dev/null +++ b/files/images/actions/qgroundcontrol-px4.svg @@ -0,0 +1,165 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/images/actions/qgroundcontrol-wifi.svg b/files/images/actions/qgroundcontrol-wifi.svg new file mode 100644 index 0000000000000000000000000000000000000000..eaaf531d8cffea255bd241b2fb25f2e952ca0811 --- /dev/null +++ b/files/images/actions/qgroundcontrol-wifi.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/files/styles/style-dark.css b/files/styles/style-dark.css index 0e04d607fd9d548a71bfe2bc99d1522236e229ae..762299c346c13ed4d3a62179c6d13d4209561a1a 100644 --- a/files/styles/style-dark.css +++ b/files/styles/style-dark.css @@ -5,6 +5,11 @@ font-size: 11px; } +QWidget#viewModeWidget { + border-radius: 12px; + border: 3px solid #465158; +} + *::disabled { color: #777; } @@ -340,6 +345,16 @@ QPushButton, QToolButton { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777, stop: 1 #333); } +QPushButton#viewModeGeneric, QPushButton#viewModePX4, QPushButton#viewModeAPM, QPushButton#viewModeAR { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #73D95D, stop: 1 #18A154); + border-radius: 12px; + min-height: 120px; + max-height: 140px; + min-width: 120px; + max-width: 140px; + border: 3px solid #465158; +} + QPushButton#connectButton, QPushButton#controlButton { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #73D95D, stop: 1 #18A154); } diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 52b9fd44cdcf9606412f07e541b5afc3d1cb6faa..8282fb3d80cf1d3f7dd94745aa4a2a00e06e9a7b 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -236,7 +236,9 @@ FORMS += src/ui/MainWindow.ui \ src/ui/UASRawStatusView.ui \ src/ui/uas/QGCMessageView.ui \ src/ui/JoystickButton.ui \ - src/ui/JoystickAxis.ui + src/ui/JoystickAxis.ui \ + src/ui/main/QGCViewModeSelection.ui \ + src/ui/main/QGCWelcomeMainWindow.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -252,7 +254,8 @@ INCLUDEPATH += src \ src/ui/watchdog \ src/ui/map3D \ src/ui/mission \ - src/ui/designer + src/ui/designer \ + src/ui/main HEADERS += src/MG.h \ src/QGCCore.h \ src/uas/UASInterface.h \ @@ -395,7 +398,9 @@ HEADERS += src/MG.h \ src/ui/PrimaryFlightDisplay.h \ src/ui/uas/QGCMessageView.h \ src/ui/JoystickButton.h \ - src/ui/JoystickAxis.h + src/ui/JoystickAxis.h \ + src/ui/main/QGCViewModeSelection.h \ + src/ui/main/QGCWelcomeMainWindow.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -573,7 +578,9 @@ SOURCES += src/main.cc \ src/ui/PrimaryFlightDisplay.cc \ src/ui/uas/QGCMessageView.cc \ src/ui/JoystickButton.cc \ - src/ui/JoystickAxis.cc + src/ui/JoystickAxis.cc \ + src/ui/main/QGCViewModeSelection.cc \ + src/ui/main/QGCWelcomeMainWindow.cc # 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 diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 1323ec395e2857d97670657cc0ad138b7b22829a..b6b141040a2f9dca3148c6aa52803e3b2f4bcf2f 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -102,6 +102,11 @@ files/images/patterns/lenna.jpg files/images/rc_stick.svg files/images/actions/qgroundcontrol-connect.svg + files/images/actions/qgroundcontrol-generic.svg + files/images/actions/qgroundcontrol-px4.svg + files/images/actions/qgroundcontrol-apm.svg + files/images/actions/qgroundcontrol-ardrone.svg + files/images/actions/qgroundcontrol-wifi.svg files/styles/Vera.ttf diff --git a/src/QGCCore.cc b/src/QGCCore.cc index 1825bacc594c77484fdffc2a41c0b24f5ac35f2f..f279b19b88228a22dd04e5b999e72cf9620df780 100644 --- a/src/QGCCore.cc +++ b/src/QGCCore.cc @@ -45,6 +45,7 @@ This file is part of the QGROUNDCONTROL project #include "QGC.h" #include "QGCCore.h" #include "MainWindow.h" +#include "QGCWelcomeMainWindow.h" #include "GAudioOutput.h" #ifdef OPAL_RT @@ -65,8 +66,13 @@ This file is part of the QGROUNDCONTROL project **/ -QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) +QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc, argv), + restartRequested(false), + welcome(NULL) { + // Exit main application when last window is closed + connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit())); + // Set application name this->setApplicationName(QGC_APPLICATION_NAME); this->setApplicationVersion(QGC_APPLICATION_VERSION); @@ -83,8 +89,9 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) // Show user an upgrade message if QGC got upgraded (see code below, after splash screen) bool upgraded = false; + enum MainWindow::CUSTOM_MODE mode = MainWindow::CUSTOM_MODE_NONE; QString lastApplicationVersion(""); - if (settings.contains("QGC_APPLICATION_VERSION")) + if (settings.contains("QGC_APPLICATION_VERSION") && firstStart) { QString qgcVersion = settings.value("QGC_APPLICATION_VERSION").toString(); if (qgcVersion != QGC_APPLICATION_VERSION) @@ -95,6 +102,10 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION); upgraded = true; } + else + { + mode = (enum MainWindow::CUSTOM_MODE) settings.value("QGC_CUSTOM_MODE", (int)MainWindow::CUSTOM_MODE_NONE).toInt(); + } } else { @@ -106,6 +117,15 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) settings.sync(); + // "Bootload" the application + if ((!settings.contains("QGC_CUSTOM_MODE_STORED") || settings.value("QGC_CUSTOM_MODE_STORED") == false) && firstStart) + { + welcome = new QGCWelcomeMainWindow(); + connect(welcome, SIGNAL(customViewModeSelected(MainWindow::CUSTOM_MODE)), this, SLOT(customViewModeSelected(MainWindow::CUSTOM_MODE))); + restartRequested = true; + return; + } + // Show splash screen QPixmap splashImage(":/files/images/splash.png"); QSplashScreen* splashScreen = new QSplashScreen(splashImage); @@ -115,9 +135,6 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) processEvents(); splashScreen->showMessage(tr("Loading application fonts"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); - // Exit main application when last window is closed - connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit())); - // Load application font QFontDatabase fontDatabase = QFontDatabase(); const QString fontFileName = ":/general/vera.ttf"; ///< Font file is part of the QRC file and compiled into the app @@ -140,16 +157,19 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) splashScreen->showMessage(tr("Starting user interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); // The first call to instance() creates the MainWindow, so make sure it's passed the splashScreen. - mainWindow = MainWindow::instance(splashScreen); + mainWindow = MainWindow::instance_mode(splashScreen, mode); - // Connect links - // to make sure that all components are initialized when the - // first messages arrive - UDPLink* udpLink = new UDPLink(QHostAddress::Any, 14550); - MainWindow::instance()->addLink(udpLink); - // Listen on Multicast-Address 239.255.77.77, Port 14550 - //QHostAddress * multicast_udp = new QHostAddress("239.255.77.77"); - //UDPLink* udpLink = new UDPLink(*multicast_udp, 14550); + UDPLink* udpLink = NULL; + + //if (mainWindow->getCustomMode() == MainWindow::CUSTOM_MODE_WIFI) + if (settings.value("QGC_CUSTOM_MODE", (unsigned int)MainWindow::CUSTOM_MODE_NONE) == MainWindow::CUSTOM_MODE_WIFI) + { + // Connect links + // to make sure that all components are initialized when the + // first messages arrive + udpLink = new UDPLink(QHostAddress::Any, 14550); + MainWindow::instance()->addLink(udpLink); + } #ifdef OPAL_RT // Add OpalRT Link, but do not connect @@ -165,7 +185,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"), tr("QGroundControl has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION)); // Check if link could be connected - if (!udpLink->connect()) + if (udpLink && !udpLink->connect()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Critical); @@ -193,17 +213,24 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) **/ QGCCore::~QGCCore() { - //mainWindow->storeSettings(); - //mainWindow->close(); - //mainWindow->deleteLater(); - // Delete singletons - // First systems - delete UASManager::instance(); - // then links - delete LinkManager::instance(); - // Finally the main window - //delete MainWindow::instance(); - //The main window now autodeletes on close. + + if (welcome) + { + welcome->close(); + delete welcome; + } else { + //mainWindow->storeSettings(); + //mainWindow->close(); + //mainWindow->deleteLater(); + // Delete singletons + // First systems + delete UASManager::instance(); + // then links + delete LinkManager::instance(); + // Finally the main window + //delete MainWindow::instance(); + //The main window now autodeletes on close. + } } /** @@ -258,4 +285,14 @@ void QGCCore::startUASManager() } } +void QGCCore::customViewModeSelected(enum MainWindow::CUSTOM_MODE mode) +{ + qDebug() << "SET MODE =" << (unsigned int)mode; + QSettings settings; + settings.setValue("QGC_CUSTOM_MODE", (unsigned int)mode); + // Store settings only if requested by user + settings.setValue("QGC_CUSTOM_MODE_STORED", welcome->getStoreSettings()); + settings.sync(); + welcome->close(); +} diff --git a/src/QGCCore.h b/src/QGCCore.h index 5c507806f19ca5aa6d3b6064447b8d591c28fdac..1512f71ca42daec271f4c51f9e8ff8e4793c1b5e 100644 --- a/src/QGCCore.h +++ b/src/QGCCore.h @@ -36,6 +36,7 @@ This file is part of the PIXHAWK project #include #include "MainWindow.h" +#include "QGCWelcomeMainWindow.h" #include "UASManager.h" #include "LinkManager.h" /*#include "ViconTarsusProtocol.h" */ @@ -56,9 +57,17 @@ class QGCCore : public QApplication Q_OBJECT public: - QGCCore(int &argc, char* argv[]); + QGCCore(bool firstStart, int &argc, char* argv[]); ~QGCCore(); + bool getRestartRequested() + { + return restartRequested; + } + +public slots: + void customViewModeSelected(enum MainWindow::CUSTOM_MODE mode); + protected: void startLinkManager(); @@ -71,6 +80,8 @@ protected: private: MainWindow* mainWindow; + bool restartRequested; + QGCWelcomeMainWindow* welcome; }; #endif /* _CORE_H_ */ diff --git a/src/configuration.h b/src/configuration.h index 88e19d8258c054e84e240da0995cd1a7484b6a58..84b0f2530c7e04f0c20ab962b5ea8439d70e35da 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -11,14 +11,14 @@ #define WITH_TEXT_TO_SPEECH 1 #define QGC_APPLICATION_NAME "QGroundControl" -#define QGC_APPLICATION_VERSION "v. 1.0.9 (beta RC1)" +#define QGC_APPLICATION_VERSION "v. 1.1.1 (beta)" namespace QGC { const QString APPNAME = "QGROUNDCONTROL"; const QString COMPANYNAME = "QGROUNDCONTROL"; -const int APPLICATIONVERSION = 109; // 1.0.9 +const int APPLICATIONVERSION = 110; // 1.1.0 } #endif // QGC_CONFIGURATION_H diff --git a/src/main.cc b/src/main.cc index d09dc6c20f777b49410fd678bb7a5ed6f947d22d..b3658b650779bf6ae9c298c74a7e85398efc3299 100644 --- a/src/main.cc +++ b/src/main.cc @@ -69,6 +69,18 @@ int main(int argc, char *argv[]) qInstallMsgHandler( msgHandler ); #endif - QGCCore core(argc, argv); - return core.exec(); + QGCCore* core = NULL; + int val; + bool firstStart = true; + + do { + if (core) { + delete core; + firstStart = false; + } + core = new QGCCore(firstStart, argc, argv); + val = core->exec(); + } while (core->getRestartRequested()); + + return val; } diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index e695f0bbb9590ad42e0b2a3a4d74f7d3a55ea523..0b55b7a8b1390ffb28e4a4faab8c5c7466e780a5 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -80,12 +80,13 @@ This file is part of the QGROUNDCONTROL project const QString MainWindow::defaultDarkStyle = ":files/styles/style-dark.css"; const QString MainWindow::defaultLightStyle = ":files/styles/style-light.css"; -MainWindow* MainWindow::instance(QSplashScreen* screen) +MainWindow* MainWindow::instance_mode(QSplashScreen* screen, enum MainWindow::CUSTOM_MODE mode) { static MainWindow* _instance = 0; if (_instance == 0) { _instance = new MainWindow(); + _instance->setCustomMode(mode); if (screen) { connect(_instance, SIGNAL(initStatusChanged(QString,int,QColor)), @@ -96,6 +97,11 @@ MainWindow* MainWindow::instance(QSplashScreen* screen) return _instance; } +MainWindow* MainWindow::instance(QSplashScreen* screen) +{ + instance_mode(screen, CUSTOM_MODE_NONE); +} + /** * Create new mainwindow. The constructor instantiates all parts of the user * interface. It does NOT show the mainwindow. To display it, call the show() @@ -115,16 +121,15 @@ MainWindow::MainWindow(QWidget *parent): autoReconnect(false), lowPowerMode(false), isAdvancedMode(false), - dockWidgetTitleBarEnabled(true) + dockWidgetTitleBarEnabled(true), + customMode(CUSTOM_MODE_WIFI) { this->setAttribute(Qt::WA_DeleteOnClose); - hide(); + loadSettings(); } void MainWindow::init() { - emit initStatusChanged(tr("Loading settings"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); - loadSettings(); emit initStatusChanged(tr("Loading style"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); qApp->setStyle("plastique"); @@ -1139,6 +1144,9 @@ void MainWindow::loadCustomWidgetsFromDefaults(const QString& systemType, const void MainWindow::loadSettings() { QSettings settings; + settings.sync(); + customMode = static_cast(settings.value("QGC_CUSTOM_MODE", (unsigned int)MainWindow::CUSTOM_MODE_NONE).toInt()); + qDebug() << "MAINWINDOW: CUSTOM MODE:" << customMode; settings.beginGroup("QGC_MAINWINDOW"); autoReconnect = settings.value("AUTO_RECONNECT", autoReconnect).toBool(); currentStyle = (QGC_MAINWINDOW_STYLE)settings.value("CURRENT_STYLE", currentStyle).toInt(); @@ -1171,6 +1179,7 @@ void MainWindow::storeSettings() // Save the current power mode } settings.setValue("LOW_POWER_MODE", lowPowerMode); + settings.setValue("QGC_CUSTOM_MODE", (int)customMode); settings.sync(); } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index b757d67539a78b1e718fe18b63f045e596a5eb9e..70d512e9220d1c96a94c23efb7d28b65b505d19e 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -97,6 +97,14 @@ class MainWindow : public QMainWindow Q_OBJECT public: + + enum CUSTOM_MODE { + CUSTOM_MODE_NONE = 0, + CUSTOM_MODE_PX4, + CUSTOM_MODE_APM, + CUSTOM_MODE_WIFI + }; + /** * A static function for obtaining the sole instance of the MainWindow. The screen * argument is only important on the FIRST call to this function. The provided splash @@ -104,6 +112,7 @@ public: * function cannot be used within the MainWindow constructor! */ static MainWindow* instance(QSplashScreen* screen = 0); + static MainWindow* instance_mode(QSplashScreen* screen = 0, enum MainWindow::CUSTOM_MODE mode = MainWindow::CUSTOM_MODE_NONE); /** * Initializes the MainWindow. Some variables are initialized and the widget is hidden. @@ -167,6 +176,16 @@ public: return lowPowerMode; } + void setCustomMode(enum MainWindow::CUSTOM_MODE mode) + { + customMode = mode; + } + + enum MainWindow::CUSTOM_MODE getCustomMode() + { + return customMode; + } + QList listLinkMenuActions(void); public slots: @@ -480,6 +499,7 @@ private: QMap > 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. + CUSTOM_MODE customMode; Ui::MainWindow ui; /** @brief Set the appropriate titlebar for a given dock widget. diff --git a/src/ui/QGCSettingsWidget.cc b/src/ui/QGCSettingsWidget.cc index 5f16ce1170e0cea32dca5a85e275164254d6a421..1f92c064c396ff6c5a0d3b17847e970ecb144c04 100644 --- a/src/ui/QGCSettingsWidget.cc +++ b/src/ui/QGCSettingsWidget.cc @@ -48,10 +48,20 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) : ui->lowPowerCheckBox->setChecked(mainWindow->lowPowerModeEnabled()); connect(ui->lowPowerCheckBox, SIGNAL(clicked(bool)), mainWindow, SLOT(enableLowPowerMode(bool))); - //Dock widget title bars + // Dock widget title bars ui->titleBarCheckBox->setChecked(mainWindow->dockWidgetTitleBarsEnabled()); connect(ui->titleBarCheckBox,SIGNAL(clicked(bool)),mainWindow,SLOT(enableDockWidgetTitleBars(bool))); + // Custom mode + + ui->customModeComboBox->addItem(tr("Default: Generic MAVLink and serial links"), MainWindow::CUSTOM_MODE_NONE); + ui->customModeComboBox->addItem(tr("Wifi: Generic MAVLink, wifi or serial links"), MainWindow::CUSTOM_MODE_WIFI); + ui->customModeComboBox->addItem(tr("PX4: Optimized for PX4 Autopilot Users"), MainWindow::CUSTOM_MODE_PX4); + ui->customModeComboBox->addItem(tr("APM: Optimized for ArduPilot Users"), MainWindow::CUSTOM_MODE_APM); + + ui->customModeComboBox->setCurrentIndex(ui->customModeComboBox->findData(mainWindow->getCustomMode())); + connect(ui->customModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectCustomMode(int))); + // Intialize the style UI to the proper values obtained from the MainWindow. MainWindow::QGC_MAINWINDOW_STYLE style = mainWindow->getStyle(); ui->styleChooser->setCurrentIndex(style); @@ -177,3 +187,9 @@ void QGCSettingsWidget::setDefaultStyle() mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_DARK, MainWindow::defaultDarkStyle); } } + +void QGCSettingsWidget::selectCustomMode(int mode) +{ + MainWindow::instance()->setCustomMode(static_cast(ui->customModeComboBox->itemData(mode).toInt())); + MainWindow::instance()->showInfoMessage(tr("Please restart QGroundControl"), tr("The optimization selection was changed. The application needs to be closed and restarted to put all optimizations into effect.")); +} diff --git a/src/ui/QGCSettingsWidget.h b/src/ui/QGCSettingsWidget.h index 87b81f0b958c5c5174b4f141abf920748603f2b0..e77bbec17002a4b2a1f882995a87e15c5a7e6158 100644 --- a/src/ui/QGCSettingsWidget.h +++ b/src/ui/QGCSettingsWidget.h @@ -22,6 +22,7 @@ public slots: void lineEditFinished(); void setDefaultStyle(); void selectStylesheet(); + void selectCustomMode(int mode); private: MainWindow* mainWindow; diff --git a/src/ui/QGCSettingsWidget.ui b/src/ui/QGCSettingsWidget.ui index 746b37fb3ef44f86ae9935143c466b8c68fef4b5..e5ba63d43a0671c5d634d15cde5cc39397168252 100644 --- a/src/ui/QGCSettingsWidget.ui +++ b/src/ui/QGCSettingsWidget.ui @@ -7,7 +7,7 @@ 0 0 528 - 321 + 455 @@ -72,6 +72,9 @@ + + + diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index 294fb60f9ec1e7c5a3ae8c2d98c787709849d871..8577cdd3373c39bcdfa438d9d0a898daf1275497 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -301,7 +301,8 @@ void QGCToolBar::advancedActivityTriggered(QAction* action) void QGCToolBar::setActiveUAS(UASInterface* active) { // Do nothing if system is the same - if (mav == active) return; + if (mav == active || active == NULL) + return; // If switching UASes, disconnect the only one. if (mav) diff --git a/src/ui/main/QGCViewModeSelection.cc b/src/ui/main/QGCViewModeSelection.cc new file mode 100644 index 0000000000000000000000000000000000000000..55378844732466a7813fac12b7ecc3c42afdfbd6 --- /dev/null +++ b/src/ui/main/QGCViewModeSelection.cc @@ -0,0 +1,54 @@ +#include "QGCViewModeSelection.h" +#include "ui_QGCViewModeSelection.h" +#include "QGC.h" +#include "MainWindow.h" + +QGCViewModeSelection::QGCViewModeSelection(QWidget *parent) : + QWidget(parent), + selected(false), + ui(new Ui::QGCViewModeSelection) +{ + ui->setupUi(this); + + connect(ui->viewModeGeneric, SIGNAL(clicked()), this, SLOT(selectGeneric())); + connect(ui->viewModeAR, SIGNAL(clicked()), this, SLOT(selectWifi())); + connect(ui->viewModePX4, SIGNAL(clicked()), this, SLOT(selectPX4())); + connect(ui->viewModeAPM, SIGNAL(clicked()), this, SLOT(selectAPM())); + connect(ui->notAgainCheckBox, SIGNAL(clicked(bool)), this, SIGNAL(settingsStorageRequested(bool))); +} + +QGCViewModeSelection::~QGCViewModeSelection() +{ + delete ui; +} + +enum MainWindow::CUSTOM_MODE QGCViewModeSelection::waitForInput() { + while (!selected) + QGC::SLEEP::msleep(200); + + return mode; +} + +void QGCViewModeSelection::selectGeneric() { + emit customViewModeSelected(MainWindow::CUSTOM_MODE_NONE); + mode = MainWindow::CUSTOM_MODE_NONE; + selected = true; +} + +void QGCViewModeSelection::selectWifi() { + emit customViewModeSelected(MainWindow::CUSTOM_MODE_WIFI); + mode = MainWindow::CUSTOM_MODE_WIFI; + selected = true; +} + +void QGCViewModeSelection::selectPX4() { + emit customViewModeSelected(MainWindow::CUSTOM_MODE_PX4); + mode = MainWindow::CUSTOM_MODE_PX4; + selected = true; +} + +void QGCViewModeSelection::selectAPM() { + emit customViewModeSelected(MainWindow::CUSTOM_MODE_APM); + mode = MainWindow::CUSTOM_MODE_APM; + selected = true; +} diff --git a/src/ui/main/QGCViewModeSelection.h b/src/ui/main/QGCViewModeSelection.h new file mode 100644 index 0000000000000000000000000000000000000000..9a3f5826efeebaad0e00f57ebd355fe29e03d7d2 --- /dev/null +++ b/src/ui/main/QGCViewModeSelection.h @@ -0,0 +1,38 @@ +#ifndef QGCVIEWMODESELECTION_H +#define QGCVIEWMODESELECTION_H + +#include +#include "MainWindow.h" + +namespace Ui { +class QGCViewModeSelection; +} + +class QGCViewModeSelection : public QWidget +{ + Q_OBJECT + +public: + explicit QGCViewModeSelection(QWidget *parent = 0); + ~QGCViewModeSelection(); + + enum MainWindow::CUSTOM_MODE waitForInput(); + +public slots: + + void selectGeneric(); + void selectPX4(); + void selectAPM(); + void selectWifi(); + +signals: + void customViewModeSelected(enum MainWindow::CUSTOM_MODE mode); + void settingsStorageRequested(bool requested); + +private: + Ui::QGCViewModeSelection *ui; + bool selected; + enum MainWindow::CUSTOM_MODE mode; +}; + +#endif // QGCVIEWMODESELECTION_H diff --git a/src/ui/main/QGCViewModeSelection.ui b/src/ui/main/QGCViewModeSelection.ui new file mode 100644 index 0000000000000000000000000000000000000000..b48ad0a51c9d328dea9eab6cb0299e90e1412061 --- /dev/null +++ b/src/ui/main/QGCViewModeSelection.ui @@ -0,0 +1,211 @@ + + + QGCViewModeSelection + + + + 0 + 0 + 750 + 409 + + + + Form + + + + + + Qt::Horizontal + + + + 47 + 20 + + + + + + + + + + + + + + + :/files/images/actions/qgroundcontrol-px4.svg:/files/images/actions/qgroundcontrol-px4.svg + + + + 120 + 120 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + :/files/images/actions/qgroundcontrol-generic.svg:/files/images/actions/qgroundcontrol-generic.svg + + + + 120 + 120 + + + + + + + + Radio / Serial Link + + + + + + + + + + + :/files/images/actions/qgroundcontrol-wifi.svg:/files/images/actions/qgroundcontrol-wifi.svg + + + + 120 + 120 + + + + + + + + PX4 Autopilot + + + + + + + WiFi / UDP + + + + + + + APM Autopilot + + + + + + + + + + + :/files/images/actions/qgroundcontrol-apm.svg:/files/images/actions/qgroundcontrol-apm.svg + + + + 120 + 120 + + + + + + + + Do not ask again on next startup + + + + + + + + + + Qt::Vertical + + + + 20 + 76 + + + + + + + + Please select the connection or autopilot you want to use QGroundControl with. + + + + + + + Qt::Vertical + + + + 20 + 76 + + + + + + + + Qt::Horizontal + + + + 46 + 20 + + + + + + + + The selection can be changed any time in the preferences. + + + + + + + + + + diff --git a/src/ui/main/QGCWelcomeMainWindow.cc b/src/ui/main/QGCWelcomeMainWindow.cc new file mode 100644 index 0000000000000000000000000000000000000000..79e3ae32a694a7f37d71770ea8035a799b1ac502 --- /dev/null +++ b/src/ui/main/QGCWelcomeMainWindow.cc @@ -0,0 +1,59 @@ +#include "QGCWelcomeMainWindow.h" +#include "ui_QGCWelcomeMainWindow.h" +#include "MainWindow.h" +#include "QGCViewModeSelection.h" + +QGCWelcomeMainWindow::QGCWelcomeMainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::QGCWelcomeMainWindow), + storeSettings(false) +{ + ui->setupUi(this); + statusBar()->hide(); + + QString windowname = qApp->applicationName() + " " + qApp->applicationVersion(); + setWindowTitle(windowname); + + viewModeSelection = new QGCViewModeSelection(this); + + connect(viewModeSelection, SIGNAL(customViewModeSelected(MainWindow::CUSTOM_MODE)), this, SIGNAL(customViewModeSelected(MainWindow::CUSTOM_MODE))); + connect(viewModeSelection, SIGNAL(settingsStorageRequested(bool)), this, SIGNAL(settingsStorageRequested(bool))); + connect(viewModeSelection, SIGNAL(settingsStorageRequested(bool)), this, SLOT(setStoreSettings(bool))); + + setCentralWidget(viewModeSelection); + + // Load the new stylesheet. + QFile styleSheet(":files/styles/style-dark.css"); + + // Attempt to open the stylesheet. + if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) + { + // Signal to the user that the app will pause to apply a new stylesheet + qApp->setOverrideCursor(Qt::WaitCursor); + + qApp->setStyleSheet(styleSheet.readAll()); + + // Finally restore the cursor before returning. + qApp->restoreOverrideCursor(); + } + + resize(780, 400); + show(); + +} + +QGCWelcomeMainWindow::~QGCWelcomeMainWindow() +{ + delete ui; + delete viewModeSelection; +} + +enum MainWindow::CUSTOM_MODE QGCWelcomeMainWindow::getCustomMode() +{ +// QGCViewModeSelection* s = new QGCViewModeSelection(this); +// setCentralWidget(s); +// show(); +// enum MainWindow::CUSTOM_MODE mode = MainWindow::CUSTOM_MODE_WIFI;// = s->waitForInput(); +// delete s; +// return mode; +} diff --git a/src/ui/main/QGCWelcomeMainWindow.h b/src/ui/main/QGCWelcomeMainWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..42bfd6e6901b1959620647030b57b34e19d90d0d --- /dev/null +++ b/src/ui/main/QGCWelcomeMainWindow.h @@ -0,0 +1,42 @@ +#ifndef QGCWELCOMEMAINWINDOW_H +#define QGCWELCOMEMAINWINDOW_H + +#include +#include "MainWindow.h" +#include "QGCViewModeSelection.h" + +namespace Ui { +class QGCWelcomeMainWindow; +} + +class QGCWelcomeMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit QGCWelcomeMainWindow(QWidget *parent = 0); + ~QGCWelcomeMainWindow(); + + enum MainWindow::CUSTOM_MODE getCustomMode(); + bool getStoreSettings() + { + return storeSettings; + } + +public slots: + void setStoreSettings(bool settings) + { + storeSettings = settings; + } + +signals: + void customViewModeSelected(enum MainWindow::CUSTOM_MODE mode); + void settingsStorageRequested(bool requested); + +private: + Ui::QGCWelcomeMainWindow *ui; + QGCViewModeSelection* viewModeSelection; + bool storeSettings; +}; + +#endif // QGCWELCOMEMAINWINDOW_H diff --git a/src/ui/main/QGCWelcomeMainWindow.ui b/src/ui/main/QGCWelcomeMainWindow.ui new file mode 100644 index 0000000000000000000000000000000000000000..5ef45995f3fddcbf643a67f60845d7435bf5a98b --- /dev/null +++ b/src/ui/main/QGCWelcomeMainWindow.ui @@ -0,0 +1,24 @@ + + + + + QGCWelcomeMainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + +