From b09ccfd4f582f67e3c92d4b41b4180de7c4b4dfb Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 4 Aug 2023 14:10:47 +0200 Subject: [PATCH] Add custom ProgressEvent class for future use. --- OnDemandUpdatePTU.pro | 2 ++ progress_event.cpp | 19 +++++++++++++++++++ progress_event.h | 22 ++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 progress_event.cpp create mode 100644 progress_event.h diff --git a/OnDemandUpdatePTU.pro b/OnDemandUpdatePTU.pro index 84e9d3f..3c83520 100644 --- a/OnDemandUpdatePTU.pro +++ b/OnDemandUpdatePTU.pro @@ -77,6 +77,7 @@ contains( CONFIG, DesktopLinux ) { SOURCES += \ main.cpp \ + progress_event.cpp \ mainwindow.cpp \ utils.cpp \ update.cpp \ @@ -89,6 +90,7 @@ SOURCES += \ HEADERS += \ update.h \ + progress_event.h \ utils.h \ mainwindow.h \ git/git_client.h \ diff --git a/progress_event.cpp b/progress_event.cpp new file mode 100644 index 0000000..9f07341 --- /dev/null +++ b/progress_event.cpp @@ -0,0 +1,19 @@ +#include "progress_event.h" + +QEvent::Type ProgressEvent::customEventType = QEvent::None; + +ProgressEvent::ProgressEvent() + : QEvent(ProgressEvent::type()) + , m_progressPercent(0) { +} + +ProgressEvent::~ProgressEvent() { +} + +QEvent::Type ProgressEvent::type() { + if (customEventType == QEvent::None) { + int generatedType = QEvent::registerEventType(); + customEventType = static_cast(generatedType); + } + return customEventType; +} diff --git a/progress_event.h b/progress_event.h new file mode 100644 index 0000000..3a67e0b --- /dev/null +++ b/progress_event.h @@ -0,0 +1,22 @@ +#ifndef PROGRESS_EVENT_H_INCLUDED +#define PROGRESS_EVENT_H_INCLUDED + +#include + +class ProgressEvent : public QEvent { + + int m_progressPercent; +public: + ProgressEvent(); + virtual ~ProgressEvent(); + static QEvent::Type type(); + + void setProgress(int progressPercent) { m_progressPercent = progressPercent; } + int progressPercent() { return m_progressPercent; } + int progressPercent() const { return m_progressPercent; } +private: + static QEvent::Type customEventType; +}; + + +#endif // PROGRESS_EVENT_H_INCLUDED