Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
info_banner_widget.h
Go to the documentation of this file.
1
10#ifndef INFO_BANNER_WIDGET_H
11#define INFO_BANNER_WIDGET_H
12
13#include <QFrame>
14#include <QColor>
15#include <QDate>
16#include <QString>
17#include <QList>
18#include <QMap>
19#include <QPair>
20#include <QTimer>
21
25class QJsonObject;
26
36Q_DECLARE_METATYPE(BannerSlideType)
37
38
39
44 QString tag;
45 QString title;
46 QString description;
48 QString body_text;
49 QString button_label;
50 QString url;
51 QString image;
54 QString application;
55 QDate date_from;
56 QDate date_until;
57};
58
59
64 bool randomized = false;
65 int maxdisplay = 0;
66 bool only = false;
67 bool hidden = false;
68 QColor color_start;
69 QColor color_end;
71 QList<QColor> steps;
72};
73
78class InfoBannerWidget : public QFrame
79{
80 Q_OBJECT
81public:
86 explicit InfoBannerWidget(QWidget *parent = nullptr);
87
97 void setCompactMode(bool compact);
98
103 bool isCompactMode() const;
104
111 void setSlideDeckFreeze(bool freeze);
112
120 void setSlideTypeVisible(BannerSlideType type, bool visible);
121
127 void setAutoAdvance(bool advance);
128
136 void setAutoAdvanceInterval(unsigned seconds);
137
142 void setSlidesTest(bool test);
143
149 bool hasVisibleSlides() const;
150
156 QSize sizeHint() const override;
157
162 QSize minimumSizeHint() const override;
163
164protected:
170 void paintEvent(QPaintEvent *event) override;
171
176 void mousePressEvent(QMouseEvent *event) override;
177
183 void mouseMoveEvent(QMouseEvent *event) override;
184
190 void leaveEvent(QEvent *event) override;
191
198 void changeEvent(QEvent *event) override;
199
206 bool event(QEvent *event) override;
207
208private:
209 QList<BannerSlide> slides_;
210 int current_slide_;
211 bool compact_mode_;
212 bool hovered_;
215 QMap<BannerSlideType, bool> slide_type_visible_;
216 QTimer *auto_advance_timer_;
217 int auto_advance_ms_;
218 bool slides_test_;
221 QMap<BannerSlideType, SlideTypeConfig> type_config_;
222
224 QMap<BannerSlideType, QList<BannerSlide>> slides_by_type_;
225
227 QMap<BannerSlideType, int> type_offsets_;
228
229 QColor default_color_start_;
230 QColor default_color_end_;
235 void setupSlides();
236
246 QString resolveI18nField(const QJsonObject &obj,
247 const QString &field,
248 bool is_custom) const;
249
260 void loadSlidesFromResource(const QString &resource_path,
261 bool is_custom,
262 QMap<BannerSlideType, SlideTypeConfig> &file_config,
263 QMap<BannerSlideType, QList<BannerSlide>> &file_slides);
264
268 void applySlideFilter();
269
273 void buildSlideSequence();
274
278 void advanceSlide();
279
283 void advanceRandomSlide();
284
293 void updateAccessibility();
294
301 int dotHitTest(const QPoint &pos) const;
302
309 QRect dotRect(int index) const;
310
315 QRect buttonRect() const;
316
323 static BannerSlideType typeFromString(const QString &type_str);
324
334 static BannerSlideType validTypeFromString(const QString &type_str,
335 const QString &resource_path,
336 const QString &context,
337 bool is_custom);
338
339 // ── Layout constants ──────────────────────────────────────────────────
340
341 static constexpr int kCardWidth = 300;
342 static constexpr int kCardHeight = 360;
343 static constexpr int kCardHeightCompact = 180;
344 static constexpr int kIllustrationHeight = 120;
345 static constexpr int kContentLeftMargin = 16;
346 static constexpr int kContentRightMargin = 16;
347 static constexpr int kDotRadius = 4;
348 static constexpr int kDotSpacing = 12;
349 static constexpr int kDotBottomMargin = 14;
350 static constexpr int kDefaultAutoAdvanceMs = 8000;
351};
352
353#endif // INFO_BANNER_WIDGET_H
A custom-painted rotating banner widget that cycles through informational slides.
Definition info_banner_widget.h:79
void paintEvent(QPaintEvent *event) override
Paint the current slide onto the widget surface.
Definition info_banner_widget.cpp:673
void setSlideDeckFreeze(bool freeze)
Freeze or unfreeze slide deck processing in case of changing preference settings.
Definition info_banner_widget.cpp:445
void setAutoAdvance(bool advance)
Enable or disable automatic slide advancement.
Definition info_banner_widget.cpp:458
void setSlideTypeVisible(BannerSlideType type, bool visible)
Show or hide all slides of a given type.
Definition info_banner_widget.cpp:451
void leaveEvent(QEvent *event) override
Clear the hover state when the pointer leaves the widget.
Definition info_banner_widget.cpp:1040
void mousePressEvent(QMouseEvent *event) override
Handle mouse press events for dot navigation and button clicks.
Definition info_banner_widget.cpp:993
void mouseMoveEvent(QMouseEvent *event) override
Track the hovered dot and update the cursor.
Definition info_banner_widget.cpp:1024
bool hasVisibleSlides() const
Return whether any slides are currently visible.
Definition info_banner_widget.cpp:488
bool isCompactMode() const
Return whether compact mode is currently active.
Definition info_banner_widget.cpp:655
void setCompactMode(bool compact)
Switch between full-height and compact-height layout modes.
Definition info_banner_widget.cpp:644
QSize minimumSizeHint() const override
Return the minimum acceptable size for the widget.
Definition info_banner_widget.cpp:668
void changeEvent(QEvent *event) override
Respond to widget state changes such as palette or font updates.
Definition info_banner_widget.cpp:181
QSize sizeHint() const override
Return the preferred size for the widget.
Definition info_banner_widget.cpp:660
void setSlidesTest(bool test)
Enable or disable slide test mode.
Definition info_banner_widget.cpp:483
bool event(QEvent *event) override
Handle miscellaneous events, including tooltip queries.
Definition info_banner_widget.cpp:596
void setAutoAdvanceInterval(unsigned seconds)
Set the auto-advance interval.
Definition info_banner_widget.cpp:470
BannerSlideType
Categorises the content type of a banner slide shown in the welcome or news panel.
Definition info_banner_widget.h:30
@ BannerSponsorship
Definition info_banner_widget.h:32
@ BannerTips
Definition info_banner_widget.h:33
@ BannerSeasonal
Definition info_banner_widget.h:34
@ BannerEvents
Definition info_banner_widget.h:31
Describes the full content and display metadata for a single banner slide.
Definition info_banner_widget.h:42
int date_day
Definition info_banner_widget.h:53
QString description_sub
Definition info_banner_widget.h:47
QDate date_until
Definition info_banner_widget.h:56
QDate date_from
Definition info_banner_widget.h:55
QString tag
Definition info_banner_widget.h:44
int date_month
Definition info_banner_widget.h:52
QString application
Definition info_banner_widget.h:54
QString body_text
Definition info_banner_widget.h:48
QString url
Definition info_banner_widget.h:50
QString image
Definition info_banner_widget.h:51
QString button_label
Definition info_banner_widget.h:49
QString title
Definition info_banner_widget.h:45
BannerSlideType type
Definition info_banner_widget.h:43
QString description
Definition info_banner_widget.h:46
Per-type display configuration controlling selection, limits, and gradient styling of banner slides.
Definition info_banner_widget.h:63
bool hidden
Definition info_banner_widget.h:67
QColor color_start
Definition info_banner_widget.h:68
QColor color_end
Definition info_banner_widget.h:69
QList< QColor > steps
Definition info_banner_widget.h:71
bool only
Definition info_banner_widget.h:66
bool randomized
Definition info_banner_widget.h:64
int maxdisplay
Definition info_banner_widget.h:65
int color_gradient
Definition info_banner_widget.h:70