2022-04-23 09:59:50 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-04-29 00:01:23 +01:00
|
|
|
|
|
|
|
#include <QtConcurrent/QtConcurrent>
|
2021-04-15 00:07:40 +01:00
|
|
|
#include "common/settings.h"
|
2021-08-12 20:32:53 +01:00
|
|
|
#include "core/core.h"
|
2021-12-25 19:27:52 +00:00
|
|
|
#include "core/internal_network/network_interface.h"
|
2021-08-12 20:32:53 +01:00
|
|
|
#include "ui_configure_network.h"
|
|
|
|
#include "yuzu/configuration/configure_network.h"
|
2019-04-29 00:01:23 +01:00
|
|
|
|
2021-09-03 02:40:55 +01:00
|
|
|
ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent)
|
|
|
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()), system{system_} {
|
2019-04-29 00:01:23 +01:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
2021-08-12 23:34:04 +01:00
|
|
|
ui->network_interface->addItem(tr("None"));
|
2021-08-13 11:39:14 +01:00
|
|
|
for (const auto& iface : Network::GetAvailableNetworkInterfaces()) {
|
|
|
|
ui->network_interface->addItem(QString::fromStdString(iface.name));
|
2021-08-12 20:32:53 +01:00
|
|
|
}
|
|
|
|
|
2019-06-21 01:31:17 +01:00
|
|
|
this->SetConfiguration();
|
2019-04-29 00:01:23 +01:00
|
|
|
}
|
|
|
|
|
2021-08-12 20:32:53 +01:00
|
|
|
ConfigureNetwork::~ConfigureNetwork() = default;
|
2019-04-29 00:01:23 +01:00
|
|
|
|
2021-08-12 20:32:53 +01:00
|
|
|
void ConfigureNetwork::ApplyConfiguration() {
|
|
|
|
Settings::values.network_interface = ui->network_interface->currentText().toStdString();
|
2019-04-29 00:01:23 +01:00
|
|
|
}
|
|
|
|
|
2022-05-02 04:36:10 +01:00
|
|
|
void ConfigureNetwork::changeEvent(QEvent* event) {
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
RetranslateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureNetwork::RetranslateUI() {
|
2019-04-29 00:01:23 +01:00
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
2021-08-12 20:32:53 +01:00
|
|
|
void ConfigureNetwork::SetConfiguration() {
|
2021-09-03 02:40:55 +01:00
|
|
|
const bool runtime_lock = !system.IsPoweredOn();
|
2021-08-12 20:32:53 +01:00
|
|
|
|
|
|
|
const std::string& network_interface = Settings::values.network_interface.GetValue();
|
|
|
|
|
|
|
|
ui->network_interface->setCurrentText(QString::fromStdString(network_interface));
|
|
|
|
ui->network_interface->setEnabled(runtime_lock);
|
2019-04-29 00:01:23 +01:00
|
|
|
}
|