configure_network.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <QtConcurrent/QtConcurrent>
  4. #include "common/settings.h"
  5. #include "core/core.h"
  6. #include "core/internal_network/network_interface.h"
  7. #include "ui_configure_network.h"
  8. #include "yuzu/configuration/configure_network.h"
  9. ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent)
  10. : QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()), system{system_} {
  11. ui->setupUi(this);
  12. ui->network_interface->addItem(tr("None"));
  13. for (const auto& iface : Network::GetAvailableNetworkInterfaces()) {
  14. ui->network_interface->addItem(QString::fromStdString(iface.name));
  15. }
  16. this->SetConfiguration();
  17. }
  18. ConfigureNetwork::~ConfigureNetwork() = default;
  19. void ConfigureNetwork::ApplyConfiguration() {
  20. Settings::values.network_interface = ui->network_interface->currentText().toStdString();
  21. }
  22. void ConfigureNetwork::changeEvent(QEvent* event) {
  23. if (event->type() == QEvent::LanguageChange) {
  24. RetranslateUI();
  25. }
  26. QWidget::changeEvent(event);
  27. }
  28. void ConfigureNetwork::RetranslateUI() {
  29. ui->retranslateUi(this);
  30. }
  31. void ConfigureNetwork::SetConfiguration() {
  32. const bool runtime_lock = !system.IsPoweredOn();
  33. const std::string& network_interface = Settings::values.network_interface.GetValue();
  34. ui->network_interface->setCurrentText(QString::fromStdString(network_interface));
  35. ui->network_interface->setEnabled(runtime_lock);
  36. }