mirror-chatterino2/src/singletons/Theme.hpp
nerix 4e3433e966
Store Themes as JSON files (#4471)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
2023-04-08 09:05:55 +00:00

134 lines
2.6 KiB
C++

#pragma once
#include "common/ChatterinoSetting.hpp"
#include "common/Singleton.hpp"
#include "util/RapidJsonSerializeQString.hpp"
#include <pajlada/settings/setting.hpp>
#include <QColor>
#include <QPixmap>
namespace chatterino {
class WindowManager;
class Theme final : public Singleton
{
public:
Theme();
bool isLightTheme() const;
struct TabColors {
QColor text;
struct {
QColor regular;
QColor hover;
QColor unfocused;
} backgrounds;
struct {
QColor regular;
QColor hover;
QColor unfocused;
} line;
};
QColor accent{"#00aeef"};
/// WINDOW
struct {
QColor background;
QColor text;
} window;
/// TABS
struct {
TabColors regular;
TabColors newMessage;
TabColors highlighted;
TabColors selected;
QColor dividerLine;
} tabs;
/// MESSAGES
struct {
struct {
QColor regular;
QColor caret;
QColor link;
QColor system;
QColor chatPlaceholder;
} textColors;
struct {
QColor regular;
QColor alternate;
} backgrounds;
QColor disabled;
QColor selection;
QColor highlightAnimationStart;
QColor highlightAnimationEnd;
} messages;
/// SCROLLBAR
struct {
QColor background;
QColor thumb;
QColor thumbSelected;
} scrollbars;
/// SPLITS
struct {
QColor messageSeperator;
QColor background;
QColor dropPreview;
QColor dropPreviewBorder;
QColor dropTargetRect;
QColor dropTargetRectBorder;
QColor resizeHandle;
QColor resizeHandleBackground;
struct {
QColor border;
QColor focusedBorder;
QColor background;
QColor focusedBackground;
QColor text;
QColor focusedText;
} header;
struct {
QColor background;
QColor text;
QString styleSheet;
} input;
} splits;
struct {
QPixmap copy;
QPixmap pin;
} buttons;
void normalizeColor(QColor &color) const;
void update();
pajlada::Signals::NoArgSignal updated;
QStringSetting themeName{"/appearance/theme/name", "Dark"};
private:
bool isLight_ = false;
void parse();
void parseFrom(const QJsonObject &root);
pajlada::Signals::NoArgSignal repaintVisibleChatWidgets_;
friend class WindowManager;
};
Theme *getTheme();
} // namespace chatterino