Changeset View
Changeset View
Standalone View
Standalone View
src/qt/rpcconsole.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
/** Class for handling RPC timers | /** Class for handling RPC timers | ||||
* (used for e.g. re-locking the wallet after a timeout) | * (used for e.g. re-locking the wallet after a timeout) | ||||
*/ | */ | ||||
class QtRPCTimerBase : public QObject, public RPCTimerBase { | class QtRPCTimerBase : public QObject, public RPCTimerBase { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
QtRPCTimerBase(std::function<void(void)> &_func, int64_t millis) | QtRPCTimerBase(std::function<void()> &_func, int64_t millis) : func(_func) { | ||||
: func(_func) { | |||||
timer.setSingleShot(true); | timer.setSingleShot(true); | ||||
connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); | connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); | ||||
timer.start(millis); | timer.start(millis); | ||||
} | } | ||||
~QtRPCTimerBase() {} | ~QtRPCTimerBase() {} | ||||
private Q_SLOTS: | private Q_SLOTS: | ||||
void timeout() { func(); } | void timeout() { func(); } | ||||
private: | private: | ||||
QTimer timer; | QTimer timer; | ||||
std::function<void(void)> func; | std::function<void()> func; | ||||
}; | }; | ||||
class QtRPCTimerInterface : public RPCTimerInterface { | class QtRPCTimerInterface : public RPCTimerInterface { | ||||
public: | public: | ||||
~QtRPCTimerInterface() {} | ~QtRPCTimerInterface() {} | ||||
const char *Name() override { return "Qt"; } | const char *Name() override { return "Qt"; } | ||||
RPCTimerBase *NewTimer(std::function<void(void)> &func, | RPCTimerBase *NewTimer(std::function<void()> &func, | ||||
int64_t millis) override { | int64_t millis) override { | ||||
return new QtRPCTimerBase(func, millis); | return new QtRPCTimerBase(func, millis); | ||||
} | } | ||||
}; | }; | ||||
#include <qt/rpcconsole.moc> | #include <qt/rpcconsole.moc> | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 1,314 Lines • Show Last 20 Lines |