Loading and saving of settings is starting to work

main
Aaron Rainbolt 1 year ago
parent e9e20b8f8a
commit 832b4d5cf6

1
.gitignore vendored

@ -0,0 +1 @@
CMakeLists.txt.user

@ -87,7 +87,7 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
connSettings->setPermissions(QHash<QString, QString>());
} else {
if (connSettings->permissions().isEmpty()) {
; // TODO: Add current user to permissiosn list
connSettings->addToPermissions(ConnectionSettingsEngine::userName(), QString());
} // Otherwise we just leave the permissions as-is
}
}
@ -107,3 +107,12 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
} // if it's "Automatic" we just leave it be
}
}
QString ConnectionSettingsEngine::userName()
{
QProcess userNameGetter;
userNameGetter.setProgram("whoami");
userNameGetter.start();
userNameGetter.waitForFinished();
return QString(userNameGetter.readAllStandardOutput());
}

@ -4,6 +4,7 @@
#include <QString>
#include <QVariant>
#include <QHash>
#include <QProcess>
#include <NetworkManagerQt/Connection>
#include <NetworkManagerQt/ConnectionSettings>
#include <NetworkManagerQt/Settings>
@ -15,6 +16,9 @@ public:
static QVariantMap readConnectionSettings(QString connUuidStr);
static void modifyConnectionSettings(QString connUuidStr, QVariantMap settings);
private:
static QString userName();
};
#endif // CONNECTIONSETTINGSENGINE_H

@ -1,10 +1,11 @@
#include "ethernetsettings.h"
#include "ui_genericsettings.h"
EthernetSettings::EthernetSettings(QString title, QWidget *parent) :
EthernetSettings::EthernetSettings(QString title, QString connUuidStr, QWidget *parent) :
QDialog(parent),
ui(new Ui::GenericSettings)
{
targetConnUuidStr = connUuidStr;
ui->setupUi(this);
this->setWindowTitle(title);
ui->connectionNameLineEdit->setText(title);
@ -12,6 +13,10 @@ EthernetSettings::EthernetSettings(QString title, QWidget *parent) :
ethernetSettingsTab = new EthernetSettingsTab();
ui->tabWidget->addTab(generalSettingsTab, "General");
ui->tabWidget->addTab(ethernetSettingsTab, "Ethernet");
QVariantMap connSettings = ConnectionSettingsEngine::readConnectionSettings(connUuidStr);
generalSettingsTab->loadSettings(connSettings);
connect(ui->cancelButton, &QPushButton::clicked, this, &EthernetSettings::onCancelButtonClicked);
connect(ui->saveButton, &QPushButton::clicked, this, &EthernetSettings::onSaveButtonClicked);
}
EthernetSettings::~EthernetSettings()
@ -20,3 +25,15 @@ EthernetSettings::~EthernetSettings()
delete generalSettingsTab;
delete ethernetSettingsTab;
}
void EthernetSettings::onCancelButtonClicked()
{
this->done(0);
}
void EthernetSettings::onSaveButtonClicked()
{
QVariantMap settings = generalSettingsTab->readSettings();
ConnectionSettingsEngine::modifyConnectionSettings(targetConnUuidStr, settings);
this->done(0);
}

@ -1,6 +1,7 @@
#ifndef ETHERNETSETTINGS_H
#define ETHERNETSETTINGS_H
#include "connectionsettingsengine.h"
#include "generalsettingstab.h"
#include "ethernetsettingstab.h"
@ -15,12 +16,17 @@ class EthernetSettings : public QDialog
Q_OBJECT
public:
explicit EthernetSettings(QString title, QWidget *parent = nullptr);
explicit EthernetSettings(QString title, QString connUuidStr, QWidget *parent = nullptr);
~EthernetSettings();
private slots:
void onCancelButtonClicked();
void onSaveButtonClicked();
private:
Ui::GenericSettings *ui;
QString targetConnUuidStr;
GeneralSettingsTab *generalSettingsTab;
EthernetSettingsTab *ethernetSettingsTab;
};

@ -6,6 +6,7 @@ GeneralSettingsTab::GeneralSettingsTab(QWidget *parent) :
ui(new Ui::GeneralSettingsTab)
{
ui->setupUi(this);
ui->meteredConnectionComboBox->addItems(QStringList() << "Automatic" << "Yes" << "No");
}
GeneralSettingsTab::~GeneralSettingsTab()

@ -47,7 +47,7 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -60,7 +60,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<widget class="QPushButton" name="saveButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>

@ -183,8 +183,6 @@ void NetworkSelector::regenConnTree()
break;
case NetworkManager::ConnectionSettings::Vpn:
case NetworkManager::ConnectionSettings::Tun:
case NetworkManager::ConnectionSettings::IpTunnel:
case NetworkManager::ConnectionSettings::WireGuard:
targetItem = connGroupItem("VPN");
if (targetItem == NULL) {
@ -193,6 +191,22 @@ void NetworkSelector::regenConnTree()
}
break;
case NetworkManager::ConnectionSettings::Tun:
targetItem = connGroupItem("Tun");
if (targetItem == NULL) {
targetItem = new QStandardItem("Tun");
connTreeList.append(targetItem);
}
break;
case NetworkManager::ConnectionSettings::IpTunnel:
targetItem = connGroupItem("IpTunnel");
if (targetItem == NULL) {
targetItem = new QStandardItem("IpTunnel");
connTreeList.append(targetItem);
}
break;
case NetworkManager::ConnectionSettings::Wimax:
targetItem = connGroupItem("WiMAX");
if (targetItem == NULL) {
@ -256,7 +270,7 @@ void NetworkSelector::modifyConnection(QModelIndex index)
NetworkManager::ConnectionSettings::ConnectionType connType = connList[i]->settings()->connectionType();
switch(connType) {
case NetworkManager::ConnectionSettings::Wired:
dialogWindow = new EthernetSettings(index.data().toString());
dialogWindow = new EthernetSettings(index.data().toString(), index.data(Qt::UserRole+1).toString());
dialogWindow->exec();
delete dialogWindow;
break;

Loading…
Cancel
Save