Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
theme_preview_widget.h
Go to the documentation of this file.
1
9
10#ifndef THEME_PREVIEW_WIDGET_H
11#define THEME_PREVIEW_WIDGET_H
12
13#include <QColor>
14#include <QFont>
15#include <QFontMetricsF>
16#include <QHash>
17#include <QPair>
18#include <QPainterPath>
19#include <QRect>
20#include <QRectF>
21#include <QWidget>
22
23class QPainter;
24class QPaintEvent;
25class QContextMenuEvent;
26class QSize;
27
29
41class ThemePreviewWidget : public QWidget
42{
43 Q_OBJECT
44public:
45 explicit ThemePreviewWidget(QWidget *parent = nullptr);
46
55 void setPreviewColors(const QHash<ThemeManager::ThemeToken, QColor> &colors);
56
72 void setShowColoringRules(bool show);
73 bool showColoringRules() const { return show_coloring_rules_; }
74
75signals:
76 void showColoringRulesChanged(bool show);
77
78protected:
79 void paintEvent(QPaintEvent *evt) override;
80 void contextMenuEvent(QContextMenuEvent *event) override;
81 QSize minimumSizeHint() const override;
82
83private:
84 QHash<ThemeManager::ThemeToken, QColor> colors_;
85
88 bool show_coloring_rules_ = false;
89
93 QHash<QString, QPair<QColor, QColor>> ruleColors_;
94
101 QColor c(ThemeManager::ThemeToken token,
102 const QColor &fallback = QColor()) const;
103
108 QPalette previewPalette() const;
109
123 struct Layout {
124 QRect content;
125 QFont labelFont;
126 QFont monoFont;
127 QFontMetricsF labelFm;
128 QFontMetricsF monoFm;
129 int rowH;
130 QRect toolbarRect;
131 QRect filterRect;
132 QRect headerRect;
133 QRect listRect;
134 QRect detailsRect;
135 QRect bytesRect;
136 QRect statusRect;
137 };
138
145 struct WindowChrome {
146 QPainterPath framePath;
147 QColor border;
148 QRect content;
149 };
150
155 Layout buildLayout(const QRect &content) const;
156
162 WindowChrome paintWindowChrome(QPainter &p, const QRect &outer,
163 const QColor &window);
164
170 void drawWindowControls(QPainter &p, const QRectF &titleRect, bool darkChrome);
171
173 void strokeWindowFrame(QPainter &p, const WindowChrome &chrome);
174
181 QRectF cellRect(const QRect &content, int idx, int top, int h) const;
182
184 int cellFlags(int idx) const;
185
189 void drawToolbar(QPainter &p, const Layout &layout);
190
196 void drawFilterBar(QPainter &p, const Layout &layout);
197
199 void drawColumnHeader(QPainter &p, const Layout &layout);
200
209 void drawPacketList(QPainter &p, const Layout &layout);
210
212 void rebuildRuleColors();
213
215 void drawDetailsPane(QPainter &p, const Layout &layout);
216
218 void drawBytesPane(QPainter &p, const Layout &layout);
219
221 void drawStatusBar(QPainter &p, const Layout &layout);
222
228 void saveAsImage();
229};
230
231#endif // THEME_PREVIEW_WIDGET_H
void setPreviewColors(const QHash< ThemeManager::ThemeToken, QColor > &colors)
Definition theme_preview_widget.cpp:111
void setShowColoringRules(bool show)
Definition theme_preview_widget.cpp:117