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-25 14:40:16 +01:00
|
|
|
#include "linbostartpage.h"
|
2020-11-16 00:31:28 +01:00
|
|
|
|
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-25 14:40:16 +01:00
|
|
|
this->inited = false;
|
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)
|
2020-12-01 10:03:43 +01:00
|
|
|
//linboGUIImpl* legacyGui = new linboGUIImpl(this);
|
|
|
|
//legacyGui->setStyleSheet( "QDialog { background: white }");
|
2020-11-19 14:39:32 +01:00
|
|
|
|
|
|
|
// 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-26 15:53:27 +01:00
|
|
|
this->startActionsWidget->setFixedHeight(this->height() * 0.45);
|
2020-11-19 14:39:32 +01:00
|
|
|
this->startActionsWidget->setFixedWidth(this->width());
|
|
|
|
|
2020-12-01 10:03:43 +01:00
|
|
|
QLabel* versionLabel = new QLabel(backend->getConfig()->getLinboVersion() );//+ " - GUI by Dorian Zedler");
|
2020-11-24 20:25:39 +01:00
|
|
|
versionLabel->setFont(QFont("Segoe UI"));
|
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;
|
2020-11-24 20:25:39 +01:00
|
|
|
int buttonWidth = width * 0.6;
|
2020-11-19 14:39:32 +01:00
|
|
|
powerActionsLayoutWidget->setGeometry(QRect(this->width() - (width + margins), this->height() - (height + margins), width * 1.1, height));
|
|
|
|
|
|
|
|
QModernPushButton* settingsActionButton = new QModernPushButton(":/svgIcons/settingsAction.svg");
|
2020-12-01 10:03:43 +01:00
|
|
|
//connect(settingsActionButton, SIGNAL(clicked()), legacyGui, SLOT(loginAndOpen()));
|
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-25 14:40:16 +01:00
|
|
|
|
|
|
|
this->handleLinboStateChanged(this->backend->getState());
|
2020-11-19 14:39:32 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 11:57:51 +01:00
|
|
|
void LinboStartPage::handleLinboStateChanged(LinboBackend::LinboState newState) {
|
2020-11-25 14:40:16 +01:00
|
|
|
bool powerActionButtonsVisible = true;
|
2020-11-23 11:57:51 +01:00
|
|
|
switch (newState) {
|
2020-11-25 14:40:16 +01:00
|
|
|
case LinboBackend::Autostarting:
|
2020-11-23 11:57:51 +01:00
|
|
|
case LinboBackend::Starting:
|
|
|
|
case LinboBackend::Syncing:
|
|
|
|
case LinboBackend::Reinstalling:
|
2020-11-25 14:40:16 +01:00
|
|
|
powerActionButtonsVisible = false;
|
2020-11-23 11:57:51 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2020-11-19 14:39:32 +01:00
|
|
|
}
|
2020-11-25 14:40:16 +01:00
|
|
|
|
|
|
|
for(QModernPushButton* powerActionButton : this->powerActionButtons)
|
|
|
|
if(this->inited)
|
|
|
|
powerActionButton->setVisibleAnimated(powerActionButtonsVisible);
|
|
|
|
else
|
|
|
|
powerActionButton->setVisible(powerActionButtonsVisible);
|
|
|
|
|
|
|
|
this->inited = true;
|
2020-11-16 00:31:28 +01:00
|
|
|
}
|