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
22class QJsonObject;
23
24enum BannerSlideType {
25 BannerEvents,
26 BannerSponsorship,
27 BannerTips,
28};
29
31 BannerSlideType type;
32 QString tag; // type label shown as subheader, e.g. "Tip of the Day"
33 QString title; // main heading, e.g. "Quick Filter Shortcut"
34 QString description; // primary text shown in highlight box
35 QString description_sub; // secondary line in highlight box
36 QString body_text; // additional text below the highlight box
37 QString button_label; // action button text, e.g. "More Tips"
38 QString url; // click/button target
39 QString image; // banner image filename, resolved under :/json/banners/
40 QDate date_from; // slide visible from this date (inclusive), invalid = always
41 QDate date_until; // slide visible until this date (inclusive), invalid = always
42};
43
45 bool randomized = false;
46 int maxdisplay = 0; // 0 = show all (no limit)
47 bool only = false; // only slides from this file for this type
48 bool hidden = false; // suppress this type entirely (custom files only)
49 QColor color_start;
50 QColor color_end;
51};
52
53class InfoBannerWidget : public QFrame {
54 Q_OBJECT
55public:
56 explicit InfoBannerWidget(QWidget *parent = nullptr);
57
58 void updateStyleSheets();
59 void setCompactMode(bool compact);
60 bool isCompactMode() const;
61 void setSlideTypeVisible(BannerSlideType type, bool visible);
62 void setAutoAdvanceInterval(unsigned seconds);
63 void applySlideFilter();
64
65 QSize sizeHint() const override;
66
67protected:
68 void paintEvent(QPaintEvent *event) override;
69 void mousePressEvent(QMouseEvent *event) override;
70 void mouseMoveEvent(QMouseEvent *event) override;
71 void changeEvent(QEvent *event) override;
72
73private:
74 QList<BannerSlide> all_slides_;
75 QList<BannerSlide> slides_;
76 int current_slide_;
77 bool compact_mode_;
78 QMap<BannerSlideType, bool> slide_type_visible_;
79 QTimer *auto_advance_timer_;
80 int auto_advance_ms_;
81
82 // Per-type configuration (merged from predefined + custom)
83 QMap<BannerSlideType, SlideTypeConfig> type_config_;
84 // Per-type slide lists (date-filtered, after only/hidden processing)
85 QMap<BannerSlideType, QList<BannerSlide>> slides_by_type_;
86 // Per-type rotation offset for maxdisplay windowing
87 QMap<BannerSlideType, int> type_offsets_;
88 // Default gradient colors (for types not in config)
89 QColor default_color_start_;
90 QColor default_color_end_;
91
92 void setupSlides();
93 QString resolveI18nField(const QJsonObject &obj,
94 const QString &field,
95 bool is_custom) const;
96 void loadSlidesFromResource(const QString &resource_path,
97 bool is_custom,
98 QMap<BannerSlideType, SlideTypeConfig> &file_config,
99 QMap<BannerSlideType, QList<BannerSlide>> &file_slides);
100 void buildSlideSequence();
101 void advanceSlide();
102 // Updates accessibleName/Description to reflect the current slide and
103 // notifies the platform AT via QAccessible::NameChanged. Must be called
104 // whenever current_slide_ changes, because this widget is fully
105 // custom-painted — there are no child widgets for AT to interrogate.
106 void updateAccessibility();
107 QPair<QColor, QColor> gradientForType(BannerSlideType type) const;
108 int dotHitTest(const QPoint &pos) const;
109 QRect dotRect(int index) const;
110 QRect buttonRect() const;
111 static BannerSlideType typeFromString(const QString &type_str);
112
113 // Layout constants
114 static constexpr int kCardWidth = 300;
115 static constexpr int kCardHeight = 360;
116 static constexpr int kCardHeightCompact = 180;
117 static constexpr int kIllustrationHeight = 120;
118 static constexpr int kContentLeftMargin = 16;
119 static constexpr int kContentRightMargin = 16;
120 static constexpr int kDotRadius = 4;
121 static constexpr int kDotSpacing = 12;
122 static constexpr int kDotBottomMargin = 14;
123 static constexpr int kDefaultAutoAdvanceMs = 8000;
124};
125
126#endif // INFO_BANNER_WIDGET_H
Definition info_banner_widget.h:53
Definition info_banner_widget.h:30
Definition info_banner_widget.h:44