Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
label_stack.h
Go to the documentation of this file.
1
9
10#ifndef LABEL_STACK_H
11#define LABEL_STACK_H
12
13#include <QLabel>
14#include <QStack>
15#include <QElapsedTimer>
16#include <QTimer>
17
21class LabelStack : public QLabel
22{
23 Q_OBJECT
24public:
29 explicit LabelStack(QWidget *parent = 0);
30
35 void setTemporaryContext(const int ctx);
36
44 void pushText(const QString &text, int ctx, const QString &tooltip = QString());
45
52 void setShrinkable(bool shrinkable = true);
53
54protected:
59 void mousePressEvent(QMouseEvent *event) override;
60
65 void mouseReleaseEvent(QMouseEvent *event) override;
66
71 void mouseDoubleClickEvent(QMouseEvent *event) override;
72
77 void mouseMoveEvent(QMouseEvent *event) override;
78
83 void contextMenuEvent(QContextMenuEvent *event) override;
84
89 void paintEvent(QPaintEvent *event) override;
90
91private:
95 typedef struct _StackItem {
96 QString text;
97 QString tooltip;
98 int ctx;
99 } StackItem;
100
101 int temporary_ctx_;
102 QList<StackItem> labels_;
103 bool shrinkable_;
104 QElapsedTimer temporary_epoch_;
105 QTimer temporary_timer_;
106
110 void fillLabel();
111
112
113signals:
119 void toggleTemporaryFlash(bool enable);
120
126 void mousePressedAt(const QPoint &global_pos, Qt::MouseButton button);
127
128public slots:
133 void popText(int ctx);
134
135private slots:
139 void updateTemporaryStatus();
140};
141
142#endif // LABEL_STACK_H
void toggleTemporaryFlash(bool enable)
Emitted when the temporary flash state changes.
void setTemporaryContext(const int ctx)
Designate a context ID as the "temporary" context.
Definition label_stack.cpp:38
void mouseReleaseEvent(QMouseEvent *event) override
Handle mouse button release (reserved for subclass use).
Definition label_stack.cpp:112
void popText(int ctx)
Remove the stack entry associated with ctx.
Definition label_stack.cpp:150
void pushText(const QString &text, int ctx, const QString &tooltip=QString())
Push a text message onto the label stack.
Definition label_stack.cpp:74
void mousePressedAt(const QPoint &global_pos, Qt::MouseButton button)
Emitted when a mouse button is pressed on the label.
LabelStack(QWidget *parent=0)
Construct a LabelStack.
Definition label_stack.cpp:25
void contextMenuEvent(QContextMenuEvent *event) override
Show a context menu for the label (reserved for subclass use).
Definition label_stack.cpp:124
void setShrinkable(bool shrinkable=true)
Control whether the label may shrink below its preferred width.
Definition label_stack.cpp:93
void mouseDoubleClickEvent(QMouseEvent *event) override
Handle double-click events (reserved for subclass use).
Definition label_stack.cpp:116
void paintEvent(QPaintEvent *event) override
Paint the label, applying elision if shrinkable and space is tight.
Definition label_stack.cpp:129
void mousePressEvent(QMouseEvent *event) override
Forward mouse press position and button via mousePressedAt().
Definition label_stack.cpp:105
void mouseMoveEvent(QMouseEvent *event) override
Handle mouse move events (reserved for subclass use).
Definition label_stack.cpp:120