blob: 63657b74956b238c70d15f33fcf0f979b3b6a8fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/** @file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef LABEL_STACK_H
#define LABEL_STACK_H
#include <QLabel>
#include <QStack>
#include <QElapsedTimer>
#include <QTimer>
class LabelStack : public QLabel
{
Q_OBJECT
public:
explicit LabelStack(QWidget *parent = 0);
void setTemporaryContext(const int ctx);
void pushText(const QString &text, int ctx);
void setShrinkable(bool shrinkable = true);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
void paintEvent (QPaintEvent *event);
private:
typedef struct _StackItem {
QString text;
int ctx;
} StackItem;
int temporary_ctx_;
QList<StackItem> labels_;
bool shrinkable_;
QElapsedTimer temporary_epoch_;
QTimer temporary_timer_;
void fillLabel();
signals:
void toggleTemporaryFlash(bool enable);
void mousePressedAt(const QPoint &global_pos, Qt::MouseButton button);
public slots:
void popText(int ctx);
private slots:
void updateTemporaryStatus();
};
#endif // LABEL_STACK_H
|