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/linbostartactions.cpp
2020-11-19 14:39:32 +01:00

69 lines
2.7 KiB
C++

#include "../headers/linbostartactions.h"
LinboStartActions::LinboStartActions(LinboBackend* backend, LinboOsSelectionRow* osSelectionRow, QWidget *parent) : QWidget(parent)
{
this->backend = backend;
this->osSelectionRow = osSelectionRow;
stackView = new QModernStackedWidget(this);
// Action Buttons
this->buttonWidget = new QWidget();
defaultActionButton = new QModernPushButton(":/svgIcons/startAction.svg", this->buttonWidget);
connect(defaultActionButton, SIGNAL(clicked()), this, SLOT(startOs()));
secondActionButton = new QModernPushButton(":/svgIcons/syncAction.svg", this->buttonWidget);
thirdActionButton = new QModernPushButton(":/svgIcons/resetAction.svg", this->buttonWidget);
this->stackView->addWidget(this->buttonWidget);
// Progress bar
this->progressBarWidget = new QWidget();
progressBar = new QModernProgressBar(this->progressBarWidget);
progressBar->setIndeterminate(true);
this->stackView->addWidget(this->progressBarWidget);
this->stackView->setCurrentWidget(this->buttonWidget);
}
void LinboStartActions::resizeAndPositionAllItems() {
// stack view
this->stackView->setFixedSize(this->size());
// Action buttons
this->buttonWidget->setFixedSize(this->size());
int buttonSpacing = this->height() * 0.1;
int defaultButtonHeight = this->height() * 0.6;
defaultActionButton->setGeometry((this->width() - defaultButtonHeight) / 2, 0,defaultButtonHeight, defaultButtonHeight);
int secondaryButtonHeight = this->height() * 0.3;
secondActionButton->setGeometry(
this->width() / 2 - secondaryButtonHeight - buttonSpacing / 2,
defaultButtonHeight + buttonSpacing,
secondaryButtonHeight,
secondaryButtonHeight
);
thirdActionButton->setGeometry(
this->width() / 2 + buttonSpacing / 2,
defaultButtonHeight + buttonSpacing,
secondaryButtonHeight,
secondaryButtonHeight
);
// Progress bar
this->progressBarWidget->setFixedSize(this->size());
int progressBarHeight = this->height() * 0.1;
int progressBarWidth = this->width() * 0.5;
progressBar->setGeometry((this->width() - progressBarWidth) / 2, (this->height() - progressBarHeight) / 2, progressBarWidth, progressBarHeight);
}
void LinboStartActions::resizeEvent(QResizeEvent *event) {
this->resizeAndPositionAllItems();
QWidget::resizeEvent(event);
}
void LinboStartActions::startOs() {
this->stackView->setCurrentWidgetAnimated(this->progressBarWidget);
this->osSelectionRow->setShowOnlySelectedButton(true);
this->backend->startOs(this->osSelectionRow->getSelectedOs());
//this->progressBar->show();
}