mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 14:45:41 +12:00
Allow configuring the app icon
This commit is contained in:
parent
4b841e6343
commit
95cc79e0a3
3 changed files with 39 additions and 9 deletions
|
@ -21,6 +21,7 @@ class ConfigWindow : public QDialog {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using ConfigCallback = std::function<void()>;
|
using ConfigCallback = std::function<void()>;
|
||||||
|
using IconCallback = std::function<void(const QString&)>;
|
||||||
|
|
||||||
enum class Theme : int {
|
enum class Theme : int {
|
||||||
System = 0,
|
System = 0,
|
||||||
|
@ -30,7 +31,14 @@ class ConfigWindow : public QDialog {
|
||||||
Cream = 4,
|
Cream = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class WindowIcon : int {
|
||||||
|
Rpog = 0,
|
||||||
|
Rsyn = 1,
|
||||||
|
};
|
||||||
|
|
||||||
Theme currentTheme;
|
Theme currentTheme;
|
||||||
|
WindowIcon currentIcon;
|
||||||
|
|
||||||
QTextEdit* helpText = nullptr;
|
QTextEdit* helpText = nullptr;
|
||||||
QListWidget* widgetList = nullptr;
|
QListWidget* widgetList = nullptr;
|
||||||
QStackedWidget* widgetContainer = nullptr;
|
QStackedWidget* widgetContainer = nullptr;
|
||||||
|
@ -41,13 +49,16 @@ class ConfigWindow : public QDialog {
|
||||||
// The config class holds a copy of the emulator config which it edits and sends
|
// The config class holds a copy of the emulator config which it edits and sends
|
||||||
// over to the emulator in a thread-safe manner
|
// over to the emulator in a thread-safe manner
|
||||||
EmulatorConfig config;
|
EmulatorConfig config;
|
||||||
|
|
||||||
ConfigCallback updateConfig;
|
ConfigCallback updateConfig;
|
||||||
|
IconCallback updateIcon;
|
||||||
|
|
||||||
void addWidget(QWidget* widget, QString title, QString icon, QString helpText);
|
void addWidget(QWidget* widget, QString title, QString icon, QString helpText);
|
||||||
void setTheme(Theme theme);
|
void setTheme(Theme theme);
|
||||||
|
void setIcon(WindowIcon icon);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfigWindow(ConfigCallback callback, const EmulatorConfig& config, QWidget* parent = nullptr);
|
ConfigWindow(ConfigCallback configCallback, IconCallback iconCallback, const EmulatorConfig& config, QWidget* parent = nullptr);
|
||||||
~ConfigWindow();
|
~ConfigWindow();
|
||||||
|
|
||||||
EmulatorConfig& getConfig() { return config; }
|
EmulatorConfig& getConfig() { return config; }
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
#include "panda_qt/config_window.hpp"
|
#include "panda_qt/config_window.hpp"
|
||||||
|
|
||||||
ConfigWindow::ConfigWindow(ConfigCallback callback, const EmulatorConfig& emuConfig, QWidget* parent) : QDialog(parent), config(emuConfig) {
|
ConfigWindow::ConfigWindow(ConfigCallback configCallback, IconCallback iconCallback, const EmulatorConfig& emuConfig, QWidget* parent)
|
||||||
|
: QDialog(parent), config(emuConfig) {
|
||||||
setWindowTitle(tr("Configuration"));
|
setWindowTitle(tr("Configuration"));
|
||||||
updateConfig = std::move(callback);
|
|
||||||
|
updateConfig = std::move(configCallback);
|
||||||
|
updateIcon = std::move(iconCallback);
|
||||||
|
|
||||||
// Set up theme selection
|
// Set up theme selection
|
||||||
setTheme(Theme::Dark);
|
setTheme(Theme::Dark);
|
||||||
|
setIcon(WindowIcon::Rpog);
|
||||||
|
|
||||||
// Initialize the widget list and the widget container widgets
|
// Initialize the widget list and the widget container widgets
|
||||||
widgetList = new QListWidget(this);
|
widgetList = new QListWidget(this);
|
||||||
|
@ -37,8 +41,8 @@ ConfigWindow::ConfigWindow(ConfigCallback callback, const EmulatorConfig& emuCon
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
QVBoxLayout* mainLayout = new QVBoxLayout();
|
||||||
QHBoxLayout* hLayout = new QHBoxLayout;
|
QHBoxLayout* hLayout = new QHBoxLayout();
|
||||||
|
|
||||||
// Set up widget layouts
|
// Set up widget layouts
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
@ -55,7 +59,7 @@ ConfigWindow::ConfigWindow(ConfigCallback callback, const EmulatorConfig& emuCon
|
||||||
guiLayout->setHorizontalSpacing(20);
|
guiLayout->setHorizontalSpacing(20);
|
||||||
guiLayout->setVerticalSpacing(10);
|
guiLayout->setVerticalSpacing(10);
|
||||||
|
|
||||||
QComboBox* themeSelect = new QComboBox;
|
QComboBox* themeSelect = new QComboBox();
|
||||||
themeSelect->addItem(tr("System"));
|
themeSelect->addItem(tr("System"));
|
||||||
themeSelect->addItem(tr("Light"));
|
themeSelect->addItem(tr("Light"));
|
||||||
themeSelect->addItem(tr("Dark"));
|
themeSelect->addItem(tr("Dark"));
|
||||||
|
@ -67,6 +71,13 @@ ConfigWindow::ConfigWindow(ConfigCallback callback, const EmulatorConfig& emuCon
|
||||||
});
|
});
|
||||||
guiLayout->addRow(tr("Color theme"), themeSelect);
|
guiLayout->addRow(tr("Color theme"), themeSelect);
|
||||||
|
|
||||||
|
QComboBox* iconSelect = new QComboBox();
|
||||||
|
iconSelect->addItem(tr("Happy panda"));
|
||||||
|
iconSelect->addItem(tr("Happy panda (colourful)"));
|
||||||
|
iconSelect->setCurrentIndex(static_cast<int>(currentIcon));
|
||||||
|
connect(iconSelect, &QComboBox::currentIndexChanged, this, [&](int index) { setIcon(static_cast<WindowIcon>(index)); });
|
||||||
|
guiLayout->addRow(tr("Window icon"), iconSelect);
|
||||||
|
|
||||||
QCheckBox* showAppVersion = new QCheckBox(tr("Show version on window title"));
|
QCheckBox* showAppVersion = new QCheckBox(tr("Show version on window title"));
|
||||||
showAppVersion->setChecked(config.windowSettings.showAppVersion);
|
showAppVersion->setChecked(config.windowSettings.showAppVersion);
|
||||||
connectCheckbox(showAppVersion, config.windowSettings.showAppVersion);
|
connectCheckbox(showAppVersion, config.windowSettings.showAppVersion);
|
||||||
|
@ -218,7 +229,7 @@ ConfigWindow::ConfigWindow(ConfigCallback callback, const EmulatorConfig& emuCon
|
||||||
connectCheckbox(muteAudio, config.audioDeviceConfig.muteAudio);
|
connectCheckbox(muteAudio, config.audioDeviceConfig.muteAudio);
|
||||||
audioLayout->addRow(muteAudio);
|
audioLayout->addRow(muteAudio);
|
||||||
|
|
||||||
QSpinBox* volumeRaw = new QSpinBox;
|
QSpinBox* volumeRaw = new QSpinBox();
|
||||||
volumeRaw->setRange(0, 200);
|
volumeRaw->setRange(0, 200);
|
||||||
volumeRaw->setValue(config.audioDeviceConfig.volumeRaw* 100);
|
volumeRaw->setValue(config.audioDeviceConfig.volumeRaw* 100);
|
||||||
connect(volumeRaw, &QSpinBox::valueChanged, this, [&](int value) {
|
connect(volumeRaw, &QSpinBox::valueChanged, this, [&](int value) {
|
||||||
|
@ -375,6 +386,15 @@ void ConfigWindow::setTheme(Theme theme) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigWindow::setIcon(WindowIcon icon) {
|
||||||
|
switch (icon) {
|
||||||
|
case WindowIcon::Rsyn: updateIcon(":/docs/img/rsyn_icon.png"); break;
|
||||||
|
|
||||||
|
case WindowIcon::Rpog:
|
||||||
|
default: updateIcon(":/docs/img/rpog_icon.png"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigWindow::addWidget(QWidget* widget, QString title, QString icon, QString helpText) {
|
void ConfigWindow::addWidget(QWidget* widget, QString title, QString icon, QString helpText) {
|
||||||
const int index = widgetList->count();
|
const int index = widgetList->count();
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) {
|
MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) {
|
||||||
setWindowTitle("Alber");
|
setWindowTitle("Alber");
|
||||||
setWindowIcon(QIcon(":/docs/img/rpog_icon.png"));
|
|
||||||
|
|
||||||
// Enable drop events for loading ROMs
|
// Enable drop events for loading ROMs
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
@ -96,7 +95,7 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
||||||
EmulatorMessage message{.type = MessageType::UpdateConfig};
|
EmulatorMessage message{.type = MessageType::UpdateConfig};
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
},
|
},
|
||||||
emu->getConfig(), this
|
[&](const QString& icon) { setWindowIcon(QIcon(icon)); }, emu->getConfig(), this
|
||||||
);
|
);
|
||||||
|
|
||||||
auto args = QCoreApplication::arguments();
|
auto args = QCoreApplication::arguments();
|
||||||
|
|
Loading…
Add table
Reference in a new issue