Commit 7160a6c1 authored by Mariano Lizarraga's avatar Mariano Lizarraga

Major cleanup of MainWindow constructor. All widgets have now the visible...

Major cleanup of MainWindow constructor. All widgets have now the visible property set to false on its constructor
parent 70e660c9
...@@ -36,7 +36,7 @@ This file is part of the PIXHAWK project ...@@ -36,7 +36,7 @@ This file is part of the PIXHAWK project
/* SDL does ugly things to main() */ /* SDL does ugly things to main() */
#ifdef main #ifdef main
# undef main #undef main
#endif #endif
/** /**
......
...@@ -101,6 +101,8 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -101,6 +101,8 @@ DebugConsole::DebugConsole(QWidget *parent) :
connect(m_ui->holdCheckBox, SIGNAL(clicked(bool)), this, SLOT(setAutoHold(bool))); connect(m_ui->holdCheckBox, SIGNAL(clicked(bool)), this, SLOT(setAutoHold(bool)));
// Connect hold button // Connect hold button
connect(m_ui->holdButton, SIGNAL(toggled(bool)), this, SLOT(hold(bool))); connect(m_ui->holdButton, SIGNAL(toggled(bool)), this, SLOT(hold(bool)));
this->setVisible(false);
} }
DebugConsole::~DebugConsole() DebugConsole::~DebugConsole()
......
...@@ -100,6 +100,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) : ...@@ -100,6 +100,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) :
// Connect with UAS // Connect with UAS
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
//start(); //start();
this->setVisible(false);
} }
HDDisplay::~HDDisplay() HDDisplay::~HDDisplay()
......
...@@ -100,6 +100,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) : ...@@ -100,6 +100,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
xCenterPos = vwidth/2.0f; xCenterPos = vwidth/2.0f;
yCenterPos = vheight/2.0f + topMargin - bottomMargin; yCenterPos = vheight/2.0f + topMargin - bottomMargin;
this->setVisible(false);
} }
void HSIDisplay::paintEvent(QPaintEvent * event) void HSIDisplay::paintEvent(QPaintEvent * event)
......
...@@ -153,6 +153,8 @@ HUD::HUD(int width, int height, QWidget* parent) ...@@ -153,6 +153,8 @@ HUD::HUD(int width, int height, QWidget* parent)
// Connect with UAS // Connect with UAS
UASManager* manager = UASManager::instance(); UASManager* manager = UASManager::instance();
connect(manager, SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(manager, SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
this->setVisible(false);
} }
HUD::~HUD() HUD::~HUD()
......
...@@ -62,94 +62,23 @@ This file is part of the QGROUNDCONTROL project ...@@ -62,94 +62,23 @@ This file is part of the QGROUNDCONTROL project
* *
* @see QMainWindow::show() * @see QMainWindow::show()
**/ **/
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), MainWindow::MainWindow(QWidget *parent) :
settings() QMainWindow(parent),
settings()
{ {
this->hide(); this->hide();
this->setVisible(false); this->setVisible(false);
mavlink = new MAVLinkProtocol();
// Setup user interface // Setup user interface
ui.setupUi(this); ui.setupUi(this);
// Initialize views, NOT show them yet, only initialize model and controller buildWidgets();
centerStack = new QStackedWidget(this);
linechart = new Linecharts(this);
linechart->setActive(false);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), linechart, SLOT(addSystem(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)), linechart, SLOT(selectSystem(int)));
centerStack->addWidget(linechart);
control = new UASControlWidget(this);
//controlDock = new QDockWidget(this);
//controlDock->setWidget(control);
list = new UASListWidget(this);
list->setVisible(false);
waypoints = new WaypointList(this, NULL);
waypoints->setVisible(false);
info = new UASInfoWidget(this);
info->setVisible(false);
detection = new ObjectDetectionView("patterns", this);
detection->setVisible(false);
hud = new HUD(640, 480, this);
hud->setVisible(false);
debugConsole = new DebugConsole(this);
debugConsole->setVisible(false);
map = new MapWidget(this);
map->setVisible(false);
protocol = new XMLCommProtocolWidget(this);
protocol->setVisible(false);
centerStack->addWidget(protocol);
parameters = new ParameterInterface(this);
parameters->setVisible(false);
watchdogControl = new WatchdogControl(this);
watchdogControl->setVisible(false);
hsi = new HSIDisplay(this);
hsi->setVisible(false);
QStringList* acceptList = new QStringList();
acceptList->append("roll IMU");
acceptList->append("pitch IMU");
acceptList->append("yaw IMU");
acceptList->append("rollspeed IMU");
acceptList->append("pitchspeed IMU");
acceptList->append("yawspeed IMU");
headDown1 = new HDDisplay(acceptList, this);
headDown1->setVisible(false);
QStringList* acceptList2 = new QStringList();
acceptList2->append("Battery");
acceptList2->append("Pressure");
headDown2 = new HDDisplay(acceptList2, this);
headDown2->setVisible(false);
centerStack->addWidget(map);
centerStack->addWidget(hud);
setCentralWidget(centerStack);
// Get IPs
QList<QHostAddress> hostAddresses = QNetworkInterface::allAddresses();
QString windowname = qApp->applicationName() + " " + qApp->applicationVersion();
windowname.append(" (" + QHostInfo::localHostName() + ": ");
bool prevAddr = false;
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(prevAddr) windowname.append("/");
windowname.append(hostAddresses.at(i).toString());
prevAddr = true;
}
}
windowname.append(")"); connectWidgets();
setWindowTitle(windowname); arrangeCenterStack();
#ifndef Q_WS_MAC
//qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png")); configureWindowName();
#endif
// Add status bar // Add status bar
setStatusBar(createStatusBar()); setStatusBar(createStatusBar());
...@@ -157,10 +86,10 @@ settings() ...@@ -157,10 +86,10 @@ settings()
// Set the application style (not the same as a style sheet) // Set the application style (not the same as a style sheet)
// Set the style to Plastique // Set the style to Plastique
qApp->setStyle("plastique"); qApp->setStyle("plastique");
// Set style sheet as last step // Set style sheet as last step
reloadStylesheet(); reloadStylesheet();
joystick = new JoystickInput();
// Create actions // Create actions
connectActions(); connectActions();
...@@ -170,9 +99,6 @@ settings() ...@@ -170,9 +99,6 @@ settings()
// Adjust the size // Adjust the size
adjustSize(); adjustSize();
//
connect(mavlink, SIGNAL(receiveLossChanged(int, float)), info, SLOT(updateSendLoss(int, float)));
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -181,6 +107,86 @@ MainWindow::~MainWindow() ...@@ -181,6 +107,86 @@ MainWindow::~MainWindow()
statusBar = NULL; statusBar = NULL;
} }
void MainWindow::buildWidgets()
{
QStringList* acceptList = new QStringList();
acceptList->append("roll IMU");
acceptList->append("pitch IMU");
acceptList->append("yaw IMU");
acceptList->append("rollspeed IMU");
acceptList->append("pitchspeed IMU");
acceptList->append("yawspeed IMU");
QStringList* acceptList2 = new QStringList();
acceptList2->append("Battery");
acceptList2->append("Pressure");
mavlink = new MAVLinkProtocol();
linechart = new Linecharts(this);
control = new UASControlWidget(this);
list = new UASListWidget(this);
waypoints = new WaypointList(this, NULL);
info = new UASInfoWidget(this);
detection = new ObjectDetectionView("patterns", this);
hud = new HUD(640, 480, this);
debugConsole= new DebugConsole(this);
map = new MapWidget(this);
protocol = new XMLCommProtocolWidget(this);
parameters = new ParameterInterface(this);
watchdogControl = new WatchdogControl(this);
hsi = new HSIDisplay(this);
headDown1 = new HDDisplay(acceptList, this);
headDown2 = new HDDisplay(acceptList2, this);
joystick = new JoystickInput();
}
void MainWindow::connectWidgets(){
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), linechart, SLOT(addSystem(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)), linechart, SLOT(selectSystem(int)));
connect(mavlink, SIGNAL(receiveLossChanged(int, float)), info, SLOT(updateSendLoss(int, float)));
}
void MainWindow::arrangeCenterStack(){
centerStack = new QStackedWidget(this);
centerStack->addWidget(linechart);
centerStack->addWidget(protocol);
centerStack->addWidget(map);
centerStack->addWidget(hud);
setCentralWidget(centerStack);
}
void MainWindow::configureWindowName(){
QList<QHostAddress> hostAddresses = QNetworkInterface::allAddresses();
QString windowname = qApp->applicationName() + " " + qApp->applicationVersion();
bool prevAddr = false;
windowname.append(" (" + QHostInfo::localHostName() + ": ");
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(prevAddr) windowname.append("/");
windowname.append(hostAddresses.at(i).toString());
prevAddr = true;
}
}
windowname.append(")");
setWindowTitle(windowname);
#ifndef Q_WS_MAC
//qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
#endif
}
QStatusBar* MainWindow::createStatusBar() QStatusBar* MainWindow::createStatusBar()
{ {
QStatusBar* bar = new QStatusBar(); QStatusBar* bar = new QStatusBar();
......
...@@ -129,6 +129,10 @@ protected: ...@@ -129,6 +129,10 @@ protected:
void loadWidgets(); void loadWidgets();
void connectActions(); void connectActions();
void clearView(); void clearView();
void buildWidgets();
void connectWidgets();
void arrangeCenterStack();
void configureWindowName();
// TODO Should be moved elsewhere, as the protocol does not belong to the UI // TODO Should be moved elsewhere, as the protocol does not belong to the UI
MAVLinkProtocol* mavlink; MAVLinkProtocol* mavlink;
...@@ -178,6 +182,7 @@ protected: ...@@ -178,6 +182,7 @@ protected:
private: private:
Ui::MainWindow ui; Ui::MainWindow ui;
}; };
#endif /* _MAINWINDOW_H_ */ #endif /* _MAINWINDOW_H_ */
...@@ -107,6 +107,8 @@ MapWidget::MapWidget(QWidget *parent) : ...@@ -107,6 +107,8 @@ MapWidget::MapWidget(QWidget *parent) :
mc->setZoom(3); mc->setZoom(3);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
this->setVisible(false);
} }
MapWidget::~MapWidget() MapWidget::~MapWidget()
......
...@@ -57,6 +57,8 @@ ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) : ...@@ -57,6 +57,8 @@ ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) :
letterTimer.start(1000); letterTimer.start(1000);
connect(&letterTimer, SIGNAL(timeout()), this, SLOT(decreaseLetterTime())); connect(&letterTimer, SIGNAL(timeout()), this, SLOT(decreaseLetterTime()));
connect(m_ui->clearButton, SIGNAL(clicked()), this, SLOT(clearLists())); connect(m_ui->clearButton, SIGNAL(clicked()), this, SLOT(clearLists()));
this->setVisible(false);
} }
ObjectDetectionView::~ObjectDetectionView() ObjectDetectionView::~ObjectDetectionView()
......
...@@ -23,6 +23,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) : ...@@ -23,6 +23,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
// Setup MAV connections // Setup MAV connections
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
this->setVisible(false);
} }
ParameterInterface::~ParameterInterface() ParameterInterface::~ParameterInterface()
......
...@@ -84,6 +84,8 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : ...@@ -84,6 +84,8 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
// STATUS LABEL // STATUS LABEL
updateStatusLabel(""); updateStatusLabel("");
this->setVisible(false);
} }
WaypointList::~WaypointList() WaypointList::~WaypointList()
......
...@@ -24,6 +24,8 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) : ...@@ -24,6 +24,8 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) :
connect(m_ui->selectOutputButton, SIGNAL(clicked()), this, SLOT(selectOutputDirectory())); connect(m_ui->selectOutputButton, SIGNAL(clicked()), this, SLOT(selectOutputDirectory()));
connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generate())); connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generate()));
connect(m_ui->saveButton, SIGNAL(clicked()), this, SLOT(save())); connect(m_ui->saveButton, SIGNAL(clicked()), this, SLOT(save()));
this->setVisible(false);
} }
void XMLCommProtocolWidget::selectXMLFile() void XMLCommProtocolWidget::selectXMLFile()
......
...@@ -5,6 +5,7 @@ Linecharts::Linecharts(QWidget *parent) : ...@@ -5,6 +5,7 @@ Linecharts::Linecharts(QWidget *parent) :
plots(), plots(),
active(true) active(true)
{ {
this->setVisible(false);
} }
......
...@@ -75,6 +75,8 @@ UASInfoWidget::UASInfoWidget(QWidget *parent, QString name) : QWidget(parent) ...@@ -75,6 +75,8 @@ UASInfoWidget::UASInfoWidget(QWidget *parent, QString name) : QWidget(parent)
connect(updateTimer, SIGNAL(timeout()), this, SLOT(refresh())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refresh()));
updateTimer->start(50); updateTimer->start(50);
this->setVisible(false);
} }
UASInfoWidget::~UASInfoWidget() UASInfoWidget::~UASInfoWidget()
......
...@@ -51,6 +51,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA ...@@ -51,6 +51,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA
this->setMinimumWidth(250); this->setMinimumWidth(250);
uasViews = QMap<UASInterface*, UASView*>(); uasViews = QMap<UASInterface*, UASView*>();
this->setVisible(false);
} }
UASListWidget::~UASListWidget() UASListWidget::~UASListWidget()
......
...@@ -24,6 +24,8 @@ WatchdogControl::WatchdogControl(QWidget *parent) : ...@@ -24,6 +24,8 @@ WatchdogControl::WatchdogControl(QWidget *parent) :
ui->mainWidget->setLayout(listLayout); ui->mainWidget->setLayout(listLayout);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(setUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(setUAS(UASInterface*)));
this->setVisible(false);
} }
WatchdogControl::~WatchdogControl() WatchdogControl::~WatchdogControl()
......
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