summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/qt-signal.cpp13
-rw-r--r--compat/qt-signal.hpp30
2 files changed, 43 insertions, 0 deletions
diff --git a/compat/qt-signal.cpp b/compat/qt-signal.cpp
new file mode 100644
index 00000000..08aac663
--- /dev/null
+++ b/compat/qt-signal.cpp
@@ -0,0 +1,13 @@
+#include "qt-signal.hpp"
+
+namespace qt_sig {
+
+nullary::nullary(QObject* parent) : QObject(parent) {}
+nullary::~nullary() = default;
+
+void nullary::operator()() const
+{
+ notify();
+}
+
+} // ns qt_sig
diff --git a/compat/qt-signal.hpp b/compat/qt-signal.hpp
new file mode 100644
index 00000000..119e063c
--- /dev/null
+++ b/compat/qt-signal.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+// this is to avoid dealing with QMetaObject for the time being -sh 20190203
+
+#include "export.hpp"
+#include <QObject>
+
+namespace qt_sig {
+
+class OTR_COMPAT_EXPORT nullary : public QObject
+{
+ Q_OBJECT
+
+public:
+ template<typename t, typename F>
+ nullary(t* datum, F&& f, Qt::ConnectionType conntype = Qt::AutoConnection) : QObject(datum)
+ {
+ connect(this, &nullary::notify, datum, f, conntype);
+ }
+
+ nullary(QObject* parent = nullptr);
+ ~nullary() override;
+
+ void operator()() const;
+
+signals:
+ void notify() const;
+};
+
+} // ns qt_sig