Implement Ethernet connection creation
This commit is contained in:
parent
9f2438711a
commit
4e07bf46e2
@ -828,7 +828,6 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
|
|||||||
// TODO: Handle WiFi here
|
// TODO: Handle WiFi here
|
||||||
}
|
}
|
||||||
qWarning() << connSettingsMap;
|
qWarning() << connSettingsMap;
|
||||||
// TODO: Do something to surpress app exit here
|
|
||||||
QDBusPendingReply<> reply = conn->update(connSettingsMap);
|
QDBusPendingReply<> reply = conn->update(connSettingsMap);
|
||||||
auto watcher = new QDBusPendingCallWatcher(reply);
|
auto watcher = new QDBusPendingCallWatcher(reply);
|
||||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, saveReplyFinished);
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, saveReplyFinished);
|
||||||
|
@ -1,14 +1,50 @@
|
|||||||
#include "networkcreator.h"
|
#include "networkcreator.h"
|
||||||
#include "ui_networkcreator.h"
|
#include "ui_networkcreator.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
NetworkCreator::NetworkCreator(QWidget *parent) :
|
NetworkCreator::NetworkCreator(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::NetworkCreator)
|
ui(new Ui::NetworkCreator)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->connectionTypeComboBox->addItems(QStringList() << tr("Ethernet"));
|
||||||
|
connect(ui->okButton, &QPushButton::clicked, this, &NetworkCreator::onOkButtonClicked);
|
||||||
|
connect(ui->cancelButton, &QPushButton::clicked, this, &NetworkCreator::onCancelButtonClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkCreator::~NetworkCreator()
|
NetworkCreator::~NetworkCreator()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkCreator::onOkButtonClicked()
|
||||||
|
{
|
||||||
|
NetworkManager::ConnectionSettings::Ptr connSettings;
|
||||||
|
NetworkManager::WiredSetting::Ptr wiredSetting;
|
||||||
|
|
||||||
|
switch(ui->connectionTypeComboBox->currentIndex()) {
|
||||||
|
case 0: // Ethernet
|
||||||
|
connSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wired));
|
||||||
|
wiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
||||||
|
wiredSetting->setAutoNegotiate(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
connSettings->setId(ui->connectionNameLineEdit->text());
|
||||||
|
connSettings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||||
|
|
||||||
|
QDBusPendingReply<> reply = NetworkManager::addConnection(connSettings->toMap());
|
||||||
|
auto watcher = new QDBusPendingCallWatcher(reply);
|
||||||
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &NetworkCreator::createReplyFinished);
|
||||||
|
connSettings.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkCreator::onCancelButtonClicked()
|
||||||
|
{
|
||||||
|
this->done(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkCreator::createReplyFinished()
|
||||||
|
{
|
||||||
|
this->done(0);
|
||||||
|
}
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
#define NETWORKCREATOR_H
|
#define NETWORKCREATOR_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <NetworkManagerQt/Settings>
|
||||||
|
#include <NetworkManagerQt/ConnectionSettings>
|
||||||
|
#include <NetworkManagerQt/WiredSetting>
|
||||||
|
#include <QDBusPendingReply>
|
||||||
|
#include <QDBusPendingCallWatcher>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class NetworkCreator;
|
class NetworkCreator;
|
||||||
@ -15,8 +23,14 @@ public:
|
|||||||
explicit NetworkCreator(QWidget *parent = nullptr);
|
explicit NetworkCreator(QWidget *parent = nullptr);
|
||||||
~NetworkCreator();
|
~NetworkCreator();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onOkButtonClicked();
|
||||||
|
void onCancelButtonClicked();
|
||||||
|
void createReplyFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NetworkCreator *ui;
|
Ui::NetworkCreator *ui;
|
||||||
|
QDialog *dialogWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NETWORKCREATOR_H
|
#endif // NETWORKCREATOR_H
|
||||||
|
@ -7,12 +7,78 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>300</height>
|
<height>191</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Create New Connection...</string>
|
<string>Create New Connection...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Choose connection type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="connectionTypeComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Specify connection name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="connectionNameLineEdit"/>
|
||||||
|
</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>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<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>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user