2020-11-16 18:01:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
** Modern Linbo GUI
|
|
|
|
** Copyright (C) 2020 Dorian Zedler <dorian@itsblue.de>
|
|
|
|
**
|
|
|
|
** This program is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU Affero General Public License as published
|
|
|
|
** by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program 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 Affero General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU Affero General Public License
|
|
|
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-11-16 00:31:28 +01:00
|
|
|
#include "../headers/linbostartpage.h"
|
|
|
|
|
2020-11-19 14:39:32 +01:00
|
|
|
LinboStartPage::LinboStartPage(LinboBackend* backend, QWidget *parent) : QWidget(parent)
|
2020-11-16 00:31:28 +01:00
|
|
|
{
|
|
|
|
|
2020-11-19 14:39:32 +01:00
|
|
|
this->backend = backend;
|
2020-11-23 11:57:51 +01:00
|
|
|
connect(this->backend, SIGNAL(stateChanged(LinboBackend::LinboState)), this, SLOT(handleLinboStateChanged(LinboBackend::LinboState)));
|
|
|
|
|
2020-11-19 14:39:32 +01:00
|
|
|
this->setGeometry(QRect(0,0,parent->width(), parent->height()));
|
|
|
|
|
|
|
|
// create an instance of the old GUI (as a backup)
|
|
|
|
linboGUIImpl* legacyGui = new linboGUIImpl(this);
|
|
|
|
legacyGui->setStyleSheet( "QDialog { background: white }");
|
|
|
|
|
|
|
|
// create the main layout
|
|
|
|
|
2020-11-23 11:57:51 +01:00
|
|
|
// main layout
|
|
|
|
QWidget* mainLayoutWidget = new QWidget(this);
|
|
|
|
mainLayoutWidget->setGeometry(this->geometry());
|
|
|
|
QVBoxLayout* mainLayout = new QVBoxLayout(mainLayoutWidget);
|
|
|
|
mainLayout->setSpacing(this->height()*0.025);
|
|
|
|
mainLayout->setContentsMargins(0,0,0,0);
|
|
|
|
mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
|
2020-11-19 14:39:32 +01:00
|
|
|
// OS Buttons
|
|
|
|
osSelectionRow = new LinboOsSelectionRow(this->backend);
|
2020-11-23 11:57:51 +01:00
|
|
|
mainLayout->addWidget(osSelectionRow);
|
2020-11-19 14:39:32 +01:00
|
|
|
osSelectionRow->setFixedHeight(this->height() * 0.25);
|
|
|
|
osSelectionRow->setFixedWidth(this->width());
|
|
|
|
|
|
|
|
// action buttons
|
|
|
|
this->startActionsWidget = new LinboStartActions(this->backend, this->osSelectionRow);
|
2020-11-23 11:57:51 +01:00
|
|
|
mainLayout->addWidget(this->startActionsWidget);
|
2020-11-19 14:39:32 +01:00
|
|
|
this->startActionsWidget->setFixedHeight(this->height() * 0.15);
|
|
|
|
this->startActionsWidget->setFixedWidth(this->width());
|
|
|
|
|
|
|
|
mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
2020-11-23 11:57:51 +01:00
|
|
|
|
|
|
|
QLabel* versionLabel = new QLabel(backend->getConfig()->getVersion() + " - mod by Dorian Zedler");
|
2020-11-19 14:39:32 +01:00
|
|
|
mainLayout->addWidget(versionLabel);
|
|
|
|
|
|
|
|
|
|
|
|
// power and settings Buttons
|
|
|
|
QWidget* powerActionsLayoutWidget = new QWidget(this);
|
|
|
|
int height = this->height() * 0.2;
|
|
|
|
int width = height / 3;
|
|
|
|
int margins = width * 0.1;
|
|
|
|
int buttonWidth = width * 0.8;
|
|
|
|
powerActionsLayoutWidget->setGeometry(QRect(this->width() - (width + margins), this->height() - (height + margins), width * 1.1, height));
|
|
|
|
|
|
|
|
QModernPushButton* settingsActionButton = new QModernPushButton(":/svgIcons/settingsAction.svg");
|
|
|
|
connect(settingsActionButton, SIGNAL(clicked()), legacyGui, SLOT(open()));
|
2020-11-23 11:57:51 +01:00
|
|
|
this->powerActionButtons.append(settingsActionButton);
|
2020-11-19 14:39:32 +01:00
|
|
|
settingsActionButton->setFixedHeight(buttonWidth);
|
|
|
|
settingsActionButton->setFixedWidth(buttonWidth);
|
|
|
|
|
|
|
|
QModernPushButton* rebootActionButton = new QModernPushButton(":/svgIcons/rebootAction.svg");
|
|
|
|
connect(rebootActionButton, SIGNAL(clicked()), this->backend, SLOT(reboot()));
|
2020-11-23 11:57:51 +01:00
|
|
|
this->powerActionButtons.append(rebootActionButton);
|
2020-11-19 14:39:32 +01:00
|
|
|
rebootActionButton->setFixedHeight(buttonWidth);
|
|
|
|
rebootActionButton->setFixedWidth(buttonWidth);
|
|
|
|
|
|
|
|
QModernPushButton* shutdownActionButton = new QModernPushButton(":/svgIcons/shutdownAction.svg");
|
|
|
|
connect(shutdownActionButton, SIGNAL(clicked()), this->backend, SLOT(shutdown()));
|
2020-11-23 11:57:51 +01:00
|
|
|
this->powerActionButtons.append(shutdownActionButton);
|
2020-11-19 14:39:32 +01:00
|
|
|
shutdownActionButton->setFixedHeight(buttonWidth);
|
|
|
|
shutdownActionButton->setFixedWidth(buttonWidth);
|
|
|
|
|
|
|
|
QVBoxLayout* powerActionsLayout = new QVBoxLayout(powerActionsLayoutWidget);
|
|
|
|
powerActionsLayout->setSpacing(0);
|
|
|
|
powerActionsLayout->addWidget(settingsActionButton);
|
|
|
|
powerActionsLayout->addWidget(rebootActionButton);
|
|
|
|
powerActionsLayout->addWidget(shutdownActionButton);
|
|
|
|
}
|
|
|
|
|
2020-11-23 11:57:51 +01:00
|
|
|
void LinboStartPage::handleLinboStateChanged(LinboBackend::LinboState newState) {
|
|
|
|
switch (newState) {
|
|
|
|
case LinboBackend::Idle:
|
|
|
|
for(QModernPushButton* powerActionButton : this->powerActionButtons)
|
|
|
|
powerActionButton->setVisibleAnimated(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LinboBackend::Starting:
|
|
|
|
case LinboBackend::Syncing:
|
|
|
|
case LinboBackend::Reinstalling:
|
|
|
|
for(QModernPushButton* powerActionButton : this->powerActionButtons)
|
|
|
|
powerActionButton->setVisibleAnimated(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2020-11-19 14:39:32 +01:00
|
|
|
}
|
2020-11-16 00:31:28 +01:00
|
|
|
}
|