Newer
Older
pixhawk
committed
/*===================================================================
======================================================================*/
/**
* @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 "MG.h"
#include "MAVLinkSimulationLink.h"
#include "SerialLink.h"
#include "UDPLink.h"
#include "MAVLinkProtocol.h"
#include "CommConfigurationWindow.h"
#include "WaypointList.h"
#include "MainWindow.h"
#include "JoystickWidget.h"
lm
committed
#include "QGCToolWidget.h"
#include "QGCMAVLinkLogPlayer.h"
#include "Q3DWidgetFactory.h"
MainWindow* MainWindow::instance()
{
static MainWindow* _instance = 0;
if(_instance == 0)
{
_instance = new MainWindow();
/* Set the application as parent to ensure that this object
* will be destroyed when the main application exits */
//_instance->setParent(qApp);
}
return _instance;
/**
* 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()
**/
Mariano Lizarraga
committed
MainWindow::MainWindow(QWidget *parent):
Mariano Lizarraga
committed
toolsMenuActions(),
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_OPERATOR &&
currentViewCandidate != VIEW_PILOT)
settings.sync();
setVisible(false);
Mariano Lizarraga
committed
buildCommonWidgets();
Mariano Lizarraga
committed
Mariano Lizarraga
committed
connectCommonWidgets();
Mariano Lizarraga
committed
Mariano Lizarraga
committed
arrangeCommonCenterStack();
Mariano Lizarraga
committed
configureWindowName();
// Set the application style (not the same as a style sheet)
// Set the style to Plastique
qApp->setStyle("plastique");
Mariano Lizarraga
committed
QFile* styleSheet = new QFile(":/images/style-mission.css");
if (styleSheet->open(QIODevice::ReadOnly | QIODevice::Text))
{
QString style = QString(styleSheet->readAll());
style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "/images/");
qApp->setStyleSheet(style);
}
Mariano Lizarraga
committed
connectCommonActions();
// Set dock options
setDockOptions(AnimatedDocks | AllowTabbedDocks | AllowNestedDocks);
Mariano Lizarraga
committed
// Load mavlink view as default widget set
//loadMAVLinkView();
// Restore the window position and size
if (settings.contains(getWindowGeometryKey()))
{
// Restore the window geometry
restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray());
}
else
{
// Adjust the size
adjustSize();
}
// Populate link menu
QList<LinkInterface*> links = LinkManager::instance()->getLinks();
foreach(LinkInterface* link, links)
{
this->addLink(link);
}
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addLink(LinkInterface*)));
// Connect user interface devices
if (!joystick)
{
joystick = new JoystickInput();
}
/**
* Set default settings for this AP type.
*/
void MainWindow::setDefaultSettingsForAp()
{
// Check if the settings exist, instantiate defaults if necessary
// UNCONNECTED VIEW DEFAULT
QString centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_UNCONNECTED);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
// ENABLE UAS LIST
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_UAS_LIST, VIEW_UNCONNECTED), true);
// ENABLE COMMUNICATION CONSOLE
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_DEBUG_CONSOLE, VIEW_UNCONNECTED), true);
}
// OPERATOR VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_OPERATOR);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
// ENABLE UAS LIST
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_UAS_LIST,VIEW_OPERATOR), true);
// ENABLE HUD TOOL WIDGET
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_HUD,VIEW_OPERATOR), true);
Loading
Loading full blame...