diff --git a/build_qt b/build_qt index 774ad86..5229807 100755 --- a/build_qt +++ b/build_qt @@ -14,13 +14,14 @@ -opensource \ -release \ -static \ + -fontconfig \ + -freetype \ -no-accessibility \ -no-xmlpatterns \ -no-phonon \ -no-phonon-backend \ -no-webkit \ -no-exceptions \ - -no-svg \ -no-script \ -no-scripttools \ -no-nis \ @@ -38,7 +39,6 @@ -no-largefile \ -no-xinerama \ -no-xrender \ - -no-freetype \ -no-opengl \ -no-glib \ -nomake examples \ diff --git a/headers/backend/linbobackend.h b/headers/backend/linbobackend.h index 4184def..65434b2 100644 --- a/headers/backend/linbobackend.h +++ b/headers/backend/linbobackend.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -30,6 +32,7 @@ #include #include +#include "linbologger.h" #include "linboconfig.h" #include "linboos.h" #include "linboimage.h" @@ -42,12 +45,15 @@ class LinboBackend : public QObject Q_OBJECT Q_PROPERTY(LinboBackend::LinboState state READ getState NOTIFY stateChanged) Q_PROPERTY(LinboOs* currentOs READ getCurrentOs WRITE setCurrentOs NOTIFY currentOsChanged) + Q_PROPERTY(double autostartTimeoutProgress READ getAutostartTimeoutProgress NOTIFY autostartTimeoutProgressChanged) + Q_PROPERTY(int autostartTimeoutRemainingSeconds READ getAutostartTimeoutRemainingSeconds NOTIFY autostartTimeoutProgressChanged) public: explicit LinboBackend(QObject *parent = nullptr); enum LinboState { Initializing, + Autostarting, Idle, Starting, Syncing, @@ -59,10 +65,13 @@ public: }; LinboState getState(); + LinboLogger* getLogger(); LinboConfig* getConfig(); QList getOperatingSystems(); LinboOs* getCurrentOs(); void setCurrentOs(LinboOs* os); + double getAutostartTimeoutProgress(); + int getAutostartTimeoutRemainingSeconds(); protected: bool read_pair(ifstream* input, QString& key, QString& value); @@ -73,11 +82,16 @@ protected: private: LinboState state; + LinboLogger* logger; LinboConfig* config; QStringList linboCommandCache; QList operatingSystems; QList diskPartitions; + QElapsedTimer* autostartElapsedTimer; + QTimer* autostartTimer; + QTimer* autostartRemainingTimeRefreshTimer; + LinboOs* currentOs; QString const linboCmdCommand = "linbo_cmd"; @@ -126,6 +140,7 @@ public slots: private slots: void executeAutostart(); + void handleAutostartTimerTimeout(); void readFromStdout(); void readFromStderr(); diff --git a/headers/backend/linbologger.h b/headers/backend/linbologger.h new file mode 100644 index 0000000..2fafbc7 --- /dev/null +++ b/headers/backend/linbologger.h @@ -0,0 +1,47 @@ +#ifndef LINBOLOGGER_H +#define LINBOLOGGER_H + +#include +#include +#include + +class LinboLogger : public QObject +{ + Q_OBJECT + Q_PROPERTY(LinboLog latestLog READ getLatestLog NOTIFY latestLogChanged) +public: + + friend class LinboBackend; + + enum LinboLogType { + UnknownLogType = -1, + StdOut, + StdErr, + LinboGuiInfo, + LinboGuiError + }; + + typedef struct { + QString message; + LinboLogType type; + QDateTime time; + } LinboLog; + + const LinboLog& getLatestLog(); + + QString logTypeToString(LinboLogType logType); + + +private: + explicit LinboLogger(QObject *parent = nullptr); + + void log(QString logText, LinboLogType logType); + + QList logHistory; + +signals: + void latestLogChanged(const LinboLogger::LinboLog& latestLog); + +}; + +#endif // LINBOLOGGER_H diff --git a/headers/backend/linboos.h b/headers/backend/linboos.h index 24afa7e..7261175 100644 --- a/headers/backend/linboos.h +++ b/headers/backend/linboos.h @@ -66,7 +66,6 @@ public: } LinboOsStartAction startActionFromString(const QString& name) const { - qDebug() << "default action name is: " << name; if(name == "start") return StartOs; else if(name == "sync") diff --git a/headers/linbogui.h b/headers/linbogui.h index 1b15ee2..68d8b81 100644 --- a/headers/linbogui.h +++ b/headers/linbogui.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "linboGUIImpl.hh" #include "linbostartpage.h" diff --git a/headers/linbostartactions.h b/headers/linbostartactions.h index b8d83de..e20c025 100644 --- a/headers/linbostartactions.h +++ b/headers/linbostartactions.h @@ -6,8 +6,10 @@ #include #include #include +#include #include "linbobackend.h" +#include "linbologger.h" #include "linboosselectionrow.h" #include "qmodernstackedwidget.h" #include "qmodernpushbutton.h" @@ -35,6 +37,8 @@ private: QWidget* progressBarWidget; QModernProgressBar* progressBar; + QFont logFont; + QLabel* logLabel; bool inited; @@ -42,6 +46,7 @@ private slots: void resizeAndPositionAllItems(); void handleCurrentOsChanged(LinboOs* newOs); void handleLinboStateChanged(LinboBackend::LinboState newState); + void handleLatestLogChanged(const LinboLogger::LinboLog& latestLog); signals: void selectedOsChanged(); diff --git a/linboGUI.pro b/linboGUI.pro index 6454074..1c6b028 100644 --- a/linboGUI.pro +++ b/linboGUI.pro @@ -25,6 +25,7 @@ HEADERS += \ headers/backend/linboconfig.h \ headers/backend/linbodiskpartition.h \ headers/backend/linboimage.h \ + headers/backend/linbologger.h \ headers/backend/linboos.h \ headers/legacy/image_description.hh \ headers/legacy/linboConsoleImpl.hh \ @@ -57,6 +58,7 @@ SOURCES += \ sources/backend/linboconfig.cpp \ sources/backend/linbodiskpartition.cpp \ sources/backend/linboimage.cpp \ + sources/backend/linbologger.cpp \ sources/backend/linboos.cpp \ sources/legacy/image_description.cc \ sources/legacy/linboConsoleImpl.cc \ @@ -105,3 +107,9 @@ FORMS += \ RESOURCES += \ resources/linbo.qrc + +DISTFILES += \ + resources/fonts/Segoe UI Bold Italic.ttf \ + resources/fonts/Segoe UI Bold.ttf \ + resources/fonts/Segoe UI Italic.ttf \ + resources/fonts/Segoe UI.ttf diff --git a/resources/fonts/Segoe UI Italic.ttf b/resources/fonts/Segoe UI Italic.ttf new file mode 100644 index 0000000..07fdf85 Binary files /dev/null and b/resources/fonts/Segoe UI Italic.ttf differ diff --git a/resources/fonts/SegoeUI.eot b/resources/fonts/SegoeUI.eot new file mode 100644 index 0000000..c29e0de Binary files /dev/null and b/resources/fonts/SegoeUI.eot differ diff --git a/resources/fonts/SegoeUI.svg b/resources/fonts/SegoeUI.svg new file mode 100644 index 0000000..07bc4bf --- /dev/null +++ b/resources/fonts/SegoeUI.svg @@ -0,0 +1,1520 @@ + + + + +Created by FontForge 20170924 at Wed Jun 28 12:30:21 2006 + By www-data +(c) 2006 Microsoft Corporation. All Rights Reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/fonts/SegoeUI.ttf b/resources/fonts/SegoeUI.ttf new file mode 100644 index 0000000..074dde6 Binary files /dev/null and b/resources/fonts/SegoeUI.ttf differ diff --git a/resources/fonts/SegoeUI.woff2 b/resources/fonts/SegoeUI.woff2 new file mode 100644 index 0000000..bd7253b Binary files /dev/null and b/resources/fonts/SegoeUI.woff2 differ diff --git a/resources/linbo.qrc b/resources/linbo.qrc index be7e1a6..2a7d248 100644 --- a/resources/linbo.qrc +++ b/resources/linbo.qrc @@ -26,5 +26,6 @@ svgIcons/shutdownAction.svg svgIcons/rebootAction.svg svgIcons/settingsAction.svg + fonts/SegoeUI.ttf diff --git a/sources/backend/linbobackend.cpp b/sources/backend/linbobackend.cpp index 3b0a253..60c0707 100644 --- a/sources/backend/linbobackend.cpp +++ b/sources/backend/linbobackend.cpp @@ -25,11 +25,18 @@ using namespace std; LinboBackend::LinboBackend(QObject *parent) : QObject(parent) { this->setState(Initializing); + this->logger = new LinboLogger(this); this->config = new LinboConfig(this); + this->autostartTimer = new QTimer(this); + this->autostartTimer->setSingleShot(true); + this->autostartRemainingTimeRefreshTimer = new QTimer(this); + this->autostartRemainingTimeRefreshTimer->setSingleShot(true); + this->autostartRemainingTimeRefreshTimer->setInterval(10); + this->autostartElapsedTimer = new QElapsedTimer(); this->currentOs = nullptr; // read start.conf - qDebug() << "Starting to parse start.conf"; + this->logger->log("Starting to parse start.conf", LinboLogger::LinboGuiInfo); ifstream input; input.open( "start.conf", ios_base::in ); @@ -83,12 +90,8 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent) } input.close(); - // default select first OS - if(this->operatingSystems.length() > 0 && this->currentOs == nullptr) - this->currentOs = this->operatingSystems[0]; - - qDebug() << "Finished parsing start.conf"; - qDebug() << "Loading global configuration"; + this->logger->log("Finished to parsing start.conf", LinboLogger::LinboGuiInfo); + this->logger->log("Loading global configuration", LinboLogger::LinboGuiInfo); // load global config QStringList command; @@ -130,8 +133,18 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent) hd.remove( *removePartition ); this->config->setHddSize(this->executeCommand(true, "size", hd)); - qDebug() << "Finished loading global configuration"; - this->setState(Idle); + + this->logger->log("Finished loading global configuration", LinboLogger::LinboGuiInfo); + + // default select first OS if no other OS has been selected yet + if(this->operatingSystems.length() > 0 && this->currentOs == nullptr) + this->currentOs = this->operatingSystems[0]; + + // triger autostart + if(this->currentOs->getAutostart()) + this->executeAutostart(); + else + this->setState(Idle); } // -------------------- @@ -139,6 +152,11 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent) // -------------------- void LinboBackend::executeAutostart() { + this->autostartTimer->setInterval(this->currentOs->getAutostartTimeout() * 1000); + this->autostartElapsedTimer->restart(); +} + +void handleAutostartTimerTimeout() { } @@ -159,6 +177,7 @@ bool LinboBackend::startCurrentOs() { this->setState(Starting); return true; + this->executeCommand( false, "start", @@ -284,6 +303,10 @@ bool LinboBackend::updateLinbo() { return true; } +LinboLogger* LinboBackend::getLogger() { + return this->logger; +} + LinboConfig* LinboBackend::getConfig() { return this->config; } @@ -304,13 +327,22 @@ void LinboBackend::setCurrentOs(LinboOs* os) { emit this->currentOsChanged(os); } + +double LinboBackend::getAutostartTimeoutProgress() { + return this->autostartElapsedTimer->elapsed() / this->autostartTimer->interval(); +} + +int LinboBackend::getAutostartTimeoutRemainingSeconds() { + return (this->autostartTimer->interval() - this->autostartElapsedTimer->elapsed()) / 1000; +} + // ----------- // - Helpers - // ----------- QString LinboBackend::executeCommand(bool waitForFinished, QString command, QStringList commandArgs) { - qDebug() << "Executing " << (waitForFinished ? "synchronos":"asynchronos") << ": " << command << " " << commandArgs.join(" "); + this->logger->log("Executing " + QString(waitForFinished ? "synchronos":"asynchronos") + ": " + command + " " + commandArgs.join(" "), LinboLogger::LinboGuiInfo); if(waitForFinished) { // clear old output @@ -332,11 +364,19 @@ QString LinboBackend::executeCommand(bool waitForFinished, QString command, QStr void LinboBackend::readFromStdout() { - qDebug() << "OUT: " << this->asynchronosProcess->readAllStandardOutput(); + QString stdOut = this->asynchronosProcess->readAllStandardOutput(); + QStringList lines = stdOut.split("\n"); + for(QString line : lines) { + this->logger->log(line, LinboLogger::StdOut); + } } void LinboBackend::readFromStderr() { - qDebug() << "ERR: " << this->asynchronosProcess->readAllStandardError(); + QString stdOut = this->asynchronosProcess->readAllStandardError(); + QStringList lines = stdOut.split("\n"); + for(QString line : lines) { + this->logger->log(line, LinboLogger::StdErr); + } } LinboBackend::LinboState LinboBackend::getState() { @@ -377,7 +417,6 @@ LinboOs* LinboBackend::read_os(ifstream* input) { LinboOs* os = new LinboOs(this); QString key, value; while(!input->eof() && read_pair(input, key, value)) { - qDebug() << key << "=" << value; if(key.compare("name") == 0) os->setName(value); else if(key.compare("description") == 0) os->setDescription(value); else if(key.compare("version") == 0) os->setVersion(value); diff --git a/sources/backend/linbologger.cpp b/sources/backend/linbologger.cpp new file mode 100644 index 0000000..4d62eee --- /dev/null +++ b/sources/backend/linbologger.cpp @@ -0,0 +1,34 @@ +#include "../../headers/backend/linbologger.h" + +LinboLogger::LinboLogger(QObject *parent) : QObject(parent) +{ + +} + +QString LinboLogger::logTypeToString(LinboLogType logType) { + switch (logType) { + case StdErr: + return "StrErr"; + case StdOut: + return "StdOut"; + case LinboGuiInfo: + return "Info"; + case LinboGuiError: + return "Error"; + default: + return "UNKNOW"; + } +} + +void LinboLogger::log(QString logText, LinboLogType logType) { + if(logText.isEmpty() || logText == "") + return; + qDebug() << qPrintable("[" + this->logTypeToString(logType) + "]") << logText; + LinboLog latestLog {logText, logType, QDateTime::currentDateTime()}; + this->logHistory.append(latestLog); + emit this->latestLogChanged(latestLog); +} + +const LinboLogger::LinboLog& LinboLogger::getLatestLog() { + return this->logHistory.last(); +} diff --git a/sources/legacy/linboGUIImpl.cc b/sources/legacy/linboGUIImpl.cc index 31ce4a1..cc5ac8f 100644 --- a/sources/legacy/linboGUIImpl.cc +++ b/sources/legacy/linboGUIImpl.cc @@ -1504,7 +1504,7 @@ void linboGUIImpl::resetButtons() { } void linboGUIImpl::executeAutostart() { - return; // autostart is handles by new GUI + return; // autostart is handled by new backend // if there is "autopartition" set, execute the hidden button if( autopartition ) autopartition->lclicked(); @@ -1543,6 +1543,7 @@ void linboGUIImpl::executeAutostart() { } void linboGUIImpl::autostartTimeoutSlot() { + return; // autostart is handled by new backend if( !myCounter->timeoutCheck->isChecked() ) { // do nothing but dont stop timer } diff --git a/sources/linbogui.cpp b/sources/linbogui.cpp index 373c122..3aa75a5 100644 --- a/sources/linbogui.cpp +++ b/sources/linbogui.cpp @@ -29,7 +29,9 @@ LinboGui::LinboGui() this->setFixedHeight(QApplication::desktop()->screenGeometry().height()); this->setFixedWidth(QApplication::desktop()->screenGeometry().width()); - qDebug() << this->geometry(); + QFontDatabase db; + qDebug() << QFontDatabase::addApplicationFont(":/fonts/SegoeUI.ttf"); + qDebug() << db.families(); // white bakground // linuxmuster background color: #394f5e diff --git a/sources/linbostartactions.cpp b/sources/linbostartactions.cpp index 382e573..ab74d4b 100644 --- a/sources/linbostartactions.cpp +++ b/sources/linbostartactions.cpp @@ -5,6 +5,7 @@ LinboStartActions::LinboStartActions(LinboBackend* backend, QWidget *parent) : Q this->backend = backend; connect(this->backend, SIGNAL(currentOsChanged(LinboOs*)), this, SLOT(handleCurrentOsChanged(LinboOs*))); connect(this->backend, SIGNAL(stateChanged(LinboBackend::LinboState)), this, SLOT(handleLinboStateChanged(LinboBackend::LinboState))); + connect(this->backend->getLogger(), SIGNAL(latestLogChanged(const LinboLogger::LinboLog&)), this, SLOT(handleLatestLogChanged(const LinboLogger::LinboLog&))); this->stackView = new QModernStackedWidget(this); @@ -28,6 +29,13 @@ LinboStartActions::LinboStartActions(LinboBackend* backend, QWidget *parent) : Q this->progressBarWidget = new QWidget(); this->progressBar = new QModernProgressBar(this->progressBarWidget); this->progressBar->setIndeterminate(true); + + this->logLabel = new QLabel("", this->progressBarWidget); + this->logLabel->setAlignment(Qt::AlignCenter); + + this->logFont = QFont("Segoe UI"); + this->logLabel->setFont(this->logFont); + this->stackView->addWidget(this->progressBarWidget); connect(this->stackView, SIGNAL(currentChanged(int)), this, SLOT(resizeAndPositionAllItems())); @@ -142,7 +150,13 @@ void LinboStartActions::resizeAndPositionAllItems() { 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); + int logLabelHeight = progressBarHeight * 2; + int logLabelWidth = this->width() * 0.8; + progressBar->setGeometry((this->width() - progressBarWidth) / 2, (this->height() - logLabelHeight - progressBarHeight) / 2, progressBarWidth, progressBarHeight); + + this->logFont.setPixelSize(logLabelHeight * 0.8); + this->logLabel->setFont(this->logFont); + this->logLabel->setGeometry((this->width() - logLabelWidth) / 2, this->height() - logLabelHeight, logLabelWidth, logLabelHeight); this->inited = true; } @@ -173,3 +187,20 @@ void LinboStartActions::handleLinboStateChanged(LinboBackend::LinboState newStat break; } } + + +void LinboStartActions::handleLatestLogChanged(const LinboLogger::LinboLog& latestLog) { + QString logColor = "black"; + switch (latestLog.type) { + case LinboLogger::StdErr: + logColor = this->backend->getConfig()->getConsoleFontcolorStderr(); + break; + case LinboLogger::StdOut: + // TODO?? logColor = this->backend->getConfig()->getConsoleFontcolorStdout(); + break; + default: + break; + } + this->logLabel->setStyleSheet("QLabel { color : " + logColor + "; }"); + this->logLabel->setText(latestLog.message); +} diff --git a/sources/linbostartpage.cpp b/sources/linbostartpage.cpp index 3f29a7e..9e693fd 100644 --- a/sources/linbostartpage.cpp +++ b/sources/linbostartpage.cpp @@ -55,6 +55,7 @@ LinboStartPage::LinboStartPage(LinboBackend* backend, QWidget *parent) : QWidget mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding)); QLabel* versionLabel = new QLabel(backend->getConfig()->getVersion() + " - mod by Dorian Zedler"); + versionLabel->setFont(QFont("Segoe UI")); mainLayout->addWidget(versionLabel); @@ -63,7 +64,7 @@ LinboStartPage::LinboStartPage(LinboBackend* backend, QWidget *parent) : QWidget int height = this->height() * 0.2; int width = height / 3; int margins = width * 0.1; - int buttonWidth = width * 0.8; + int buttonWidth = width * 0.6; powerActionsLayoutWidget->setGeometry(QRect(this->width() - (width + margins), this->height() - (height + margins), width * 1.1, height)); QModernPushButton* settingsActionButton = new QModernPushButton(":/svgIcons/settingsAction.svg"); diff --git a/sources/qmodernpushbutton.cpp b/sources/qmodernpushbutton.cpp index 29d1b57..032ebfd 100644 --- a/sources/qmodernpushbutton.cpp +++ b/sources/qmodernpushbutton.cpp @@ -100,7 +100,7 @@ void QModernPushButton::keyReleaseEvent(QKeyEvent *e) { void QModernPushButton::enterEvent(QEvent *e) { - if(this->overlays.length() >= 2) + if(this->overlays.length() >= 2 && this->isEnabled()) this->overlays[1]->setVisible(true); return QAbstractButton::enterEvent(e); } @@ -112,7 +112,7 @@ void QModernPushButton::leaveEvent(QEvent *e) { } void QModernPushButton::mousePressEvent(QMouseEvent *e) { - if(this->overlays.length() >= 3) + if(this->overlays.length() >= 3 && this->isEnabled()) this->overlays[2]->setVisible(true); return QAbstractButton::mousePressEvent(e); }