Add custom ProgressEvent class for future use.

This commit is contained in:
Gerhard Hoffmann 2023-08-04 14:10:47 +02:00
parent 6b4c486549
commit b09ccfd4f5
3 changed files with 43 additions and 0 deletions

View File

@ -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 \

19
progress_event.cpp Normal file
View File

@ -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<QEvent::Type>(generatedType);
}
return customEventType;
}

22
progress_event.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef PROGRESS_EVENT_H_INCLUDED
#define PROGRESS_EVENT_H_INCLUDED
#include <QEvent>
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