-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwidget.h
More file actions
109 lines (81 loc) · 2.35 KB
/
widget.h
File metadata and controls
109 lines (81 loc) · 2.35 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QColorDialog>
class BatteryEvent;
class QTimer;
namespace QtCharts {
class QChart;
}
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
BatteryEvent *btevt_=nullptr;
public:
explicit Widget(QWidget *parent = nullptr);
~Widget() override;
private slots:
void on_btn_scbc_clicked();
void on_btn_subc_clicked();
void on_tabWidget_currentChanged(int index);
void on_btn_color_font_u_clicked();
void on_btn_color_font_c_clicked();
private:
void updatebtshow();
void showbtinfo();
//初始化托盘
void inittray();
//初始化电量记录模块
void init_bt_rec();
//初始化统计图
void init_chart();
//显示主窗口
void showmain();
//如果需要更新统计图就更新
void update_chart_need();
//更新统计图
void update_chart();
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent * event) override;
void onactivetray(QSystemTrayIcon::ActivationReason reason);
//选择完毕充电背景色
void selected_bkc_c(const QColor &color);
//选择完毕电池背景色
void selected_bkc_b(const QColor &color);
//选择完毕用电池时字体颜色
void selected_fc_u(const QColor &color);
//选择完毕充电时字体颜色
void selected_fc_c(const QColor &color);
//保存电量记录
static void save_record();
void on_select_tab_rec(int index);
private:
Ui::Widget *ui;
QSystemTrayIcon *sti_=nullptr;
//更新电量的定时器
QTimer * timer_update_battery_=nullptr;
//保存记录的定时器
QTimer* timer_save_record_=nullptr;
//更新图表的计时器
QTimer *timer_update_chart_=nullptr;
//右键菜单
QMenu* menu_=nullptr;
//充电背景颜色选择
QColorDialog* cld_c_=nullptr;
//电池背景颜色选择
QColorDialog* cld_b_=nullptr;
//用电池时字体颜色选择
QColorDialog* cld_f_u_=nullptr;
//充电时字体颜色选择
QColorDialog* cld_f_c_=nullptr;
//统计图
QtCharts::QChart* chart_ =nullptr;
bool close_by_tray_{false};
};
#endif // WIDGET_H