summaryrefslogtreecommitdiff
path: root/ui/qt5/pkgdefaults.cc
blob: e3c358d04ad3ce9a1c24c97ca110d0d8af4749ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * 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 <QButtonGroup>
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
#include <QVBoxLayout>

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:"));
    shellLabel->setWordWrap(true);

    dashShell = new QRadioButton("Dash");
    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);

    bashShell = new QRadioButton("Bash");
    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<void (QButtonGroup:: *)(int)>(&QButtonGroup::buttonClicked),
            [=](int choice) {
        horizonWizard()->binsh = static_cast<HorizonWizard::BinShProvider>(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):"));
    initLabel->setWordWrap(true);

    s6Init = new QRadioButton("s6-linux-init");
    s6Init->setWhatsThis(tr("Use the lightweight, customisable s6-linux-init init system."));
    initGroup->addButton(s6Init, HorizonWizard::S6);

    sysvInit = new QRadioButton("SysV Init");
    sysvInit->setWhatsThis(tr("Use the traditional sysvinit init system."));
    initGroup->addButton(sysvInit, HorizonWizard::SysVInit);

    connect(initGroup, static_cast<void (QButtonGroup:: *)(int)>(&QButtonGroup::buttonClicked),
            [=](int choice) {
        horizonWizard()->sbininit = static_cast<HorizonWizard::InitSystem>(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:"));
    udevLabel->setWordWrap(true);

    eudev = new QRadioButton("eudev");
    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);

    mdevd = new QRadioButton("mdevd");
    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<void (QButtonGroup:: *)(int)>(&QButtonGroup::buttonClicked),
            [=](int choice) {
        horizonWizard()->eudev = static_cast<bool>(choice);
    });

    QHBoxLayout *udevLayout = new QHBoxLayout;
    udevLayout->addWidget(eudev);
    udevLayout->addWidget(mdevd);

    mainLayout->addWidget(udevLabel);
    mainLayout->addLayout(udevLayout);
    mainLayout->addStretch();

    setLayout(mainLayout);
}

void PkgDefaultsPage::initializePage() {
    switch(horizonWizard()->binsh) {
    case HorizonWizard::Dash:
        dashShell->setChecked(true);
        bashShell->setChecked(false);
        break;
    case HorizonWizard::Bash:
        dashShell->setChecked(false);
        bashShell->setChecked(true);
        break;
    }

    switch(horizonWizard()->sbininit) {
    case HorizonWizard::S6:
        s6Init->setChecked(true);
        sysvInit->setChecked(false);
        break;
    case HorizonWizard::SysVInit:
        s6Init->setChecked(false);
        sysvInit->setChecked(true);
        break;
    }

    if(horizonWizard()->eudev) {
        eudev->setChecked(true);
        mdevd->setChecked(false);
    } else {
        eudev->setChecked(false);
        mdevd->setChecked(true);
    }
}