summaryrefslogtreecommitdiff
path: root/ui/qt5/partitionmanualpage.cc
blob: e94911873195a1a52d90787368acf9519ef4ff16 (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
/*
 * partitionmanualpage.cc - Implementation of UI.Partition.Install.Manual page
 * horizon-qt5, the Qt 5 user interface for
 * Project Horizon
 *
 * Copyright (c) 2020 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 "partitionmanualpage.hh"

#include <QLabel>
#ifdef HAS_INSTALL_ENV
#   include <QProcess>
#   include <QPushButton>
#endif  /* HAS_INSTALL_ENV */
#include <QVBoxLayout>

PartitionManualPage::PartitionManualPage(QWidget *parent)
    : HorizonWizardPage(parent) {
    QLabel *descLabel = new QLabel;
    descLabel->setWordWrap(true);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(descLabel);

    loadWatermark("disk");
#ifdef HAS_INSTALL_ENV
    setTitle(tr("Launch Manual Partitioner"));

    descLabel->setText(tr("Choose 'Launch Partitioner' to launch the manual partitioning utility.\n\n"
                          "When you have finished partitioning the disk, quit the partitioning utility and choose Next."));

    QPushButton *button = new QPushButton(tr("Launch Partitioner"));
    button->setWhatsThis(tr("Opens the partition editor."));
    connect(button, &QPushButton::clicked, [=]{
        QProcess p;
        p.execute("partitionmanager");
    });
    layout->addStretch();
    layout->addWidget(button, 0, Qt::AlignCenter);
    layout->addStretch();
#else  /* !HAS_INSTALL_ENV */
    setTitle(tr("Enter Partitioning Information"));

    descLabel->setText(tr("Enter the partitioning commands you wish to use for the target computer.\n\n"
                          "For a list of valid commands, review the HorizonScript Reference."));

    partitionEdit = new QTextEdit;
    connect(partitionEdit, &QTextEdit::textChanged, [=]{
        horizonWizard()->part_lines = partitionEdit->toPlainText().split("\n");
        emit completeChanged();
    });
    partitionEdit->setAcceptRichText(false);
    partitionEdit->setFontFamily("monospace");
    partitionEdit->setReadOnly(false);
    partitionEdit->setWhatsThis(tr("Input the HorizonScript commands to partition the disk."));
    layout->addWidget(partitionEdit);
#endif  /* HAS_INSTALL_ENV */

    setLayout(layout);
}

#ifndef HAS_INSTALL_ENV
bool PartitionManualPage::isComplete() const {
    return partitionEdit->toPlainText().size() > 0;
}

int PartitionManualPage::nextId() const {
    /* Skip the Mount page for 'mount' keyword in the partitioning commands. */
    return HorizonWizard::Page_Network;
}
#endif  /* !HAS_INSTALL_ENV */