diff --git a/CMakeLists.txt b/CMakeLists.txt index af34113..538adf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,9 @@ set(PROJECT_SOURCES ipv4settingstab.cpp ipv4settingstab.ui qvarianthelper.h + listeditordialog.h + listeditordialog.cpp + listeditordialog.ui ${TS_FILES} ) diff --git a/ipv4settingstab.cpp b/ipv4settingstab.cpp index 0d920ae..ea91f44 100644 --- a/ipv4settingstab.cpp +++ b/ipv4settingstab.cpp @@ -7,6 +7,8 @@ Ipv4SettingsTab::Ipv4SettingsTab(QWidget *parent) : { ui->setupUi(this); ui->methodComboBox->addItems(QStringList() << tr("Automatic") << tr("Automatic (address-only)") << tr("Link-Local") << tr("Manual") << tr("Shared to other computers") << tr("Disabled")); + connect(ui->editDnsServersButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onEditDnsServersButtonClicked); + connect(ui->editSearchDomainsButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onEditSearchDomainsButtonClicked); } Ipv4SettingsTab::~Ipv4SettingsTab() @@ -107,3 +109,17 @@ void Ipv4SettingsTab::loadSettings(QVariantMap settings) ui->ipv4RequiredCheckBox->setChecked(settings["ipv4Required"].toBool()); } } + +void Ipv4SettingsTab::onEditDnsServersButtonClicked() +{ + ListEditorDialog led(this, ui->dnsServersLineEdit->text(), ','); + led.exec(); + ui->dnsServersLineEdit->setText(led.list()); +} + +void Ipv4SettingsTab::onEditSearchDomainsButtonClicked() +{ + ListEditorDialog led(this, ui->searchDomainsLineEdit->text(), ','); + led.exec(); + ui->searchDomainsLineEdit->setText(led.list()); +} diff --git a/ipv4settingstab.h b/ipv4settingstab.h index 5e77d39..e85d3e6 100644 --- a/ipv4settingstab.h +++ b/ipv4settingstab.h @@ -3,6 +3,7 @@ #include "qvarianthelper.h" #include "connectionsettingsengine.h" +#include "listeditordialog.h" #include namespace Ui { @@ -20,6 +21,10 @@ public: QVariantMap readSettings(); void loadSettings(QVariantMap settings); +private slots: + void onEditDnsServersButtonClicked(); + void onEditSearchDomainsButtonClicked(); + private: Ui::Ipv4SettingsTab *ui; }; diff --git a/listeditordialog.cpp b/listeditordialog.cpp new file mode 100644 index 0000000..50b748d --- /dev/null +++ b/listeditordialog.cpp @@ -0,0 +1,92 @@ +#include "listeditordialog.h" +#include "ui_listeditordialog.h" + +ListEditorDialog::ListEditorDialog(QWidget *parent, QString listStr, QChar separator) : + QDialog(parent), + ui(new Ui::ListEditorDialog) +{ + ui->setupUi(this); + QStringList itemList = listStr.split(separator); + for (int i = 0;i < itemList.count();i++) { + ui->itemListWidget->addItem(itemList[i]); + } + origListStr = listStr; + listModified = false; + connect(ui->addItemButton, &QPushButton::clicked, this, &ListEditorDialog::onAddItemButtonClicked); + connect(ui->removeItemButton, &QPushButton::clicked, this, &ListEditorDialog::onRemoveItemButtonClicked); + connect(ui->moveUpItemButton, &QPushButton::clicked, this, &ListEditorDialog::onMoveUpItemButtonClicked); + connect(ui->moveDownItemButton, &QPushButton::clicked, this, &ListEditorDialog::onMoveDownItemButtonClicked); + connect(ui->okButton, &QPushButton::clicked, this, &ListEditorDialog::onOkButtonClicked); + connect(ui->cancelButton, &QPushButton::clicked, this, &ListEditorDialog::onCancelButtonClicked); +} + +ListEditorDialog::~ListEditorDialog() +{ + delete ui; +} + +QString ListEditorDialog::list() +{ + if (!listModified) { + return origListStr; + } else { + QStringList final; + for (int i = 0;i < ui->itemListWidget->count();i++) { + final.append(ui->itemListWidget->item(i)->text()); + } + return final.join(','); + } +} + +void ListEditorDialog::onAddItemButtonClicked() +{ + if (ui->newItemLineEdit->text().trimmed() != "") { + ui->itemListWidget->addItem(ui->newItemLineEdit->text().trimmed()); + } + ui->newItemLineEdit->setText(""); +} + +void ListEditorDialog::onRemoveItemButtonClicked() +{ + if (ui->itemListWidget->count() != 0) { + delete ui->itemListWidget->item(ui->itemListWidget->currentRow()); + } +} + +void ListEditorDialog::onMoveUpItemButtonClicked() +{ + bool isBottomItemSelected = ui->itemListWidget->currentRow() == ui->itemListWidget->count() - 1; + if (ui->itemListWidget->count() != 0 && ui->itemListWidget->currentRow() != 0) { + ui->itemListWidget->insertItem(ui->itemListWidget->currentRow() - 1, ui->itemListWidget->takeItem(ui->itemListWidget->currentRow())); + + // Somehow the actively selected item ends up shifting down a row during the removal and reinsertion of the current item. + // If the actively selected item is the bottommost one, this has no effect, and so we only move up one row. + // Otherwise, we need to move up two rows to compensate. + if (isBottomItemSelected) { + ui->itemListWidget->setCurrentRow(ui->itemListWidget->currentRow() - 1); + } else { + ui->itemListWidget->setCurrentRow(ui->itemListWidget->currentRow() - 2); + } + } +} + +void ListEditorDialog::onMoveDownItemButtonClicked() +{ + if (ui->itemListWidget->count() != 0 && ui->itemListWidget->currentRow() != ui->itemListWidget->count() - 1) + { + ui->itemListWidget->insertItem(ui->itemListWidget->currentRow() + 1, ui->itemListWidget->takeItem(ui->itemListWidget->currentRow())); + ui->itemListWidget->setCurrentRow(ui->itemListWidget->currentRow() + 1); + } +} + +void ListEditorDialog::onOkButtonClicked() +{ + listModified = true; + this->close(); +} + +void ListEditorDialog::onCancelButtonClicked() +{ + listModified = false; + this->close(); +} diff --git a/listeditordialog.h b/listeditordialog.h new file mode 100644 index 0000000..488e3f0 --- /dev/null +++ b/listeditordialog.h @@ -0,0 +1,37 @@ +#ifndef LISTEDITORDIALOG_H +#define LISTEDITORDIALOG_H + +#include +#include +#include +#include +#include + +namespace Ui { +class ListEditorDialog; +} + +class ListEditorDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ListEditorDialog(QWidget *parent = nullptr, QString listStr = "", QChar separator = '\0'); + ~ListEditorDialog(); + QString list(); + +private slots: + void onAddItemButtonClicked(); + void onRemoveItemButtonClicked(); + void onMoveUpItemButtonClicked(); + void onMoveDownItemButtonClicked(); + void onOkButtonClicked(); + void onCancelButtonClicked(); + +private: + Ui::ListEditorDialog *ui; + QString origListStr; + bool listModified; +}; + +#endif // LISTEDITORDIALOG_H diff --git a/listeditordialog.ui b/listeditordialog.ui new file mode 100644 index 0000000..9c9a56f --- /dev/null +++ b/listeditordialog.ui @@ -0,0 +1,107 @@ + + + ListEditorDialog + + + + 0 + 0 + 430 + 371 + + + + Dialog + + + + + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + Move Up + + + + + + + Move Down + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + diff --git a/security802_1xtab.ui b/security802_1xtab.ui index 0949100..916c5cf 100644 --- a/security802_1xtab.ui +++ b/security802_1xtab.ui @@ -31,7 +31,7 @@ - 3 + 0 @@ -183,7 +183,11 @@ - + + + URL (e.g., file:///path/to/file) + + @@ -217,7 +221,11 @@ - + + + URL (e.g., file:///path/to/file) + + @@ -231,7 +239,11 @@ - + + + URL (e.g., file:///path/to/file) + + @@ -335,7 +347,11 @@ - + + + URL (e.g., file:///path/to/file) + + @@ -508,7 +524,11 @@ - + + + URL (e.g., file:///path/to/file) + + @@ -597,7 +617,11 @@ - + + + URL (e.g., file:///path/to/file) + +