|
| 1 | +#ifndef WINHOVERNET_H |
| 2 | +#define WINHOVERNET_H |
| 3 | + |
| 4 | +#include "lfx_global.h" |
| 5 | +#include "lib/MonitorInfo_x11.h" |
| 6 | +#include <QWidget> |
| 7 | +#include <QVector> |
| 8 | +#include <QLabel> |
| 9 | +#include <QGridLayout> |
| 10 | +#include "WinSetting.h" |
| 11 | +#include "WinTransparent.h" |
| 12 | +LFX_USE_NAESPACE |
| 13 | + |
| 14 | +class QTimer; |
| 15 | +class WinHoverNet : public WinTransparent |
| 16 | +{ |
| 17 | + Q_OBJECT |
| 18 | + |
| 19 | +private: |
| 20 | + explicit WinHoverNet(Qt::Orientation orientation = Qt::Horizontal, QWidget *parent = nullptr); |
| 21 | + |
| 22 | +public: |
| 23 | + static WinHoverNet* getInstance(); |
| 24 | + ~WinHoverNet(); |
| 25 | + |
| 26 | + |
| 27 | + void init(); |
| 28 | + void initSigConnect(); |
| 29 | + void setLabWidgetLayout(bool isHorizontal); |
| 30 | + void setLabWidgetLayout(Qt::Orientation orientation); |
| 31 | + |
| 32 | + bool setSingleInstance(); |
| 33 | + |
| 34 | +public slots: |
| 35 | + // 响应本身 |
| 36 | + void onNet(); |
| 37 | + void onCpu(); |
| 38 | + void onMemory(); |
| 39 | + |
| 40 | + // 响应 个性化 发射的信号 |
| 41 | + void onUnitModel(const QString &text); |
| 42 | + void onUnitModelIndex(int index); |
| 43 | + |
| 44 | + void onLabUploadText(const QString &text); |
| 45 | + void onLabDownText(const QString &text); |
| 46 | + void onLabCpuText(const QString &text); |
| 47 | + void onLabMemoryText(const QString &text); |
| 48 | + |
| 49 | + void onCurrentFont(const QFont &font); |
| 50 | + void onFontSize(int size); |
| 51 | + |
| 52 | + void onLabTextColor(const QColor color); |
| 53 | + void onTextColor(const QColor color); |
| 54 | + void onBackgroundColor(const QColor color); |
| 55 | + void onBackgroundImage(const QColor color); |
| 56 | + |
| 57 | + // 响应 基础配置 发射的信号 |
| 58 | + // void onCurrystemStyle(int index); |
| 59 | + // void onCurrystemStyleText(QString text); |
| 60 | + void onWindowTop(bool check); |
| 61 | + |
| 62 | + void onDisolayNet(bool check); |
| 63 | + void onDisolayCPUAndMemory(bool check); |
| 64 | + void onLocationExchangeNet(bool check); |
| 65 | + void onLocationExchangeCPUAndMenory(bool check); |
| 66 | + void onFractionalAccuracy(int num); |
| 67 | + void onRefreshInterval(int interval); |
| 68 | + |
| 69 | + void onShowModel(bool check); |
| 70 | + |
| 71 | +protected: |
| 72 | + virtual void mouseReleaseEvent(QMouseEvent *event) override; |
| 73 | +// virtual bool eventFilter(QObject *watched, QEvent *event) override; |
| 74 | + |
| 75 | +private: |
| 76 | + WinSetting *m_winSetting; // UI 界面控件 |
| 77 | + long m_upload; // 网速的上次数值 |
| 78 | + long m_down; |
| 79 | + QVector<CpuInfo> m_vec; // 获取 CPU 信息 |
| 80 | + |
| 81 | + MonitorInfo_x11 *m_info; |
| 82 | + ModelUnit m_modelUnit; // 网速单位模式 |
| 83 | + QTimer *m_timer; // 定时刷新内容 |
| 84 | + int m_precision; // 精确度 |
| 85 | + Qt::Orientation m_orientation; // 控件布局(水平 | 竖直) |
| 86 | + QGridLayout *m_gridLayout; // 存放下面 8 个标签的布局 |
| 87 | + QVector<QLabel *> m_vecLabel; // 顺序:0上传标签、1上传;2下载标签、3下载;4CPU标签、5CPU;6Mem标签、7Mem; |
| 88 | +}; |
| 89 | + |
| 90 | +#endif // WINHOVERNET_H |
0 commit comments