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/linbogui.h"
|
|
|
|
|
2020-11-16 18:01:03 +01:00
|
|
|
LinboGui::LinboGui()
|
2020-11-16 00:31:28 +01:00
|
|
|
{
|
|
|
|
// fill whole screen
|
|
|
|
Qt::WindowFlags flags;
|
|
|
|
flags = Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint;
|
|
|
|
setWindowFlags( flags );
|
|
|
|
setAttribute( Qt::WA_AlwaysShowToolTips );
|
|
|
|
this->setGeometry(QApplication::desktop()->screenGeometry());
|
|
|
|
this->setFixedHeight(QApplication::desktop()->screenGeometry().height());
|
|
|
|
this->setFixedWidth(QApplication::desktop()->screenGeometry().width());
|
|
|
|
|
|
|
|
// black bakground
|
2020-11-16 18:01:03 +01:00
|
|
|
// linuxmuster background color: #394f5e
|
2020-11-16 00:31:28 +01:00
|
|
|
this->setStyleSheet( "QDialog { background: white }");
|
|
|
|
|
2020-11-16 18:01:03 +01:00
|
|
|
// create an instance of the old GUI (as a backup)
|
2020-11-16 00:31:28 +01:00
|
|
|
linboGUIImpl* legacyGui = new linboGUIImpl(this);
|
|
|
|
legacyGui->setStyleSheet( "QDialog { background: white }");
|
2020-11-16 18:01:03 +01:00
|
|
|
|
|
|
|
// create the backend
|
|
|
|
this->backend = new LinboBackend(this);
|
|
|
|
|
|
|
|
qDebug() << this->backend->getOperatingSystems()[0]->getName();
|
2020-11-16 00:31:28 +01:00
|
|
|
|
|
|
|
// create the main layout
|
|
|
|
|
|
|
|
// OS Buttons
|
2020-11-16 18:01:03 +01:00
|
|
|
LinboOsSelectButton* osButton = new LinboOsSelectButton(":/svgIcons/ubuntu.svg", nullptr, this);
|
2020-11-16 00:31:28 +01:00
|
|
|
osButton->setFixedHeight(250);
|
|
|
|
osButton->setFixedWidth(250);
|
|
|
|
osButton->setChecked(true);
|
|
|
|
|
|
|
|
|
2020-11-16 18:01:03 +01:00
|
|
|
LinboOsSelectButton* osButton_1 = new LinboOsSelectButton(":/svgIcons/windows.svg", nullptr, this);
|
2020-11-16 00:31:28 +01:00
|
|
|
osButton_1->setFixedHeight(250);
|
|
|
|
osButton_1->setFixedWidth(250);
|
|
|
|
|
|
|
|
QButtonGroup* group = new QButtonGroup();
|
|
|
|
group->setExclusive(true);
|
|
|
|
group->addButton(osButton);
|
|
|
|
group->addButton(osButton_1);
|
|
|
|
|
|
|
|
// OS Button Layout
|
|
|
|
QHBoxLayout* osButtonRow = new QHBoxLayout();
|
|
|
|
osButtonRow->addWidget(osButton);
|
|
|
|
osButtonRow->addWidget(osButton_1);
|
|
|
|
|
|
|
|
// action buttons
|
|
|
|
QModernPushButton* defaultActionButton = new QModernPushButton(":/svgIcons/startAction.svg");
|
|
|
|
defaultActionButton->setFixedHeight(110);
|
|
|
|
defaultActionButton->setFixedWidth(110);
|
2020-11-16 18:01:03 +01:00
|
|
|
connect(defaultActionButton, SIGNAL(clicked()), this, SLOT(startOs()));
|
2020-11-16 00:31:28 +01:00
|
|
|
|
|
|
|
QModernPushButton* secondActionButton = new QModernPushButton(":/svgIcons/syncAction.svg");
|
|
|
|
secondActionButton->setFixedHeight(50);
|
|
|
|
secondActionButton->setFixedWidth(50);
|
|
|
|
|
|
|
|
QModernPushButton* thirdActionButton = new QModernPushButton(":/svgIcons/resetAction.svg");
|
|
|
|
thirdActionButton->setFixedHeight(50);
|
|
|
|
thirdActionButton->setFixedWidth(50);
|
|
|
|
|
|
|
|
QHBoxLayout* actionButtonLayout = new QHBoxLayout();
|
|
|
|
actionButtonLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
actionButtonLayout->addWidget(secondActionButton);
|
|
|
|
actionButtonLayout->addWidget(thirdActionButton);
|
|
|
|
actionButtonLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
|
2020-11-16 18:01:03 +01:00
|
|
|
QLabel* versionLabel = new QLabel(backend->getConfig()->getVersion());
|
|
|
|
|
2020-11-16 00:31:28 +01:00
|
|
|
// main layout
|
2020-11-16 18:01:03 +01:00
|
|
|
QWidget* mainLayoutWidget = new QWidget(this);
|
|
|
|
mainLayoutWidget->setGeometry(this->geometry());
|
|
|
|
QVBoxLayout* mainLayout = new QVBoxLayout(mainLayoutWidget);
|
2020-11-16 00:31:28 +01:00
|
|
|
mainLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
mainLayout->addLayout(osButtonRow);
|
2020-11-16 18:01:03 +01:00
|
|
|
//mainLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
2020-11-16 00:31:28 +01:00
|
|
|
mainLayout->addWidget(defaultActionButton);
|
|
|
|
mainLayout->setAlignment(defaultActionButton, Qt::AlignHCenter);
|
|
|
|
mainLayout->addLayout(actionButtonLayout);
|
|
|
|
mainLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
2020-11-16 18:01:03 +01:00
|
|
|
mainLayout->addWidget(versionLabel);
|
|
|
|
|
|
|
|
// power and settings Buttons
|
|
|
|
QWidget* powerActionsLayoutWidget = new QWidget(this);
|
|
|
|
int height = this->height() * 0.25;
|
|
|
|
int width = height / 3;
|
|
|
|
int buttonWidth = width * 0.8;
|
|
|
|
powerActionsLayoutWidget->setGeometry(QRect(this->width() - width * 1.1, this->height() - height + width * 0.1, width, 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);
|
2020-11-16 00:31:28 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-16 18:01:03 +01:00
|
|
|
void LinboGui::startOs() {
|
|
|
|
qDebug() << "starting: " << this->backend->getOperatingSystems()[1]->getName();
|
|
|
|
this->backend->startOs(this->backend->getOperatingSystems()[1]);
|
|
|
|
}
|
|
|
|
|
2020-11-16 00:31:28 +01:00
|
|
|
// prevent closing (eg. by pressing escape key)
|
2020-11-16 18:01:03 +01:00
|
|
|
void LinboGui::done(int r) {
|
2020-11-16 00:31:28 +01:00
|
|
|
Q_UNUSED(r)
|
|
|
|
}
|