From a9a0aad00f1281768b84090ae724e4ae05c1cce1 Mon Sep 17 00:00:00 2001 From: Krad Date: Tue, 23 Nov 2021 17:16:31 +0800 Subject: [PATCH] Lock func merge --- src/InputObject.cpp | 5 +++++ src/InputObject.h | 20 +++++++++++--------- src/main.cpp | 2 +- src/mainwindow.h | 8 ++++++++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/InputObject.cpp b/src/InputObject.cpp index a35eaeb..10038bb 100644 --- a/src/InputObject.cpp +++ b/src/InputObject.cpp @@ -85,6 +85,11 @@ void InputObject::initUi() bool InputObject::eventFilter(QObject* obj, QEvent* event) { + if (event->type() == QEvent::MouseButtonPress) + { + emit touchScreen(); + qDebug() << "touchScreen()"; + } //mouse button release means setfocus is useless if (event->type() == QEvent::MouseButtonRelease) { diff --git a/src/InputObject.h b/src/InputObject.h index ab2676f..90ae424 100644 --- a/src/InputObject.h +++ b/src/InputObject.h @@ -9,24 +9,26 @@ class QTextEdit; //#define CUTE_STYLE namespace Ui { -class InputObject; + class InputObject; } class InputObject : public QWidget { - Q_OBJECT + Q_OBJECT public: - explicit InputObject(QWidget *parent = nullptr); - ~InputObject(); - bool eventFilter(QObject *obj, QEvent *event); - void ShowPanel(); + explicit InputObject(QWidget* parent = nullptr); + ~InputObject(); + bool eventFilter(QObject* obj, QEvent* event); + void ShowPanel(); +signals: + void touchScreen(); private: - Ui::InputObject *ui; + Ui::InputObject* ui; void initUi(); -// void ShowPanel(); + // void ShowPanel(); void HidePanel(); - QDateEdit *curDateEdit = nullptr; + QDateEdit* curDateEdit = nullptr; QLineEdit* curLine = nullptr; QTextEdit* curText = nullptr; }; diff --git a/src/main.cpp b/src/main.cpp index 671c67d..337e8bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,8 +55,8 @@ int main(int argc, char* argv[]) InputObject* obj = new InputObject(); a.installEventFilter(obj); SQLHelper::Open(); - UserOperationLog::Default()->init(); MainWindow w; + QObject::connect(obj, SIGNAL(touchScreen()), &w, SLOT(refreshTimer())); QStringList app_args = a.arguments(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 47bdcff..bed6364 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2,6 +2,8 @@ #define MAINWINDOW_H #include +#include +#include #include "StdOutRedirector.h" namespace Ui { class MainWindow; @@ -21,7 +23,13 @@ public: void requestLogin(); QTextEdit* getEdit(); void debugConsoleOn(); +public slots: + void coverScreen(); + void refreshTimer(); + private: + QTimer* screenTimer = nullptr; + int counter = 30000; Ui::MainWindow* ui; GUIMessageDialog* msgDialog = nullptr; StdOutRedirector* redir = nullptr;