-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
534 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
// Some UI settings that aren't fully frontend-dependent. Note: Not all frontends will support the same settings. | ||
// Note: Any enums should ideally be ordered in the same order we want to show them in UI dropdown menus, so that we can cast indices to enums | ||
// directly. | ||
struct FrontendSettings { | ||
enum class Theme : int { | ||
System = 0, | ||
Light = 1, | ||
Dark = 2, | ||
GreetingsCat = 3, | ||
Cream = 4, | ||
}; | ||
|
||
// Different panda-themed window icons | ||
enum class WindowIcon : int { | ||
Rpog = 0, | ||
Rsyn = 1, | ||
Rnap = 2, | ||
Rcow = 3, | ||
}; | ||
|
||
Theme theme = Theme::Dark; | ||
WindowIcon icon = WindowIcon::Rpog; | ||
|
||
static Theme themeFromString(std::string inString); | ||
static const char* themeToString(Theme theme); | ||
|
||
static WindowIcon iconFromString(std::string inString); | ||
static const char* iconToString(WindowIcon icon); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,56 @@ | ||
#pragma once | ||
|
||
#include <QApplication> | ||
#include <QCheckBox> | ||
#include <QComboBox> | ||
#include <QDialog> | ||
#include <QListWidget> | ||
#include <QPalette> | ||
#include <QStackedWidget> | ||
#include <QTextEdit> | ||
#include <QWidget> | ||
#include <QtWidgets> | ||
#include <array> | ||
#include <functional> | ||
#include <utility> | ||
|
||
#include "emulator.hpp" | ||
#include "frontend_settings.hpp" | ||
|
||
class ConfigWindow : public QDialog { | ||
Q_OBJECT | ||
|
||
private: | ||
enum class Theme : int { | ||
System = 0, | ||
Light = 1, | ||
Dark = 2, | ||
GreetingsCat = 3, | ||
Cream = 4, | ||
}; | ||
using ConfigCallback = std::function<void()>; | ||
using MainWindowCallback = std::function<QWidget*()>; | ||
|
||
using Theme = FrontendSettings::Theme; | ||
using WindowIcon = FrontendSettings::WindowIcon; | ||
|
||
QTextEdit* helpText = nullptr; | ||
QListWidget* widgetList = nullptr; | ||
QStackedWidget* widgetContainer = nullptr; | ||
|
||
static constexpr size_t settingWidgetCount = 6; | ||
std::array<QString, settingWidgetCount> helpTexts; | ||
|
||
Theme currentTheme; | ||
QComboBox* themeSelect = nullptr; | ||
// The config class holds a copy of the emulator config which it edits and sends | ||
// over to the emulator in a thread-safe manner | ||
EmulatorConfig config; | ||
|
||
void setTheme(Theme theme); | ||
ConfigCallback updateConfig; | ||
MainWindowCallback getMainWindow; | ||
|
||
void addWidget(QWidget* widget, QString title, QString icon, QString helpText); | ||
void setTheme(FrontendSettings::Theme theme); | ||
void setIcon(FrontendSettings::WindowIcon icon); | ||
|
||
public: | ||
ConfigWindow(QWidget* parent = nullptr); | ||
ConfigWindow(ConfigCallback configCallback, MainWindowCallback windowCallback, const EmulatorConfig& config, QWidget* parent = nullptr); | ||
~ConfigWindow(); | ||
|
||
EmulatorConfig& getConfig() { return config; } | ||
|
||
private: | ||
Emulator* emu; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "frontend_settings.hpp" | ||
|
||
#include <algorithm> | ||
#include <cctype> | ||
#include <unordered_map> | ||
|
||
// Frontend setting serialization/deserialization functions | ||
|
||
FrontendSettings::Theme FrontendSettings::themeFromString(std::string inString) { | ||
// Transform to lower-case to make the setting case-insensitive | ||
std::transform(inString.begin(), inString.end(), inString.begin(), [](unsigned char c) { return std::tolower(c); }); | ||
|
||
static const std::unordered_map<std::string, Theme> map = { | ||
{"system", Theme::System}, {"light", Theme::Light}, {"dark", Theme::Dark}, {"greetingscat", Theme::GreetingsCat}, {"cream", Theme::Cream}, | ||
}; | ||
|
||
if (auto search = map.find(inString); search != map.end()) { | ||
return search->second; | ||
} | ||
|
||
// Default to dark theme | ||
return Theme::Dark; | ||
} | ||
|
||
const char* FrontendSettings::themeToString(Theme theme) { | ||
switch (theme) { | ||
case Theme::System: return "system"; | ||
case Theme::Light: return "light"; | ||
case Theme::GreetingsCat: return "greetingscat"; | ||
case Theme::Cream: return "cream"; | ||
|
||
case Theme::Dark: | ||
default: return "dark"; | ||
} | ||
} | ||
|
||
FrontendSettings::WindowIcon FrontendSettings::iconFromString(std::string inString) { // Transform to lower-case to make the setting case-insensitive | ||
std::transform(inString.begin(), inString.end(), inString.begin(), [](unsigned char c) { return std::tolower(c); }); | ||
|
||
static const std::unordered_map<std::string, WindowIcon> map = { | ||
{"rpog", WindowIcon::Rpog}, | ||
{"rsyn", WindowIcon::Rsyn}, | ||
{"rcow", WindowIcon::Rcow}, | ||
{"rnap", WindowIcon::Rnap}, | ||
}; | ||
|
||
if (auto search = map.find(inString); search != map.end()) { | ||
return search->second; | ||
} | ||
|
||
// Default to the icon rpog icon | ||
return WindowIcon::Rpog; | ||
} | ||
|
||
const char* FrontendSettings::iconToString(WindowIcon icon) { | ||
switch (icon) { | ||
case WindowIcon::Rsyn: return "rsyn"; | ||
case WindowIcon::Rcow: return "rcow"; | ||
case WindowIcon::Rnap: return "rnap"; | ||
|
||
case WindowIcon::Rpog: | ||
default: return "rpog"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.