2023-06-10 05:45:04 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
2023-05-09 06:36:05 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-12 22:42:21 +01:00
|
|
|
#include <forward_list>
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringLiteral>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <qobjectdefs.h>
|
2023-05-09 03:37:03 +01:00
|
|
|
#include "yuzu/configuration/shared_translation.h"
|
|
|
|
|
2023-06-12 22:42:21 +01:00
|
|
|
class QCheckBox;
|
2023-05-09 03:37:03 +01:00
|
|
|
class QComboBox;
|
2023-06-12 22:42:21 +01:00
|
|
|
class QDateTimeEdit;
|
|
|
|
class QLabel;
|
2023-05-09 03:37:03 +01:00
|
|
|
class QLineEdit;
|
2023-06-12 22:42:21 +01:00
|
|
|
class QObject;
|
|
|
|
class QPushButton;
|
2023-05-09 03:37:03 +01:00
|
|
|
class QSlider;
|
2023-06-12 22:42:21 +01:00
|
|
|
class QSpinBox;
|
2023-05-09 03:37:03 +01:00
|
|
|
|
|
|
|
namespace Settings {
|
|
|
|
class BasicSetting;
|
2023-06-12 22:42:21 +01:00
|
|
|
} // namespace Settings
|
2023-05-09 03:37:03 +01:00
|
|
|
|
|
|
|
namespace ConfigurationShared {
|
|
|
|
|
|
|
|
enum class RequestType {
|
|
|
|
Default,
|
|
|
|
ComboBox,
|
|
|
|
SpinBox,
|
|
|
|
Slider,
|
|
|
|
ReverseSlider,
|
|
|
|
LineEdit,
|
2023-05-10 22:57:25 +01:00
|
|
|
HexEdit,
|
|
|
|
DateTimeEdit,
|
2023-05-09 03:37:03 +01:00
|
|
|
MaxEnum,
|
|
|
|
};
|
|
|
|
|
|
|
|
class Widget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-05-19 03:17:36 +01:00
|
|
|
Widget(Settings::BasicSetting* setting, const TranslationMap& translations,
|
|
|
|
const ComboboxTranslationMap& combobox_translations, QWidget* parent, bool runtime_lock,
|
|
|
|
std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
2023-05-09 03:37:03 +01:00
|
|
|
RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f,
|
2023-05-18 22:54:22 +01:00
|
|
|
Settings::BasicSetting* other_setting = nullptr,
|
|
|
|
const QString& string = QStringLiteral(""));
|
2023-05-09 03:37:03 +01:00
|
|
|
virtual ~Widget();
|
|
|
|
|
2023-06-06 20:45:44 +01:00
|
|
|
bool Valid() const;
|
2023-05-09 03:37:03 +01:00
|
|
|
|
2023-05-18 22:54:22 +01:00
|
|
|
[[nodiscard]] static QPushButton* CreateRestoreGlobalButton(bool using_global, QWidget* parent);
|
2023-05-09 19:26:03 +01:00
|
|
|
|
2023-05-09 03:37:03 +01:00
|
|
|
QPushButton* restore_button{};
|
|
|
|
QLineEdit* line_edit{};
|
2023-05-09 20:46:07 +01:00
|
|
|
QSpinBox* spinbox{};
|
2023-05-09 03:37:03 +01:00
|
|
|
QCheckBox* checkbox{};
|
|
|
|
QSlider* slider{};
|
|
|
|
QComboBox* combobox{};
|
2023-05-10 22:57:25 +01:00
|
|
|
QDateTimeEdit* date_time_edit{};
|
2023-05-09 03:37:03 +01:00
|
|
|
|
|
|
|
private:
|
2023-06-06 20:45:44 +01:00
|
|
|
void SetupComponent(const QString& label, std::function<void()>& load_func, bool managed,
|
2023-06-07 02:20:37 +01:00
|
|
|
RequestType request, float multiplier,
|
|
|
|
Settings::BasicSetting* other_setting, const QString& string);
|
2023-06-06 20:45:44 +01:00
|
|
|
|
2023-06-09 21:53:26 +01:00
|
|
|
QLabel* CreateLabel(const QString& text);
|
2023-06-07 02:20:37 +01:00
|
|
|
QWidget* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label,
|
|
|
|
std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func,
|
|
|
|
const std::function<void()>& touch);
|
2023-06-09 21:53:26 +01:00
|
|
|
|
2023-06-06 20:45:44 +01:00
|
|
|
QWidget* CreateCombobox(std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func,
|
2023-06-07 02:20:37 +01:00
|
|
|
const std::function<void()>& touch);
|
|
|
|
QWidget* CreateLineEdit(std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func, const std::function<void()>& touch,
|
|
|
|
bool managed = true);
|
|
|
|
QWidget* CreateHexEdit(std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func, const std::function<void()>& touch);
|
|
|
|
QWidget* CreateSlider(bool reversed, float multiplier, const QString& format,
|
|
|
|
std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func, const std::function<void()>& touch);
|
|
|
|
QWidget* CreateDateTimeEdit(bool disabled, bool restrict,
|
|
|
|
std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func,
|
|
|
|
const std::function<void()>& touch);
|
|
|
|
QWidget* CreateSpinBox(const QString& suffix, std::function<std::string()>& serializer,
|
|
|
|
std::function<void()>& restore_func, const std::function<void()>& touch);
|
2023-05-09 03:37:03 +01:00
|
|
|
|
|
|
|
QWidget* parent;
|
|
|
|
const TranslationMap& translations;
|
2023-05-19 03:17:36 +01:00
|
|
|
const ComboboxTranslationMap& combobox_enumerations;
|
2023-05-09 03:37:03 +01:00
|
|
|
Settings::BasicSetting& setting;
|
2023-06-09 21:53:26 +01:00
|
|
|
std::forward_list<std::function<void(bool)>>& apply_funcs;
|
2023-05-09 03:37:03 +01:00
|
|
|
|
|
|
|
bool created{false};
|
2023-05-18 22:54:22 +01:00
|
|
|
bool runtime_lock{false};
|
2023-05-09 03:37:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ConfigurationShared
|