/* * Copyright (c) 2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #define AK_DONT_REPLACE_STD #include "EventLoopPluginQt.h" #include "TimerQt.h" #include #include #include #include namespace Ladybird { EventLoopPluginQt::EventLoopPluginQt() = default; EventLoopPluginQt::~EventLoopPluginQt() = default; void EventLoopPluginQt::spin_until(Function goal_condition) { while (!goal_condition()) QCoreApplication::processEvents(QEventLoop::ProcessEventsFlag::AllEvents | QEventLoop::ProcessEventsFlag::WaitForMoreEvents); } void EventLoopPluginQt::deferred_invoke(Function function) { VERIFY(function); QTimer::singleShot(0, [function = move(function)] { function(); }); } NonnullRefPtr EventLoopPluginQt::create_timer() { return TimerQt::create(); } void EventLoopPluginQt::quit() { QCoreApplication::quit(); } }