This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
modern-linbo-gui/sources/linbostartpage.cpp

110 lines
4.9 KiB
C++
Raw Normal View History

/****************************************************************************
** 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/>.
****************************************************************************/
#include "../headers/linbostartpage.h"
LinboStartPage::LinboStartPage(LinboBackend* backend, QWidget *parent) : QWidget(parent)
{
this->backend = backend;
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
// OS Buttons
osSelectionRow = new LinboOsSelectionRow(this->backend);
osSelectionRow->setFixedHeight(this->height() * 0.25);
osSelectionRow->setFixedWidth(this->width());
// action buttons
this->startActionsWidget = new LinboStartActions(this->backend, this->osSelectionRow);
this->startActionsWidget->setFixedHeight(this->height() * 0.15);
this->startActionsWidget->setFixedWidth(this->width());
QLabel* versionLabel = new QLabel(backend->getConfig()->getVersion() + " - mod by Dorian Zedler");
// main layout
QWidget* mainLayoutWidget = new QWidget(this);
mainLayoutWidget->setGeometry(this->geometry());
QVBoxLayout* mainLayout = new QVBoxLayout(mainLayoutWidget);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
mainLayout->addWidget(osSelectionRow);
mainLayout->addWidget(this->startActionsWidget);
mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding));
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()));
settingsActionButton->setFixedHeight(buttonWidth);
settingsActionButton->setFixedWidth(buttonWidth);
QModernPushButton* rebootActionButton = new QModernPushButton(":/svgIcons/rebootAction.svg");
connect(rebootActionButton, SIGNAL(clicked()), this->backend, SLOT(reboot()));
rebootActionButton->setFixedHeight(buttonWidth);
rebootActionButton->setFixedWidth(buttonWidth);
QModernPushButton* shutdownActionButton = new QModernPushButton(":/svgIcons/shutdownAction.svg");
connect(shutdownActionButton, SIGNAL(clicked()), this->backend, SLOT(shutdown()));
shutdownActionButton->setFixedHeight(buttonWidth);
shutdownActionButton->setFixedWidth(buttonWidth);
QVBoxLayout* powerActionsLayout = new QVBoxLayout(powerActionsLayoutWidget);
powerActionsLayout->setSpacing(0);
powerActionsLayout->addWidget(settingsActionButton);
powerActionsLayout->addWidget(rebootActionButton);
powerActionsLayout->addWidget(shutdownActionButton);
}
void LinboStartPage::startOs() {
/*progressBar->show();
defaultActionButton->hide();
secondActionButton->hide();
thirdActionButton->hide();*/
this->osSelectionRow->setShowOnlySelectedButton(true);
/*LinboOs* startOs = static_cast<LinboOsSelectButton*>(this->osButtonGroup->checkedButton()->parent())->getOs();
for(QAbstractButton* abstractButton : this->osButtonGroup->buttons()) {
LinboOsSelectButton* button = static_cast<LinboOsSelectButton*>(abstractButton->parent());
if(button->getOs() != startOs)
button->setFixedWidth(this->width() * 0.1); //hide();
//button->setMaximumSize(QSize(0, this->height() * 0.25));
}
//this->osButtonGroup->checkedButton()->setFixedWidth(this->width() * 0.8);
//this->osButtonGroup->checkedButton()->setMaximumSize(QSize(this->width(), this->height() * 0.25));
qDebug() << "starting: " << startOs->getName();
this->backend->startOs(startOs);*/
}