mempoolstats.h raw
1 // Copyright (c) 2016 The Limenka developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 #ifndef LIMENKA_QT_MEMPOOLSTATS_H
6 #define LIMENKA_QT_MEMPOOLSTATS_H
7
8 #include <QWidget>
9 #include <QGraphicsLineItem>
10 #include <QGraphicsPixmapItem>
11
12 #include <QCheckBox>
13 #include <QColor>
14 #include <QGraphicsProxyWidget>
15
16 #include <QEvent>
17
18 class ClientModel;
19
20 class ClickableTextItem : public QGraphicsTextItem
21 {
22 Q_OBJECT
23 public:
24 void setEnabled(bool state);
25 protected:
26 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
27 Q_SIGNALS:
28 void objectClicked(QGraphicsItem*);
29 };
30
31
32 namespace Ui {
33 class MempoolStats;
34 }
35
36 class MempoolStats : public QWidget
37 {
38 Q_OBJECT
39
40 public:
41 struct ThemeColors {
42 QColor orange;
43 QColor green;
44 QColor blue;
45 };
46 MempoolStats(QWidget *parent = nullptr);
47 ~MempoolStats();
48
49 void setClientModel(ClientModel *model);
50
51 public Q_SLOTS:
52 void drawChart();
53 void objectClicked(QGraphicsItem *);
54
55 private:
56 ClientModel *clientModel{nullptr};
57
58 virtual void resizeEvent(QResizeEvent *event) override;
59 virtual void showEvent(QShowEvent *event) override;
60 void changeEvent(QEvent* e) override;
61 void updateThemeColors();
62
63 // Theme Colors
64 const ThemeColors *m_theme_colors;
65 QColor m_bg_color; // Background color for gradient
66 QColor m_text_color; // System text color
67
68 QGraphicsTextItem *titleItem{nullptr};
69 QGraphicsLineItem *titleLine;
70 QGraphicsTextItem *noDataItem;
71
72 QGraphicsTextItem *dynMemUsageValueItem;
73 QGraphicsTextItem *txCountValueItem;
74 QGraphicsTextItem *minFeeValueItem;
75
76 ClickableTextItem *last10MinLabel;
77 ClickableTextItem *lastHourLabel;
78 ClickableTextItem *lastDayLabel;
79 ClickableTextItem *allDataLabel;
80
81 QGraphicsProxyWidget *txCountSwitch;
82 QGraphicsProxyWidget *minFeeSwitch;
83 QGraphicsProxyWidget *dynMemUsageSwitch;
84
85 QGraphicsScene *scene{nullptr};
86 QVector<QGraphicsItem*> redrawItems;
87
88 QCheckBox *cbShowMemUsage;
89 QCheckBox *cbShowNumTxns;
90 QCheckBox *cbShowMinFeerate;
91
92 int64_t timeFilter;
93
94 Ui::MempoolStats *ui;
95 };
96
97 #endif // LIMENKA_QT_MEMPOOLSTATS_H
98