Newer
Older
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2013 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of class MainWindow
* @author Lorenz Meier <mail@qgroundcontrol.org>
*/
#include <QSettings>
#include <QDockWidget>
#include <QNetworkInterface>
#include <QMessageBox>
#include <QDebug>
#include <QTimer>
#include <QHostInfo>
#include <QSplashScreen>
#include <QGCHilLink.h>
#include <QGCHilConfiguration.h>
#include <QGCHilFlightGearConfiguration.h>
#include "dockwidgettitlebareventfilter.h"
#include "QGC.h"
#include "MAVLinkSimulationLink.h"
#include "SerialLink.h"
#include "UDPLink.h"
#include "MAVLinkProtocol.h"
#include "CommConfigurationWindow.h"
#include "QGCWaypointListMulti.h"
#include "MainWindow.h"
#include "JoystickWidget.h"
#include "GAudioOutput.h"
#include "QGCToolWidget.h"
#include "QGCMAVLinkLogPlayer.h"
#include "QGCSettingsWidget.h"
#include "QGCMapTool.h"
#include "MAVLinkDecoder.h"
#include "QGCMAVLinkMessageSender.h"
#include "QGCRGBDView.h"
#include "QGCStatusBar.h"
Michael Carpenter
committed
#include "UASQuickView.h"
#include "QGCDataPlot2D.h"
#include "Linecharts.h"
Michael Carpenter
committed
#include "UASActionsWidget.h"
#include "QGCTabbedInfoView.h"
#include "UASRawStatusView.h"
dongfang
committed
#include "PrimaryFlightDisplay.h"
Lorenz Meier
committed
#include <apmtoolbar.h>
#include <ApmHardwareConfig.h>
#include <ApmSoftwareConfig.h>
#include "SerialSettingsDialog.h"
#include "terminalconsole.h"
#ifdef QGC_OSG_ENABLED
#include "Q3DWidgetFactory.h"
#endif
// FIXME Move
#include "PxQuadMAV.h"
#include "SlugsMAV.h"
#include "LogCompressor.h"
// Set up some constants
const QString MainWindow::defaultDarkStyle = ":files/styles/style-dark.css";
const QString MainWindow::defaultLightStyle = ":files/styles/style-light.css";
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)),
screen, SLOT(showMessage(QString,int,QColor)));
}
_instance->init();
}
return _instance;
}
MainWindow* MainWindow::instance(QSplashScreen* screen)
{
return instance_mode(screen, CUSTOM_MODE_UNCHANGED);
/**
* Create new mainwindow. The constructor instantiates all parts of the user
* interface. It does NOT show the mainwindow. To display it, call the show()
* method.
*
* @see QMainWindow::show()
**/
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent),
currentView(VIEW_FLIGHT),
currentStyle(QGC_MAINWINDOW_STYLE_DARK),
aboutToCloseFlag(false),
changingViewsFlag(false),
centerStackActionGroup(new QActionGroup(this)),
darkStyleFileName(defaultDarkStyle),
lightStyleFileName(defaultLightStyle),
autoReconnect(false),
lowPowerMode(false),
isAdvancedMode(false),
dockWidgetTitleBarEnabled(true),
customMode(CUSTOM_MODE_NONE)
Michael Carpenter
committed
this->setAttribute(Qt::WA_DeleteOnClose);
//TODO: move protocol outside UI
connect(mavlink, SIGNAL(protocolStatusMessage(QString,QString)), this, SLOT(showCriticalMessage(QString,QString)), Qt::QueuedConnection);
loadSettings();
}
void MainWindow::init()
{
emit initStatusChanged(tr("Loading style"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
qApp->setStyle("plastique");
if (currentStyle == QGC_MAINWINDOW_STYLE_LIGHT)
{
loadStyle(currentStyle, lightStyleFileName);
}
else
{
loadStyle(currentStyle, darkStyleFileName);
}
Michael Carpenter
committed
if (settings.contains("ADVANCED_MODE"))
{
isAdvancedMode = settings.value("ADVANCED_MODE").toBool();
}
if (!settings.contains("CURRENT_VIEW"))
{
// Set this view as default view
settings.setValue("CURRENT_VIEW", currentView);
}
else
{
// LOAD THE LAST VIEW
VIEW_SECTIONS currentViewCandidate = (VIEW_SECTIONS) settings.value("CURRENT_VIEW", currentView).toInt();
if (currentViewCandidate != VIEW_ENGINEER &&
currentViewCandidate != VIEW_MISSION &&
currentViewCandidate != VIEW_FLIGHT &&
currentViewCandidate != VIEW_FULL)
{
currentView = currentViewCandidate;
}
}
settings.sync();
emit initStatusChanged(tr("Setting up user interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
// Setup user interface
ui.setupUi(this);
hide();
// We only need this menu if we have more than one system
Lorenz Meier
committed
// ui.menuConnected_Systems->setEnabled(false);
// Set dock options
setDockOptions(AnimatedDocks | AllowTabbedDocks | AllowNestedDocks);
configureWindowName();
// Setup corners
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
// Setup UI state machines
centerStackActionGroup->setExclusive(true);
centerStack = new QStackedWidget(this);
setCentralWidget(centerStack);
Loading
Loading full blame...