Commit 964600d3 authored by Don Gagne's avatar Don Gagne

Remove custom mode startup screen

parent bc7a05bb
......@@ -324,8 +324,6 @@ FORMS += \
src/ui/JoystickButton.ui \
src/ui/JoystickAxis.ui \
src/ui/QGCConfigView.ui \
src/ui/main/QGCViewModeSelection.ui \
src/ui/main/QGCWelcomeMainWindow.ui \
src/ui/configuration/terminalconsole.ui \
src/ui/configuration/SerialSettingsDialog.ui \
src/ui/px4_configuration/QGCPX4AirframeConfig.ui \
......@@ -473,8 +471,6 @@ HEADERS += \
src/ui/JoystickButton.h \
src/ui/JoystickAxis.h \
src/ui/QGCConfigView.h \
src/ui/main/QGCViewModeSelection.h \
src/ui/main/QGCWelcomeMainWindow.h \
src/ui/configuration/console.h \
src/ui/configuration/SerialSettingsDialog.h \
src/ui/configuration/terminalconsole.h \
......@@ -630,8 +626,6 @@ SOURCES += \
src/ui/JoystickAxis.cc \
src/ui/uas/QGCMessageView.cc \
src/ui/QGCConfigView.cc \
src/ui/main/QGCViewModeSelection.cc \
src/ui/main/QGCWelcomeMainWindow.cc \
src/ui/configuration/terminalconsole.cpp \
src/ui/configuration/console.cpp \
src/ui/configuration/SerialSettingsDialog.cc \
......
......@@ -45,7 +45,6 @@ This file is part of the QGROUNDCONTROL project
#include "QGC.h"
#include "QGCCore.h"
#include "MainWindow.h"
#include "QGCWelcomeMainWindow.h"
#include "GAudioOutput.h"
#include "CmdLineOptParser.h"
......@@ -68,19 +67,16 @@ This file is part of the QGROUNDCONTROL project
**/
QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc, argv),
restartRequested(false),
welcome(NULL)
QGCCore::QGCCore(int &argc, char* argv[]) :
QApplication(argc, argv),
_mainWindow(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);
this->setOrganizationName(QGC::ORG_NAME);
this->setOrganizationDomain(QGC::ORG_DOMAIN);
// Set settings format
QSettings::setDefaultFormat(QSettings::IniFormat);
......@@ -92,19 +88,38 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
{ "--clear-settings", &fClearSettingsOptions },
// Add additional command line option flags here
};
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
QSettings settings;
if (fClearSettingsOptions) {
// User requested settings to be cleared on command line
settings.clear();
settings.sync();
}
}
bool QGCCore::init(void)
{
QSettings settings;
// SSL support is required. No reason to go any further without it
if (!QSslSocket::supportsSsl()) {
QMessageBox::critical(NULL,
QObject::tr("Missing SSL Support"),
QObject::tr("QGroundControl requires support for SSL to be installed prior to running. Please see http://www.qgroundcontrol.org/downloads for instructions on installing prerequisites for QGroundControl."));
return false;
}
// Exit main application when last window is closed
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
// 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;
enum MainWindow::CUSTOM_MODE mode = MainWindow::CUSTOM_MODE_PX4;
QString lastApplicationVersion("");
if (settings.contains("QGC_APPLICATION_VERSION"))
{
......@@ -116,31 +131,18 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
// Write current application version
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_PX4).toInt();
}
else
{
mode = (enum MainWindow::CUSTOM_MODE) settings.value("QGC_CUSTOM_MODE", (int)MainWindow::CUSTOM_MODE_NONE).toInt();
}
}
else
{
} else {
// If application version is not set, clear settings anyway
settings.clear();
// Write current application version
settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION);
}
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);
......@@ -149,7 +151,7 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
splashScreen->show();
processEvents();
splashScreen->showMessage(tr("Loading application fonts"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
// 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
......@@ -159,53 +161,48 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
// Avoid Using setFont(). In the Qt docu you can read the following:
// "Warning: Do not use this function in conjunction with Qt Style Sheets."
// setFont(fontDatabase.font(fontFamilyName, "Roman", 12));
// Start the comm link manager
splashScreen->showMessage(tr("Starting communication links"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
startLinkManager();
// Start the UAS Manager
splashScreen->showMessage(tr("Starting UAS manager"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
startUASManager();
// Start the user interface
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_mode(splashScreen, mode);
_mainWindow = MainWindow::instance_mode(splashScreen, mode);
UDPLink* udpLink = NULL;
if (mainWindow->getCustomMode() == MainWindow::CUSTOM_MODE_WIFI)
if (_mainWindow->getCustomMode() == 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);
LinkManager::instance()->add(udpLink);
} else if (mainWindow->getCustomMode() == MainWindow::CUSTOM_MODE_PX4) {
udpLink = new UDPLink(QHostAddress::Any, 14550);
LinkManager::instance()->add(udpLink);
SerialLink *slink = new SerialLink();
LinkManager::instance()->add(slink);
} else {
// We want to have a default serial link available for "quick" connecting.
SerialLink *slink = new SerialLink();
LinkManager::instance()->add(slink);
}
#ifdef QGC_RTLAB_ENABLED
// Add OpalRT Link, but do not connect
OpalLink* opalLink = new OpalLink();
MainWindow::instance()->addLink(opalLink);
#endif
// Remove splash screen
splashScreen->finish(mainWindow);
if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"),
splashScreen->finish(_mainWindow);
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 && !udpLink->connect())
{
......@@ -216,17 +213,19 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
QTimer::singleShot(15000, &msgBox, SLOT(reject()));
// Exit application
if (ret == QMessageBox::Yes)
{
//mainWindow->close();
QTimer::singleShot(200, mainWindow, SLOT(close()));
QTimer::singleShot(200, _mainWindow, SLOT(close()));
}
}
return true;
}
/**
......@@ -235,23 +234,8 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
**/
QGCCore::~QGCCore()
{
if (welcome)
{
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.
}
delete UASManager::instance();
delete LinkManager::instance();
}
/**
......@@ -305,14 +289,3 @@ void QGCCore::startUASManager()
}
}
}
void QGCCore::customViewModeSelected(enum MainWindow::CUSTOM_MODE 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();
}
......@@ -36,15 +36,12 @@ This file is part of the PIXHAWK project
#include <QApplication>
#include "MainWindow.h"
#include "QGCWelcomeMainWindow.h"
#include "UASManager.h"
#include "LinkManager.h"
/*#include "ViconTarsusProtocol.h" */
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
#endif
/**
* @brief The main application and management class.
*
......@@ -57,16 +54,12 @@ class QGCCore : public QApplication
Q_OBJECT
public:
QGCCore(bool firstStart, int &argc, char* argv[]);
QGCCore(int &argc, char* argv[]);
~QGCCore();
bool getRestartRequested()
{
return restartRequested;
}
public slots:
void customViewModeSelected(enum MainWindow::CUSTOM_MODE mode);
/// @brief Initialize the applicaation.
/// @return false: init failed, app should exit
bool init(void);
protected:
void startLinkManager();
......@@ -79,9 +72,7 @@ protected:
void startUASManager();
private:
MainWindow* mainWindow;
bool restartRequested;
QGCWelcomeMainWindow* welcome;
MainWindow* _mainWindow;
};
#endif /* _CORE_H_ */
......@@ -140,26 +140,12 @@ int main(int argc, char *argv[])
}
#endif
QGCCore* core = NULL;
int val;
bool firstStart = true;
do {
if (core) {
delete core;
firstStart = false;
}
core = new QGCCore(firstStart, argc, argv);
if (!QSslSocket::supportsSsl()) {
QMessageBox::critical(NULL,
QObject::tr("Missing SSL Support"),
QObject::tr("QGroundControl requires support for SSL to be installed prior to running. Please see http://www.qgroundcontrol.org/downloads for instructions on installing prerequisites for QGroundControl."));
return 1;
}
val = core->exec();
} while (core->getRestartRequested());
QGCCore* core = new QGCCore(argc, argv);
Q_CHECK_PTR(core);
if (!core->init()) {
return -1;
}
return val;
return core->exec();
}
#include "QGCWelcomeWidget.h"
#include "ui_QGCWelcomeWidget.h"
QGCWelcomeWidget::QGCWelcomeWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCWelcomeWidget)
{
ui->setupUi(this);
}
QGCWelcomeWidget::~QGCWelcomeWidget()
{
delete ui;
}
#ifndef QGCWELCOMEWIDGET_H
#define QGCWELCOMEWIDGET_H
#include <QWidget>
namespace Ui {
class QGCWelcomeWidget;
}
class QGCWelcomeWidget : public QWidget
{
Q_OBJECT
public:
explicit QGCWelcomeWidget(QWidget *parent = 0);
~QGCWelcomeWidget();
private:
Ui::QGCWelcomeWidget *ui;
};
#endif // QGCWELCOMEWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCWelcomeWidget</class>
<widget class="QWidget" name="QGCWelcomeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>30</number>
</property>
<property name="rightMargin">
<number>30</number>
</property>
<item row="0" column="0">
<widget class="QToolButton" name="connectButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="logreplayButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="demoButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "QGCViewModeSelection.h"
#include "ui_QGCViewModeSelection.h"
#include "QGC.h"
#include "MainWindow.h"
QGCViewModeSelection::QGCViewModeSelection(QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCViewModeSelection),
selected(false)
{
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->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;
}
#ifndef QGCVIEWMODESELECTION_H
#define QGCVIEWMODESELECTION_H
#include <QWidget>
#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 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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCViewModeSelection</class>
<widget class="QWidget" name="QGCViewModeSelection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<height>409</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="1">
<widget class="QCheckBox" name="notAgainCheckBox">
<property name="text">
<string>Do not ask again on next startup. The selection can be changed any time in the preferences.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>47</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>46</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QWidget" name="viewModeWidget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="viewModeAR">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/actions/qgroundcontrol-wifi.svg</normaloff>:/files/images/actions/qgroundcontrol-wifi.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>PX4 Autopilot</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>WiFi / UDP</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="viewModePX4">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/actions/qgroundcontrol-px4.svg</normaloff>:/files/images/actions/qgroundcontrol-px4.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="viewModeGeneric">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/actions/qgroundcontrol-generic.svg</normaloff>:/files/images/actions/qgroundcontrol-generic.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Radio / Serial Link</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="viewModeHintLabel">
<property name="text">
<string>Please select the connection or autopilot you want to use QGroundControl with.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>76</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>76</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="../../../qgroundcontrol.qrc"/>
</resources>
<connections/>
</ui>
#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);
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;
}
#ifndef QGCWELCOMEMAINWINDOW_H
#define QGCWELCOMEMAINWINDOW_H
#include <QMainWindow>
#include "MainWindow.h"
#include "QGCViewModeSelection.h"
namespace Ui {
class QGCWelcomeMainWindow;
}
class QGCWelcomeMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit QGCWelcomeMainWindow(QWidget *parent = 0);
~QGCWelcomeMainWindow();
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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCWelcomeMainWindow</class>
<widget class="QMainWindow" name="QGCWelcomeMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
</widget>
<resources/>
<connections/>
</ui>
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