Skip to content

Commit 3ebaf00

Browse files
committed
window: generate qmltypes
1 parent 4e48c6e commit 3ebaf00

File tree

9 files changed

+53
-10
lines changed

9 files changed

+53
-10
lines changed

src/core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ target_link_libraries(quickshell-core PRIVATE quickshell-build)
4444
qt_add_qml_module(quickshell-core
4545
URI Quickshell
4646
VERSION 0.1
47-
IMPORTS Quickshell._Window
47+
OPTIONAL_IMPORTS Quickshell._Window
48+
DEFAULT_IMPORTS Quickshell._Window
4849
)
4950

5051
target_link_libraries(quickshell-core PRIVATE ${QT_DEPS} CLI11::CLI11)

src/core/doc.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#define QSDOC_ELEMENT
1111
#define QSDOC_NAMED_ELEMENT(name)
1212

13+
// unmark uncreatable (will be overlayed by other types)
14+
#define QSDOC_CREATABLE
15+
1316
// change the cname used for this type
1417
#define QSDOC_CNAME(name)
1518

src/core/module.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ headers = [
77
"shell.hpp",
88
"variants.hpp",
99
"region.hpp",
10-
"proxywindow.hpp",
10+
"../window/proxywindow.hpp",
1111
"persistentprops.hpp",
12-
"windowinterface.hpp",
13-
"panelinterface.hpp",
14-
"floatingwindow.hpp",
15-
"popupwindow.hpp",
12+
"../window/windowinterface.hpp",
13+
"../window/panelinterface.hpp",
14+
"../window/floatingwindow.hpp",
15+
"../window/popupwindow.hpp",
1616
"singleton.hpp",
1717
"lazyloader.hpp",
1818
"easingcurve.hpp",

src/core/plugin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ void QuickshellPlugin::initPlugins() {
1919
plugins.end()
2020
);
2121

22+
std::sort(plugins.begin(), plugins.end(), [](QuickshellPlugin* a, QuickshellPlugin* b) {
23+
return b->dependencies().contains(a->name());
24+
});
25+
2226
for (QuickshellPlugin* plugin: plugins) {
2327
plugin->init();
2428
}

src/core/plugin.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <qcontainerfwd.h>
44
#include <qfunctionpointer.h>
5+
#include <qlist.h>
56

67
class EngineGeneration;
78

@@ -14,6 +15,8 @@ class QuickshellPlugin {
1415
void operator=(QuickshellPlugin&&) = delete;
1516
void operator=(const QuickshellPlugin&) = delete;
1617

18+
virtual QString name() { return QString(); }
19+
virtual QList<QString> dependencies() { return {}; }
1720
virtual bool applies() { return true; }
1821
virtual void init() {}
1922
virtual void registerTypes() {}

src/wayland/init.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <qguiapplication.h>
2+
#include <qlist.h>
23
#include <qlogging.h>
34
#include <qqml.h>
45
#include <qtenvironmentvariables.h>
@@ -14,7 +15,9 @@ void installPopupPositioner();
1415

1516
namespace {
1617

17-
class WaylandPlugin: public QuickshellPlugin {
18+
class WindowPlugin: public QuickshellPlugin {
19+
QList<QString> dependencies() override { return {"window"}; }
20+
1821
bool applies() override {
1922
auto isWayland = QGuiApplication::platformName() == "wayland";
2023

@@ -52,6 +55,6 @@ class WaylandPlugin: public QuickshellPlugin {
5255
}
5356
};
5457

55-
QS_REGISTER_PLUGIN(WaylandPlugin);
58+
QS_REGISTER_PLUGIN(WindowPlugin);
5659

5760
} // namespace

src/window/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ qt_add_qml_module(quickshell-window
1111
VERSION 0.1
1212
)
1313

14+
add_library(quickshell-window-init OBJECT init.cpp)
15+
1416
target_link_libraries(quickshell-window PRIVATE ${QT_DEPS} Qt6::QuickPrivate)
17+
target_link_libraries(quickshell-windowplugin PRIVATE ${QT_DEPS})
18+
target_link_libraries(quickshell-window-init PRIVATE ${QT_DEPS})
1519

1620
qs_pch(quickshell-window)
1721
qs_pch(quickshell-windowplugin)
22+
qs_pch(quickshell-window-init)
1823

19-
target_link_libraries(quickshell PRIVATE quickshell-windowplugin)
24+
target_link_libraries(quickshell PRIVATE quickshell-windowplugin quickshell-window-init)
2025

2126
if (BUILD_TESTING)
2227
add_subdirectory(test)

src/window/init.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "../core/plugin.hpp"
2+
3+
namespace {
4+
5+
class WindowPlugin: public QuickshellPlugin {
6+
// _Window has to be registered before wayland or x11 modules, otherwise module overlays
7+
// will apply in the wrong order.
8+
QString name() override { return "window"; }
9+
10+
void registerTypes() override {
11+
qmlRegisterModuleImport(
12+
"Quickshell",
13+
QQmlModuleImportModuleAny,
14+
"Quickshell._Window",
15+
QQmlModuleImportLatest
16+
);
17+
}
18+
};
19+
20+
QS_REGISTER_PLUGIN(WindowPlugin);
21+
22+
} // namespace

src/window/panelinterface.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ class PanelWindowInterface: public WindowInterface {
128128
/// Note: On Wayland this property corrosponds to @@Quickshell.Wayland.WlrLayershell.keyboardFocus.
129129
Q_PROPERTY(bool focusable READ focusable WRITE setFocusable NOTIFY focusableChanged);
130130
// clang-format on
131-
QSDOC_NAMED_ELEMENT(PanelWindow);
131+
QML_NAMED_ELEMENT(PanelWindow);
132+
QML_UNCREATABLE("No PanelWindow backend loaded.");
133+
QSDOC_CREATABLE;
132134

133135
public:
134136
explicit PanelWindowInterface(QObject* parent = nullptr): WindowInterface(parent) {}

0 commit comments

Comments
 (0)