diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-10 01:56:18 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-10 01:56:18 -0600 |
commit | a960999ec41917860c72591de8c072c060f71e0a (patch) | |
tree | 1ab8112bf3b77a804acbc66977080948d9ea0044 | |
parent | 3b4ce3c25eac554499564b1946bc732a7c0bb69c (diff) | |
download | horizon-a960999ec41917860c72591de8c072c060f71e0a.tar.gz horizon-a960999ec41917860c72591de8c072c060f71e0a.tar.bz2 horizon-a960999ec41917860c72591de8c072c060f71e0a.tar.xz horizon-a960999ec41917860c72591de8c072c060f71e0a.zip |
Qt UI: Add draft for UI.Network.ChooseIface
-rw-r--r-- | ui/qt5/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ui/qt5/horizonwizard.cc | 2 | ||||
-rw-r--r-- | ui/qt5/networkifacepage.cc | 70 | ||||
-rw-r--r-- | ui/qt5/networkifacepage.hh | 24 |
4 files changed, 97 insertions, 0 deletions
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt index 647c833..e453a25 100644 --- a/ui/qt5/CMakeLists.txt +++ b/ui/qt5/CMakeLists.txt @@ -10,6 +10,7 @@ set(UI_SOURCES intropage.cc inputpage.cc networkingpage.cc + networkifacepage.cc horizon.qrc) add_executable(horizon-qt5 ${UI_SOURCES}) diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc index dc80dea..59bef95 100644 --- a/ui/qt5/horizonwizard.cc +++ b/ui/qt5/horizonwizard.cc @@ -26,6 +26,7 @@ #include "intropage.hh" #include "inputpage.hh" #include "networkingpage.hh" +#include "networkifacepage.hh" #include "netsimplewifipage.hh" static std::map<int, std::string> help_id_map = { @@ -146,6 +147,7 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) { setPage(Page_Intro, new IntroPage); setPage(Page_Input, new InputPage); setPage(Page_Network, new NetworkingPage); + setPage(Page_Network_Iface, new NetworkIfacePage); QObject::connect(this, &QWizard::helpRequested, [=](void) { if(help_id_map.find(currentId()) == help_id_map.end()) { diff --git a/ui/qt5/networkifacepage.cc b/ui/qt5/networkifacepage.cc new file mode 100644 index 0000000..6823333 --- /dev/null +++ b/ui/qt5/networkifacepage.cc @@ -0,0 +1,70 @@ +/* + * networkifacepage.cc - Implementation of the UI.Network.ChooseIface 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 "networkifacepage.hh" +#include "horizonwizard.hh" + +#include <QLabel> +#include <QListView> +#include <QListWidget> +#include <QVBoxLayout> + +NetworkIfacePage::NetworkIfacePage(QWidget *parent) : + HorizonWizardPage(parent) { + loadWatermark("network"); + setTitle(tr("Multiple Network Interfaces Detected")); +} + +void NetworkIfacePage::initializePage() { + QLabel *descLabel; + QListWidget *ifaceList; + QVBoxLayout *layout; + + descLabel = new QLabel(tr( + "Your computer has more than one network interface device. Select the one you wish to use during installation.")); + descLabel->setWordWrap(true); + + ifaceList = new QListWidget(this); + for(auto &iface : horizonWizard()->interfaces) { + QIcon ifaceIcon; + QString ifaceDevName = QString::fromStdString(iface.first); + QString ifaceName; + + switch(iface.second) { + case HorizonWizard::Wireless: + ifaceIcon = QIcon::fromTheme("network-wireless"); + ifaceName = tr("Wi-Fi (%1)").arg(ifaceDevName); + break; + case HorizonWizard::Ethernet: + ifaceIcon = QIcon::fromTheme("network-wired"); + ifaceName = tr("Ethernet (%1)").arg(ifaceDevName); + break; + case HorizonWizard::Bonded: + ifaceIcon = QIcon::fromTheme("network-card"); + ifaceName = tr("Bonded Interface (%1)").arg(ifaceDevName); + break; + case HorizonWizard::Unknown: + ifaceIcon = QIcon::fromTheme("network-card"); + ifaceName = tr("Unknown Interface (%1)").arg(ifaceDevName); + break; + } + + new QListWidgetItem(ifaceIcon, ifaceName, ifaceList); + } + + ifaceList->setViewMode(QListView::IconMode); + + layout = new QVBoxLayout; + layout->addWidget(descLabel); + layout->addWidget(ifaceList); + setLayout(layout); +} diff --git a/ui/qt5/networkifacepage.hh b/ui/qt5/networkifacepage.hh new file mode 100644 index 0000000..bcd37c6 --- /dev/null +++ b/ui/qt5/networkifacepage.hh @@ -0,0 +1,24 @@ +/* + * networkifacepage.hh - Definition of the UI.Network.ChooseIface 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 NETWORKIFACEPAGE_HH +#define NETWORKIFACEPAGE_HH + +#include "horizonwizardpage.hh" + +class NetworkIfacePage : public HorizonWizardPage { +public: + NetworkIfacePage(QWidget *parent = nullptr); + void initializePage() override; +}; + +#endif /* !NETWORKIFACEPAGE_HH */ |