blob: b1c58332b22b5a16062da54f47699a1e277c0875 (
plain)
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
41
42
43
44
45
|
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#define AK_DONT_REPLACE_STD
#include "EventLoopPluginQt.h"
#include "TimerQt.h"
#include <AK/Function.h>
#include <AK/NonnullRefPtr.h>
#include <QCoreApplication>
#include <QTimer>
namespace Ladybird {
EventLoopPluginQt::EventLoopPluginQt() = default;
EventLoopPluginQt::~EventLoopPluginQt() = default;
void EventLoopPluginQt::spin_until(Function<bool()> goal_condition)
{
while (!goal_condition())
QCoreApplication::processEvents(QEventLoop::ProcessEventsFlag::AllEvents | QEventLoop::ProcessEventsFlag::WaitForMoreEvents);
}
void EventLoopPluginQt::deferred_invoke(Function<void()> function)
{
VERIFY(function);
QTimer::singleShot(0, [function = move(function)] {
function();
});
}
NonnullRefPtr<Web::Platform::Timer> EventLoopPluginQt::create_timer()
{
return TimerQt::create();
}
void EventLoopPluginQt::quit()
{
QCoreApplication::quit();
}
}
|