#include "albert/config.h"
#include "albert/extension.h"
#include "albert/extension/pluginprovider/plugininstance.h"
#include <QObject>
#include <QStringLiteral>
Go to the source code of this file.
◆ ALBERT_PLUGIN
#define ALBERT_PLUGIN Q_PLUGIN_METADATA(IID ALBERT_PLUGIN_IID FILE "metadata.json") |
Declare an class as Albert plugin.
Sets the interface identifier to #ALBERT_PLUGIN_IID and uses the metadata file named 'metadata.json' located at CMAKE_CURRENT_SOURCE_DIR.
- Note
- This macro has to be put into the plugin class body. The class this macro appears on must be default-constructible, inherit QObject and contain the Q_OBJECT macro. There should be exactly one occurrence of this macro in the source code for a plugin.
◆ ALBERT_PLUGIN_PROPERTY
#define ALBERT_PLUGIN_PROPERTY |
( |
|
type, |
|
|
|
name, |
|
|
|
defaultValue |
|
) |
| |
Value:public: static const type name##_default{defaultValue}; \
protected:
void store_##name() { settings()->setValue(
EXPAND_STRINGIZE(name), name()); } \
protected:
void restore_##name() { name##_ =
settings()->value(
EXPAND_STRINGIZE(name), name##_default).value<type>(); } \
Q_SIGNAL void name##Changed(); \
Q_PROPERTY(type name READ name WRITE set_##name RESET reset_##name NOTIFY name##Changed USER true) \
private: type name##_{defaultValue}; \
public: type name() const { return name##_; } \
public: void set_##name(type val) { if (val != name()){ name##_=val; store_##name(); emit name##Changed(); } } \
ALBERT_EXPORT std::unique_ptr< QSettings > settings()
Persistent app settings. @reentrant.
#define EXPAND_STRINGIZE(s)
Definition: plugin.h:10
Convenience macro for trivial user property definition.
Writes the boilerplate code for user properties of extensions.
- Parameters
-
type | The type of the property |
name | The name of the property |
defaultValue | The default value of the property |
◆ ALBERT_PLUGIN_PROPERTY_CONNECT
#define ALBERT_PLUGIN_PROPERTY_CONNECT |
( |
|
object, |
|
|
|
name, |
|
|
|
widget, |
|
|
|
widget_setter, |
|
|
|
widget_signal |
|
) |
| |
Value:widget->widget_setter(object->name()); \
connect(widget, &std::remove_pointer<decltype(widget)>::type::widget_signal, \
object, &std::remove_pointer<decltype(object)>::type::set_##name); \
connect(object, &std::remove_pointer<decltype(object)>::type::name##Changed, \
widget, [o=object,w=widget](){ w->widget_setter(o->name()); });
Convenience macro to connect UI elemetens to albert user properties.
- Parameters
-
object | The object containing the property |
name | The property name |
widget | The widget to connect to |
widget_setter | The setter function of the widget |
widget_signal | The changed signal of the widget |
◆ ALBERT_PLUGIN_PROPERTY_NONTRIVIAL
#define ALBERT_PLUGIN_PROPERTY_NONTRIVIAL |
( |
|
type, |
|
|
|
name, |
|
|
|
defaultValue |
|
) |
| |
Value:public: static const type name##_default{defaultValue}; \
protected:
void store_##name() { settings()->setValue(
EXPAND_STRINGIZE(name), name()); } \
protected:
void restore_##name() { set_##name##_(
settings()->value(
EXPAND_STRINGIZE(name), name##_default).value<type>()); } \
Q_SIGNAL void name##Changed(); \
Q_PROPERTY(type name READ name WRITE set_##name RESET reset_##name NOTIFY name##Changed USER true) \
public: void set_##name(type val) { if (val != name()){ set_##name##_(val); store_##name(); emit name##Changed(); } } \
private: void set_##name##_(type); \
public: type name() const; \
Convenience macro for (incomplete) user property definition.
Writes the boilerplate code for user properties of extensions. The property this macro produces is incomplete. It still requires you to define
- the public getter 'type name() const'
- the private setter 'void set_name_(type)'
- Parameters
-
type | The type of the property |
name | The name of the property |
defaultValue | The default value of the property |
◆ EXPAND_STRINGIZE
◆ STRINGIZE
#define STRINGIZE |
( |
|
s | ) |
#s |