Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
informationdialog.cpp
Go to the documentation of this file.
1 #include "informationdialog.h"
2 
3 #include <QNetworkInterface>
4 #include <QHostInfo>
5 #include <QDir>
6 #include <QDirIterator>
7 #include <QLayout>
8 #include <QFormLayout>
9 #include <QLabel>
10 
12 {
13 
14  /* widgets */
15  _lblTitle = new QLabel(tr("<h1>system information</h1>"), this);
16  _tableWidget = new QWidget(this);
17 
18  /* layouts */
19  _layout = new QVBoxLayout(this);
20  _tableLayout = new QFormLayout(this);
21 
22  /* */
23  _tableWidget->setLayout(_tableLayout);
24  _layout->addWidget(_lblTitle);
25  _layout->addWidget(_tableWidget);
26  this->setLayout(_layout);
27 
28  initTable();
29 
30  qDebug() << "create information dialog";
31 }
32 
34 {
35  /* NETWORK*/
36  /* hostnames */
37  _tableLayout->addRow(new QLabel("<b>" + tr("hostname") + "</b>", this),
38  new QLabel(QHostInfo::localHostName(), this));
39  /* ips */
40  QStringList interfaceFilter;
41  QString bridgeDevicePath("/sys/devices/virtual/net/");
42  QDirIterator it(bridgeDevicePath, QStringList("brif"), QDir::Dirs, QDirIterator::Subdirectories);
43  while (it.hasNext()) {
44  it.next();
45  QDir dir = it.filePath();
46  dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
47  interfaceFilter += dir.entryList();
48  }
49 
50  for (const auto& interface : QNetworkInterface::allInterfaces()) {
51 
52  if (interfaceFilter.contains(interface.name()) || interface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
53  qDebug() << "interface filtered: " << interface.name();
54  continue;
55  }
56 
57  _tableLayout->addRow("<u><b>" + interface.name() + "</b></u>", new QLabel(this));
58 
59  for (const auto &entry : interface.addressEntries()) {
60  QLabel* label;
61  QLabel* value;
62  QHostAddress hostAddr = entry.ip();
63 
64  if (hostAddr == QHostAddress::Null || hostAddr == QHostAddress::Broadcast || hostAddr == QHostAddress::LocalHost
65  || hostAddr == QHostAddress::AnyIPv6)
66  continue;
67 
68  if (hostAddr.protocol() == QAbstractSocket::IPv6Protocol) {
69  label = new QLabel("IPv6", this);
70  value = new QLabel(hostAddr.toString().split("%").first(), this);
71  } else {
72  label = new QLabel("IPv4", this);
73  value = new QLabel(hostAddr.toString(), this);
74  }
75 
76  _tableLayout->addRow(label, value);
77  }
78  _tableLayout->addRow("MAC", new QLabel(interface.hardwareAddress(), this));
79  }
80 
81  /* TODO: Add other information */
82 }
QFormLayout * _tableLayout