mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(model): return connection from interface macro
connection is normally returned from Qt's connect, and the caller may want to track the connection to manually disconnect it. (cherry picked from commit 41b2b35ce3037a32f705caf92600c42b0ae4798a)
This commit is contained in:
parent
dfeca3e906
commit
40e43586f1
@ -20,6 +20,8 @@
|
|||||||
#ifndef INTERFACE_H
|
#ifndef INTERFACE_H
|
||||||
#define INTERFACE_H
|
#define INTERFACE_H
|
||||||
|
|
||||||
|
#include <QMetaObject>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +50,7 @@
|
|||||||
*/
|
*/
|
||||||
#define DECLARE_SIGNAL(name, ...) \
|
#define DECLARE_SIGNAL(name, ...) \
|
||||||
using Slot_##name = std::function<void (__VA_ARGS__)>; \
|
using Slot_##name = std::function<void (__VA_ARGS__)>; \
|
||||||
virtual void connectTo_##name(Slot_##name slot) const = 0
|
virtual QMetaObject::Connection connectTo_##name(Slot_##name slot) const = 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def DECLARE_SIGNAL
|
* @def DECLARE_SIGNAL
|
||||||
@ -56,7 +58,7 @@
|
|||||||
*/
|
*/
|
||||||
#define DECLARE_SIGNAL(name, ...) \
|
#define DECLARE_SIGNAL(name, ...) \
|
||||||
using Slot_##name = std::function<void (__VA_ARGS__)>; \
|
using Slot_##name = std::function<void (__VA_ARGS__)>; \
|
||||||
virtual void connectTo_##name(Slot_##name slot) const = 0
|
virtual QMetaObject::Connection connectTo_##name(Slot_##name slot) const = 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def SIGNAL_IMPL
|
* @def SIGNAL_IMPL
|
||||||
@ -65,7 +67,7 @@
|
|||||||
#define SIGNAL_IMPL(classname, name, ...) \
|
#define SIGNAL_IMPL(classname, name, ...) \
|
||||||
using Slot_##name = std::function<void (__VA_ARGS__)>; \
|
using Slot_##name = std::function<void (__VA_ARGS__)>; \
|
||||||
Q_SIGNAL void name(__VA_ARGS__); \
|
Q_SIGNAL void name(__VA_ARGS__); \
|
||||||
void connectTo_##name(Slot_##name slot) const override { \
|
QMetaObject::Connection connectTo_##name(Slot_##name slot) const override { \
|
||||||
connect(this, &classname::name, slot); \
|
connect(this, &classname::name, slot); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user