2020-08-20 09:16:44 -06:00
|
|
|
#include "window.hpp"
|
2020-10-21 07:15:21 -06:00
|
|
|
|
2020-08-20 09:16:44 -06:00
|
|
|
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
|
|
|
|
main_layout = new QStackedLayout;
|
2021-03-22 14:40:08 -06:00
|
|
|
main_layout->setMargin(0);
|
2020-08-20 09:16:44 -06:00
|
|
|
|
2020-12-02 21:47:47 -07:00
|
|
|
homeWindow = new HomeWindow(this);
|
|
|
|
main_layout->addWidget(homeWindow);
|
2020-08-20 09:16:44 -06:00
|
|
|
|
2020-11-20 05:21:18 -07:00
|
|
|
settingsWindow = new SettingsWindow(this);
|
2020-08-20 09:16:44 -06:00
|
|
|
main_layout->addWidget(settingsWindow);
|
|
|
|
|
2020-11-20 05:21:18 -07:00
|
|
|
onboardingWindow = new OnboardingWindow(this);
|
2020-10-31 18:07:04 -06:00
|
|
|
main_layout->addWidget(onboardingWindow);
|
2020-09-18 15:12:03 -06:00
|
|
|
|
2020-12-02 21:47:47 -07:00
|
|
|
QObject::connect(homeWindow, SIGNAL(openSettings()), this, SLOT(openSettings()));
|
2021-02-23 06:40:56 -07:00
|
|
|
QObject::connect(homeWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));
|
2021-02-22 02:47:33 -07:00
|
|
|
QObject::connect(homeWindow, SIGNAL(offroadTransition(bool)), this, SLOT(offroadTransition(bool)));
|
2020-08-20 09:16:44 -06:00
|
|
|
QObject::connect(settingsWindow, SIGNAL(closeSettings()), this, SLOT(closeSettings()));
|
|
|
|
|
2020-10-31 18:07:04 -06:00
|
|
|
// start at onboarding
|
2020-11-12 22:37:02 -07:00
|
|
|
main_layout->setCurrentWidget(onboardingWindow);
|
2020-10-31 18:07:04 -06:00
|
|
|
QObject::connect(onboardingWindow, SIGNAL(onboardingDone()), this, SLOT(closeSettings()));
|
2020-11-12 22:37:02 -07:00
|
|
|
onboardingWindow->updateActiveScreen();
|
2020-10-31 18:07:04 -06:00
|
|
|
|
2021-02-28 19:10:50 -07:00
|
|
|
// no outline to prevent the focus rectangle
|
2021-03-22 14:40:08 -06:00
|
|
|
setLayout(main_layout);
|
2020-08-20 09:16:44 -06:00
|
|
|
setStyleSheet(R"(
|
|
|
|
* {
|
2020-12-24 15:10:43 -07:00
|
|
|
font-family: Inter;
|
2021-02-28 19:10:50 -07:00
|
|
|
outline: none;
|
2020-08-20 09:16:44 -06:00
|
|
|
}
|
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
2021-02-22 02:47:33 -07:00
|
|
|
void MainWindow::offroadTransition(bool offroad){
|
|
|
|
if(!offroad){
|
|
|
|
closeSettings();
|
2021-02-28 19:10:50 -07:00
|
|
|
}
|
2021-02-22 02:47:33 -07:00
|
|
|
}
|
|
|
|
|
2020-09-09 11:04:28 -06:00
|
|
|
void MainWindow::openSettings() {
|
2020-12-02 21:47:47 -07:00
|
|
|
main_layout->setCurrentWidget(settingsWindow);
|
2020-08-20 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
2020-09-09 11:04:28 -06:00
|
|
|
void MainWindow::closeSettings() {
|
2020-12-02 21:47:47 -07:00
|
|
|
main_layout->setCurrentWidget(homeWindow);
|
2020-08-20 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
2020-11-20 05:21:18 -07:00
|
|
|
bool MainWindow::eventFilter(QObject *obj, QEvent *event){
|
|
|
|
if (event->type() == QEvent::MouseButtonPress) {
|
2020-12-02 21:47:47 -07:00
|
|
|
homeWindow->glWindow->wake();
|
2020-11-20 05:21:18 -07:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|