- added some FANCY animations

- booting works now
This commit is contained in:
Dorian Zedler 2020-11-19 14:39:32 +01:00
parent b3400db395
commit b73d45d955
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
29 changed files with 762 additions and 177 deletions

View file

@ -43,6 +43,15 @@ class LinboBackend : public QObject
public:
explicit LinboBackend(QObject *parent = nullptr);
enum LinboState {
Idle,
Root,
Partitioning,
Starting,
Syncing,
Installing
};
LinboConfig* getConfig();
QList<LinboOs*> getOperatingSystems();

View file

@ -24,8 +24,6 @@ class LinboConfig : public QObject
{
Q_OBJECT
public:
explicit LinboConfig(QObject *parent = nullptr);
friend class LinboBackend;
const QString& getServer() const {return this->server;}
@ -50,6 +48,8 @@ public:
const bool& getAutoFormat() {return this->autoFormat;}
protected:
explicit LinboConfig(QObject *parent = nullptr);
void setServer( const QString& server ) {this->server = server;}
void setIpAddress( const QString& ipAddress ) {this->ipAddress = ipAddress;}
void setMacAddress( const QString& macAddress ) {this->macAddress = macAddress;}

View file

@ -25,8 +25,6 @@ class LinboDiskPartition : public QObject
{
Q_OBJECT
public:
explicit LinboDiskPartition(QObject *parent = nullptr);
friend class LinboBackend;
const QString& getPath() const {return this->path;}
@ -36,6 +34,8 @@ public:
const bool& getBootable() const {return this->bootable;}
protected:
explicit LinboDiskPartition(QObject *parent = nullptr);
void setPath( const QString& path ) {this->path = path;}
void setId( const QString& id ) {this->id = id;}
void setFstype( const QString& fstype ) {this->fstype = fstype;}

View file

@ -25,14 +25,14 @@ class LinboImage : public QObject
{
Q_OBJECT
public:
explicit LinboImage(QString name, QObject *parent = nullptr);
friend class LinboBackend;
const QString& getDescription() const {return this->description;}
const QString& getName() const {return this->name;}
protected:
explicit LinboImage(QString name, QObject *parent = nullptr);
void setDescription (const QString& description) {this->description = description;}
void setName(const QString& name) {this->name = name;}

View file

@ -27,8 +27,6 @@ class LinboOs : public QObject
{
Q_OBJECT
public:
explicit LinboOs(QObject *parent = nullptr);
friend class LinboBackend;
const QString& getName() const {return this->name;}
@ -51,6 +49,8 @@ public:
const bool& getHidden() const {return this->hidden;}
protected:
explicit LinboOs(QObject *parent = nullptr);
void setName( const QString& name ) {this->name = name;}
void setDescription ( const QString& description ) {this->description = description;}
void setVersion( const QString& version ) {this->version = version;}

View file

@ -39,9 +39,8 @@ public:
private:
LinboBackend* backend;
LinboStartPage* startPage;
private slots:
void startOs();
};
#endif // LINBOGUI_H

View file

@ -20,18 +20,32 @@
#define LINBOOSSELECTBUTTON_H
#include <QObject>
#include <QWidget>
#include <QButtonGroup>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QEventLoop>
#include "qmodernpushbutton.h"
#include "linboos.h"
class LinboOsSelectButton : public QModernPushButton
class LinboOsSelectButton : public QWidget
{
Q_OBJECT
public:
LinboOsSelectButton(QString icon, LinboOs* os, QWidget* parent = nullptr);
friend class LinboOsSelectionRow;
LinboOs* getOs();
protected:
void resizeEvent(QResizeEvent *event) override;
private:
LinboOsSelectButton(QString icon, LinboOs* os, QButtonGroup* buttonGroup, QWidget* parent = nullptr);
LinboOs* getOs();
void setVisible(bool visible) override;
QModernPushButton* button;
QButtonGroup* buttonGroup;
LinboOs* os;
};

View file

@ -0,0 +1,36 @@
#ifndef LINBOOSSELECTIONROW_H
#define LINBOOSSELECTIONROW_H
#include <QObject>
#include <QWidget>
#include <Q3ButtonGroup>
#include "linbobackend.h"
#include "linboosselectbutton.h"
class LinboOsSelectionRow : public QWidget
{
Q_OBJECT
public:
explicit LinboOsSelectionRow(LinboBackend* backend, QWidget *parent = nullptr);
LinboOs* getSelectedOs();
void setShowOnlySelectedButton(bool value);
protected:
void resizeEvent(QResizeEvent *event) override;
private:
LinboBackend* backend;
QList<LinboOsSelectButton*> osButtons;
QButtonGroup* osButtonGroup;
bool showOnlySelectedButton;
private slots:
void resizeAndPositionAllButtons();
signals:
};
#endif // LINBOOSSELECTIONROW_H

View file

@ -0,0 +1,47 @@
#ifndef LINBOSTARTACTIONS_H
#define LINBOSTARTACTIONS_H
#include <QObject>
#include <QWidget>
#include <QHBoxLayout>
#include <QStackedWidget>
#include "linbobackend.h"
#include "linboosselectionrow.h"
#include "qmodernstackedwidget.h"
#include "qmodernpushbutton.h"
#include "qmodernprogressbar.h"
class LinboStartActions : public QWidget
{
Q_OBJECT
public:
explicit LinboStartActions(LinboBackend* backend, LinboOsSelectionRow* osSelectionRow, QWidget *parent = nullptr);
protected:
void resizeEvent(QResizeEvent *event) override;
private:
LinboBackend* backend;
LinboOsSelectionRow* osSelectionRow;
QModernStackedWidget* stackView;
QWidget* buttonWidget;
QModernPushButton* defaultActionButton;
QModernPushButton* secondActionButton;
QModernPushButton* thirdActionButton;
QWidget* progressBarWidget;
QModernProgressBar* progressBar;
void resizeAndPositionAllItems();
private slots:
void startOs();
signals:
};
#endif // LINBOSTARTACTIONS_H

View file

@ -21,14 +21,32 @@
#include <QObject>
#include <QWidget>
#include <QBoxLayout>
#include <QButtonGroup>
#include <QLabel>
#include <QProgressBar>
#include <QMacStyle>
#include "linboGUIImpl.hh"
#include "linbobackend.h"
#include "linboosselectbutton.h"
#include "qmodernprogressbar.h"
#include "linboosselectionrow.h"
#include "linbostartactions.h"
class linboStartPage : public QWidget
class LinboStartPage : public QWidget
{
Q_OBJECT
public:
explicit linboStartPage(QWidget *parent = nullptr);
explicit LinboStartPage(LinboBackend* backend, QWidget *parent = nullptr);
private:
LinboBackend* backend;
LinboOsSelectionRow* osSelectionRow;
LinboStartActions* startActionsWidget;
private slots:
void startOs();
signals:

View file

@ -0,0 +1,36 @@
#ifndef QMODERNPROGRESSBAR_H
#define QMODERNPROGRESSBAR_H
#include <QProgressBar>
#include <QObject>
#include <QPainter>
#include <QPaintEvent>
#include <QDebug>
#include <QTimer>
#include <QPropertyAnimation>
class QModernProgressBar : public QProgressBar
{
Q_OBJECT
public:
QModernProgressBar(QWidget* parent = nullptr);
void setIndeterminate(bool indeterminate);
bool getIndeterminate();
protected:
QTimer* refreshTimer;
QPropertyAnimation* indeterminateAnimtion;
void paintEvent(QPaintEvent *e) override;
private:
bool indeterminate;
int preIndeterminateValue;
protected slots:
void updateIndeterminate();
};
#endif // QMODERNPROGRESSBAR_H

View file

@ -26,7 +26,11 @@
#include <QResizeEvent>
#include <QPropertyAnimation>
#include <QString>
#include <QStringList>
#include <QDebug>
#include <QEventLoop>
#include "qmodernpushbuttonoverlay.h"
class QModernPushButton : public QAbstractButton
{
@ -34,6 +38,9 @@ class QModernPushButton : public QAbstractButton
public:
QModernPushButton(QString icon, QWidget* parent = nullptr);
void setVisible(bool visible) override;
void setVisible(bool visible, bool animated, bool asynchronos = true);
protected:
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *e) override;
@ -45,18 +52,11 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) override;
private:
QSvgWidget* svgWidget;
QSvgWidget* overlayHoveredWidget;
QGraphicsOpacityEffect* overlayHoveredEffect;
QSvgWidget* overlayPressedWidget;
QGraphicsOpacityEffect* overlayPressedEffect;
QSvgWidget* overlayCheckedWidget;
QGraphicsOpacityEffect* overlayCheckedEffect;
QGraphicsOpacityEffect* opacityEffect;
QList<QModernPushButtonOverlay*> overlays;
private slots:
void handleToggled(bool checked);
};
#endif // QMODERNPUSHBUTTON_H

View file

@ -0,0 +1,38 @@
#ifndef QMODERNPUSHBUTTONOVERLAY_H
#define QMODERNPUSHBUTTONOVERLAY_H
#include <QObject>
#include <QSvgWidget>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
#include <QDebug>
// This class automatically enables and disabled the QGraphicsOpacityEffect as needed, to prevent
// "QPainter::begin: A paint device can only be painted by one painter at a time." Error messages
// When applying a QGraphicalEffect to the parent
class QModernPushButtonOverlay : public QObject
{
Q_OBJECT
public:
friend class QModernPushButton;
private:
explicit QModernPushButtonOverlay(QWidget* overlayWidget, QObject *parent = nullptr);
QWidget* widget;
QGraphicsOpacityEffect* effect;
QPropertyAnimation* animation;
void setAnimationDuration(int duration);
void setVisible(bool visible);
void setEffectEnabled(bool enabled);
private slots:
void handleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State);
signals:
};
#endif // QMODERNPUSHBUTTONOVERLAY_H

View file

@ -0,0 +1,26 @@
#ifndef QMODERNSTACKEDWIDGET_H
#define QMODERNSTACKEDWIDGET_H
#include <QStackedWidget>
#include <QObject>
#include <QtDebug>
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>
class QModernStackedWidget : public QStackedWidget
{
Q_OBJECT
public:
QModernStackedWidget(QWidget* parent = nullptr);
void setCurrentWidgetAnimated(QWidget* widget);
private:
QWidget* newWidget;
QPropertyAnimation* opacityAnimation;
private slots:
void handleAnimationFinished();
};
#endif // QMODERNSTACKEDWIDGET_H

View file

@ -5,6 +5,9 @@ CFLAGS += -DQWS -static
QT += \
qt3support \
widgets \
widgets \
widgets \
widgets \
svg
QMAKE_POST_LINK=strip $(TARGET)
@ -42,8 +45,13 @@ HEADERS += \
headers/backend/linbobackend.h \
headers/linbogui.h \
headers/linboosselectbutton.h \
headers/linboosselectionrow.h \
headers/linbostartactions.h \
headers/linbostartpage.h \
headers/qmodernpushbutton.h
headers/qmodernprogressbar.h \
headers/qmodernpushbutton.h \
headers/qmodernpushbuttonoverlay.h \
headers/qmodernstackedwidget.h
SOURCES += \
sources/backend/linboconfig.cpp \
@ -70,9 +78,14 @@ SOURCES += \
sources/backend/linbobackend.cpp \
sources/linbogui.cpp \
sources/linboosselectbutton.cpp \
sources/linboosselectionrow.cpp \
sources/linbostartactions.cpp \
sources/linbostartpage.cpp \
sources/main.cpp \
sources/qmodernpushbutton.cpp
sources/qmodernprogressbar.cpp \
sources/qmodernpushbutton.cpp \
sources/qmodernpushbuttonoverlay.cpp \
sources/qmodernstackedwidget.cpp
FORMS += \
forms/linboConsole.ui \

View file

@ -21,7 +21,7 @@
<file>svgIcons/startAction.svg</file>
<file>svgIcons/syncAction.svg</file>
<file>svgIcons/resetAction.svg</file>
<file>svgIcons/overlayNormal.svg</file>
<file>svgIcons/overlayHovered.svg</file>
<file>svgIcons/overlayPressed.svg</file>
<file>svgIcons/shutdownAction.svg</file>
<file>svgIcons/rebootAction.svg</file>

View file

@ -43,20 +43,20 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1245"
inkscape:window-height="1376"
inkscape:window-width="1850"
inkscape:window-height="1016"
id="namedview6"
showgrid="false"
inkscape:zoom="1"
inkscape:cx="256"
inkscape:cx="46"
inkscape:cy="256"
inkscape:window-x="70"
inkscape:window-y="27"
inkscape:window-maximized="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4"
inkscape:document-rotation="0" />
<path
d="m 208.14107,253.45876 c 1.89377,8.20136 -7.10331,14.43455 -14.10234,10.05936 l -23.86876,-14.91501 -29.8049,47.69639 c -7.7836,12.45408 1.21289,28.70034 15.8918,28.70034 h 30.46174 c 3.88301,0 7.03125,3.14823 7.03125,7.03122 v 23.43745 c 0,3.88301 -3.14824,7.03125 -7.03125,7.03125 h -30.40138 c -44.14104,0 -71.075433,-48.66085 -47.70003,-86.06233 l 29.77852,-47.68818 -23.86231,-14.9109 c -7.07871,-4.42206 -5.25351,-15.2115 2.85879,-17.08473 l 64.59202,-14.91207 c 5.04552,-1.16486 10.07873,1.98105 11.24357,7.02537 z m 57.75064,-107.17651 24.19279,38.71632 -23.87112,14.91618 c -7.06113,4.41091 -5.27343,15.20679 2.85879,17.08473 l 64.59204,14.91207 c 5.08125,1.17129 10.08692,-2.01444 11.24355,-7.02537 l 14.91213,-64.59186 c 1.87323,-8.1117 -7.0254,-14.48376 -14.10235,-10.05936 l -23.84006,14.89686 -24.17755,-38.71987 c -21.98498,-35.175491 -73.36471,-35.256361 -95.40007,0 l -10.5252,16.85506 c -2.05663,3.29296 -1.05468,7.62948 2.23829,9.68728 l 19.87443,12.41892 c 3.29296,2.05781 7.63125,1.05644 9.68907,-2.23651 l 10.52401,-16.84157 c 7.44846,-11.91854 24.59359,-11.52889 31.79125,-0.0135 z m 125.48796,130.15518 -16.12208,-25.81928 c -2.05722,-3.29472 -6.39609,-4.29726 -9.69024,-2.23887 l -19.84044,12.39783 c -3.29298,2.05781 -4.29492,6.39549 -2.23711,9.68904 l 16.15078,25.84682 c 7.76778,12.42831 -1.20526,28.68744 -15.9,28.68744 H 287.49993 V 296.8866 c 0,-8.32791 -10.10274,-12.52907 -16.00373,-6.62868 l -46.87503,46.86376 c -3.66152,3.66093 -3.66152,9.59706 0,13.25799 l 46.87503,46.86845 c 5.86056,5.86171 16.00373,1.75546 16.00373,-6.62987 v -28.11849 h 56.17972 c 44.10588,0 71.09475,-48.63097 47.70002,-86.06233 z"
d="m 205.38458,253.6619 c 2.01848,8.74144 -7.57108,15.38509 -15.03101,10.72179 L 164.913,248.4865 133.14539,299.32379 c -8.29617,13.27421 1.29276,30.59032 16.93831,30.59032 h 32.4677 c 4.13872,0 7.49428,3.35554 7.49428,7.49424 v 24.98085 c 0,4.13871 -3.35556,7.49427 -7.49428,7.49427 h -32.40337 c -47.04782,0 -75.755889,-51.86526 -50.841165,-91.72971 L 131.04635,227.32522 105.61266,211.4324 c -7.544855,-4.71326 -5.59946,-16.2132 3.04705,-18.20979 l 68.84553,-15.89406 c 5.37778,-1.24157 10.74244,2.11151 11.98399,7.48801 z m 61.55363,-114.2343 25.78594,41.26587 -25.44308,15.89844 c -7.52612,4.70137 -5.6207,16.20819 3.04704,18.20979 l 68.84556,15.89406 c 5.41586,1.24842 10.75117,-2.14709 11.98396,-7.488 l 15.89413,-68.84537 c 1.99658,-8.64587 -7.48804,-15.43754 -15.03102,-10.72179 l -25.40998,15.87785 -25.76969,-41.26965 c -23.43274,-37.491868 -78.19593,-37.578064 -101.68236,0 l -11.2183,17.965 c -2.19207,3.50981 -1.12414,8.13189 2.38568,10.32521 l 21.1832,13.23673 c 3.50981,2.19332 8.13379,1.12601 10.32712,-2.38379 l 11.21704,-17.95062 c 7.93895,-12.7034 26.21312,-12.2881 33.88476,-0.0144 z m 133.7516,138.72616 -17.18375,-27.51953 c -2.19269,-3.51168 -6.81728,-4.58024 -10.32836,-2.3863 l -21.14697,13.21425 c -3.50983,2.19332 -4.57775,6.81664 -2.38443,10.32708 l 17.21434,27.54889 c 8.2793,13.24674 -1.28463,30.57656 -16.94705,30.57656 h -59.94421 v -29.96516 c 0,-8.87632 -10.76803,-13.35413 -17.05761,-7.06519 l -49.96184,49.94983 c -3.90264,3.90201 -3.90264,10.22905 0,14.13106 l 49.96184,49.95483 c 6.24649,6.24772 17.05761,1.87106 17.05761,-7.06646 v -29.97015 h 59.87927 c 47.01034,0 75.77648,-51.83342 50.84116,-91.72971 z"
id="path2"
style="fill:#000000;fill-opacity:1;stroke-width:10;stroke:#ffffff;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" />
style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:5.32926;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -81,6 +81,11 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent)
// load global config
QStringList command;
this->process = new QProcess();
/* connect( process, SIGNAL(readyReadStandardOutput()),
this, SLOT(readFromStdout()) );
connect( process, SIGNAL(readyReadStandardError()),
this, SLOT(readFromStderr()) );
*/
// client ip
command = LINBO_CMD("ip");
@ -148,7 +153,6 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent)
// - Public functions -
// --------------------
void LinboBackend::executeAutostart() {
}
@ -207,6 +211,8 @@ void LinboBackend::executeCommand(QStringList commandArgs, bool waitForFinished)
qDebug() << "Executing: " << command << " " << commandArgs.join(" ");
return;
process->start(command, commandArgs);
process->waitForStarted();

View file

@ -1504,7 +1504,7 @@ void linboGUIImpl::resetButtons() {
}
void linboGUIImpl::executeAutostart() {
return; // autostart is handles by new GUI
// if there is "autopartition" set, execute the hidden button
if( autopartition )
autopartition->lclicked();

View file

@ -29,111 +29,18 @@ LinboGui::LinboGui()
this->setFixedHeight(QApplication::desktop()->screenGeometry().height());
this->setFixedWidth(QApplication::desktop()->screenGeometry().width());
// black bakground
qDebug() << this->geometry();
// white 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 start page
this->startPage = new LinboStartPage(this->backend, this);
// 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)

View file

@ -18,12 +18,28 @@
#include "linboosselectbutton.h"
LinboOsSelectButton::LinboOsSelectButton(QString icon, LinboOs* os, QWidget* parent) : QModernPushButton(icon, parent)
LinboOsSelectButton::LinboOsSelectButton(QString icon, LinboOs* os, QButtonGroup* buttonGroup, QWidget* parent) : QWidget(parent)
{
this->setCheckable(true);
this->buttonGroup = buttonGroup;
this->button = new QModernPushButton(icon, this);
this->button->setCheckable(true);
this->buttonGroup->addButton(this->button);
this->os = os;
QWidget::setVisible(true);
}
LinboOs* LinboOsSelectButton::getOs() {
return this->os;
}
void LinboOsSelectButton::setVisible(bool visible) {
this->button->setVisible(visible, true, true);
}
void LinboOsSelectButton::resizeEvent(QResizeEvent *event) {
qDebug() << "Resize: width: " << event->size().width() << " height: " << event->size().height();
this->button->setGeometry(QRect(event->size().width() / 2 - event->size().height() / 2 , 0, event->size().height(), event->size().height()));
}

View file

@ -0,0 +1,71 @@
#include "../headers/linboosselectionrow.h"
LinboOsSelectionRow::LinboOsSelectionRow(LinboBackend* backend, QWidget *parent) : QWidget(parent)
{
this->backend = backend;
this->showOnlySelectedButton = false;
this->osButtonGroup = new QButtonGroup();
this->osButtonGroup->setExclusive(true);
for(LinboOs* os : backend->getOperatingSystems()) {
LinboOsSelectButton* osButton = new LinboOsSelectButton("/icons/" + os->getIconName(), os, this->osButtonGroup, this);
this->osButtons.append(osButton);
}
// TODO: figure out by autostart
this->osButtonGroup->buttons()[0]->setChecked(true);
}
void LinboOsSelectionRow::resizeAndPositionAllButtons() {
qDebug() << "Resizing all Buttons";
if(this->showOnlySelectedButton) {
int buttonWidth = this->width() / this->osButtonGroup->buttons().length();
for(int i = 0; i < this->osButtons.length(); i++) {
if(!this->osButtons[i]->button->isChecked())
this->osButtons[i]->hide();
else {
QPropertyAnimation* moveAnimation = new QPropertyAnimation(this->osButtons[i], "geometry");
moveAnimation->setEasingCurve(QEasingCurve::InOutQuad);
moveAnimation->setDuration(400);
moveAnimation->setStartValue(this->osButtons[i]->geometry());
moveAnimation->setEndValue(QRect(buttonWidth / 2, 0, buttonWidth, this->height()));
moveAnimation->start();
}
}
}
else {
int buttonWidth = this->width() / this->osButtonGroup->buttons().length();
for(int i = 0; i < this->osButtons.length(); i++) {
this->osButtons[i]->setGeometry(buttonWidth * i, 0, buttonWidth, this->height());
}
}
}
LinboOs* LinboOsSelectionRow::getSelectedOs() {
for(LinboOsSelectButton* button : this->osButtons) {
if(button->button->isChecked())
return button->getOs();
}
return nullptr;
}
void LinboOsSelectionRow::setShowOnlySelectedButton(bool value) {
// find selected button
// set its x so it is in the middle (animated)
// set Opacity of all other buttons to 0 (animated)
if(value == this->showOnlySelectedButton)
return;
this->showOnlySelectedButton = value;
this->resizeAndPositionAllButtons();
}
void LinboOsSelectionRow::resizeEvent(QResizeEvent *event) {
QWidget::resizeEvent(event);
qDebug() << "RESIZE EVENT: width: " << width() << " height: " << height();
this->resizeAndPositionAllButtons();
}

View file

@ -0,0 +1,69 @@
#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();
}

View file

@ -18,7 +18,92 @@
#include "../headers/linbostartpage.h"
linboStartPage::linboStartPage(QWidget *parent) : QWidget(parent)
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);*/
}

View file

@ -16,7 +16,6 @@
int main( int argc, char* argv[] )
{
QApplication linboGuiApp( argc, argv );
QWSServer* wsServer = QWSServer::instance();

View file

@ -0,0 +1,74 @@
#include "../headers/qmodernprogressbar.h"
QModernProgressBar::QModernProgressBar(QWidget* parent) : QProgressBar(parent)
{
this->refreshTimer = new QTimer();
this->refreshTimer->setSingleShot(false);
this->refreshTimer->setInterval(400);
connect(this->refreshTimer, SIGNAL(timeout()), this, SLOT(updateIndeterminate()));
this->indeterminateAnimtion = new QPropertyAnimation(this, "value");
this->indeterminateAnimtion->setDuration(2000);
this->indeterminateAnimtion->setStartValue(0);
this->indeterminateAnimtion->setEndValue(1000);
this->indeterminateAnimtion->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
this->indeterminateAnimtion->setLoopCount(-1);
this->setValue(0);
}
void QModernProgressBar::setIndeterminate(bool indeterminate) {
if(this->indeterminate == indeterminate)
return;
this->indeterminate = indeterminate;
if(this->indeterminate) {
this->preIndeterminateValue = this->value();
// finer steps, so the Animation is fluid
this->setMinimum(0);
this->setMaximum(1000);
this->indeterminateAnimtion->start();
}
else {
// reset minimum and maximum
this->setMinimum(0);
this->setMaximum(100);
this->setValue(this->preIndeterminateValue);
this->indeterminateAnimtion->stop();
}
}
bool QModernProgressBar::getIndeterminate() {
return this->indeterminate;
}
void QModernProgressBar::updateIndeterminate() {
qDebug() << "update indeterminate";
}
void QModernProgressBar::paintEvent(QPaintEvent *e) {
QPainter painter;
painter.begin(this);
// background
painter.fillRect(e->rect(), QColor("#c7c7c7"));
// progress
if(this->indeterminate) {
int maximum = this->maximum() / 2;
if(this->value() <= maximum)
// for the first half -> fill from left
painter.fillRect(QRect(0,0, e->rect().width() * double(double(this->value()) / double(maximum)), e->rect().height()), QColor(0,0,0));
else
// for the second half -> empty from right
painter.fillRect(QRect(e->rect().width() * double(double(this->value()- (maximum)) / double(maximum)),0, e->rect().width(), e->rect().height()), QColor(0,0,0));
}
else
painter.fillRect(QRect(0,0, e->rect().width() * float(float(this->value()) / float(this->maximum())), e->rect().height()), QColor(0,0,0));
painter.end();
QWidget::paintEvent(e);
}

View file

@ -20,60 +20,66 @@
QModernPushButton::QModernPushButton(QString icon, QWidget* parent) : QAbstractButton(parent)
{
this->svgWidget = new QSvgWidget(this);
this->svgWidget->load(QString(icon));
this->setMouseTracking(true);
this->overlayHoveredWidget = new QSvgWidget(this->svgWidget);
this->overlayHoveredEffect = new QGraphicsOpacityEffect(this);
this->overlayHoveredEffect->setOpacity(0);
this->overlayHoveredWidget->setGraphicsEffect(this->overlayHoveredEffect);
QStringList overlays;
overlays.append(icon);
overlays.append(":svgIcons/overlayHovered.svg");
overlays.append(":svgIcons/overlayPressed.svg");
overlays.append(":svgIcons/overlayChecked.svg");
this->overlayPressedWidget = new QSvgWidget(this->svgWidget);
this->overlayPressedWidget->load(QString(":svgIcons/overlayPressed.svg"));
this->overlayPressedEffect = new QGraphicsOpacityEffect(this);
this->overlayPressedEffect->setOpacity(0);
this->overlayPressedWidget->setGraphicsEffect(this->overlayPressedEffect);
for(QString overlayName : overlays) {
this->overlayCheckedWidget = new QSvgWidget(this->svgWidget);
this->overlayCheckedWidget->load(QString(":svgIcons/overlayChecked.svg"));
this->overlayCheckedEffect = new QGraphicsOpacityEffect(this);
this->overlayCheckedEffect->setOpacity(0);
this->overlayCheckedWidget->setGraphicsEffect(this->overlayCheckedEffect);
QSvgWidget* overlayWidget = new QSvgWidget(this);
overlayWidget->load(overlayName);
QModernPushButtonOverlay* overlay = new QModernPushButtonOverlay(overlayWidget, this);
this->overlays.append(overlay);
}
this->overlays[0]->setVisible(true);
this->overlays[1]->setAnimationDuration(200);
this->overlays[2]->setAnimationDuration(100);
connect(this, SIGNAL(toggled(bool)), this, SLOT(handleToggled(bool)));
}
void QModernPushButton::handleToggled(bool checked) {
int startValue = 1;
if(checked) {
startValue = 0;
}
QPropertyAnimation *animation = new QPropertyAnimation(this->overlayCheckedEffect, "opacity");
animation->setDuration(400);
animation->setStartValue(startValue);
animation->setEndValue(1-startValue);
animation->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
animation->start();
if(this->overlays.length() >= 4)
this->overlays[3]->setVisible(checked);
}
void QModernPushButton::resizeEvent(QResizeEvent *event) {
this->svgWidget->setGeometry(QRect(0, 0, event->size().width(), event->size().height()));
// make border width match button size
QFile file(":svgIcons/overlayNormal.svg");
file.open(QFile::ReadOnly);
QString overlayNormalString = file.readAll();
//QFile file(":svgIcons/overlayNormal.svg");
//file.open(QFile::ReadOnly);
//QString overlayNormalString = file.readAll();
//overlayNormalString.replace("stroke-width:15px", "stroke-width:" + QString::number(500/event->size().width() * 5) + "px");
this->overlayHoveredWidget->load(overlayNormalString.toUtf8());
this->overlayHoveredWidget->setGeometry(QRect(0, 0, event->size().width(), event->size().height()));
//this->overlayHoveredWidget->load(overlayNormalString.toUtf8());
this->overlayCheckedWidget->setGeometry(QRect(0, 0, event->size().width(), event->size().height()));
for(QModernPushButtonOverlay* overlay : this->overlays) {
overlay->widget->setGeometry(QRect(0, 0, event->size().width(), event->size().height()));
}
}
void QModernPushButton::setVisible(bool visible, bool animated, bool asynchronos) {
if(this->isVisible() == visible)
return;
if(animated) {
this->overlays[0]->setVisible(visible);
}
else {
QWidget::setVisible(visible);
}
}
void QModernPushButton::setVisible(bool visible) {
QAbstractButton::setVisible(visible);
}
void QModernPushButton::paintEvent(QPaintEvent *e) {
Q_UNUSED(e)
QWidget::paintEvent(e);
}
@ -89,21 +95,26 @@ void QModernPushButton::keyReleaseEvent(QKeyEvent *e) {
}
void QModernPushButton::enterEvent(QEvent *e) {
this->overlayHoveredEffect->setOpacity(1);
if(this->overlays.length() >= 2)
this->overlays[1]->setVisible(true);
return QAbstractButton::enterEvent(e);
}
void QModernPushButton::leaveEvent(QEvent *e) {
this->overlayHoveredEffect->setOpacity(0);
if(this->overlays.length() >= 2)
this->overlays[1]->setVisible(false);
return QAbstractButton::leaveEvent(e);
}
void QModernPushButton::mousePressEvent(QMouseEvent *e) {
this->overlayPressedEffect->setOpacity(1);
if(this->overlays.length() >= 3)
this->overlays[2]->setVisible(true);
return QAbstractButton::mousePressEvent(e);
}
void QModernPushButton::mouseReleaseEvent(QMouseEvent *e) {
this->overlayPressedEffect->setOpacity(0);
if(this->overlays.length() >= 3)
this->overlays[2]->setVisible(false);
return QAbstractButton::mouseReleaseEvent(e);
}

View file

@ -0,0 +1,59 @@
#include "../headers/qmodernpushbuttonoverlay.h"
QModernPushButtonOverlay::QModernPushButtonOverlay(QWidget* overlayWidget, QObject *parent) : QObject(parent)
{
this->widget = overlayWidget;
this->widget->setVisible(false);
this->effect = new QGraphicsOpacityEffect(overlayWidget);
this->effect->setOpacity(0);
this->effect->setEnabled(false);
this->widget->setGraphicsEffect(this->effect);
this->animation = new QPropertyAnimation(this->effect, "opacity");
this->animation->setDuration(400);
this->animation->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
this->setEffectEnabled(false);
connect(this->animation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), this, SLOT(handleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
}
void QModernPushButtonOverlay::setAnimationDuration(int duration) {
this->animation->setDuration(duration);
}
void QModernPushButtonOverlay::setVisible(bool visible) {
if(this->widget->isVisible() == visible)
return;
int startValue = visible ? 0:1;
this->animation->setStartValue(startValue);
this->animation->setEndValue(1-startValue);
this->animation->start();
}
void QModernPushButtonOverlay::setEffectEnabled(bool enabled) {
if(enabled) {
this->effect->setEnabled(true);
this->widget->setVisible(true);
}
else {
this->widget->setVisible(this->effect->opacity() > 0);
this->effect->setEnabled(false);
}
}
void QModernPushButtonOverlay::handleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State) {
switch (newState) {
case QAbstractAnimation::Running:
this->setEffectEnabled(true);
break;
case QAbstractAnimation::Stopped:
this->setEffectEnabled(false);
break;
default:
break;
}
}

View file

@ -0,0 +1,52 @@
#include "../headers/qmodernstackedwidget.h"
QModernStackedWidget::QModernStackedWidget(QWidget* parent) : QStackedWidget(parent)
{
opacityAnimation = new QPropertyAnimation();
opacityAnimation->setPropertyName("opacity");
opacityAnimation->setEasingCurve(QEasingCurve::InOutQuad);
opacityAnimation->setDuration(400);
opacityAnimation->setLoopCount(1);
connect(opacityAnimation, SIGNAL(finished()), this, SLOT(handleAnimationFinished()));
}
void QModernStackedWidget::setCurrentWidgetAnimated(QWidget* widget) {
if(widget == nullptr)
return;
this->newWidget = widget;
// fade old widget out
QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this);
this->currentWidget()->setGraphicsEffect(opacityEffect);
opacityEffect->setOpacity(1);
opacityAnimation->setStartValue(1);
opacityAnimation->setEndValue(0);
opacityAnimation->setTargetObject(opacityEffect);
opacityAnimation->start();
}
void QModernStackedWidget::handleAnimationFinished() {
// disable graphical effect to prevent errors
this->currentWidget()->graphicsEffect()->setEnabled(false);
if(this->newWidget == nullptr) {
return;
}
// hide new widget
QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this);
this->newWidget->setGraphicsEffect(opacityEffect);
opacityEffect->setOpacity(0);
// set new widget
this->setCurrentWidget(this->newWidget);
this->newWidget = nullptr;
// fade new widget in
opacityAnimation->setTargetObject(opacityEffect);
opacityAnimation->setStartValue(0);
opacityAnimation->setEndValue(1);
opacityAnimation->start();
}