summaryrefslogtreecommitdiff
path: root/ui/qt5
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt5')
-rw-r--r--ui/qt5/CMakeLists.txt7
-rw-r--r--ui/qt5/horizon.qrc1
-rw-r--r--ui/qt5/horizonwizard.cc2
-rw-r--r--ui/qt5/horizonwizard.hh8
-rw-r--r--ui/qt5/partitionpage.cc97
-rw-r--r--ui/qt5/partitionpage.hh45
-rw-r--r--ui/qt5/partitionprobe.cc19
-rw-r--r--ui/qt5/partitionprobe.hh32
-rw-r--r--ui/qt5/resources/disk-low.pngbin0 -> 6553 bytes
9 files changed, 208 insertions, 3 deletions
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt
index a8779fd..dfcaf53 100644
--- a/ui/qt5/CMakeLists.txt
+++ b/ui/qt5/CMakeLists.txt
@@ -15,6 +15,7 @@ set(UI_SOURCES
intropage.cc
inputpage.cc
+ partitionpage.cc
networkingpage.cc
networkifacepage.cc
netsimplewifipage.cc
@@ -45,7 +46,9 @@ set(RUN_QT_SOURCES
horizon.qrc)
IF(INSTALL)
- LIST(APPEND UI_SOURCES commitpage.cc)
+ LIST(APPEND UI_SOURCES
+ commitpage.cc
+ partitionprobe.cc)
ELSE(INSTALL)
LIST(APPEND UI_SOURCES writeoutpage.cc)
ENDIF(INSTALL)
@@ -68,7 +71,7 @@ IF(INSTALL)
pkg_check_modules(XKBFile REQUIRED xkbfile)
pkg_check_modules(LIBX11 REQUIRED x11)
pkg_check_modules(LibCap REQUIRED libcap)
- target_link_libraries(horizon-qt5 ${BCNM} ${SKARNET} ${LIBUDEV_LIBRARIES} ${LibCap_LIBRARIES} ${LIBX11_LIBRARIES} ${XKBFile_LIBRARIES})
+ target_link_libraries(horizon-qt5 ${BCNM} ${SKARNET} ${LIBUDEV_LIBRARIES} ${LibCap_LIBRARIES} ${LIBX11_LIBRARIES} ${XKBFile_LIBRARIES} diskman)
add_executable(horizon-run-qt5 ${RUN_QT_SOURCES})
target_link_libraries(horizon-run-qt5 Qt5::Widgets)
target_compile_definitions(horizon-run-qt5 PRIVATE IN_RUNNER)
diff --git a/ui/qt5/horizon.qrc b/ui/qt5/horizon.qrc
index 709cdc2..9e67f22 100644
--- a/ui/qt5/horizon.qrc
+++ b/ui/qt5/horizon.qrc
@@ -2,6 +2,7 @@
<qresource prefix="/wizard_pixmaps">
<file>resources/intro-high.png</file>
<file>resources/intro-low.png</file>
+ <file>resources/disk-low.png</file>
<file>resources/network-low.png</file>
<file>resources/network-high.png</file>
<file>resources/software-high.png</file>
diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc
index 72af147..9672006 100644
--- a/ui/qt5/horizonwizard.cc
+++ b/ui/qt5/horizonwizard.cc
@@ -38,6 +38,7 @@ extern "C" {
#include "intropage.hh"
#include "inputpage.hh"
+#include "partitionpage.hh"
#ifdef NON_LIBRE_FIRMWARE
#include "firmwarepage.hh"
#endif /* NON_LIBRE_FIRMWARE */
@@ -205,6 +206,7 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
setPage(Page_Intro, new IntroPage);
setPage(Page_Input, new InputPage);
+ setPage(Page_Partition, new PartitionPage);
#ifdef NON_LIBRE_FIRMWARE
setPage(Page_Firmware, new FirmwarePage);
#endif /* NON_LIBRE_FIRMWARE */
diff --git a/ui/qt5/horizonwizard.hh b/ui/qt5/horizonwizard.hh
index 6c6d781..3252d5b 100644
--- a/ui/qt5/horizonwizard.hh
+++ b/ui/qt5/horizonwizard.hh
@@ -13,10 +13,12 @@
#ifndef HORIZONWIZARD_HH
#define HORIZONWIZARD_HH
+#include <diskman/disk.hh>
#include <QShortcut>
#include <QWizard>
#include <map>
#include <string>
+#include <vector>
inline QString fromMacAddress(char address[6]) {
char buf[18];
@@ -134,12 +136,16 @@ public:
std::string version;
/*! The architecture being installed. */
Arch arch;
+#ifdef HAS_INSTALL_ENV
+ /*! The disks present on this computer. */
+ std::vector<Horizon::DiskMan::Disk> disks;
+#endif
/*! Whether to erase the disk when automatically partitioning. */
bool erase;
/*! The disk to partition automatically. */
std::string auto_disk;
/*! The HorizonScript lines describing what to do about partitioning.
- * If auto_erase_disk is set, this is not used.
+ * If auto_disk is set, this is not used.
* Otherwise, this should have any relevant disklabel/partition/fs etc. */
QStringList part_lines;
#ifdef NON_LIBRE_FIRMWARE
diff --git a/ui/qt5/partitionpage.cc b/ui/qt5/partitionpage.cc
new file mode 100644
index 0000000..8ca704a
--- /dev/null
+++ b/ui/qt5/partitionpage.cc
@@ -0,0 +1,97 @@
+/*
+ * partitionpage.cc - Implementation of the UI.Partition page:
+ * either UI.Partition.Runtime.DiskDetails, or UI.Partition.Install.Details
+ * 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 "partitionpage.hh"
+
+#include <QVBoxLayout>
+
+PartitionPage::PartitionPage(QWidget *parent) : HorizonWizardPage(parent) {
+ loadWatermark("disk");
+#ifdef HAS_INSTALL_ENV
+ setTitle(tr("Detecting Disks"));
+
+ thread = nullptr;
+ scanDone = false;
+
+ descLabel = new QLabel;
+ descLabel->setWordWrap(true);
+ progress = new QProgressBar;
+ progress->setRange(0, 0);
+
+ scanButton = new QPushButton(tr("Rescan Devices"));
+ connect(scanButton, &QPushButton::clicked, this, &PartitionPage::scanDisks);
+ scanButton->setHidden(true);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addStretch();
+ layout->addWidget(descLabel);
+ layout->addWidget(progress);
+ layout->addWidget(scanButton, 0, Qt::AlignCenter);
+ layout->addStretch();
+
+ setLayout(layout);
+#else /* !HAS_INSTALL_ENV */
+ setTitle(tr("Enter Disk Information"));
+#endif /* HAS_INSTALL_ENV */
+}
+
+void PartitionPage::initializePage() {
+#ifdef HAS_INSTALL_ENV
+ scanDisks();
+#endif
+}
+
+bool PartitionPage::isComplete() const {
+#ifdef HAS_INSTALL_ENV
+ return scanDone;
+#else /* !HAS_INSTALL_ENV */
+ // determine whether a valid disk has been input
+ return false;
+#endif /* HAS_INSTALL_ENV */
+}
+
+#ifdef HAS_INSTALL_ENV
+void PartitionPage::scanDisks() {
+ descLabel->setText(tr("Please wait while System Installation collects information on your computer's disk drives."));
+ scanButton->setEnabled(false);
+ scanButton->setHidden(true);
+ progress->setHidden(false);
+
+ if(thread != nullptr) {
+ thread->deleteLater();
+ }
+
+ thread = new PartitionProbeThread;
+ connect(thread, &PartitionProbeThread::foundDisks,
+ this, &PartitionPage::processDisks);
+ thread->start();
+}
+
+void PartitionPage::processDisks(void *disk_obj) {
+ /* Qt can only fling void*s around threads; convert back to vec of Disk */
+ vector<Disk> *disks = static_cast<vector<Disk> *>(disk_obj);
+
+ scanButton->setEnabled(true);
+ scanButton->setHidden(false);
+ progress->setHidden(true);
+ descLabel->setText(tr("System Installation has finished scanning your computer for disk drives.\n\nIf you've changed your computer's disk drive layout, choose Rescan Devices to run another scan."));
+
+ /* Copy our disk information into the wizard's global object */
+ horizonWizard()->disks.swap(*disks);
+ delete disks;
+
+ scanDone = true;
+ emit completeChanged();
+ wizard()->next();
+}
+#endif
diff --git a/ui/qt5/partitionpage.hh b/ui/qt5/partitionpage.hh
new file mode 100644
index 0000000..ab9ad79
--- /dev/null
+++ b/ui/qt5/partitionpage.hh
@@ -0,0 +1,45 @@
+/*
+ * partitionpage.hh - Definition of the UI.Partition page:
+ * either UI.Partition.Runtime.DiskDetails, or UI.Partition.Install.Details
+ * 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
+ */
+
+#ifndef PARTITIONPAGE_HH
+#define PARTITIONPAGE_HH
+
+#ifdef HAS_INSTALL_ENV
+# include <QLabel>
+# include <QProgressBar>
+# include <QPushButton>
+# include "partitionprobe.hh"
+#endif /* HAS_INSTALL_ENV */
+
+
+#include "horizonwizardpage.hh"
+
+class PartitionPage : public HorizonWizardPage {
+public:
+ PartitionPage(QWidget *parent = nullptr);
+ void initializePage();
+ bool isComplete() const override;
+private:
+#ifdef HAS_INSTALL_ENV
+ void scanDisks();
+ void processDisks(void *disks);
+ bool scanDone;
+
+ QProgressBar *progress;
+ QLabel *descLabel;
+ QPushButton *scanButton;
+ PartitionProbeThread *thread;
+#endif /* HAS_INSTALL_ENV */
+};
+
+#endif /* !PARTITIONPAGE_HH */
diff --git a/ui/qt5/partitionprobe.cc b/ui/qt5/partitionprobe.cc
new file mode 100644
index 0000000..32a45ab
--- /dev/null
+++ b/ui/qt5/partitionprobe.cc
@@ -0,0 +1,19 @@
+/*
+ * partitionprobe.cc - Implementation of the disk probing thread routines
+ * 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 "partitionprobe.hh"
+
+void PartitionProbeThread::run() {
+ vector<Disk> *disks = new vector<Disk>{myMan.find_disks(true, true, false)};
+ sleep(3);
+ emit foundDisks(disks);
+}
diff --git a/ui/qt5/partitionprobe.hh b/ui/qt5/partitionprobe.hh
new file mode 100644
index 0000000..f718907
--- /dev/null
+++ b/ui/qt5/partitionprobe.hh
@@ -0,0 +1,32 @@
+/*
+ * partitionprobe.hh - Definition of the disk probing thread routines
+ * 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 PARTITIONPROBE_HH
+#define PARTITIONPROBE_HH
+
+#include <QThread>
+#include <diskman/diskman.hh>
+
+using std::vector;
+using Horizon::DiskMan::Disk;
+
+class PartitionProbeThread : public QThread {
+ Q_OBJECT
+public:
+ void run() override;
+signals:
+ void foundDisks(void *disks);
+private:
+ Horizon::DiskMan::DiskMan myMan;
+};
+
+#endif /* !PARTITIONPROBE_HH */
diff --git a/ui/qt5/resources/disk-low.png b/ui/qt5/resources/disk-low.png
new file mode 100644
index 0000000..845ca7f
--- /dev/null
+++ b/ui/qt5/resources/disk-low.png
Binary files differ