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