summaryrefslogtreecommitdiff
path: root/ui/qt5/partitionchoicepage.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-02-16 23:34:27 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-02-16 23:34:27 -0600
commit910848185f3632cbd8b3bb72bf9d8b54ff4d2909 (patch)
treee9ef9383bfbcebc0a98da22442dcc50bbd947c5d /ui/qt5/partitionchoicepage.cc
parent1851d7105965e9631240c83bb8e03a3160e1d830 (diff)
downloadhorizon-910848185f3632cbd8b3bb72bf9d8b54ff4d2909.tar.gz
horizon-910848185f3632cbd8b3bb72bf9d8b54ff4d2909.tar.bz2
horizon-910848185f3632cbd8b3bb72bf9d8b54ff4d2909.tar.xz
horizon-910848185f3632cbd8b3bb72bf9d8b54ff4d2909.zip
Qt UI: Add UI.Partition.Install.UserPrompt page
Diffstat (limited to 'ui/qt5/partitionchoicepage.cc')
-rw-r--r--ui/qt5/partitionchoicepage.cc128
1 files changed, 128 insertions, 0 deletions
diff --git a/ui/qt5/partitionchoicepage.cc b/ui/qt5/partitionchoicepage.cc
new file mode 100644
index 0000000..63317e7
--- /dev/null
+++ b/ui/qt5/partitionchoicepage.cc
@@ -0,0 +1,128 @@
+/*
+ * partitionchoicepage.cc - Implementation of UI.Partition.Install.UserPrompt
+ * 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 "partitionchoicepage.hh"
+
+#include <QLabel>
+#include <QVBoxLayout>
+
+PartitionChoicePage::PartitionChoicePage(QWidget *parent)
+ : HorizonWizardPage(parent) {
+ loadWatermark("disk");
+ setTitle(tr("Choose Partitioning Type"));
+
+ descLabel = new QLabel(tr("Select the method you wish to use for partitioning %1:"));
+ descLabel->setWordWrap(true);
+
+ eraseButton = new QRadioButton(tr("&Erase and Use Whole Disk"));
+ eraseButton->setHidden(true);
+ eraseLabel = new QLabel(tr("The entire disk will be erased and then automatically partitioned.<br><strong>Warning: This will destroy all existing data on the disk.</strong>"));
+ eraseLabel->setHidden(true);
+ eraseLabel->setIndent(25);
+ eraseLabel->setTextFormat(Qt::RichText);
+ eraseLabel->setWordWrap(true);
+
+ fitInButton = new QRadioButton(tr("Use &Free Space"));
+ fitInButton->setHidden(true);
+ fitInLabel = new QLabel(tr("The free space on the disk will be automatically partitioned for use with Adélie. Existing data will be preserved."));
+ fitInLabel->setHidden(true);
+ fitInLabel->setIndent(25);
+ fitInLabel->setWordWrap(true);
+
+ useExistingButton = new QRadioButton(tr("Use Existing &Partition"));
+ useExistingButton->setHidden(true);
+ useExistingLabel = new QLabel(tr("No partitions will be modified. You must select the partition on which you wish to install Adélie."));
+ useExistingLabel->setHidden(true);
+ useExistingLabel->setIndent(25);
+ useExistingLabel->setWordWrap(true);
+
+ manualButton = new QRadioButton(tr("&Manual"));
+ manualButton->setHidden(true);
+ manualLabel = new QLabel(tr("Open a partitioning tool."));
+ manualLabel->setHidden(true);
+ manualLabel->setIndent(25);
+ manualLabel->setWordWrap(true);
+
+ buttons = new QButtonGroup(this);
+ buttons->setExclusive(true);
+ buttons->addButton(eraseButton);
+ buttons->addButton(fitInButton);
+ buttons->addButton(useExistingButton);
+ buttons->addButton(manualButton);
+
+ connect(buttons, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
+ this, &PartitionChoicePage::completeChanged);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(descLabel);
+ layout->addStretch();
+ layout->addWidget(eraseButton);
+ layout->addWidget(eraseLabel);
+ layout->addStretch();
+ layout->addWidget(fitInButton);
+ layout->addWidget(fitInLabel);
+ layout->addStretch();
+ layout->addWidget(useExistingButton);
+ layout->addWidget(useExistingLabel);
+ layout->addStretch();
+ layout->addWidget(manualButton);
+ layout->addWidget(manualLabel);
+ layout->addStretch();
+ setLayout(layout);
+}
+
+void PartitionChoicePage::initializePage() {
+ Q_ASSERT(horizonWizard()->chosen_disk.size() > 0);
+
+ QString chosen{QString::fromStdString(horizonWizard()->chosen_disk)};
+ descLabel->setText(descLabel->text().arg(chosen));
+
+ /* these options are, as of right now, always available */
+ eraseButton->setHidden(false);
+ eraseLabel->setHidden(false);
+ manualButton->setHidden(false);
+ manualLabel->setHidden(false);
+
+ Horizon::DiskMan::Disk *d = nullptr;
+ for(auto &disk : horizonWizard()->disks) {
+ if(disk.node() == horizonWizard()->chosen_disk) {
+ d = &disk;
+ break;
+ }
+ }
+
+ Q_ASSERT(d != nullptr);
+ if(d->has_label()) {
+ useExistingButton->setHidden(false);
+ useExistingLabel->setHidden(false);
+
+ if(d->contiguous_block() > 2000) {
+ fitInButton->setHidden(false);
+ fitInLabel->setHidden(false);
+ }
+ }
+
+}
+
+bool PartitionChoicePage::isComplete() const {
+ return buttons->checkedButton() != nullptr;
+}
+
+int PartitionChoicePage::nextId() const {
+ if(buttons->checkedButton() == manualButton) {
+ return HorizonWizard::Page_PartitionManual;
+ } else if(buttons->checkedButton() == useExistingButton) {
+ return HorizonWizard::Page_PartitionMount;
+ } else {
+ return HorizonWizard::Page_Network;
+ }
+}