Wireshark 4.7.2
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
117 struct Layout {
118 QRect content;
119 QFont labelFont;
120 QFont monoFont;
121 QFontMetricsF labelFm;
122 QFontMetricsF monoFm;
123 int rowH;
124 QRect toolbarRect;
125 QRect filterRect;
126 QRect headerRect;
127 QRect listRect;
128 QRect detailsRect;
129 QRect bytesRect;
130 QRect statusRect;
131 };
132
139 struct WindowChrome {
140 QPainterPath framePath;
141 QColor border;
142 QRect content;
143 };
144
149 Layout buildLayout(const QRect &content) const;
150
156 WindowChrome paintWindowChrome(QPainter &p, const QRect &outer,
157 const QColor &window);
158
164 void drawWindowControls(QPainter &p, const QRectF &titleRect, bool darkChrome);
165
167 void strokeWindowFrame(QPainter &p, const WindowChrome &chrome);
168
175 QRectF cellRect(const QRect &content, int idx, int top, int h) const;
176
178 int cellFlags(int idx) const;
179
183 void drawToolbar(QPainter &p, const Layout &layout);
184
190 void drawFilterBar(QPainter &p, const Layout &layout);
191
193 void drawColumnHeader(QPainter &p, const Layout &layout);
194
203 void drawPacketList(QPainter &p, const Layout &layout);
204
206 void rebuildRuleColors();
207
209 void drawDetailsPane(QPainter &p, const Layout &layout);
210
212 void drawBytesPane(QPainter &p, const Layout &layout);
213
215 void drawStatusBar(QPainter &p, const Layout &layout);
216
222 void saveAsImage();
223};
224
225#endif // THEME_PREVIEW_WIDGET_H
void setPreviewColors(const QHash< ThemeManager::ThemeToken, QColor > &colors)
Definition theme_preview_widget.cpp:129
void setShowColoringRules(bool show)
Definition theme_preview_widget.cpp:135