Libplasma

wallpaperitem.h
1/*
2 SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef WALLPAPERITEM_H
8#define WALLPAPERITEM_H
9
10#include <QQmlEngine>
11#include <QQuickItem>
12
13#include <KPackage/Package>
14
15class KConfigLoader;
17
18class ContainmentItem;
19
20namespace Plasma
21{
22class Containment;
23}
24
25namespace PlasmaQuick
26{
27class SharedQmlEngine;
28}
29
30/**
31 * @brief This class is exposed to wallpapers as the WallpaperItem root qml item
32 *
33 * <b>Import Statement</b>
34 * @code import org.kde.plasma.plasmoid @endcode
35 * @version 2.0
36 */
37class WallpaperItem : public QQuickItem
38{
40
41 Q_PROPERTY(QString pluginName READ pluginName CONSTANT)
42 Q_PROPERTY(KConfigPropertyMap *configuration READ configuration CONSTANT)
43 /**
44 * Actions to be added in the desktop context menu. To instantiate QActions in a declarative way,
45 * PlasmaCore.Action {} can be used
46 */
47 Q_PROPERTY(QQmlListProperty<QAction> contextualActions READ qmlContextualActions NOTIFY contextualActionsChanged)
48 Q_PROPERTY(bool loading MEMBER m_loading NOTIFY isLoadingChanged)
49
50 /*
51 * The accent color manually set by the wallpaper plugin.
52 * By default it's transparent, which means either the dominant color is used
53 * when "Accent Color From Wallpaper" is enabled, or the theme color is used.
54 *
55 * @since 6.0
56 */
57 Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged RESET resetAccentColor)
58
59public:
60 explicit WallpaperItem(QQuickItem *parent = nullptr);
61 ~WallpaperItem() override;
62
63 void classBegin() override;
64 void componentComplete() override;
65
66 /**
67 * Returns a list of all known wallpapers that can accept the given mimetype
68 * @param mimetype the mimetype to search for
69 * @param formFactor the format of the wallpaper being search for (e.g. desktop)
70 * @return list of wallpapers
71 */
72 static QList<KPluginMetaData> listWallpaperMetadataForMimetype(const QString &mimetype, const QString &formFactor = QString());
73
74 /**
75 * Instantiate the WallpaperItem for a given containment, using the proper plugin
76 */
77 static WallpaperItem *loadWallpaper(ContainmentItem *ContainmentItem);
78
79 KPackage::Package kPackage() const;
80
81 QString pluginName() const;
82
83 KConfigPropertyMap *configuration() const;
84
85 KConfigLoader *configScheme();
86
87 void requestOpenUrl(const QUrl &url);
88
90
91 QML_LIST_PROPERTY_ASSIGN_BEHAVIOR_REPLACE
92 QQmlListProperty<QAction> qmlContextualActions();
93
94 bool supportsMimetype(const QString &mimetype) const;
95
96 bool isLoading() const;
97
98 QColor accentColor() const;
99 void setAccentColor(const QColor &newColor);
100 void resetAccentColor();
101
103 void isLoadingChanged();
104 void openUrlRequested(const QUrl &url);
105 void contextualActionsChanged(const QList<QAction *> &actions);
106 void accentColorChanged();
107
108private:
109 static void contextualActions_append(QQmlListProperty<QAction> *prop, QAction *action);
110 static qsizetype contextualActions_count(QQmlListProperty<QAction> *prop);
111 static QAction *contextualActions_at(QQmlListProperty<QAction> *prop, qsizetype idx);
112 static void contextualActions_clear(QQmlListProperty<QAction> *prop);
113 static void contextualActions_replace(QQmlListProperty<QAction> *prop, qsizetype idx, QAction *action);
114 static void contextualActions_removeLast(QQmlListProperty<QAction> *prop);
115
116 QString m_wallpaperPlugin;
117 Plasma::Containment *m_containment = nullptr;
118 PlasmaQuick::SharedQmlEngine *m_qmlObject = nullptr;
119 KPackage::Package m_pkg;
120 KConfigPropertyMap *m_configuration = nullptr;
121 KConfigLoader *m_configLoader = nullptr;
122 QList<QAction *> m_contextualActions;
123 bool m_loading = false;
124 std::optional<QColor> m_accentColor;
125};
126
127#endif
This class is exposed to containments QML as the attached property Plasmoid.
An object that instantiates an entire QML context, with its own declarative engine.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
QQmlListProperty< QAction > contextualActions
Actions to be added in the desktop context menu.
static WallpaperItem * loadWallpaper(ContainmentItem *ContainmentItem)
Instantiate the WallpaperItem for a given containment, using the proper plugin.
static QList< KPluginMetaData > listWallpaperMetadataForMimetype(const QString &mimetype, const QString &formFactor=QString())
Returns a list of all known wallpapers that can accept the given mimetype.
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
Definition action.h:20
Namespace for everything in libplasma.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QQuickItem(QQuickItem *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:23 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.