From 3ccce005ff16a1eed262e194402fa27b00c56ec3 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Thu, 29 Sep 2016 13:39:46 +0200 Subject: added an information dialog that displays ip and hostname. --- src/client/informationdialog/informationdialog.cpp | 43 ++++++++++++++++++++++ src/client/informationdialog/informationdialog.h | 26 +++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/client/informationdialog/informationdialog.cpp create mode 100644 src/client/informationdialog/informationdialog.h (limited to 'src/client/informationdialog') diff --git a/src/client/informationdialog/informationdialog.cpp b/src/client/informationdialog/informationdialog.cpp new file mode 100644 index 0000000..bc53ee9 --- /dev/null +++ b/src/client/informationdialog/informationdialog.cpp @@ -0,0 +1,43 @@ +#include "informationdialog.h" +#include +#include + +InformationDialog::InformationDialog() : QDialog() { + + /* widgets */ + _lblTitle = new QLabel(tr("

system information

")); + _tableWidget = new QWidget(); + + /* layouts */ + _layout = new QVBoxLayout(); + _tableLayout = new QFormLayout(); + + /* */ + _tableWidget->setLayout(_tableLayout); + _layout->addWidget(_lblTitle); + _layout->addWidget(_tableWidget); + this->setLayout(_layout); + + initTable(); + + qDebug() << "create information dialog"; +} + +void InformationDialog::initTable() { + /* NETWORK*/ + /* hostnames */ + _tableLayout->addRow(new QLabel(tr("hostname")), new QLabel(QHostInfo::localHostName())); + /* ips */ + for (QHostAddress a: QNetworkInterface::allAddresses()) { + + QString ip = a.toString(); + if (ip == "::1" || ip == "127.0.0.1") { continue;} + + QLabel* label = new QLabel(tr("IP") ); + QLabel* value = new QLabel(ip); + _tableLayout->addRow(label, value); + } + + /* TODO: Add other information */ +} + diff --git a/src/client/informationdialog/informationdialog.h b/src/client/informationdialog/informationdialog.h new file mode 100644 index 0000000..6bbf41c --- /dev/null +++ b/src/client/informationdialog/informationdialog.h @@ -0,0 +1,26 @@ +#ifndef INFORMATION_DIALOG_H +#define INFORMATION_DIALOG_H +#include +#include +#include +#include +#include +#include + + +class InformationDialog : public QDialog { + + private: + QLayout* _layout; + QFormLayout* _tableLayout; + QLabel* _lblTitle; + QWidget* _tableWidget; + + void initTable(); + + public: + InformationDialog(); + +}; + +#endif -- cgit v1.2.3-55-g7522