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/linbogui.cpp
Dorian Zedler cacd1f5468
- a few new buttons
- started to implement new backend
2020-11-16 18:01:03 +01:00

142 lines
6 KiB
C++

/****************************************************************************
** 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/linbogui.h"
LinboGui::LinboGui()
{
// 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
// linuxmuster background color: #394f5e
this->setStyleSheet( "QDialog { background: white }");
// create an instance of the old GUI (as a backup)
linboGUIImpl* legacyGui = new linboGUIImpl(this);
legacyGui->setStyleSheet( "QDialog { background: white }");
// create the backend
this->backend = new LinboBackend(this);
qDebug() << this->backend->getOperatingSystems()[0]->getName();
// create the main layout
// OS Buttons
LinboOsSelectButton* osButton = new LinboOsSelectButton(":/svgIcons/ubuntu.svg", nullptr, this);
osButton->setFixedHeight(250);
osButton->setFixedWidth(250);
osButton->setChecked(true);
LinboOsSelectButton* osButton_1 = new LinboOsSelectButton(":/svgIcons/windows.svg", nullptr, this);
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);
connect(defaultActionButton, SIGNAL(clicked()), this, SLOT(startOs()));
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));
QLabel* versionLabel = new QLabel(backend->getConfig()->getVersion());
// main layout
QWidget* mainLayoutWidget = new QWidget(this);
mainLayoutWidget->setGeometry(this->geometry());
QVBoxLayout* mainLayout = new QVBoxLayout(mainLayoutWidget);
mainLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Minimum, QSizePolicy::Expanding));
mainLayout->addLayout(osButtonRow);
//mainLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Minimum, QSizePolicy::Expanding));
mainLayout->addWidget(defaultActionButton);
mainLayout->setAlignment(defaultActionButton, Qt::AlignHCenter);
mainLayout->addLayout(actionButtonLayout);
mainLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Minimum, QSizePolicy::Expanding));
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);
}
void LinboGui::startOs() {
qDebug() << "starting: " << this->backend->getOperatingSystems()[1]->getName();
this->backend->startOs(this->backend->getOperatingSystems()[1]);
}
// prevent closing (eg. by pressing escape key)
void LinboGui::done(int r) {
Q_UNUSED(r)
}