Albert
Loading...
Searching...
No Matches
plugininstance.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 Manuel Schneider
2// SPDX-License-Identifier: MIT
3
4#pragma once
5#include <QObject>
6#include <QString>
7#include <albert/config.h>
8#include <albert/export.h>
9#include <filesystem>
10#include <memory>
11#include <vector>
12class QSettings;
13class QWidget;
14
15namespace albert
16{
17class Extension;
18class PluginLoader;
19
25class ALBERT_EXPORT PluginInstance : public QObject
26{
27public:
28
31 virtual QWidget *buildConfigWidget();
32
35 virtual std::vector<albert::Extension*> extensions();
36
37public:
38
41 [[nodiscard]] const PluginLoader &loader() const;
42
45 [[nodiscard]] std::filesystem::path cacheLocation() const;
46
49 [[nodiscard]] std::filesystem::path configLocation() const;
50
53 [[nodiscard]] std::filesystem::path dataLocation() const;
54
57 [[nodiscard]] std::vector<std::filesystem::path> dataLocations() const;
58
63 [[nodiscard]] std::unique_ptr<QSettings> settings() const;
64
69 [[nodiscard]] std::unique_ptr<QSettings> state() const;
70
73 void readKeychain(const QString &key,
74 std::function<void(const QString &)> onSuccess,
75 std::function<void(const QString &)> onError) const;
76
79 void writeKeychain(const QString &key,
80 const QString &value,
81 std::function<void()> onSuccess,
82 std::function<void(const QString&)> onError) const;
83
84protected:
85
87 virtual ~PluginInstance();
88
89private:
90
91 class Private;
92 std::unique_ptr<Private> d;
93
94};
95
96}
97
108#define ALBERT_PLUGIN Q_OBJECT Q_PLUGIN_METADATA(IID ALBERT_PLUGIN_IID FILE "metadata.json")
Abstract plugin instance class.
Definition plugininstance.h:26
const PluginLoader & loader() const
The PluginLoader of this instance.
std::vector< std::filesystem::path > dataLocations() const
The existing data locations of this plugin.
std::unique_ptr< QSettings > state() const
Persistent plugin state.
std::filesystem::path dataLocation() const
The recommended data location.
void writeKeychain(const QString &key, const QString &value, std::function< void()> onSuccess, std::function< void(const QString &)> onError) const
Sets the keychain value of key to value asynchronously.
std::unique_ptr< QSettings > settings() const
Persistent plugin settings.
std::filesystem::path cacheLocation() const
The recommended cache location.
virtual QWidget * buildConfigWidget()
The widget used to configure the plugin in the settings.
std::filesystem::path configLocation() const
The recommended config location.
virtual std::vector< albert::Extension * > extensions()
The extensions provided by this plugin.
void readKeychain(const QString &key, std::function< void(const QString &)> onSuccess, std::function< void(const QString &)> onError) const
Reads the keychain value for key asynchronously.
Asynchronous plugin loader turning a physical plugin into a logical PluginInstance.
Definition pluginloader.h:16
Albert core interface namespace.
Definition albert.h:14