You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

#include "networkcreator.h"
#include "ui_networkcreator.h"
#include <QDebug>
NetworkCreator::NetworkCreator(QWidget *parent) :
QDialog(parent),
ui(new Ui::NetworkCreator)
{
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()
{
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);
}