summaryrefslogtreecommitdiffstats
path: root/src/shared-lib/applicationinterfaceimpl.cpp
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2025-10-24 18:41:23 +0200
committerRobert Griebl <robert.griebl@qt.io>2025-12-09 14:34:41 +0100
commitb66401c1993b79a38c252078ef26a6c64ee56106 (patch)
tree96473a725eae531a40988055ab53412e7917df5b /src/shared-lib/applicationinterfaceimpl.cpp
parent1a83c314cb23e1fb3861637ac4676c8ae8fd32ee (diff)
Re-organize the appman libraries into more manageable chunks
This is part 2 of this patch series. Part 1 was about converting the libs from static to shared. This patch now consolidates the library zoo into more manageable and logical chunks. Plus this will also help with keeping the hit to the startup performance (incurred by part 1) in check. The new setup closely follows the QML module nomenclature, but needs to account for the tool builds as well. The new libs are: - Common no changes - Package a combination of Package, Application and Crypto - Shared renamed from SharedMain and combined with Monitor and IntentClient - SystemUI renamed from Main and combined with Manager, DBus, IntentServer and Window - Application renamed from ApplicationMain Because the CrashHandler is using a "constructor" function, it had to be moved from the Common to the Shared lib to avoid having the custom crash handler also in the tools, as they need to install their own CTRL+C handler at times. In addition the 3 QML import modules are now built as official QML plugins and they are installed into $QTDIR/qml as any other import library. NB! There is a problem we still have to solve: custom appman binaries (system-ui's) are currently built by linking against Qt::AppManMain, but this no longer exists. It would be ideal if we could add an alias here. The other renamed modules are not that problematic, as they shouldn't be used outside of the appman project itself. If an alias is not possible, a dummy library which depends on the new "SystemUI" one should also do the trick. Change-Id: Id07e05a523c48e773c295c5be2f27804229155e0 Pick-to: 6.11 Reviewed-by: Bernd Weimer <bernd.weimer@qt.io>
Diffstat (limited to 'src/shared-lib/applicationinterfaceimpl.cpp')
-rw-r--r--src/shared-lib/applicationinterfaceimpl.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/shared-lib/applicationinterfaceimpl.cpp b/src/shared-lib/applicationinterfaceimpl.cpp
new file mode 100644
index 00000000..417a28da
--- /dev/null
+++ b/src/shared-lib/applicationinterfaceimpl.cpp
@@ -0,0 +1,60 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QMetaMethod>
+#include "applicationinterface.h"
+#include "applicationinterfaceimpl.h"
+
+QT_BEGIN_NAMESPACE_AM
+
+std::function<ApplicationInterfaceImpl *(ApplicationInterface *)> ApplicationInterfaceImpl::s_factory;
+
+void ApplicationInterfaceImpl::setFactory(const std::function<ApplicationInterfaceImpl *(ApplicationInterface *)> &factory)
+{
+ s_factory = factory;
+}
+
+ApplicationInterfaceImpl::ApplicationInterfaceImpl()
+{ }
+
+ApplicationInterfaceImpl *ApplicationInterfaceImpl::create(ApplicationInterface *iface)
+{
+ auto aminterface = s_factory ? s_factory(iface) : nullptr;
+ if (aminterface)
+ aminterface->attach(iface);
+ return aminterface;
+}
+
+void ApplicationInterfaceImpl::attach(ApplicationInterface *iface)
+{
+ m_aminterfaces << iface;
+}
+
+void ApplicationInterfaceImpl::detach(ApplicationInterface *iface)
+{
+ m_aminterfaces.removeAll(iface);
+}
+
+QList<ApplicationInterface *> ApplicationInterfaceImpl::amInterfaces()
+{
+ return m_aminterfaces;
+}
+
+void ApplicationInterfaceImpl::handleQuit()
+{
+ static const QMetaMethod quitSignal = QMetaMethod::fromSignal(&ApplicationInterface::quit);
+
+ bool isQuitConnected = false;
+ for (auto aminterface : std::as_const(m_aminterfaces)) {
+ if (aminterface->isSignalConnected(quitSignal)) {
+ emit aminterface->quit();
+ isQuitConnected = true;
+ }
+ }
+ if (!isQuitConnected)
+ acknowledgeQuit();
+}
+
+QT_END_NAMESPACE_AM
+
+#include "moc_applicationinterfaceimpl.cpp"