summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-10 03:54:10 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-10 03:54:10 -0600
commit7fe9e61230de11feb2698443105ecb57f4709c23 (patch)
treed9df0036e8e0e409ed044592ba514e4bc8a1e702
parentd295d6ebbb87bdfe57eb9d398f6758eaf6bc0715 (diff)
downloadhorizon-7fe9e61230de11feb2698443105ecb57f4709c23.tar.gz
horizon-7fe9e61230de11feb2698443105ecb57f4709c23.tar.bz2
horizon-7fe9e61230de11feb2698443105ecb57f4709c23.tar.xz
horizon-7fe9e61230de11feb2698443105ecb57f4709c23.zip
Qt UI: Finish implementing UI.Network.ChooseIface and add help doc
-rw-r--r--ui/qt5/horizon.qrc1
-rw-r--r--ui/qt5/networkifacepage.cc70
-rw-r--r--ui/qt5/networkifacepage.hh6
-rw-r--r--ui/qt5/resources/network-iface-help.txt21
4 files changed, 91 insertions, 7 deletions
diff --git a/ui/qt5/horizon.qrc b/ui/qt5/horizon.qrc
index b828069..562418c 100644
--- a/ui/qt5/horizon.qrc
+++ b/ui/qt5/horizon.qrc
@@ -12,6 +12,7 @@
<file>resources/input-help.txt</file>
<file>resources/partition-help.txt</file>
<file>resources/network-start-help.txt</file>
+ <file>resources/network-iface-help.txt</file>
<file>resources/packages-simple-help.txt</file>
</qresource>
<qresource prefix="/">
diff --git a/ui/qt5/networkifacepage.cc b/ui/qt5/networkifacepage.cc
index d8a9655..323bbe2 100644
--- a/ui/qt5/networkifacepage.cc
+++ b/ui/qt5/networkifacepage.cc
@@ -13,27 +13,45 @@
#include "networkifacepage.hh"
#include "horizonwizard.hh"
+#ifdef HAS_INSTALL_ENV
+# include <net/if.h> /* ifreq */
+# include <sys/ioctl.h> /* ioctl */
+# include <unistd.h> /* close */
+#endif
+
+#include <algorithm>
+#include <QDebug>
#include <QLabel>
#include <QListView>
-#include <QListWidget>
#include <QVBoxLayout>
NetworkIfacePage::NetworkIfacePage(QWidget *parent) :
HorizonWizardPage(parent) {
loadWatermark("network");
setTitle(tr("Multiple Network Interfaces Detected"));
+
+ ifaceList = new QListWidget(this);
+ connect(ifaceList, &QListWidget::currentRowChanged, [=](int row) {
+ emit completeChanged();
+ if(row == -1) return;
+ auto iterator = horizonWizard()->interfaces.begin();
+ std::advance(iterator, row);
+ horizonWizard()->chosen_auto_iface = iterator->first;
+ });
+
+ ifaceList->setGridSize(QSize(160, 128));
+ ifaceList->setIconSize(QSize(96, 96));
+ ifaceList->setViewMode(QListView::IconMode);
}
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);
@@ -58,14 +76,52 @@ void NetworkIfacePage::initializePage() {
break;
}
- new QListWidgetItem(ifaceIcon, ifaceName, ifaceList);
+ QListWidgetItem *item = new QListWidgetItem(ifaceIcon, ifaceName,
+ ifaceList);
+ /* Retrieving the index is always valid, and is not even privileged. */
+ struct ifreq request;
+ int my_sock = ::socket(AF_INET, SOCK_STREAM, 0);
+ if(my_sock == -1) {
+ continue;
+ }
+ memset(&request, 0, sizeof(request));
+ memcpy(&request.ifr_name, iface.first.c_str(), iface.first.size());
+ errno = 0;
+ if(ioctl(my_sock, SIOCGIFHWADDR, &request) != -1) {
+ char *buf;
+ asprintf(&buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ request.ifr_ifru.ifru_hwaddr.sa_data[0],
+ request.ifr_ifru.ifru_hwaddr.sa_data[1],
+ request.ifr_ifru.ifru_hwaddr.sa_data[2],
+ request.ifr_ifru.ifru_hwaddr.sa_data[3],
+ request.ifr_ifru.ifru_hwaddr.sa_data[4],
+ request.ifr_ifru.ifru_hwaddr.sa_data[5]);
+ item->setToolTip(QString(buf));
+ free(buf);
+ }
+ ::close(my_sock);
}
- ifaceList->setGridSize(QSize(160, 128));
- ifaceList->setIconSize(QSize(96, 96));
- ifaceList->setViewMode(QListView::IconMode);
layout = new QVBoxLayout;
layout->addWidget(descLabel);
layout->addWidget(ifaceList);
setLayout(layout);
}
+
+bool NetworkIfacePage::isComplete() const {
+ return ifaceList->currentRow() != -1;
+}
+
+int NetworkIfacePage::nextId() const {
+ if(ifaceList->currentRow() < 0) return HorizonWizard::Page_Network_Iface;
+
+ auto iterator = horizonWizard()->interfaces.begin();
+ std::advance(iterator, ifaceList->currentRow());
+
+ switch(iterator->second) {
+ case HorizonWizard::Wireless:
+ return HorizonWizard::Page_Network_Wireless;
+ default:
+ return HorizonWizard::Page_Network_DHCP;
+ }
+}
diff --git a/ui/qt5/networkifacepage.hh b/ui/qt5/networkifacepage.hh
index bcd37c6..05b0e2b 100644
--- a/ui/qt5/networkifacepage.hh
+++ b/ui/qt5/networkifacepage.hh
@@ -13,12 +13,18 @@
#ifndef NETWORKIFACEPAGE_HH
#define NETWORKIFACEPAGE_HH
+#include <QListWidget>
+
#include "horizonwizardpage.hh"
class NetworkIfacePage : public HorizonWizardPage {
public:
NetworkIfacePage(QWidget *parent = nullptr);
void initializePage() override;
+ bool isComplete() const;
+ int nextId() const;
+private:
+ QListWidget *ifaceList;
};
#endif /* !NETWORKIFACEPAGE_HH */
diff --git a/ui/qt5/resources/network-iface-help.txt b/ui/qt5/resources/network-iface-help.txt
new file mode 100644
index 0000000..14e31d8
--- /dev/null
+++ b/ui/qt5/resources/network-iface-help.txt
@@ -0,0 +1,21 @@
+<h2>Network Interface Selection</h2>
+
+<p>This page is shown when your computer has multiple network interfaces.
+Select the one that you wish to use during installation. You can configure
+additional network interfaces after installation.</p>
+
+<h3>How do I know which interface to select?</h3>
+
+<ul>
+ <li>If you use a wireless connection, select <b>Wi-Fi</b>.</li>
+ <li>If you use a wired connection, select <b>Ethernet</b>.</li>
+</ul>
+
+<p>If you're not sure which interface is correct, and you know the MAC address
+of your interface, use the mouse to hover over each interface. Each interface
+has its MAC address in its tool-tip.</p>
+
+<p>If you see multiple interfaces of the same type, and you aren't expecting
+this, your hardware may have been incorrectly detected by Adélie Linux. You
+can contact our community for help at <a href="https://help.adelielinux.org/">
+https://help.adelielinux.org/</a>.</p>