Port to qmlRegisterAnonymousType()

The anonymous variant of qmlRegisterType() is deprecated in Qt5 and
gone in Qt6.

This however now requires us to specify a module URI and major version
number. I used the names and (lowest) versions used already for other
types nearby where available, and fell back to "org.kde.kwin" and 0
otherwise.
This commit is contained in:
Volker Krause 2022-03-09 17:43:24 +01:00
parent 3733abab2c
commit 5aae8c768a
4 changed files with 13 additions and 9 deletions

View file

@ -34,7 +34,7 @@ VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args)
QStringLiteral("2.0"), QString(), KAboutLicense::GPL);
setAboutData(about);
qmlRegisterType<VirtualDesktopsSettings>();
qmlRegisterAnonymousType<VirtualDesktopsSettings>("org.kde.kwin.kcm.desktop", 0);
setButtons(Apply | Default);

View file

@ -35,7 +35,7 @@ LayoutPreview::LayoutPreview(const QString &path, bool showDesktopThumbnail, QOb
qmlRegisterType<SwitcherItem>("org.kde.kwin", 2, 0, "Switcher");
qmlRegisterType<WindowThumbnailItem>("org.kde.kwin", 3, 0, "WindowThumbnailItem");
qmlRegisterType<SwitcherItem>("org.kde.kwin", 3, 0, "TabBoxSwitcher");
qmlRegisterType<QAbstractItemModel>();
qmlRegisterAnonymousType<QAbstractItemModel>("org.kde.kwin", 2);
component->loadUrl(QUrl::fromLocalFile(path));
if (component->isError()) {
qDebug() << component->errorString();

View file

@ -223,8 +223,8 @@ void Helper::init()
m_engine->importPlugin(pluginPath, "org.kde.kwin.decoration", nullptr);
qmlRegisterType<KWin::Borders>("org.kde.kwin.decoration", 0, 1, "Borders");
qmlRegisterType<KDecoration2::Decoration>();
qmlRegisterType<KDecoration2::DecoratedClient>();
qmlRegisterAnonymousType<KDecoration2::Decoration>("org.kde.kwin.decoration", 0);
qmlRegisterAnonymousType<KDecoration2::DecoratedClient>("org.kde.kwin.decoration", 0);
qRegisterMetaType<KDecoration2::BorderSize>();
}

View file

@ -643,7 +643,7 @@ void KWin::Scripting::init()
qmlRegisterType<WindowThumbnailItem>("org.kde.kwin", 2, 0, "ThumbnailItem");
qmlRegisterType<DBusCall>("org.kde.kwin", 2, 0, "DBusCall");
qmlRegisterType<ScreenEdgeItem>("org.kde.kwin", 2, 0, "ScreenEdgeItem");
qmlRegisterType<ScriptingModels::V2::ClientModel>();
qmlRegisterAnonymousType<ScriptingModels::V2::ClientModel>("org.kde.kwin", 2);
qmlRegisterType<ScriptingModels::V2::SimpleClientModel>("org.kde.kwin", 2, 0, "ClientModel");
qmlRegisterType<ScriptingModels::V2::ClientModelByScreen>("org.kde.kwin", 2, 0, "ClientModelByScreen");
qmlRegisterType<ScriptingModels::V2::ClientModelByScreenAndDesktop>("org.kde.kwin", 2, 0, "ClientModelByScreenAndDesktop");
@ -665,10 +665,14 @@ void KWin::Scripting::init()
});
qmlRegisterSingletonInstance("org.kde.kwin", 3, 0, "Options", options);
qmlRegisterType<KWin::AbstractClient>();
qmlRegisterType<KWin::VirtualDesktop>();
qmlRegisterType<KWin::X11Client>();
qmlRegisterType<QAbstractItemModel>();
qmlRegisterAnonymousType<KWin::AbstractClient>("org.kde.kwin", 2);
qmlRegisterAnonymousType<KWin::VirtualDesktop>("org.kde.kwin", 2);
qmlRegisterAnonymousType<KWin::X11Client>("org.kde.kwin", 2);
qmlRegisterAnonymousType<QAbstractItemModel>("org.kde.kwin", 2);
qmlRegisterAnonymousType<KWin::AbstractClient>("org.kde.kwin", 3);
qmlRegisterAnonymousType<KWin::VirtualDesktop>("org.kde.kwin", 3);
qmlRegisterAnonymousType<KWin::X11Client>("org.kde.kwin", 3);
qmlRegisterAnonymousType<QAbstractItemModel>("org.kde.kwin", 3);
// TODO Plasma 6: Drop context properties.
m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("workspace"), m_workspaceWrapper);