diff --git a/headers/backend/linbobackend.h b/headers/backend/linbobackend.h index 9e8ffc2..b7408a9 100644 --- a/headers/backend/linbobackend.h +++ b/headers/backend/linbobackend.h @@ -34,8 +34,6 @@ #include "linboimage.h" #include "linbodiskpartition.h" -using namespace std; - class LinboBackend : public QObject { Q_OBJECT @@ -57,7 +55,8 @@ public: Root, Partitioning, InitializingCache, - Updating + Updating, + Error }; LinboState getState(); @@ -138,12 +137,14 @@ public slots: bool updateLinbo(); bool cancelCurrentAction(); + bool resetError(); private slots: void executeAutostart(); void handleAutostartTimerTimeout(); void readFromStdout(); void readFromStderr(); + void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); signals: void stateChanged(LinboBackend::LinboState state); diff --git a/headers/backend/linbologger.h b/headers/backend/linbologger.h index 48287da..79dfed3 100644 --- a/headers/backend/linbologger.h +++ b/headers/backend/linbologger.h @@ -23,6 +23,27 @@ #include #include #include +#include + +enum class LinboLogType { + UnknownLogType = -1, + StdOut = 1, + StdErr = 2, + LinboGuiInfo = 4, + LinboGuiError = 8, + LinboLogChapterBeginning = 16, + LinboLogChapterEnd = 32 +}; + +inline LinboLogType operator|(LinboLogType a, LinboLogType b) +{ + return static_cast(static_cast(a) | static_cast(b)); +}; + +inline LinboLogType operator&(LinboLogType a, LinboLogType b) +{ + return static_cast(static_cast(a) & static_cast(b)); +}; class LinboLogger : public QObject { @@ -32,14 +53,6 @@ public: friend class LinboBackend; - enum LinboLogType { - UnknownLogType = -1, - StdOut, - StdErr, - LinboGuiInfo, - LinboGuiError - }; - typedef struct { QString message; LinboLogType type; @@ -49,7 +62,10 @@ public: const LinboLog& getLatestLog(); static QString logTypeToString(LinboLogType logType); - + QList getLogs(); + QList getLogsOfCurrentChapter(); + static QList getFilterLogs(QList logs, LinboLogType filterType); + static QStringList logsToStacktrace(QList logs, int limit); private: explicit LinboLogger(QString logFilePath, QObject *parent = nullptr); diff --git a/headers/linbostartactions.h b/headers/linbostartactions.h index 059c302..4efb8c2 100644 --- a/headers/linbostartactions.h +++ b/headers/linbostartactions.h @@ -51,7 +51,6 @@ private: QModernPushButton* startOsButton; QModernPushButton* syncOsButton; QModernPushButton* reinstallOsButton; - QModernPushButton* cancelButton; QList actionButtons; QLabel* noBaseImageLabel; QFont noBaseImageLabelFont; @@ -60,6 +59,15 @@ private: QModernProgressBar* progressBar; QFont logFont; QLabel* logLabel; + QModernPushButton* cancelButton; + + QWidget* errorWidget; + QVBoxLayout* errorLayout; + QLabel* errorLabel; + QFont errorLabelFont; + QLabel* errorDetailsLabel; + QFont errorDetailsFont; + QModernPushButton* resetErrorButton; bool inited; diff --git a/linboGUI.pro.user b/linboGUI.pro.user index 9b93059..a78fe2f 100644 --- a/linboGUI.pro.user +++ b/linboGUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -315,9 +315,216 @@ 1 + + ProjectExplorer.Project.Target.1 + + Desktop + Qt 4.8.7 + Qt 4.8.7 + {f4afd0ca-2727-4cca-babb-18e3098b3665} + 0 + 0 + 0 + + true + 2 + /home/dorian/Qt/builds/build-linboGUI-Qt_4_8_7-Debug + /home/dorian/Qt/builds/build-linboGUI-Qt_4_8_7-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + /home/dorian/Qt/builds/build-linboGUI-Qt_4_8_7-Release + /home/dorian/Qt/builds/build-linboGUI-Qt_4_8_7-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 2 + 2 + + 2 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/Documents/git/modern-linbo-gui/linboGUI.pro + /home/dorian/Documents/git/modern-linbo-gui/linboGUI.pro + + false + + false + true + true + false + false + true + + /home/dorian/Qt/builds/build-linboGUI-Qt_4_8_7-Debug + + 1 + + ProjectExplorer.Project.TargetCount - 1 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/resources/linbo.qrc b/resources/linbo.qrc index b2d4d16..88359e5 100644 --- a/resources/linbo.qrc +++ b/resources/linbo.qrc @@ -28,5 +28,6 @@ svgIcons/settingsAction.svg fonts/SegoeUI.ttf svgIcons/cancel.svg + svgIcons/back.svg diff --git a/resources/svgIcons/back.svg b/resources/svgIcons/back.svg new file mode 100644 index 0000000..1c468ef --- /dev/null +++ b/resources/svgIcons/back.svg @@ -0,0 +1,38 @@ + + diff --git a/resources/svgIcons/cancel.svg b/resources/svgIcons/cancel.svg index 834b1d4..96964c0 100644 --- a/resources/svgIcons/cancel.svg +++ b/resources/svgIcons/cancel.svg @@ -7,17 +7,17 @@ xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" - data-prefix="far" - data-icon="times-circle" - class="svg-inline--fa fa-times-circle fa-w-16" + data-prefix="fas" + data-icon="times" + class="svg-inline--fa fa-times fa-w-11" role="img" viewBox="0 0 500 500" version="1.1" - id="svg4" + id="svg14" width="500" height="500"> + id="metadata20"> @@ -29,10 +29,10 @@ + id="defs18" /> + d="m 306.86364,250 85.28693,-85.28693 c 10.46591,-10.46591 10.46591,-27.43466 0,-37.90909 l -18.95455,-18.95455 c -10.46591,-10.465908 -27.43466,-10.465908 -37.90909,0 L 250,193.13636 164.71307,107.84943 c -10.46591,-10.465908 -27.43466,-10.465908 -37.90909,0 l -18.95455,18.95455 c -10.465909,10.46591 -10.465909,27.43466 0,37.90909 L 193.13636,250 107.84943,335.28693 c -10.465909,10.46591 -10.465909,27.43466 0,37.90909 l 18.95455,18.95455 c 10.4659,10.46591 27.44318,10.46591 37.90909,0 L 250,306.86364 l 85.28693,85.28693 c 10.46591,10.46591 27.44318,10.46591 37.90909,0 l 18.95455,-18.95455 c 10.46591,-10.46591 10.46591,-27.43466 0,-37.90909 z" + id="path12" + style="stroke-width:30;stroke:#ffffff;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" /> diff --git a/sources/backend/linbobackend.cpp b/sources/backend/linbobackend.cpp index feaa486..f30904c 100644 --- a/sources/backend/linbobackend.cpp +++ b/sources/backend/linbobackend.cpp @@ -24,7 +24,6 @@ /* * TODO: - * - State StartError (ish) * - enter state StartError when starting / syncing / reinstalling fails */ @@ -58,6 +57,8 @@ LinboBackend::LinboBackend(QObject *parent) : QObject(parent) this, SLOT(readFromStdout()) ); connect( asynchronosProcess, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()) ); + connect(this->asynchronosProcess, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(handleProcessFinished(int, QProcess::ExitStatus))); // synchronos commands are not logged this->synchronosProcess = new QProcess(this); @@ -84,7 +85,7 @@ void LinboBackend::executeAutostart() { } this->setState(Autostarting); - this->logger->log("Beginning autostart timeout for " + this->currentOs->getName(), LinboLogger::LinboGuiInfo); + this->logger->log("Beginning autostart timeout for " + this->currentOs->getName(), LinboLogType::LinboGuiInfo); this->autostartTimer->setInterval(this->currentOs->getAutostartTimeout() * 1000); this->autostartTimer->start(); this->autostartElapsedTimer->restart(); @@ -94,7 +95,7 @@ void LinboBackend::executeAutostart() { void LinboBackend::handleAutostartTimerTimeout() { this->autostartElapsedTimer->invalidate(); this->autostartRemainingTimeRefreshTimer->stop(); - this->logger->log("Executing autostart for " + this->currentOs->getName(), LinboLogger::LinboGuiInfo); + this->logger->log("Executing autostart for " + this->currentOs->getName(), LinboLogType::LinboGuiInfo); LinboOs::LinboOsStartAction defaultAction = this->currentOs->getDefaultAction(); bool wasSuccessfull = false; @@ -112,9 +113,9 @@ void LinboBackend::handleAutostartTimerTimeout() { } if(wasSuccessfull) - this->logger->log("Executed autostart successfully!", LinboLogger::LinboGuiInfo); + this->logger->log("Executed autostart successfully!", LinboLogType::LinboGuiInfo); else - this->logger->log("An error occured when executing autostart for " + this->currentOs->getName(), LinboLogger::LinboGuiError); + this->logger->log("An error occured when executing autostart for " + this->currentOs->getName(), LinboLogType::LinboGuiError); } void LinboBackend::shutdown() { @@ -131,6 +132,8 @@ bool LinboBackend::startCurrentOs() { if(os == nullptr || (this->state != Idle && this->state != Autostarting) || !os->getActionEnabled(LinboOs::StartOs)) return false; + this->logger->log("Starting " + this->currentOs->name, LinboLogType::LinboLogChapterBeginning); + this->setState(Starting); this->executeCommand( @@ -153,6 +156,8 @@ bool LinboBackend::syncCurrentOs() { if(os == nullptr || (this->state != Idle && this->state != Autostarting) || !os->getActionEnabled(LinboOs::SyncOs)) return false; + this->logger->log("Syncing " + this->currentOs->name, LinboLogType::LinboLogChapterBeginning); + this->setState(Syncing); qDebug() << "TEST2"; @@ -186,6 +191,8 @@ bool LinboBackend::reinstallCurrentOs() { if(os == nullptr || (this->state != Idle && this->state != Autostarting) || !os->getActionEnabled(LinboOs::ReinstallOs)) return false; + this->logger->log("Reinstalling " + this->currentOs->name, LinboLogType::LinboLogChapterBeginning); + this->setState(Reinstalling); QString differentialImage; @@ -275,7 +282,7 @@ bool LinboBackend::updateLinbo() { bool LinboBackend::cancelCurrentAction() { switch (this->state) { case Autostarting: - this->logger->log("Cancelling autostart", LinboLogger::LinboGuiInfo); + this->logger->log("Cancelling autostart", LinboLogType::LinboGuiInfo); this->autostartTimer->stop(); this->autostartRemainingTimeRefreshTimer->stop(); this->autostartElapsedTimer->invalidate(); @@ -285,17 +292,26 @@ bool LinboBackend::cancelCurrentAction() { case Starting: case Syncing: case Reinstalling: - this->logger->log("Cancelling current start action: " + QString::number(this->state), LinboLogger::LinboGuiInfo); + this->logger->log("Cancelling current start action: " + QString::number(this->state), LinboLogType::LinboGuiInfo); this->asynchronosProcess->kill(); this->setState(Idle); return true; default: - this->logger->log("Cannot cancel current action: " + QString::number(this->state), LinboLogger::LinboGuiInfo); + this->logger->log("Cannot cancel current action: " + QString::number(this->state), LinboLogType::LinboGuiInfo); return false; } } + +bool LinboBackend::resetError() { + if(this->state != Error) + return false; + + this->setState(Idle); + return true; +} + LinboLogger* LinboBackend::getLogger() { return this->logger; } @@ -335,7 +351,7 @@ int LinboBackend::getAutostartTimeoutRemainingSeconds() { QString LinboBackend::executeCommand(bool waitForFinished, QString command, QStringList commandArgs) { - this->logger->log("Executing " + QString(waitForFinished ? "synchronos":"asynchronos") + ": " + command + " " + commandArgs.join(" "), LinboLogger::LinboGuiInfo); + this->logger->log("Executing " + QString(waitForFinished ? "synchronos":"asynchronos") + ": " + command + " " + commandArgs.join(" "), LinboLogType::LinboGuiInfo); if(waitForFinished) { // clear old output @@ -359,7 +375,7 @@ void LinboBackend::readFromStdout() { QString stdOut = this->asynchronosProcess->readAllStandardOutput(); QStringList lines = stdOut.split("\n"); for(QString line : lines) { - this->logger->log(line, LinboLogger::StdOut); + this->logger->log(line, LinboLogType::StdOut); } } @@ -367,10 +383,23 @@ void LinboBackend::readFromStderr() { QString stdOut = this->asynchronosProcess->readAllStandardError(); QStringList lines = stdOut.split("\n"); for(QString line : lines) { - this->logger->log(line, LinboLogger::StdErr); + this->logger->log(line, LinboLogType::StdErr); } } +void LinboBackend::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { + Q_UNUSED(exitStatus) + if(exitCode == 0) { + this->logger->log("Process exited normally.", LinboLogType::LinboGuiInfo); + } + else { + this->logger->log("Process exited with an error.", LinboLogType::LinboGuiError); + this->setState(Error); + } + + this->logger->log("Process exited.", LinboLogType::LinboLogChapterEnd); +} + LinboBackend::LinboState LinboBackend::getState() { return this->state; } @@ -382,12 +411,12 @@ void LinboBackend::setState(LinboState state) { this->state = state; emit this->stateChanged(this->state); - this->logger->log("Linbo state changed to: " + QString::number(state), LinboLogger::LinboGuiInfo); + this->logger->log("Linbo state changed to: " + QString::number(state), LinboLogType::LinboGuiInfo); } void LinboBackend::loadStartConfiguration(QString startConfFilePath) { // read start.conf - this->logger->log("Starting to parse start.conf", LinboLogger::LinboGuiInfo); + this->logger->log("Starting to parse start.conf", LinboLogType::LinboGuiInfo); QFile inputFile(startConfFilePath); if (inputFile.open(QIODevice::ReadOnly)) @@ -413,7 +442,7 @@ void LinboBackend::loadStartConfiguration(QString startConfFilePath) { thisLine = thisLine.stripWhiteSpace(); thisLine = thisLine.simplified(); - //qDebug() << "reading line: " << thisLine; + qDebug() << "reading line: " << thisLine; if(thisLine.startsWith("[")) { // we found a new section! @@ -510,13 +539,13 @@ void LinboBackend::loadStartConfiguration(QString startConfFilePath) { this->currentOs = this->operatingSystems[0]; } else - this->logger->log("Error opening the start configuration file: " + startConfFilePath, LinboLogger::LinboGuiError); + this->logger->log("Error opening the start configuration file: " + startConfFilePath, LinboLogType::LinboGuiError); - this->logger->log("Finished parsing start.conf", LinboLogger::LinboGuiInfo); + this->logger->log("Finished parsing start.conf", LinboLogType::LinboGuiInfo); } void LinboBackend::loadEnvironmentValues() { - this->logger->log("Loading environment values", LinboLogger::LinboGuiInfo); + this->logger->log("Loading environment values", LinboLogType::LinboGuiInfo); // client ip this->config->setIpAddress(this->executeCommand(true, "ip").replace("\n", "")); @@ -545,7 +574,7 @@ void LinboBackend::loadEnvironmentValues() { hd.remove( *removePartition ); this->config->setHddSize(this->executeCommand(true, "size", hd).replace("\n", "")); - this->logger->log("Finished loading environment values", LinboLogger::LinboGuiInfo); + this->logger->log("Finished loading environment values", LinboLogType::LinboGuiInfo); } void LinboBackend::writeToLinboConfig(QMap config, LinboConfig* linboConfig) { diff --git a/sources/backend/linbologger.cpp b/sources/backend/linbologger.cpp index 58720e8..2cf3aa6 100644 --- a/sources/backend/linbologger.cpp +++ b/sources/backend/linbologger.cpp @@ -25,14 +25,18 @@ LinboLogger::LinboLogger(QString logFilePath, QObject *parent) : QObject(parent) QString LinboLogger::logTypeToString(LinboLogType logType) { switch (logType) { - case StdErr: - return "StrErr"; - case StdOut: + case LinboLogType::StdErr: + return "StdErr"; + case LinboLogType::StdOut: return "StdOut"; - case LinboGuiInfo: + case LinboLogType::LinboGuiInfo: return "Info"; - case LinboGuiError: + case LinboLogType::LinboGuiError: return "Error"; + case LinboLogType::LinboLogChapterBeginning: + return "+++ Chapter +++"; + case LinboLogType::LinboLogChapterEnd: + return "+++ Chapter end +++"; default: return "UNKNOW"; } @@ -47,7 +51,7 @@ void LinboLogger::log(QString logText, LinboLogType logType) { this->logHistory.append(latestLog); // TODO: Log error, when this fails - this->writeToLogFile("[" + this->logTypeToString(logType) + "]" + logText); + this->writeToLogFile("[" + this->logTypeToString(logType) + "] " + logText); emit this->latestLogChanged(latestLog); } @@ -68,3 +72,45 @@ bool LinboLogger::writeToLogFile(QString text) { const LinboLogger::LinboLog& LinboLogger::getLatestLog() { return this->logHistory.last(); } + +QList LinboLogger::getLogs() { + return this->logHistory; +} + +QList LinboLogger::getLogsOfCurrentChapter() { + QList tmpLogs; + + for(int i = this->logHistory.length() - 1; i >= 0; i--) { + tmpLogs.append(this->logHistory[i]); + if(this->logHistory[i].type == LinboLogType::LinboLogChapterBeginning) + break; + else if(this->logHistory[i].type == LinboLogType::LinboLogChapterEnd) + tmpLogs.clear(); + } + + return tmpLogs; +} + +QList LinboLogger::getFilterLogs(QList logs, LinboLogType filterType) { + QList tmpLogs; + + for(LinboLog log : logs) { + if((log.type & filterType) == log.type) + tmpLogs.append(log); + } + + return tmpLogs; +} + + +QStringList LinboLogger::logsToStacktrace(QList logs, int limit) { + QStringList logStrings; + for(int i = 0; i < logs.length(); i++) { + if(logStrings.length() >= limit) + break; + + logStrings.append("#" + QString::number(logStrings.length() +1) + " [" + LinboLogger::logTypeToString(logs[i].type) + "] " + logs[i].message); + } + + return logStrings; +} diff --git a/sources/legacy/linboGUIImpl.cc b/sources/legacy/linboGUIImpl.cc index bc79ad6..7ccb76c 100644 --- a/sources/legacy/linboGUIImpl.cc +++ b/sources/legacy/linboGUIImpl.cc @@ -343,14 +343,6 @@ linboGUIImpl::linboGUIImpl(QWidget* parent) : QDialog(parent) waiting->update(); waiting->execute(); - QWSServer* wsServer = QWSServer::instance(); - QImage bgimg( "/icons/linbo_wallpaper.png", "PNG" ); - - if ( wsServer ) { - wsServer->setBackground( QBrush( bgimg.scaled( qRect.width(), qRect.height(), Qt::IgnoreAspectRatio ) ) ); - wsServer->refresh(); - } - ifstream input; input.open( "start.conf", ios_base::in ); diff --git a/sources/linboosselectionrow.cpp b/sources/linboosselectionrow.cpp index 53f8c8a..27d53fa 100644 --- a/sources/linboosselectionrow.cpp +++ b/sources/linboosselectionrow.cpp @@ -31,6 +31,9 @@ LinboOsSelectionRow::LinboOsSelectionRow(LinboBackend* backend, QWidget *parent) this->osButtonGroup->setExclusive(true); for(LinboOs* os : backend->getOperatingSystems()) { + if(this->osButtons.length() >= 4) + break; + LinboOsSelectButton* osButton = new LinboOsSelectButton("/icons/" + os->getIconName(), os, this->osButtonGroup, this); connect(osButton->button, SIGNAL(toggled(bool)), this, SLOT(handleButtonToggled(bool))); diff --git a/sources/linbostartactions.cpp b/sources/linbostartactions.cpp index f067503..f8581d8 100644 --- a/sources/linbostartactions.cpp +++ b/sources/linbostartactions.cpp @@ -68,6 +68,25 @@ LinboStartActions::LinboStartActions(LinboBackend* backend, QWidget *parent) : Q this->stackView->addWidget(this->progressBarWidget); + // Error widget + this->errorWidget = new QWidget(); + this->errorLabel = new QLabel("", this->errorWidget); + this->errorLabel->setStyleSheet("QLabel { color : red; }"); + this->errorLabelFont = QFont("Segoe UI"); + this->errorLabelFont.setBold(true); + this->errorLabel->setAlignment(Qt::AlignCenter); + + this->errorDetailsLabel = new QLabel("", this->errorWidget); + this->errorDetailsLabel->setStyleSheet("QLabel { color : red; }"); + this->errorDetailsFont = QFont("Segoe UI"); + this->errorDetailsLabel->setFont(this->errorDetailsFont); + this->errorDetailsLabel->setAlignment(Qt::AlignLeft); + + this->resetErrorButton = new QModernPushButton(":/svgIcons/back.svg", this->errorWidget); + connect(this->resetErrorButton, SIGNAL(clicked()), this->backend, SLOT(resetError())); + + this->stackView->addWidget(this->errorWidget); + connect(this->stackView, SIGNAL(currentChanged(int)), this, SLOT(resizeAndPositionAllItems())); this->handleLinboStateChanged(this->backend->getState()); } @@ -128,25 +147,25 @@ void LinboStartActions::resizeAndPositionAllItems() { geometries.append(QRect()); // move buttons into place - this->buttonWidget->setFixedSize(this->size()); + this->buttonWidget->setGeometry(0,0,this->width(), this->height() * 0.4); - int buttonSpacing = this->height() * 0.1; - int defaultButtonHeight = this->height() * 0.6; - geometries[0] = QRect((this->width() - defaultButtonHeight) / 2, 0,defaultButtonHeight, defaultButtonHeight); + int buttonSpacing = this->buttonWidget->height() * 0.1; + int defaultButtonHeight = this->buttonWidget->height() * 0.6; + geometries[0] = QRect((this->buttonWidget->width() - defaultButtonHeight) / 2, 0,defaultButtonHeight, defaultButtonHeight); - int secondaryButtonHeight = this->height() * 0.3; + int secondaryButtonHeight = this->buttonWidget->height() * 0.3; if(positionsEnabled[1] && positionsEnabled[2]) { // place buttons besides each other geometries[1] = QRect( - this->width() / 2 - secondaryButtonHeight - buttonSpacing / 2, + this->buttonWidget->width() / 2 - secondaryButtonHeight - buttonSpacing / 2, defaultButtonHeight + buttonSpacing, secondaryButtonHeight, secondaryButtonHeight ); geometries[2] = QRect( - this->width() / 2 + buttonSpacing / 2, + this->buttonWidget->width() / 2 + buttonSpacing / 2, defaultButtonHeight + buttonSpacing, secondaryButtonHeight, secondaryButtonHeight @@ -155,7 +174,7 @@ void LinboStartActions::resizeAndPositionAllItems() { else { // place buttons on top of each other geometries[1] = QRect( - this->width() / 2 - secondaryButtonHeight / 2, + this->buttonWidget->width() / 2 - secondaryButtonHeight / 2, defaultButtonHeight + buttonSpacing, secondaryButtonHeight, secondaryButtonHeight @@ -177,10 +196,10 @@ void LinboStartActions::resizeAndPositionAllItems() { } if(selectedOs != nullptr && selectedOs->getBaseImage() == nullptr) { - int noBaseImageLabelHeight = this->height() * 0.2; + int noBaseImageLabelHeight = this->buttonWidget->height() * 0.2; this->noBaseImageLabelFont.setPixelSize(noBaseImageLabelHeight * 0.8); this->noBaseImageLabel->setFont(this->noBaseImageLabelFont); - this->noBaseImageLabel->setGeometry(0, (this->height() - noBaseImageLabelHeight) / 2, this->width(), noBaseImageLabelHeight); + this->noBaseImageLabel->setGeometry(0, (this->buttonWidget->height() - noBaseImageLabelHeight) / 2, this->buttonWidget->width(), noBaseImageLabelHeight); this->noBaseImageLabel->show(); } else { @@ -188,20 +207,33 @@ void LinboStartActions::resizeAndPositionAllItems() { } // Progress bar - this->progressBarWidget->setFixedSize(this->size()); - int progressBarHeight = this->height() * 0.1; - int progressBarWidth = this->width() * 0.5; + this->progressBarWidget->setGeometry(0,0,this->width(), this->height() * 0.4); + int progressBarHeight = this->progressBarWidget->height() * 0.1; + int progressBarWidth = this->progressBarWidget->width() * 0.5; int logLabelHeight = progressBarHeight * 2; - int logLabelWidth = this->width() * 0.8; - int cancelButtonWidth = this->height() * 0.4; + int logLabelWidth = this->progressBarWidget->width() * 0.8; + int cancelButtonWidth = this->progressBarWidget->height() * 0.4; this->logFont.setPixelSize(logLabelHeight * 0.8); this->logLabel->setFont(this->logFont); - this->logLabel->setGeometry((this->width() - logLabelWidth) / 2, 0, logLabelWidth, logLabelHeight); + this->logLabel->setGeometry((this->progressBarWidget->width() - logLabelWidth) / 2, 0, logLabelWidth, logLabelHeight); - progressBar->setGeometry((this->width() - progressBarWidth) / 2, this->logLabel->y() + logLabelHeight + this->height() * 0.15, progressBarWidth, progressBarHeight); + progressBar->setGeometry((this->progressBarWidget->width() - progressBarWidth) / 2, this->logLabel->y() + logLabelHeight + this->progressBarWidget->height() * 0.15, progressBarWidth, progressBarHeight); - this->cancelButton->setGeometry((this->width() - cancelButtonWidth) / 2, this->progressBar->y() + progressBarHeight + this->height() * 0.05, cancelButtonWidth, cancelButtonWidth); + this->cancelButton->setGeometry((this->progressBarWidget->width() - cancelButtonWidth) / 2, this->progressBar->y() + progressBarHeight + this->progressBarWidget->height() * 0.05, cancelButtonWidth, cancelButtonWidth); + + // Error widget + this->errorWidget->setGeometry(QRect(0,0, this->width(), this->height())); + + this->errorLabel->setGeometry(0,0, this->width(), this->height() * 0.2); + this->errorLabelFont.setPixelSize(this->logFont.pixelSize() * 1.5); + this->errorLabel->setFont(this->errorLabelFont); + + this->errorDetailsLabel->setGeometry((this->width() * 0.3) / 2, this->errorLabel->height(), this->width() * 0.7, this->height() * 0.6); + this->errorDetailsFont.setPixelSize(this->errorLabelFont.pixelSize() / 2); + this->errorDetailsLabel->setFont(this->errorDetailsFont); + + this->resetErrorButton->setGeometry((this->width() - this->cancelButton->width()) / 2, this->height() - this->cancelButton->width() * 1.1, this->cancelButton->width(), this->cancelButton->width()); this->inited = true; } @@ -239,6 +271,26 @@ void LinboStartActions::handleLinboStateChanged(LinboBackend::LinboState newStat currentWidget = this->progressBarWidget; break; + case LinboBackend::Error: { + QList chaperLogs = this->backend->getLogger()->getLogsOfCurrentChapter(); + this->errorLabel->setText("The process \"" + chaperLogs[chaperLogs.length()-1].message + "\" crashed:"); + QString errorDetails; + if(chaperLogs.length() == 0) + errorDetails = "No logs before this crash"; + else if(LinboLogger::getFilterLogs(chaperLogs, LinboLogType::LinboGuiError | LinboLogType::StdErr).length() == 0){ + errorDetails = "The last logs before the crash were:
"; + errorDetails += LinboLogger::logsToStacktrace(chaperLogs, 8).join("
"); + } + else { + errorDetails = "The last errors before the crash were:
"; + errorDetails += LinboLogger::logsToStacktrace(LinboLogger::getFilterLogs(chaperLogs, LinboLogType::LinboGuiError | LinboLogType::StdErr), 8).join("
"); + } + + this->errorDetailsLabel->setText(errorDetails); + currentWidget = this->errorWidget; + break; + } + default: break; } @@ -256,10 +308,10 @@ void LinboStartActions::handleLatestLogChanged(const LinboLogger::LinboLog& late QString logColor = "black"; switch (latestLog.type) { - case LinboLogger::StdErr: + case LinboLogType::StdErr: logColor = this->backend->getConfig()->getConsoleFontcolorStderr(); break; - case LinboLogger::StdOut: + case LinboLogType::StdOut: // TODO?? logColor = this->backend->getConfig()->getConsoleFontcolorStdout(); break; default: diff --git a/sources/linbostartpage.cpp b/sources/linbostartpage.cpp index 589e4bd..777b0e7 100644 --- a/sources/linbostartpage.cpp +++ b/sources/linbostartpage.cpp @@ -50,11 +50,9 @@ LinboStartPage::LinboStartPage(LinboBackend* backend, QWidget *parent) : QWidget // action buttons this->startActionsWidget = new LinboStartActions(this->backend, this->osSelectionRow); mainLayout->addWidget(this->startActionsWidget); - this->startActionsWidget->setFixedHeight(this->height() * 0.15); + this->startActionsWidget->setFixedHeight(this->height() * 0.45); this->startActionsWidget->setFixedWidth(this->width()); - mainLayout->addItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding)); - QLabel* versionLabel = new QLabel(backend->getConfig()->getLinboVersion() + " - mod by Dorian Zedler"); versionLabel->setFont(QFont("Segoe UI")); mainLayout->addWidget(versionLabel); diff --git a/sources/main.cpp b/sources/main.cpp index ae21fb7..a9477a2 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -7,6 +7,7 @@ int main( int argc, char* argv[] ) { QApplication linboGuiApp( argc, argv ); + QWSServer* wsServer = QWSServer::instance(); if ( wsServer ) {