Add list editor to IPv4 settings, add some placeholder text to some 802.1x setting fields

main
Aaron Rainbolt 1 year ago
parent 0a2a90811b
commit e8ffda5a29

@ -49,6 +49,9 @@ set(PROJECT_SOURCES
ipv4settingstab.cpp ipv4settingstab.cpp
ipv4settingstab.ui ipv4settingstab.ui
qvarianthelper.h qvarianthelper.h
listeditordialog.h
listeditordialog.cpp
listeditordialog.ui
${TS_FILES} ${TS_FILES}
) )

@ -7,6 +7,8 @@ Ipv4SettingsTab::Ipv4SettingsTab(QWidget *parent) :
{ {
ui->setupUi(this); 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")); 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() Ipv4SettingsTab::~Ipv4SettingsTab()
@ -107,3 +109,17 @@ void Ipv4SettingsTab::loadSettings(QVariantMap settings)
ui->ipv4RequiredCheckBox->setChecked(settings["ipv4Required"].toBool()); 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());
}

@ -3,6 +3,7 @@
#include "qvarianthelper.h" #include "qvarianthelper.h"
#include "connectionsettingsengine.h" #include "connectionsettingsengine.h"
#include "listeditordialog.h"
#include <QWidget> #include <QWidget>
namespace Ui { namespace Ui {
@ -20,6 +21,10 @@ public:
QVariantMap readSettings(); QVariantMap readSettings();
void loadSettings(QVariantMap settings); void loadSettings(QVariantMap settings);
private slots:
void onEditDnsServersButtonClicked();
void onEditSearchDomainsButtonClicked();
private: private:
Ui::Ipv4SettingsTab *ui; Ui::Ipv4SettingsTab *ui;
}; };

@ -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();
}

@ -0,0 +1,37 @@
#ifndef LISTEDITORDIALOG_H
#define LISTEDITORDIALOG_H
#include <QDialog>
#include <QString>
#include <QChar>
#include <QList>
#include <QStringList>
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

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ListEditorDialog</class>
<widget class="QDialog" name="ListEditorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<height>371</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="newItemLineEdit"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="itemListWidget"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="addItemButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeItemButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveUpItemButton">
<property name="text">
<string>Move Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveDownItemButton">
<property name="text">
<string>Move Down</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -31,7 +31,7 @@
<item> <item>
<widget class="QTabWidget" name="authenticationModeTabs"> <widget class="QTabWidget" name="authenticationModeTabs">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="md5Tab"> <widget class="QWidget" name="md5Tab">
<attribute name="title"> <attribute name="title">
@ -183,7 +183,11 @@
<item row="4" column="1"> <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QLineEdit" name="tlsUserPrivateKeyLineEdit"/> <widget class="QLineEdit" name="tlsUserPrivateKeyLineEdit">
<property name="placeholderText">
<string>URL (e.g., file:///path/to/file)</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="tlsUserPrivateKeyOpenFileButton"> <widget class="QPushButton" name="tlsUserPrivateKeyOpenFileButton">
@ -217,7 +221,11 @@
<item row="3" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLineEdit" name="tlsUserCertificateLineEdit"/> <widget class="QLineEdit" name="tlsUserCertificateLineEdit">
<property name="placeholderText">
<string>URL (e.g., file:///path/to/file)</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="tlsUserCertificateOpenFileButton"> <widget class="QPushButton" name="tlsUserCertificateOpenFileButton">
@ -231,7 +239,11 @@
<item row="2" column="1"> <item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLineEdit" name="tlsCaCertificateLineEdit"/> <widget class="QLineEdit" name="tlsCaCertificateLineEdit">
<property name="placeholderText">
<string>URL (e.g., file:///path/to/file)</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="tlsCaCertificateOpenFileButton"> <widget class="QPushButton" name="tlsCaCertificateOpenFileButton">
@ -335,7 +347,11 @@
<item row="2" column="1"> <item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QLineEdit" name="fastPacFileLineEdit"/> <widget class="QLineEdit" name="fastPacFileLineEdit">
<property name="placeholderText">
<string>URL (e.g., file:///path/to/file)</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="fastPacFileOpenFileButton"> <widget class="QPushButton" name="fastPacFileOpenFileButton">
@ -508,7 +524,11 @@
<item row="2" column="1"> <item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QLineEdit" name="ttlsCaCertificateLineEdit"/> <widget class="QLineEdit" name="ttlsCaCertificateLineEdit">
<property name="placeholderText">
<string>URL (e.g., file:///path/to/file)</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="ttlsCaCertificateOpenFileButton"> <widget class="QPushButton" name="ttlsCaCertificateOpenFileButton">
@ -597,7 +617,11 @@
<item row="2" column="1"> <item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<widget class="QLineEdit" name="peapCaCertificateLineEdit"/> <widget class="QLineEdit" name="peapCaCertificateLineEdit">
<property name="placeholderText">
<string>URL (e.g., file:///path/to/file)</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="peapCaCertificateOpenFileButton"> <widget class="QPushButton" name="peapCaCertificateOpenFileButton">

Loading…
Cancel
Save