summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp12
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoswitchevent.h12
2 files changed, 18 insertions, 6 deletions
diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp b/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp
index b136ce8..22ea0fe 100644
--- a/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp
@@ -41,7 +41,9 @@
#include "qmeegoswitchevent.h"
-QMeeGoSwitchEvent::QMeeGoSwitchEvent(const QString &graphicsSystemName, QMeeGoSwitchEvent::State s) : QEvent((QEvent::Type) QMeeGoSwitchEvent::SwitchEvent)
+static int switchEventNumber = -1;
+
+QMeeGoSwitchEvent::QMeeGoSwitchEvent(const QString &graphicsSystemName, QMeeGoSwitchEvent::State s) : QEvent(QMeeGoSwitchEvent::eventNumber())
{
name = graphicsSystemName;
switchState = s;
@@ -55,4 +57,12 @@ QString QMeeGoSwitchEvent::graphicsSystemName() const
QMeeGoSwitchEvent::State QMeeGoSwitchEvent::state() const
{
return switchState;
+}
+
+QEvent::Type QMeeGoSwitchEvent::eventNumber()
+{
+ if (switchEventNumber < 0)
+ switchEventNumber = QEvent::registerEventType();
+
+ return (QEvent::Type) switchEventNumber;
} \ No newline at end of file
diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h
index 2d8371e..0ddbd3d 100644
--- a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h
+++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h
@@ -62,11 +62,6 @@ public:
DidSwitch
};
- //! The event type id to use to detect this event.
- enum Type {
- SwitchEvent = QEvent::User + 1024
- };
-
//! Constructor for the event.
/*!
Creates a new event with the given name and the given state.
@@ -83,6 +78,13 @@ public:
//! Returns the state represented by this event.
State state() const;
+ //! Returns the event type/number for QMeeGoSwitchEvent.
+ /*!
+ The type is registered on first access. Use this to detect incoming
+ QMeeGoSwitchEvents.
+ */
+ QEvent::Type eventNumber();
+
private:
QString name;
State switchState;