From 7fdecfd4244148454805a2f8ad2de33b9a91d756 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Sun, 3 Dec 2023 09:41:07 +0100 Subject: [PATCH] Fix LiriLocalDevice --- src/imports/device/plugin.cpp | 59 ----------------------------- src/imports/device/plugins.qmltypes | 59 ----------------------------- src/imports/device/qmldir | 4 -- src/localdevice/CMakeLists.txt | 3 +- src/localdevice/localdevice.cpp | 8 ++++ src/localdevice/localdevice.h | 5 ++- src/localdevice/osrelease.h | 1 + 7 files changed, 15 insertions(+), 124 deletions(-) delete mode 100644 src/imports/device/plugin.cpp delete mode 100644 src/imports/device/plugins.qmltypes delete mode 100644 src/imports/device/qmldir diff --git a/src/imports/device/plugin.cpp b/src/imports/device/plugin.cpp deleted file mode 100644 index 3314ebc..0000000 --- a/src/imports/device/plugin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#include -#include - -#include - -QML_DECLARE_TYPE(Liri::OsRelease) - -static QObject *localDeviceProvider(QQmlEngine *engine, QJSEngine *jsEngine) -{ - Q_UNUSED(engine); - Q_UNUSED(jsEngine); - - return new Liri::LocalDevice(); -} - -class LiriDevicePlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") -public: - LiriDevicePlugin() - { - } - - void registerTypes(const char *uri) override - { - // @uri Liri.Device - Q_ASSERT(QLatin1String(uri) == QLatin1String("Liri.Device")); - - qmlRegisterSingletonType(uri, 1, 0, "LocalDevice", localDeviceProvider); - qmlRegisterUncreatableType(uri, 1, 0, "OsRelease", - QStringLiteral("Cannot create OsRelease")); - } -}; - -#include "plugin.moc" diff --git a/src/imports/device/plugins.qmltypes b/src/imports/device/plugins.qmltypes deleted file mode 100644 index b01d4aa..0000000 --- a/src/imports/device/plugins.qmltypes +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick.tooling 1.2 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump-qt5 -noinstantiate -nonrelocatable Liri.Device 1.0 /home/plfiorini/git/liri/lirios/.build/install-root/lib/qml' - -Module { - dependencies: ["QtQuick 2.8"] - Component { - name: "Liri::LocalDevice" - prototype: "QObject" - exports: ["Liri.Device/LocalDevice 1.0"] - isCreatable: false - isSingleton: true - exportMetaObjectRevisions: [0] - Enum { - name: "Chassis" - values: { - "UnknownChassis": 0, - "DesktopChassis": 1, - "LaptopChassis": 2, - "ServerChassis": 3, - "TabletChassis": 4, - "PhoneChassis": 5, - "VirtualMachineChassis": 6, - "ContainerChassis": 7 - } - } - Enum { - name: "PowerSource" - values: { - "BatteryPower": 0, - "ACPower": 1 - } - } - Property { name: "chassis"; type: "Chassis"; isReadonly: true } - Property { name: "powerSource"; type: "PowerSource"; isReadonly: true } - Property { name: "lidPresent"; type: "bool"; isReadonly: true } - Property { name: "lidClosed"; type: "bool"; isReadonly: true } - Property { name: "hostName"; type: "string"; isReadonly: true } - Property { name: "iconName"; type: "string"; isReadonly: true } - Property { name: "materialIconName"; type: "string"; isReadonly: true } - Property { name: "operatingSystemName"; type: "string"; isReadonly: true } - Property { name: "virtualization"; type: "string"; isReadonly: true } - Property { name: "canPowerOff"; type: "bool"; isReadonly: true } - Property { name: "canRestart"; type: "bool"; isReadonly: true } - Property { name: "canSuspend"; type: "bool"; isReadonly: true } - Property { name: "canHibernate"; type: "bool"; isReadonly: true } - Property { name: "canHybridSleep"; type: "bool"; isReadonly: true } - Signal { name: "canHybridSleepdChanged" } - Method { name: "powerOff" } - Method { name: "restart" } - Method { name: "suspend" } - Method { name: "hibernate" } - Method { name: "hybridSleep" } - } -} diff --git a/src/imports/device/qmldir b/src/imports/device/qmldir deleted file mode 100644 index f98f4c9..0000000 --- a/src/imports/device/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module Liri.Device -plugin lirideviceplugin -classname LiriDevicePlugin -typeinfo plugins.qmltypes diff --git a/src/localdevice/CMakeLists.txt b/src/localdevice/CMakeLists.txt index 499703b..abe96a5 100644 --- a/src/localdevice/CMakeLists.txt +++ b/src/localdevice/CMakeLists.txt @@ -13,10 +13,11 @@ liri_add_module(LocalDevice PUBLIC_LIBRARIES Qt6::Core Qt6::DBus - Qt6::QmlIntegration + Qt6::Qml PKGCONFIG_DEPENDENCIES Qt6Core Qt6DBus + Qt6Qml ) liri_finalize_module(LocalDevice) diff --git a/src/localdevice/localdevice.cpp b/src/localdevice/localdevice.cpp index 82c5e47..f60d84c 100644 --- a/src/localdevice/localdevice.cpp +++ b/src/localdevice/localdevice.cpp @@ -560,4 +560,12 @@ void LocalDevice::hybridSleep() d->upower->hybridSleep(); } +LocalDevice *LocalDevice::create(QQmlEngine *engine, QJSEngine *jsEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(jsEngine); + + return new LocalDevice(); +} + } // namespace Liri diff --git a/src/localdevice/localdevice.h b/src/localdevice/localdevice.h index 3a73e39..08d2133 100644 --- a/src/localdevice/localdevice.h +++ b/src/localdevice/localdevice.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include @@ -34,6 +34,7 @@ class LIRILOCALDEVICE_EXPORT LocalDevice : public QObject Q_PROPERTY(bool canHybridSleep READ canHybridSleep NOTIFY canHybridSleepdChanged) Q_PROPERTY(OsRelease *osRelease READ osRelease CONSTANT) QML_ELEMENT + QML_SINGLETON public: enum Chassis { UnknownChassis = 0, @@ -80,6 +81,8 @@ class LIRILOCALDEVICE_EXPORT LocalDevice : public QObject bool canHibernate() const; bool canHybridSleep() const; + static LocalDevice *create(QQmlEngine *engine, QJSEngine *jsEngine); + Q_SIGNALS: void powerSourceChanged(); void lidPresentChanged(); diff --git a/src/localdevice/osrelease.h b/src/localdevice/osrelease.h index 2170c32..612e973 100644 --- a/src/localdevice/osrelease.h +++ b/src/localdevice/osrelease.h @@ -39,6 +39,7 @@ class LIRILOCALDEVICE_EXPORT OsRelease : public QObject Q_PROPERTY(QString variantId READ variantId NOTIFY variantIdChanged) Q_PROPERTY(QString logoIconName READ logoIconName NOTIFY logoIconNameChanged) QML_ELEMENT + QML_UNCREATABLE("Cannot create OsRelease") public: explicit OsRelease(QObject *parent = nullptr); ~OsRelease();