forked from linuxdeepin/qt5platform-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.cpp
40 lines (32 loc) · 802 Bytes
/
global.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-FileCopyrightText: 2017 - 2022 Uniontech Software Technology Co.,Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "global.h"
#include <QWindow>
#include <QGuiApplication>
QWindow * fromQtWinId(WId id) {
QWindow *window = nullptr;
for (auto win : qApp->allWindows()) {
if (win->winId() == id) {
window = win;
break;
}
}
return window;
};
DPP_BEGIN_NAMESPACE
RunInThreadProxy::RunInThreadProxy(QObject *parent)
: QObject(parent)
{
}
void RunInThreadProxy::proxyCall(FunctionType func)
{
QObject *receiver = parent();
if (!receiver)
receiver = qApp;
QObject scope;
connect(&scope, &QObject::destroyed, receiver, [func]() {
(func)();
}, Qt::QueuedConnection);
}
DPP_END_NAMESPACE