mirror of https://git.suyu.dev/suyu/suyu
general: add default configurations for applet mode
parent
78aac6b403
commit
fa12384350
@ -0,0 +1,86 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure_applets.h"
|
||||
#include "yuzu/configuration/configuration_shared.h"
|
||||
#include "yuzu/configuration/configure_applets.h"
|
||||
#include "yuzu/configuration/shared_widget.h"
|
||||
|
||||
ConfigureApplets::ConfigureApplets(Core::System& system_,
|
||||
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
|
||||
const ConfigurationShared::Builder& builder, QWidget* parent)
|
||||
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureApplets>()}, system{system_} {
|
||||
ui->setupUi(this);
|
||||
|
||||
Setup(builder);
|
||||
|
||||
SetConfiguration();
|
||||
}
|
||||
|
||||
ConfigureApplets::~ConfigureApplets() = default;
|
||||
|
||||
void ConfigureApplets::changeEvent(QEvent* event) {
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
RetranslateUI();
|
||||
}
|
||||
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
void ConfigureApplets::RetranslateUI() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ConfigureApplets::Setup(const ConfigurationShared::Builder& builder) {
|
||||
auto& library_applets_layout = *ui->group_library_applet_modes->layout();
|
||||
std::map<u32, QWidget*> applets_hold{};
|
||||
|
||||
std::vector<Settings::BasicSetting*> settings;
|
||||
auto push = [&settings](auto& list) {
|
||||
for (auto setting : list) {
|
||||
settings.push_back(setting);
|
||||
}
|
||||
};
|
||||
|
||||
push(Settings::values.linkage.by_category[Settings::Category::LibraryApplet]);
|
||||
|
||||
for (auto setting : settings) {
|
||||
ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs);
|
||||
|
||||
if (widget == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (!widget->Valid()) {
|
||||
widget->deleteLater();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Untested applets
|
||||
if (setting->Id() == Settings::values.data_erase_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.error_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.net_connect_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.web_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.shop_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.login_share_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.wifi_web_auth_applet_mode.Id() ||
|
||||
setting->Id() == Settings::values.my_page_applet_mode.Id()) {
|
||||
widget->setHidden(true);
|
||||
}
|
||||
|
||||
applets_hold.emplace(setting->Id(), widget);
|
||||
}
|
||||
for (const auto& [label, widget] : applets_hold) {
|
||||
library_applets_layout.addWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureApplets::SetConfiguration() {}
|
||||
|
||||
void ConfigureApplets::ApplyConfiguration() {
|
||||
const bool powered_on = system.IsPoweredOn();
|
||||
for (const auto& func : apply_funcs) {
|
||||
func(powered_on);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
// SPDX-FileCopyrightText: 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "yuzu/configuration/configuration_shared.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
class QDateTimeEdit;
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureApplets;
|
||||
}
|
||||
|
||||
namespace ConfigurationShared {
|
||||
class Builder;
|
||||
}
|
||||
|
||||
class ConfigureApplets : public ConfigurationShared::Tab {
|
||||
public:
|
||||
explicit ConfigureApplets(Core::System& system_,
|
||||
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::Builder& builder,
|
||||
QWidget* parent = nullptr);
|
||||
~ConfigureApplets() override;
|
||||
|
||||
void ApplyConfiguration() override;
|
||||
void SetConfiguration() override;
|
||||
|
||||
private:
|
||||
void changeEvent(QEvent* event) override;
|
||||
void RetranslateUI();
|
||||
|
||||
void Setup(const ConfigurationShared::Builder& builder);
|
||||
|
||||
std::vector<std::function<void(bool)>> apply_funcs{};
|
||||
|
||||
std::unique_ptr<Ui::ConfigureApplets> ui;
|
||||
bool enabled = false;
|
||||
|
||||
Core::System& system;
|
||||
};
|
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigureApplets</class>
|
||||
<widget class="QWidget" name="ConfigureApplets">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Applets</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group_library_applet_modes">
|
||||
<property name="title">
|
||||
<string>Applet mode preference</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="applets_widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue