mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Use json file based themes instead of code to create them (theme editor + theme mode settings)
This commit is contained in:
63
common/themes/theme_editor_dialog.h
Normal file
63
common/themes/theme_editor_dialog.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef THEME_EDITOR_DIALOG_H
|
||||
#define THEME_EDITOR_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QJsonObject>
|
||||
|
||||
class QComboBox;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
// Generic theme parameter editor.
|
||||
// Works entirely on QJsonObject — has no knowledge of app-specific ThemeParams.
|
||||
// Connect to themeJsonChanged to receive live updates as the user edits colors.
|
||||
class ThemeEditorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThemeEditorDialog(const QJsonObject ¶ms, QWidget *parent = nullptr);
|
||||
|
||||
QJsonObject currentParams() const { return params; }
|
||||
|
||||
signals:
|
||||
void themeJsonChanged(const QJsonObject ¶ms);
|
||||
|
||||
private:
|
||||
void populate(QTreeWidgetItem *parent, const QJsonObject &obj, const QStringList &path);
|
||||
void editColorItem(QTreeWidgetItem *item);
|
||||
void applyColorToItem(QTreeWidgetItem *item, const QColor &color);
|
||||
void toggleBoolItem(QTreeWidgetItem *item);
|
||||
void editNumberItem(QTreeWidgetItem *item);
|
||||
void filterTree(const QString &query);
|
||||
void saveToFile();
|
||||
void loadFromFile();
|
||||
|
||||
// Identify feature: hold the (i) button to temporarily flash the UI element
|
||||
// that uses the current item's value. The original value is restored on release.
|
||||
void identifyPressed();
|
||||
void identifyReleased();
|
||||
|
||||
static QIcon colorIcon(const QColor &color);
|
||||
static void setJsonPath(QJsonObject &root, const QStringList &path, const QJsonValue &value);
|
||||
|
||||
QTreeWidget *tree;
|
||||
QLineEdit *searchEdit;
|
||||
QJsonObject params;
|
||||
|
||||
// Meta UI
|
||||
QLabel *idLabel;
|
||||
QLineEdit *nameEdit;
|
||||
QComboBox *variantCombo;
|
||||
|
||||
void syncMetaToParams();
|
||||
void syncMetaFromParams();
|
||||
|
||||
// Identify state (null item = inactive)
|
||||
QTreeWidgetItem *identifyItem = nullptr;
|
||||
QStringList identifyPath;
|
||||
QJsonValue identifySnapshot; // original value saved on press, restored on release
|
||||
};
|
||||
|
||||
#endif // THEME_EDITOR_DIALOG_H
|
||||
Reference in New Issue
Block a user