Add custom ProgressEvent class for future use.
This commit is contained in:
		@@ -77,6 +77,7 @@ contains( CONFIG, DesktopLinux ) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
SOURCES += \
 | 
					SOURCES += \
 | 
				
			||||||
        main.cpp \
 | 
					        main.cpp \
 | 
				
			||||||
 | 
					        progress_event.cpp \
 | 
				
			||||||
        mainwindow.cpp \
 | 
					        mainwindow.cpp \
 | 
				
			||||||
        utils.cpp \
 | 
					        utils.cpp \
 | 
				
			||||||
        update.cpp \
 | 
					        update.cpp \
 | 
				
			||||||
@@ -89,6 +90,7 @@ SOURCES += \
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
HEADERS += \
 | 
					HEADERS += \
 | 
				
			||||||
        update.h \
 | 
					        update.h \
 | 
				
			||||||
 | 
					        progress_event.h \
 | 
				
			||||||
        utils.h \
 | 
					        utils.h \
 | 
				
			||||||
        mainwindow.h \
 | 
					        mainwindow.h \
 | 
				
			||||||
        git/git_client.h \
 | 
					        git/git_client.h \
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								progress_event.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								progress_event.cpp
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										22
									
								
								progress_event.h
									
									
									
									
									
										Normal 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
 | 
				
			||||||
		Reference in New Issue
	
	Block a user