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