mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
UI: Add way to exec std::function via invokeMethod
Allows the ability to use invokeMethod on the OBSApp object to execute an std::function. This allows deferring an std::function call to the Qt event queue.
This commit is contained in:
parent
d8812e0808
commit
106222154a
|
@ -1241,12 +1241,21 @@ void OBSApp::EnableInFocusHotkeys(bool enable)
|
|||
ResetHotkeyState(applicationState() != Qt::ApplicationActive);
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(VoidFunc)
|
||||
|
||||
void OBSApp::Exec(VoidFunc func)
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
bool OBSApp::OBSInit()
|
||||
{
|
||||
ProfileScope("OBSApp::OBSInit");
|
||||
|
||||
setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
qRegisterMetaType<VoidFunc>();
|
||||
|
||||
if (!StartupOBS(locale.c_str(), GetProfilerNameStore()))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <util/util.hpp>
|
||||
#include <util/platform.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -58,6 +59,8 @@ public:
|
|||
const char *disambiguation, int n) const override;
|
||||
};
|
||||
|
||||
typedef std::function<void ()> VoidFunc;
|
||||
|
||||
class OBSApp : public QApplication {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -166,6 +169,9 @@ public:
|
|||
translatorHooks.pop_front();
|
||||
}
|
||||
|
||||
public slots:
|
||||
void Exec(VoidFunc func);
|
||||
|
||||
signals:
|
||||
void StyleChanged();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue