diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-12-06 04:49:30 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-12-06 04:49:30 -0600 |
commit | d3728b38b12b2f9762ba26fc6fc302cb79f7ee6c (patch) | |
tree | 3c0d47166a89110fa504aa1557f69de6e89073bc /ui/qt5 | |
parent | d71a5c29f6d22d2fb18bd483333eaf37b827fd0d (diff) | |
download | horizon-d3728b38b12b2f9762ba26fc6fc302cb79f7ee6c.tar.gz horizon-d3728b38b12b2f9762ba26fc6fc302cb79f7ee6c.tar.bz2 horizon-d3728b38b12b2f9762ba26fc6fc302cb79f7ee6c.tar.xz horizon-d3728b38b12b2f9762ba26fc6fc302cb79f7ee6c.zip |
Qt UI: Implement UI.Writeout and UI.Commit requirements
Diffstat (limited to 'ui/qt5')
-rw-r--r-- | ui/qt5/CMakeLists.txt | 6 | ||||
-rw-r--r-- | ui/qt5/commitpage.cc | 95 | ||||
-rw-r--r-- | ui/qt5/commitpage.hh | 29 | ||||
-rw-r--r-- | ui/qt5/horizonwizard.cc | 34 | ||||
-rw-r--r-- | ui/qt5/horizonwizard.hh | 8 | ||||
-rw-r--r-- | ui/qt5/writeoutpage.cc | 18 | ||||
-rw-r--r-- | ui/qt5/writeoutpage.hh | 23 |
7 files changed, 208 insertions, 5 deletions
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt index 7fd1ebf..14d5399 100644 --- a/ui/qt5/CMakeLists.txt +++ b/ui/qt5/CMakeLists.txt @@ -25,6 +25,12 @@ set(UI_SOURCES horizon.qrc) +IF(INSTALL) + LIST(APPEND UI_SOURCES commitpage.cc) +ELSE(INSTALL) + LIST(APPEND UI_SOURCES writeoutpage.cc) +ENDIF(INSTALL) + IF(UNSUPPORTED_NONFREE_FIRMWARE) LIST(APPEND UI_SOURCES firmwarepage.cc) ENDIF(UNSUPPORTED_NONFREE_FIRMWARE) diff --git a/ui/qt5/commitpage.cc b/ui/qt5/commitpage.cc new file mode 100644 index 0000000..f144ade --- /dev/null +++ b/ui/qt5/commitpage.cc @@ -0,0 +1,95 @@ +/* + * commitpage.cc - Implementation of the UI.Commit page + * horizon-qt5, the Qt 5 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 "commitpage.hh" + +#include "datetimepage.hh" +#include "util/keymaps.hh" +#include <algorithm> + +#include <QLabel> +#include <QVariant> +#include <QVBoxLayout> + +CommitPage::CommitPage(QWidget *parent) : HorizonWizardPage(parent) { + setTitle(tr("Begin Installation")); + loadWatermark("intro"); + + QLabel *descLabel = new QLabel(tr( + "We have gathered all the information needed to begin installing Adélie Linux to your computer. " + "Choose 'Install' when you are ready to begin the installation procedure.")); + descLabel->setWordWrap(true); + + choices = new QLabel; + choices->setFrameStyle(QFrame::Panel | QFrame::Sunken); + choices->setTextFormat(Qt::RichText); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(descLabel); + layout->addSpacing(10); + layout->addWidget(choices); + + setLayout(layout); +} + +void CommitPage::initializePage() { + QString netString, zoneString, softString; + + auto iterator = valid_keymaps.begin(); + Q_ASSERT(field("keymap").toUInt() <= valid_keymaps.size()); + std::advance(iterator, field("keymap").toUInt()); + + if(horizonWizard()->network && horizonWizard()->net_dhcp && + horizonWizard()->interfaces.size() > 1) { + QString iface = QString::fromStdString(horizonWizard()->chosen_auto_iface); + netString = tr("Enabled (via %1)").arg(iface); + } else { + netString = horizonWizard()->network ? tr("Enabled") : tr("Disabled"); + } + + zoneString = dynamic_cast<DateTimePage *>( + horizonWizard()->page(HorizonWizard::Page_DateTime) + )->selectedTimeZone(); + + switch(horizonWizard()->pkgtype) { + case HorizonWizard::Standard: + softString = tr("Standard"); + break; + case HorizonWizard::Mobile: + softString = tr("Mobile"); + break; + case HorizonWizard::Compact: + softString = tr("Compact"); + break; + case HorizonWizard::TextOnly: + softString = tr("Text-Only"); + break; + case HorizonWizard::Custom: + /* XXX TODO maybe show packages selected? too lengthy? */ + softString = tr("Custom"); + break; + } + + choices->setText(tr("<br>\n" + "<p><b>Keyboard Layout</b>: %1</p>\n" + "<p><b>Networking</b>: %2</p>\n" + "<p><b>Time Zone</b>: %3</p>\n" + "<p><b>Software Selection</b>: %4</p>\n" + "<p><b>Hostname</b>: %5</p>\n" + "<p><b>Root Passphrase</b>: <i>[saved]</i></p>\n" + "<br>") + .arg(QString::fromStdString(*iterator)) + .arg(netString) + .arg(zoneString) + .arg(softString) + .arg(field("hostname").toString())); +} diff --git a/ui/qt5/commitpage.hh b/ui/qt5/commitpage.hh new file mode 100644 index 0000000..a4f480e --- /dev/null +++ b/ui/qt5/commitpage.hh @@ -0,0 +1,29 @@ +/* + * commitpage.cc - Definition of the UI.Commit page + * horizon-qt5, the Qt 5 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 COMMITPAGE_HH +#define COMMITPAGE_HH + +#include "horizonwizardpage.hh" + +#include <QLabel> + +class CommitPage : public HorizonWizardPage { +public: + CommitPage(QWidget *parent = nullptr); + + void initializePage(); +private: + QLabel *choices; +}; + +#endif /* !COMMITPAGE_HH */ diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc index 6b44d49..4c12d72 100644 --- a/ui/qt5/horizonwizard.cc +++ b/ui/qt5/horizonwizard.cc @@ -25,11 +25,15 @@ #ifdef HAS_INSTALL_ENV # include <libudev.h> # include <net/if.h> /* ifreq */ +# include "commitpage.hh" extern "C" { # include <skalibs/tai.h> /* STAMP */ } # include <sys/ioctl.h> /* ioctl */ # include <unistd.h> /* close */ +#else +# include <QFileDialog> +# include "writeoutpage.hh" #endif /* HAS_INSTALL_ENV */ #include "intropage.hh" @@ -201,6 +205,11 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) { setPage(Page_Boot, new BootPage); setPage(Page_Root, new RootPassphrasePage); setPage(Page_Accounts, new AccountPage); +#ifndef HAS_INSTALL_ENV + setPage(Page_Write, new WriteoutPage); +#else /* HAS_INSTALL_ENV */ + setPage(Page_Commit, new CommitPage); +#endif /* !HAS_INSTALL_ENV */ QObject::connect(this, &QWizard::helpRequested, [=](void) { if(help_id_map.find(currentId()) == help_id_map.end()) { @@ -402,5 +411,28 @@ QString HorizonWizard::toHScript() { #include <iostream> void HorizonWizard::accept() { - std::cout << toHScript().toStdString() << std::endl; + QFile file; +#ifdef HAS_INSTALL_ENV + file.setFileName("/etc/horizon/installfile"); +#else /* !HAS_INSTALL_ENV */ + QFileDialog fileChooser(this); + fileChooser.setAcceptMode(QFileDialog::AcceptSave); + fileChooser.setNameFilter(tr("Installation Scripts (installfile)")); + fileChooser.setViewMode(QFileDialog::List); + + if(fileChooser.exec()) { + file.setFileName(fileChooser.selectedFiles().at(0)); + } else { + return; + } +#endif /* HAS_INSTALL_ENV */ + if(!file.open(QFile::WriteOnly)) { + QMessageBox::critical(this, tr("Couldn't Save Script"), + tr("An issue occurred while saving the installation script: %1").arg(file.errorString())); + return; + } + file.write(toHScript().toUtf8()); + file.close(); + + done(QDialog::Accepted); } diff --git a/ui/qt5/horizonwizard.hh b/ui/qt5/horizonwizard.hh index 5be8c67..0cb4d0b 100644 --- a/ui/qt5/horizonwizard.hh +++ b/ui/qt5/horizonwizard.hh @@ -105,14 +105,14 @@ public: bool network; /*! Determines whether to use DHCP. */ bool net_dhcp; - /*! Determines the network interface to use. */ - std::string chosen_auto_iface; + /*! Determines whether to install GRUB. */ + bool grub; /*! Determines the packages to install. */ PackageType pkgtype; + /*! Determines the network interface to use. */ + std::string chosen_auto_iface; /*! If pkgtype is Custom, a list of packages to install. */ QStringList packages; - /*! Determines whether to install GRUB. */ - bool grub; /*! Determines the kernel to install. */ std::string kernel; }; diff --git a/ui/qt5/writeoutpage.cc b/ui/qt5/writeoutpage.cc new file mode 100644 index 0000000..8ee1a40 --- /dev/null +++ b/ui/qt5/writeoutpage.cc @@ -0,0 +1,18 @@ +/* + * writeoutpage.cc - Implementation of the UI.Writeout page + * horizon-qt5, the Qt 5 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 "writeoutpage.hh" + +WriteoutPage::WriteoutPage(QWidget *parent) : HorizonWizardPage(parent) { + setTitle(tr("Save Installation Script")); + loadWatermark("intro"); +} diff --git a/ui/qt5/writeoutpage.hh b/ui/qt5/writeoutpage.hh new file mode 100644 index 0000000..c3610b1 --- /dev/null +++ b/ui/qt5/writeoutpage.hh @@ -0,0 +1,23 @@ +/* + * writeoutpage.hh - Definition of the UI.Writeout page + * horizon-qt5, the Qt 5 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 WRITEOUTPAGE_HH +#define WRITEOUTPAGE_HH + +#include "horizonwizardpage.hh" + +class WriteoutPage : public HorizonWizardPage { +public: + WriteoutPage(QWidget *parent = nullptr); +}; + +#endif /* !WRITEOUTPAGE_HH */ |