summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-12-07 09:09:00 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-12-13 12:11:21 -0600
commit1257064e43c6c4269e1b8cf0507b238fd4a0ab1a (patch)
tree7c025c87b292bb6ab046cb13aa71042b14510e3a
parent70104d361e8ac781ffa50ac404e1e286e1239b43 (diff)
downloadhorizon-1257064e43c6c4269e1b8cf0507b238fd4a0ab1a.tar.gz
horizon-1257064e43c6c4269e1b8cf0507b238fd4a0ab1a.tar.bz2
horizon-1257064e43c6c4269e1b8cf0507b238fd4a0ab1a.tar.xz
horizon-1257064e43c6c4269e1b8cf0507b238fd4a0ab1a.zip
Qt UI: runner: Add error page
-rw-r--r--ui/qt5/CMakeLists.txt2
-rw-r--r--ui/qt5/runner/errorpage.cc109
-rw-r--r--ui/qt5/runner/errorpage.hh27
-rw-r--r--ui/qt5/runner/executepage.cc11
-rw-r--r--ui/qt5/runner/executepage.hh6
-rw-r--r--ui/qt5/runner/executorwizard.cc2
-rw-r--r--ui/qt5/runner/executorwizard.hh3
7 files changed, 158 insertions, 2 deletions
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt
index 930a84a..23f269b 100644
--- a/ui/qt5/CMakeLists.txt
+++ b/ui/qt5/CMakeLists.txt
@@ -27,10 +27,12 @@ set(UI_SOURCES
horizon.qrc)
set(RUN_QT_SOURCES
+ horizonhelpwindow.cc
horizonwizardpage.cc
runner/main.cc
runner/executorwizard.cc
runner/executepage.cc
+ runner/errorpage.cc
runner/finishedpage.cc
horizon.qrc)
diff --git a/ui/qt5/runner/errorpage.cc b/ui/qt5/runner/errorpage.cc
new file mode 100644
index 0000000..f645a10
--- /dev/null
+++ b/ui/qt5/runner/errorpage.cc
@@ -0,0 +1,109 @@
+/*
+ * errorpage.cc - Implementation of the UI.Perform.Error page
+ * horizon-run-qt5, the Qt 5 executor user interface for
+ * Project Horizon
+ *
+ * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
+ * This code is licensed under the AGPL 3.0 license, as noted in the
+ * LICENSE-code file in the root directory of this repository.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+#include "errorpage.hh"
+
+#include <QFileDialog>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMessageBox>
+#include <QProcess>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+#include "executorwizard.hh"
+#include "executepage.hh"
+#include "../horizonhelpwindow.hh"
+
+ErrorPage::ErrorPage(QWidget *parent) : HorizonWizardPage(parent) {
+ setTitle(tr("Installation Couldn't Finish"));
+ loadWatermark("intro");
+ setFinalPage(true);
+
+ descLabel = new QLabel(tr("I am Error."));
+ descLabel->setWordWrap(true);
+
+ QPushButton *viewLog = new QPushButton(tr("&View Log"));
+ viewLog->setWhatsThis(tr("Opens a log viewer, in which you can examine the contents of the installation log file."));
+ connect(viewLog, &QPushButton::clicked, [=]{
+ QFile log("/var/log/horizon/executor.log");
+ log.open(QFile::ReadOnly);
+ HorizonHelpWindow window(&log, this, true);
+ window.exec();
+ });
+ QPushButton *saveData = new QPushButton(tr("&Save Script/Log..."));
+ saveData->setWhatsThis(tr("Allows you to save the HorizonScript and installation log files to removable media."));
+ connect(saveData, &QPushButton::clicked, [=]{
+ bool success = true;
+
+ QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/target/root");
+ if(dir.size() > 0) {
+ success = QFile::copy("/etc/horizon/installfile", dir + QDir::separator() + "installfile");
+ if(success) success = QFile::copy("/var/log/horizon/executor.log", dir + QDir::separator() + "install.log");
+ }
+
+ if(!success) {
+ QMessageBox::critical(this, tr("Could Not Save Installation Data"), tr("Unable to save installation data to %1.").arg(dir));
+ }
+ });
+ QPushButton *popAnXterm = new QPushButton(tr("Open &Terminal"));
+ popAnXterm->setWhatsThis(tr("Opens a terminal, to allow you to run commands from the installation environment."));
+ connect(popAnXterm, &QPushButton::clicked, [=]{
+ QProcess p;
+ p.execute("xterm", {"-fa", "Liberation Mono", "-fs", "12"});
+ });
+
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->addWidget(viewLog);
+ buttonLayout->addWidget(saveData);
+ buttonLayout->addWidget(popAnXterm);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(descLabel);
+ layout->addStretch();
+ layout->addLayout(buttonLayout);
+
+ setLayout(layout);
+}
+
+void ErrorPage::initializePage() {
+ ExecutePage *epage = dynamic_cast<ExecutePage *>(wizard()->page(ExecutorWizard::Page_Execute));
+ switch(epage->currentPhase()) {
+ case ExecutePage::Prepare:
+ descLabel->setText(tr(
+ "An issue occurred while preparing this computer for installation.\n\n"
+ "This almost always indicates a corrupted installation medium, or a hardware fault.\n\n"
+ "Try creating a new installation medium. If that doesn't work, you will need to have your computer serviced.\n\n"
+ "Technical Details: A failure in the Prepare phase means the Executor process failed to start, crashed during initialisation, or encountered an early parsing failure in the HorizonScript."));
+ break;
+ case ExecutePage::Validate:
+ descLabel->setText(tr(
+ "An issue occurred while validating the installation script.\n\n"
+ "If you used the System Installation Wizard, you have encountered a bug in the wizard. "
+ "Please choose \"Save Script/Log...\" and follow the instructions at https://horizon.adelielinux.org/bug to report this issue.\n\n"
+ "If you wrote the script yourself, you have made a syntax error."));
+ break;
+ case ExecutePage::Disk:
+ descLabel->setText(tr(
+ "An issue occurred while manipulating this computer's hard disk(s).\n\n"
+ "This may indicate a disk is read-only, an issue with the disk's controller or cabling, or a failing disk.\n\n"
+ "Ensure you have selected the correct hard disk drive. "
+ "If the correct disk is selected, check the cabling from the drive to the controller, and the controller to the computer.\n\n"
+ "Otherwise, ensure the disk is not physically damaged."));
+ break;
+ case ExecutePage::PreMeta:
+ case ExecutePage::Net:
+ case ExecutePage::Pkg:
+ case ExecutePage::PostMeta:
+ break;
+ }
+}
diff --git a/ui/qt5/runner/errorpage.hh b/ui/qt5/runner/errorpage.hh
new file mode 100644
index 0000000..0cb59af
--- /dev/null
+++ b/ui/qt5/runner/errorpage.hh
@@ -0,0 +1,27 @@
+/*
+ * errorpage.hh - Definition of the UI.Perform.Error page
+ * horizon-run-qt5, the Qt 5 executor user interface for
+ * Project Horizon
+ *
+ * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
+ * This code is licensed under the AGPL 3.0 license, as noted in the
+ * LICENSE-code file in the root directory of this repository.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+#ifndef ERRORPAGE_HH
+#define ERRORPAGE_HH
+
+#include "../horizonwizardpage.hh"
+#include <QLabel>
+
+class ErrorPage : public HorizonWizardPage {
+public:
+ ErrorPage(QWidget *parent = nullptr);
+ void initializePage();
+private:
+ QLabel *descLabel;
+};
+
+#endif /* !ERRORPAGE_HH */
diff --git a/ui/qt5/runner/executepage.cc b/ui/qt5/runner/executepage.cc
index 817a61c..fd9581e 100644
--- a/ui/qt5/runner/executepage.cc
+++ b/ui/qt5/runner/executepage.cc
@@ -12,6 +12,8 @@
#include "executepage.hh"
+#include "executorwizard.hh"
+
#include <QAbstractButton>
#include <QGridLayout>
#include <QProcess>
@@ -21,6 +23,7 @@
ExecutePage::ExecutePage(QWidget *parent) : HorizonWizardPage(parent) {
setTitle(tr("Installing Adélie Linux…"));
loadWatermark("intro");
+ failed = false;
QLabel *descLabel = new QLabel(tr("Please wait while System Installation performs the following tasks:"));
descLabel->setWordWrap(true);
@@ -156,6 +159,7 @@ void ExecutePage::markFailed(Phase phase) {
labelsForPhase(phase, &icon, &text);
icon->setPixmap(loadDPIAwarePixmap("status-issue", ".svg"));
text->setFont(boldFont);
+ failed = true;
}
void ExecutePage::executorReady() {
@@ -196,3 +200,10 @@ void ExecutePage::executorFinished(int code, QProcess::ExitStatus status) {
wizard()->button(QWizard::CancelButton)->setEnabled(false);
finishTimer->start();
}
+
+int ExecutePage::nextId() const {
+ if(failed) {
+ return ExecutorWizard::Page_Error;
+ }
+ return ExecutorWizard::Page_Finished;
+}
diff --git a/ui/qt5/runner/executepage.hh b/ui/qt5/runner/executepage.hh
index b3d11b4..57d38da 100644
--- a/ui/qt5/runner/executepage.hh
+++ b/ui/qt5/runner/executepage.hh
@@ -1,5 +1,5 @@
/*
- * executepage.cc - Implementation of the UI.Perform page
+ * executepage.hh - Defintion of the UI.Perform page
* horizon-run-qt5, the Qt 5 executor user interface for
* Project Horizon
*
@@ -33,6 +33,9 @@ public:
};
ExecutePage(QWidget *parent = nullptr);
+ int nextId() const;
+ Phase currentPhase() { return this->current; }
+
private:
QLabel *prepareStatus;
QLabel *prepare;
@@ -55,6 +58,7 @@ private:
QFile log;
Phase current;
+ bool failed;
Phase stepToPhase(QString step);
void labelsForPhase(Phase phase, QLabel **icon, QLabel **text);
diff --git a/ui/qt5/runner/executorwizard.cc b/ui/qt5/runner/executorwizard.cc
index ae58a21..95aea6e 100644
--- a/ui/qt5/runner/executorwizard.cc
+++ b/ui/qt5/runner/executorwizard.cc
@@ -15,6 +15,7 @@
#include <QAbstractButton>
#include "executepage.hh"
+#include "errorpage.hh"
#include "finishedpage.hh"
ExecutorWizard::ExecutorWizard(QWidget *parent) : QWizard(parent) {
@@ -23,6 +24,7 @@ ExecutorWizard::ExecutorWizard(QWidget *parent) : QWizard(parent) {
setFixedSize(QSize(650, 450));
setPage(Page_Execute, new ExecutePage);
+ setPage(Page_Error, new ErrorPage);
setPage(Page_Finished, new FinishedPage);
setOption(NoBackButtonOnStartPage);
diff --git a/ui/qt5/runner/executorwizard.hh b/ui/qt5/runner/executorwizard.hh
index 578f745..eb09bcc 100644
--- a/ui/qt5/runner/executorwizard.hh
+++ b/ui/qt5/runner/executorwizard.hh
@@ -1,5 +1,5 @@
/*
- * executorwizard.cc - Implementation of the wizard class
+ * executorwizard.hh - Definition of the wizard class
* horizon-run-qt5, the Qt 5 executor user interface for
* Project Horizon
*
@@ -19,6 +19,7 @@ class ExecutorWizard : public QWizard {
public:
enum {
Page_Execute,
+ Page_Error,
Page_Finished
};