1 Star 6 Fork 2

jiangtao / GoSlowDetection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mainwindow.h 3.80 KB
一键复制 编辑 原始数据 按行查看 历史
jiangtao 提交于 2022-03-11 17:41 . 设计天气预报界面
/************************************************************************************
<GoSlowDetection> Copyright (C) <2021> <Tao Kiang>
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions;
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
************************************************************************************/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPaintEvent>
#include <QPainter>
#include <QTimer>
#include <QDateTime>
#include "pluginmanage.h"
#include "windowsupdatewidget.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
/************************************
1、显示按键、鼠标点击的次数
2、可设置开机自动启动
3、可清空当前计数
4、可设置背景透明不透明(后期可设置颜色,添加二级菜单)
5、设置警告颜色,1min无操作,显示淡红色,2-10min无操作颜色对应加深
************************************/
//背景颜色设置
#define START_COLOR QColor(255,215,0, 255) //显眼的金色
#define HY_COLOR QColor(255, 255, 255, 80) //透明
#define COLOR QColor(255, 255, 255, 255) //不透明
#define CHECK_TIME 30000 //30s判断一次,如果没有动作,红色加深一层,最多加深20层(10min全红)
class MySetting
{
public:
bool autoRunFlag; //开机自启动标志位
QSize boundSize; //边界限制框
int attractWidth; //磁吸距离,接近边界时,吸到边界上
bool isHyaline; //是否透明标志位
QBrush brush; //背景颜色刷
bool showUpdate; //检测到摸鱼后显示windows更新界面
public:
MySetting():
autoRunFlag(0)
,attractWidth(20) //磁吸距离
,isHyaline(1)
,brush(QBrush(HY_COLOR, Qt::SolidPattern))
{}
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
static void setProcessAutoRun(const QString &appPath,bool flag = 1);
static bool isAutoRun(const QString &appPath);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
void showMenu(const QPoint& pos);
void addMapCount(QMap<QString,quint64> &map);
void clickOperator();
void loadSysMenu(QMenu &menu);
void loadPluginMenu(QMenu &menu);
void closeApp();
void cleanCount();
private:
Ui::MainWindow *ui;
QDateTime startRunTime;
QTimer runTime;
QTimer mTimer;
int mNoClickTime;
bool mPressFlag; //是否按下状态
QPoint mPressPos; //拖动,鼠标按下的位置
MySetting mSetting; //设置对象
PluginManage mPlugManage; //插件管理对象
quint64 mKeyCount; //按键的总计数
quint64 mMouseCount; //鼠标总计数
QMap<QDateTime,quint64> keyMapCount; //小时 map 按下的次数
QMap<QDateTime,quint64> mouseMapCount;
};
#endif // MAINWINDOW_H
C++
1
https://gitee.com/jiangtao008/GoSlowDetection.git
git@gitee.com:jiangtao008/GoSlowDetection.git
jiangtao008
GoSlowDetection
GoSlowDetection
master

搜索帮助