File indexing completed on 2025-02-09 06:41:24
0001 /* 0002 SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "plasmoidattached_p.h" 0008 0009 #include "appletcontext_p.h" 0010 #include "appletquickitem.h" 0011 0012 #include <Plasma/Applet> 0013 #include <Plasma/Containment> 0014 0015 namespace PlasmaQuick 0016 { 0017 ///////////////////////PlasmoidAttached 0018 0019 PlasmoidAttached::PlasmoidAttached(QObject *parent) 0020 : QObject(parent) 0021 { 0022 } 0023 0024 PlasmoidAttached::~PlasmoidAttached() 0025 { 0026 } 0027 0028 Plasma::Applet *PlasmoidAttached::qmlAttachedProperties(QObject *object) 0029 { 0030 // Special case: we are asking the attached Plasmoid property of an AppletItem itself, which in this case is its own Applet 0031 if (auto *appletItem = qobject_cast<AppletQuickItem *>(object)) { 0032 return appletItem->applet(); 0033 } else if (auto *applet = qobject_cast<Plasma::Applet *>(object)) { 0034 // Asked for the Plasmoid of an Applet itself 0035 return applet; 0036 } 0037 0038 QQmlContext *context = qmlContext(object); 0039 while (context) { 0040 if (auto *appletContext = qobject_cast<AppletContext *>(context)) { 0041 return appletContext->applet(); 0042 } 0043 0044 context = context->parentContext(); 0045 } 0046 0047 return nullptr; 0048 } 0049 0050 ///////////////////////PlasmoidAttached 0051 0052 ContainmentAttached::ContainmentAttached(QObject *parent) 0053 : QObject(parent) 0054 { 0055 } 0056 0057 ContainmentAttached::~ContainmentAttached() 0058 { 0059 } 0060 0061 Plasma::Containment *ContainmentAttached::qmlAttachedProperties(QObject *object) 0062 { 0063 return qobject_cast<Plasma::Containment *>(PlasmoidAttached::qmlAttachedProperties(object)); 0064 } 0065 0066 } 0067 0068 #include "private/moc_plasmoidattached_p.cpp"