From bc55542a602637ea4169b084c1b78aada0382ee7 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Fri, 6 Dec 2019 21:00:29 -0600 Subject: Qt UI: Implement UI.Packages.Choices requirements --- ui/qt5/CMakeLists.txt | 1 + ui/qt5/horizonwizard.cc | 32 ++++++++++++ ui/qt5/horizonwizard.hh | 16 ++++++ ui/qt5/pkgdefaults.cc | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ ui/qt5/pkgdefaults.hh | 23 +++++++++ 5 files changed, 200 insertions(+) create mode 100644 ui/qt5/pkgdefaults.cc create mode 100644 ui/qt5/pkgdefaults.hh diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt index 14d5399..e752749 100644 --- a/ui/qt5/CMakeLists.txt +++ b/ui/qt5/CMakeLists.txt @@ -19,6 +19,7 @@ set(UI_SOURCES datetimepage.cc hostnamepage.cc pkgsimple.cc + pkgdefaults.cc bootpage.cc rootpwpage.cc accountpage.cc diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc index 4c12d72..50c526d 100644 --- a/ui/qt5/horizonwizard.cc +++ b/ui/qt5/horizonwizard.cc @@ -48,6 +48,7 @@ extern "C" { #include "datetimepage.hh" #include "hostnamepage.hh" #include "pkgsimple.hh" +#include "pkgdefaults.hh" #include "bootpage.hh" #include "rootpwpage.hh" #include "accountpage.hh" @@ -180,7 +181,11 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) { * Determine which platform kernel is being used, if any (-power8 etc) * Determine hardware requirements (easy or mainline) */ + grub = true; kernel = "easy-kernel"; + binsh = Dash; + sbininit = S6; + eudev = true; /* REQ: UI.Global.Back.Save */ setOption(IndependentPages); @@ -202,6 +207,7 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) { setPage(Page_DateTime, new DateTimePage); setPage(Page_Hostname, new HostnamePage); setPage(Page_PkgSimple, new PkgSimplePage); + setPage(Page_PkgCustomDefault, new PkgDefaultsPage); setPage(Page_Boot, new BootPage); setPage(Page_Root, new RootPassphrasePage); setPage(Page_Accounts, new AccountPage); @@ -358,6 +364,32 @@ QString HorizonWizard::toHScript() { lines << "pkginstall grub"; } + switch(this->binsh) { + case Dash: + lines << "pkginstall dash-binsh"; + break; + case Bash: + lines << "pkginstall bash-binsh"; + break; + } + + switch(this->sbininit) { + case S6: + lines << "pkginstall s6-linux-init"; + break; + case SysVInit: + lines << "pkginstall sysvinit"; + break; + } + + if(this->eudev) { + lines << "pkginstall eudev"; + } else { + lines << "pkginstall mdevd"; + } + + lines << "pkginstall sysklogd"; + lines << ("pkginstall " + QString::fromStdString(this->kernel) + " " + QString::fromStdString(this->kernel) + "-modules"); diff --git a/ui/qt5/horizonwizard.hh b/ui/qt5/horizonwizard.hh index 0cb4d0b..272886f 100644 --- a/ui/qt5/horizonwizard.hh +++ b/ui/qt5/horizonwizard.hh @@ -82,6 +82,16 @@ public: Custom }; + enum BinShProvider { + Dash, + Bash + }; + + enum InitSystem { + S6, + SysVInit + }; + HorizonWizard(QWidget *parent = nullptr); void accept(); /*! Emit a HorizonScript file with the user's choices. */ @@ -107,8 +117,14 @@ public: bool net_dhcp; /*! Determines whether to install GRUB. */ bool grub; + /*! Determines whether to install eudev. */ + bool eudev; /*! Determines the packages to install. */ PackageType pkgtype; + /*! Determines the /bin/sh provider. */ + BinShProvider binsh; + /*! Determines the /sbin/init provider. */ + InitSystem sbininit; /*! Determines the network interface to use. */ std::string chosen_auto_iface; /*! If pkgtype is Custom, a list of packages to install. */ diff --git a/ui/qt5/pkgdefaults.cc b/ui/qt5/pkgdefaults.cc new file mode 100644 index 0000000..1d24f89 --- /dev/null +++ b/ui/qt5/pkgdefaults.cc @@ -0,0 +1,128 @@ +/* + * pkgdefaults.cc - Implementation of the UI.Packages.Choices 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 "pkgdefaults.hh" + +#include +#include +#include +#include +#include + +PkgDefaultsPage::PkgDefaultsPage(QWidget *parent) : HorizonWizardPage(parent) { + setTitle(tr("Software Choices")); + loadWatermark("software"); + + QVBoxLayout *mainLayout = new QVBoxLayout; + + QLabel *descLabel = new QLabel(tr( + "You may customise the software used for certain functionality on this computer.\n\n" + "Most users do not need to change any of the settings on this page. " + "If you're unsure of which options are best for you, review the Help system or keep the defaults.")); + descLabel->setWordWrap(true); + mainLayout->addWidget(descLabel); + mainLayout->addStretch(); + + + /******************** /bin/sh provider ********************/ + QButtonGroup *shellGroup = new QButtonGroup; + QLabel *shellLabel = new QLabel(tr("Shell to use for /bin/sh:")); + + QRadioButton *dashShell = new QRadioButton("Dash"); + dashShell->setChecked(true); + dashShell->setWhatsThis(tr("Use the lightweight Dash shell. " + "This is an Almquist-style shell, also used as /bin/sh on Debian-derived distributions. " + "Choose this option for faster boot times and full POSIX compatibility.")); + shellGroup->addButton(dashShell, HorizonWizard::Dash); + + QRadioButton *bashShell = new QRadioButton("Bash"); + bashShell->setChecked(false); + bashShell->setWhatsThis(tr("Use the Bash shell. " + "This shell is popular on GNU systems. " + "Choose this option for compatibility with non-portable scripts. " + "Note that by choosing this option, your system will no longer be able to conform to the POSIX standard.")); + shellGroup->addButton(bashShell, HorizonWizard::Bash); + + connect(shellGroup, static_cast(&QButtonGroup::buttonClicked), + [=](int choice) { + horizonWizard()->binsh = static_cast(choice); + }); + + QHBoxLayout *shellLayout = new QHBoxLayout; + shellLayout->addWidget(dashShell); + shellLayout->addWidget(bashShell); + + mainLayout->addWidget(shellLabel); + mainLayout->addLayout(shellLayout); + mainLayout->addStretch(); + + + /******************** /sbin/init provider ********************/ + QButtonGroup *initGroup = new QButtonGroup; + QLabel *initLabel = new QLabel(tr("Init system (/sbin/init):")); + + QRadioButton *s6Init = new QRadioButton("s6-linux-init"); + s6Init->setChecked(true); + s6Init->setWhatsThis(tr("Use the lightweight, customisable s6-linux-init init system.")); + initGroup->addButton(s6Init, HorizonWizard::S6); + + QRadioButton *sysvInit = new QRadioButton("SysV Init"); + sysvInit->setChecked(false); + sysvInit->setWhatsThis(tr("Use the traditional sysvinit init system.")); + initGroup->addButton(sysvInit, HorizonWizard::SysVInit); + + connect(initGroup, static_cast(&QButtonGroup::buttonClicked), + [=](int choice) { + horizonWizard()->sbininit = static_cast(choice); + }); + + QHBoxLayout *initLayout = new QHBoxLayout; + initLayout->addWidget(s6Init); + initLayout->addWidget(sysvInit); + + mainLayout->addWidget(initLabel); + mainLayout->addLayout(initLayout); + mainLayout->addStretch(); + + + /******************** device event handler ********************/ + QButtonGroup *udevGroup = new QButtonGroup; + QLabel *udevLabel = new QLabel(tr("uevent management daemon:")); + + QRadioButton *eudev = new QRadioButton("eudev"); + eudev->setChecked(true); + eudev->setWhatsThis(tr("Use the traditional, UDev-compatible eudev system. " + "It is highly recommended that you use eudev unless you know it is inappropriate for your use case.")); + udevGroup->addButton(eudev, true); + + QRadioButton *mdevd = new QRadioButton("mdevd"); + mdevd->setChecked(false); + mdevd->setWhatsThis(tr("Use the minimalist, lightweight mdevd system. " + "This is the skarnet fork of mdevd. " + "Choosing this option on a desktop system will require manual intervention.")); + udevGroup->addButton(mdevd, false); + + connect(udevGroup, static_cast(&QButtonGroup::buttonClicked), + [=](int choice) { + horizonWizard()->eudev = static_cast(choice); + }); + + QHBoxLayout *udevLayout = new QHBoxLayout; + udevLayout->addWidget(eudev); + udevLayout->addWidget(mdevd); + + mainLayout->addWidget(udevLabel); + mainLayout->addLayout(udevLayout); + mainLayout->addStretch(); + + setLayout(mainLayout); +} diff --git a/ui/qt5/pkgdefaults.hh b/ui/qt5/pkgdefaults.hh new file mode 100644 index 0000000..08288ed --- /dev/null +++ b/ui/qt5/pkgdefaults.hh @@ -0,0 +1,23 @@ +/* + * pkgdefaults.hh - Definition of the UI.Packages.Choices 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 PKGDEFAULTS_HH +#define PKGDEFAULTS_HH + +#include "horizonwizardpage.hh" + +class PkgDefaultsPage : public HorizonWizardPage { +public: + PkgDefaultsPage(QWidget *parent = nullptr); +}; + +#endif /* !PKGDEFAULTS_HH */ -- cgit v1.2.3-60-g2f50