Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
theme_designer_dialog.h
Go to the documentation of this file.
1
9
10#ifndef THEME_DESIGNER_DIALOG_H
11#define THEME_DESIGNER_DIALOG_H
12
13#include <config.h>
14
18
19#include <QFont>
20#include <QHash>
21#include <QList>
22#include <QString>
23#include <QStringList>
24
26class QAction;
27class QComboBox;
28class QLabel;
29class QMenu;
30class QPoint;
31class QTreeWidgetItem;
32
33namespace Ui {
34class ThemeDesignerDialog;
35}
36
46{
47 Q_OBJECT
48
49public:
55
62 explicit ThemeDesignerDialog(QWidget *parent, Context context = Context::Standalone,
63 const QString &initialTheme = QString());
65
66signals:
68 void themeSaved(const QString &internalName);
70 void themeRemoved(const QString &internalName);
71
72public slots:
73 void reject() override;
74
75protected:
76 bool event(QEvent *event) override;
77 void keyPressEvent(QKeyEvent *event) override;
78 bool eventFilter(QObject *watched, QEvent *event) override;
79
80private:
81 // Theme list
82 void populateThemeList(const QString &selectStem);
83 QTreeWidgetItem *themeItem(const QString &stem) const;
84 void updateListMarker();
85 void themeSelectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
86 bool loadTheme(const QString &stem);
87 void takeDrafts(const ThemeDraft &base, const ThemeDraft &draft);
88
89 // Unsaved changes
90 bool isDirty() const;
91 bool isBundledDraft() const;
92 int metaEditedCount() const;
93 int fontEditedCount() const;
94 bool canSave() const;
95 bool maybeSaveChanges();
96 void revertDraft();
97
98 // Editor
99 void metaEdited();
100 void descriptionEdited();
101 void updateDescriptionHeight();
102 void sideToggled();
103 void colorDraftChanged();
104 void draftChanged();
105 void updateMetaFields();
106
107 // Fonts tab
108 void tabChanged(int index);
109 void fillFontFamilies();
110 void updateFontControls();
111 void fillFamilyCombo(QComboBox *combo, const QStringList &families, const QString &current);
112 void fillSizeCombo(QComboBox *combo, int current);
113 void fontFamilyChanged(bool monospace);
114 void fontSizeChanged(bool monospace);
115 void showFontContextMenu(bool monospace, QWidget *source, const QPoint &pos);
116 void updateFontLabels();
117 QFont resolvedFont(const ThemeFontHint &hint, bool monospace) const;
118
119 // Code tab
120 void updateCompareCombo();
121 QString compareText();
122 void compareChanged();
123 void updateCodeView();
124 void updateCodeCounts();
125 void updateValidation();
126 bool roundTrips(const ThemeDraft &draft, const QString &stem, QByteArray *jsonc = nullptr) const;
127 void updateCodeBanner();
128 QByteArray bundledJsonc(const QString &stem);
129 void copyCode();
130
131 // Playground, status and chrome
132 void updatePlayground();
133 void updateStatus();
134 void updateButtons();
135 void updateTitle();
136 void refreshThemeDependentLabels();
138 void themeChanged();
139
140 // Preview samples
141 void previewTabChanged(int index);
142 void previewLayerPicked(const ThemePreviewPick::Layer &layer);
143 void previewPickMenu(QMenu *menu, QAction *before, const QList<ThemePreviewPick::Layer> &layers);
145 void showPickTip(QWidget *sample, const ThemePreviewPick::Layer &layer, const QPoint &global_pos);
146
147 // File operations
148 void newTheme();
149 void copyTheme();
150 void renameTheme();
151 void deleteTheme();
152 void importTheme();
153 void exportTheme();
154 void saveDraft();
155 void useTheme();
156 bool isActiveTheme(const QString &stem) const;
157 void showError(const QString &text);
158 bool writeDraft(const ThemeDraft &draft, const QString &stem);
159 bool saveAsPersonal(const ThemeDraft &draft, const QString &stem);
160 void selectWrittenTheme(const QString &stem);
161 void notifySaved(const QString &stem, const QString &removedStem = QString());
162 void activateTheme(const QString &stem);
163 void keepInFront();
164
173 template <typename Dialog>
174 auto runChildDialog(Dialog &&dialog) -> decltype(dialog())
175 {
176 auto result = dialog();
177 keepInFront();
178 return result;
179 }
180
181 Ui::ThemeDesignerDialog *ui_;
182#ifdef HAVE_LUA
183 ThemeLuaCodePreview *lua_code_preview_ = nullptr; // The Lua Code sample
184#endif
185 Context context_;
186
187 ThemeDraft base_;
188 ThemeDraft draft_;
189 ThemeParseReport load_report_;
190 QString current_stem_;
191 bool side_dark_;
192 QString compare_;
193 bool fonts_filled_;
194 QStringList families_;
195 QStringList monospace_families_;
196 QHash<QString, QByteArray> bundled_jsonc_;
197 QByteArray draft_jsonc_; // The draft as written, updated with the validation
198 QString validation_error_;
199 QString status_note_; // Shown instead of the status until the next edit or load
200 QString status_note_tool_tip_;
201 bool picked_once_ = false; // The hover hint is shown until the first pick
202 QHash<QObject *, ThemePreviewPicker *> pickers_; // Pick state per preview sample, for eventFilter() and the hover tooltip
203 QList<ThemeInfo> themes_; // Sorted by name, filled by populateThemeList()
204 QString base_title_;
205};
206
207#endif // THEME_DESIGNER_DIALOG_H
GeometryStateDialog(QWidget *parent, Qt::WindowFlags f=Qt::Window)
Constructs a new GeometryStateDialog with the specified parent and window flags.
Definition geometry_state_dialog.h:91
Definition theme_designer_dialog.h:46
void themeSaved(const QString &internalName)
ThemeDesignerDialog(QWidget *parent, Context context=Context::Standalone, const QString &initialTheme=QString())
Definition theme_designer_dialog.cpp:206
void themeRemoved(const QString &internalName)
Context
Definition theme_designer_dialog.h:51
@ Standalone
View > Internals: "Use Theme" activates directly.
Definition theme_designer_dialog.h:52
@ Preferences
Preferences page: activation happens on OK/Apply.
Definition theme_designer_dialog.h:53
Definition theme_lua_code_preview.h:48
Definition theme_manager.h:973
Definition theme_manager.h:72
Definition theme_manager.h:87
Definition theme_preview_pick.h:60