KIO

koverlayiconplugin.h
1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2015 Olivier Goffart <ogoffart@woboq.com>
4
5 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef KOVERLAYICONPLUGIN_H
9#define KOVERLAYICONPLUGIN_H
10
11#include "kiocore_export.h"
12#include <QObject>
13
14class QUrl;
15
16/**
17 * @class KOverlayIconPlugin koverlayiconplugin.h <KOverlayIconPlugin>
18 *
19 * @brief Base class for overlay icon plugins.
20 * Enables file managers to show custom overlay icons on files.
21 *
22 * This plugin can be created and installed through kcoreaddons_add_plugin
23 * @code
24 * kcoreaddons_add_plugin(myoverlayplugin SOURCES myoverlayplugin.cpp INSTALL_NAMESPACE "kf6/overlayicon")
25 * target_link_libraries(myoverlayplugin KF6::KIOCore)
26 * @endcode
27 * The C++ file should look like this:
28 * @code
29#include <KOverlayIconPlugin>
30
31class MyOverlayPlugin : public KOverlayIconPlugin
32{
33 Q_PLUGIN_METADATA(IID "org.kde.overlayicon.myplugin")
34 Q_OBJECT
35
36public:
37 MyOverlayPlugin() {
38 }
39
40 QStringList getOverlays(const QUrl &url) override {
41 // Implement your logic
42 }
43};
44
45#include "myoverlayplugin.moc"
46 * @endcode
47 * @since 5.16
48 */
49class KIOCORE_EXPORT KOverlayIconPlugin : public QObject
50{
51 Q_OBJECT
52public:
53 explicit KOverlayIconPlugin(QObject *parent = nullptr);
54 ~KOverlayIconPlugin() override;
55
56 /**
57 * Returns a list of overlay icons to add to a file
58 * This can be a path to an icon, or the icon name
59 *
60 * This function is called from the main thread and must not block.
61 * It is recommended to have a cache. And if the item is not in cache
62 * just return an empty list and call the overlaysChanged when the
63 * information is available.
64 */
65 virtual QStringList getOverlays(const QUrl &item) = 0;
67 /**
68 * Emit this signal when the list of overlay icons changed for a given URL
69 */
70 void overlaysChanged(const QUrl &url, const QStringList &overlays);
71};
72
73#endif
Base class for overlay icon plugins.
virtual QStringList getOverlays(const QUrl &item)=0
Returns a list of overlay icons to add to a file This can be a path to an icon, or the icon name.
void overlaysChanged(const QUrl &url, const QStringList &overlays)
Emit this signal when the list of overlay icons changed for a given URL.
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:50:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.