[plasma/kscreenlocker] greeter: move from qt_extract_metatypes to qt_generate_foreign_qml_types
Harald Sitter <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 9f6f7162c7895ac607cc8d9dd3261bd2d22de907 by Harald Sitter.
Committed on 20/07/2026 at 12:40.
Pushed by davidedmundson into branch 'master'.
move from qt_extract_metatypes to qt_generate_foreign_qml_types
the latter automatically takes care of creating Foreign QML structs for
the elements in the library. this means we don't have to manually
maintain the types.h, and also the code looks more idiomatic
M +3 -3 greeter/CMakeLists.txt
M +3 -0 greeter/pamauthenticator.h
M +3 -0 greeter/pamauthenticators.h
D +0 -26 greeter/types.h
https://invent.kde.org/plasma/kscreenlocker/-/commit/9f6f7162c7895ac607cc8d9dd3261bd2d22de907
diff --git a/greeter/CMakeLists.txt b/greeter/CMakeLists.txt
index 1c704385..9b9c41d9 100644
--- a/greeter/CMakeLists.txt
+++ b/greeter/CMakeLists.txt
@@ -29,7 +29,6 @@ set(kscreenlocker_greet_SRCS
greeterapp.h
noaccessnetworkaccessmanagerfactory.h
../logind.h
- types.h
)
ecm_qt_declare_logging_category(kscreenlocker_greet_SRCS
@@ -43,11 +42,10 @@ ecm_qt_declare_logging_category(kscreenlocker_greet_SRCS
add_library(kscreenlocker_authenticator OBJECT ${kscreenlocker_authenticator_SRCS})
target_link_libraries(kscreenlocker_authenticator
Qt::Core
+ Qt::Qml
${PAM_LIBRARIES}
)
-qt_extract_metatypes(kscreenlocker_authenticator)
-
qt_add_resources(kscreenlocker_greet_SRCS fallbacktheme.qrc)
add_executable(kscreenlocker_greet ${kscreenlocker_greet_SRCS})
@@ -93,6 +91,8 @@ target_compile_definitions(kscreenlocker_greet PRIVATE
KSCREENLOCKER_PAM_SMARTCARD_SERVICE=${KSCREENLOCKER_PAM_SMARTCARD_SERVICE}
)
+qt_generate_foreign_qml_types(kscreenlocker_authenticator kscreenlocker_greet)
+
# manually install type info since it's not installed by default for executables but we want it
# for the kscreenlocker UI in shellpackage
qt6_query_qml_module(kscreenlocker_greet
diff --git a/greeter/pamauthenticator.h b/greeter/pamauthenticator.h
index d2f7721c..2519b20f 100644
--- a/greeter/pamauthenticator.h
+++ b/greeter/pamauthenticator.h
@@ -8,12 +8,15 @@
#include <QObject>
#include <QThread>
+#include <qqmlregistration.h>
class PamWorker;
class PamAuthenticator : public QObject
{
Q_OBJECT
+ QML_NAMED_ELEMENT(Authenticator)
+ QML_UNCREATABLE("Not exposed except for its enum")
Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged)
Q_PROPERTY(bool inPasswordDelay READ inPasswordDelay NOTIFY inPasswordDelayChanged)
diff --git a/greeter/pamauthenticators.h b/greeter/pamauthenticators.h
index 522a1ca3..7ffd6218 100644
--- a/greeter/pamauthenticators.h
+++ b/greeter/pamauthenticators.h
@@ -9,10 +9,13 @@
#include "pamauthenticator.h"
#include <QObject>
#include <memory>
+#include <qqmlregistration.h>
class PamAuthenticators : public QObject
{
Q_OBJECT
+ QML_NAMED_ELEMENT(Authenticators)
+ QML_UNCREATABLE("Only available through the global `authenticator` context property")
// these properties delegate to the interactive authenticator
Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged)
diff --git a/greeter/types.h b/greeter/types.h
deleted file mode 100644
index f47bcc29..00000000
--- a/greeter/types.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2026 Nicolas Fella <[email protected]>
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#pragma once
-
-#include <qqmlregistration.h>
-
-#include "pamauthenticator.h"
-#include "pamauthenticators.h"
-
-struct PamAuthenticatorForeign {
- Q_GADGET
- QML_NAMED_ELEMENT(Authenticator)
- QML_UNCREATABLE("")
- QML_FOREIGN(PamAuthenticator)
-};
-
-struct PamAuthenticatorsForeign {
- Q_GADGET
- QML_NAMED_ELEMENT(Authenticators)
- QML_UNCREATABLE("")
- QML_FOREIGN(PamAuthenticators)
-};