KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
flutter/Platform.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#pragma once
13
14#include "kddockwidgets/core/Platform.h"
15
16#include <optional>
17
18#ifdef KDDW_FLUTTER_HAS_COROUTINES
19#include "CoRoutines.h"
20#endif
21
22namespace KDDockWidgets {
23
24namespace Core {
25class MainWindow;
26}
27
28namespace flutter {
29
30class IndicatorWindow;
31
34class DOCKS_EXPORT Platform : public Core::Platform
35{
36public:
37 Platform();
38 ~Platform() override;
39
41 {
42 return static_cast<Platform *>(Platform::instance());
43 }
44
48
49 const char *name() const override;
50 bool hasActivePopup() const override;
51 Core::ViewFactory *createDefaultViewFactory() override;
52 std::shared_ptr<Core::Window> windowAt(Point globalPos) const override;
53
54 int screenNumberFor(Core::View *) const override;
55 Size screenSizeFor(Core::View *) const override;
56
57 Core::View *createView(Core::Controller *controller, Core::View *parent = nullptr) const override;
58 bool inDisallowedDragView(Point globalPos) const override;
59 bool usesFallbackMouseGrabber() const override;
60 void ungrabMouse() override;
61 Vector<std::shared_ptr<Core::Screen>> screens() const override;
62 std::shared_ptr<Core::Screen> primaryScreen() const override;
63
64 void onFloatingWindowCreated(Core::FloatingWindow *) override;
65 void onFloatingWindowDestroyed(Core::FloatingWindow *) override;
66 void onMainWindowCreated(Core::MainWindow *) override;
67 void onMainWindowDestroyed(Core::MainWindow *) override;
68 virtual void onDropIndicatorOverlayCreated(flutter::IndicatorWindow *);
69 virtual void onDropIndicatorOverlayDestroyed(flutter::IndicatorWindow *);
70 virtual void rebuildWindowOverlay();
71
72 void runDelayed(int ms, Core::DelayedCall *c) override;
73
74#ifdef KDDW_FLUTTER_HAS_COROUTINES
75 // Stuff required by the tests only and not used by dart bindings.
76 KDDW_QCORO_TASK tests_wait(int ms) const override;
77 KDDW_QCORO_TASK tests_waitForResize(Core::View *, int timeout) const override;
78 KDDW_QCORO_TASK tests_waitForResize(Core::Controller *, int timeout) const override;
79 KDDW_QCORO_TASK tests_waitForDeleted(Core::Controller *, int timeout = 5000) const override;
80 KDDW_QCORO_TASK tests_waitForDeleted(Core::View *, int timeout = 5000) const override;
81 KDDW_QCORO_TASK tests_waitForWindowActive(std::shared_ptr<Core::Window>, int timeout) const override;
82 KDDW_QCORO_TASK tests_waitForEvent(Core::Object *w, Event::Type type, int timeout) const override;
83 KDDW_QCORO_TASK tests_waitForEvent(Core::View *, Event::Type type, int timeout) const override;
84 KDDW_QCORO_TASK tests_waitForEvent(std::shared_ptr<Core::Window>, Event::Type type, int timeout) const override;
85
86 void tests_doubleClickOn(Point globalPos, Core::View *receiver) override;
87 void tests_doubleClickOn(Point globalPos, std::shared_ptr<Core::Window> receiver) override;
88 void tests_pressOn(Point globalPos, Core::View *receiver) override;
89 void tests_pressOn(Point globalPos, std::shared_ptr<Core::Window> receiver) override;
90 KDDW_QCORO_TASK tests_releaseOn(Point globalPos, Core::View *receiver) override;
91 KDDW_QCORO_TASK tests_mouseMove(Point globalPos, Core::View *receiver) override;
92 std::shared_ptr<Core::Window> tests_createWindow() override;
93
94 mutable CoRoutines m_coRoutines;
95
96 typedef KDDW_QCORO_TASK (*RunTestsFunc)();
97 static RunTestsFunc s_runTestsFunc;
98#endif
99
100#ifdef DOCKS_TESTING_METHODS
101 void tests_initPlatform_impl() override;
102 void tests_deinitPlatform_impl() override;
103 Core::View *tests_createView(Core::CreateViewOptions, Core::View *parent = nullptr) override;
104 Core::View *tests_createFocusableView(Core::CreateViewOptions, Core::View *parent = nullptr) override;
105 Core::View *tests_createNonClosableView(Core::View *parent = nullptr) override;
107 createMainWindow(const QString &uniqueName, Core::CreateViewOptions viewOpts,
108 MainWindowOptions options = MainWindowOption_HasCentralFrame,
109 Core::View *parent = nullptr, Qt::WindowFlags flags = {}) const override;
110
111 void installMessageHandler() override;
112 void uninstallMessageHandler() override;
113
114 void pauseForDebugger() override;
115
117 virtual void pauseForDartDebugger() {};
118
119 // Called by unit-test's main.dart. Runs the tests.
120 // The tests are in C++, as they are the same ones for QtWidgets and QtQuick
121 void runTests();
122
123 // Called by Dart's event loop, to wake up paused C++ unit-tests
124 void resumeCoRoutines();
125
127 virtual void scheduleResumeCoRoutines(int ms) const;
128
129 std::optional<int> testsResult() const;
130#endif
131protected:
132 void init();
133
134 // Platform interface
135public:
136 std::shared_ptr<Core::View> focusedView() const override;
137 Vector<std::shared_ptr<Core::Window>> windows() const override;
138 void sendEvent(Core::View *, Event *) const override;
139 int screenNumberFor(std::shared_ptr<Core::Window>) const override;
140 bool isProcessingAppQuitEvent() const override;
141 QString applicationName() const override;
142 void setMouseCursor(Qt::CursorShape, bool discardLast = false) override;
143 void restoreMouseCursor() override;
144 DisplayType displayType() const override;
145 bool isLeftMouseButtonPressed() const override;
146 Point cursorPos() const override;
147 void setCursorPos(Point) override;
148 void setFocusedView(std::shared_ptr<Core::View>);
149
150 class Private;
151 Private *const d;
152};
153
154}
155
156}
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
implements functions specific to a particular platform A platform can be for example qtwidgets,...
A factory class for allowing the user to customize some internal views. This is optional,...
implements functions specific to a particular platform A platform can be for example qtwidgets,...
Class to abstract QAction, so code still works with QtQuick and Flutter.
CursorShape
typedef WindowFlags

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8