### Configure qmake project file Source: https://photoflare.github.io/photoflare/plugins.html Standard qmake configuration for a Photoflare plugin library, ensuring correct build settings and file inclusion. ```qmake QT += core gui widgets CONFIG += plugin c++17 CONFIG -= app_bundle TEMPLATE = lib TARGET = myplugin INCLUDEPATH += /path/to/photoflare/src/plugins SOURCES += MyPlugin.cpp OTHER_FILES += myplugin.json DESTDIR = $$OUT_PWD/plugins ``` -------------------------------- ### Implement a minimal exporter plugin Source: https://photoflare.github.io/photoflare/plugins.html Defines a class inheriting from QObject and IExporterPlugin, providing metadata and the exportImage logic. ```cpp #include #include #include #include #include "IPhotoflarePlugin.h" #include "AppContext.h" class MyExporterPlugin : public QObject, public IExporterPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.photoflare.ExporterPlugin/1.0" FILE "myexporter.json") Q_INTERFACES(IPhotoflarePlugin IExporterPlugin) public: QString pluginId() const override { return "com.example.myexporter"; } QString displayName() const override { return "My Format Exporter"; } QString version() const override { return "1.0.0"; } QString author() const override { return "Your Name"; } QString formatName() const override { return "My Format"; } QStringList supportedExtensions() const override { return { "myf" }; } void initialise(AppContext* ctx) override { m_ctx = ctx; } bool exportImage(const QImage& image, const QString& filePath, const QVariantMap& settings, QString& errorMessage) const override { // write image to filePath; return false and set errorMessage on failure if (!image.save(filePath)) { errorMessage = "Failed to save image."; return false; } return true; } private: AppContext* m_ctx = nullptr; }; #include "MyExporterPlugin.moc" ``` -------------------------------- ### Implement a Minimal Filter Plugin Source: https://photoflare.github.io/photoflare/plugins.html A basic implementation of a filter plugin using the IFilterPlugin interface, including metadata and parameter definitions. ```cpp #include #include #include #include "IPhotoflarePlugin.h" #include "AppContext.h" class MyFilterPlugin : public QObject, public IFilterPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.photoflare.FilterPlugin/1.0" FILE "myplugin.json") Q_INTERFACES(IPhotoflarePlugin IFilterPlugin) public: QString pluginId() const override { return "com.example.myplugin"; } QString displayName() const override { return "My Filter"; } QString version() const override { return "1.0.0"; } QString author() const override { return "Your Name"; } QString menuPath() const override { return "Filters/My Plugins"; } void initialise(AppContext* ctx) override { m_ctx = ctx; } QList parameters() const override { return { { "strength", "Strength", PluginParam::Float, 0.5, 0.0, 1.0, {} }, }; } QImage apply(const QImage& input, const QVariantMap& params) const override { const float strength = params.value("strength", 0.5f).toFloat(); // ... transform the image ... return input; // replace with your result } private: AppContext* m_ctx = nullptr; }; #include "MyFilterPlugin.moc" ``` -------------------------------- ### AppContext API Methods Source: https://photoflare.github.io/photoflare/plugins.html Methods available on the AppContext object passed to plugins during initialization. ```APIDOC ## AppContext Methods ### currentImage() Returns a pointer to the currently open image, or nullptr if no image is open. ### markCanvasDirty() Commits direct modifications to the current image back to the canvas and triggers a repaint. ### pushUndoState(const QString& label) Snapshots the current image into the undo stack. ### registerMenuAction(const QString& path, QAction* action) Adds an action to the menu bar using a path separator (e.g., "Tools/My Plugin"). ### registerDockPanel(const QString& title, QWidget* panel) Registers a widget as a dockable side panel. ### showStatusMessage(const QString& msg, int ms) Displays a transient message in the status bar for a specified duration. ### pluginSettings(const QString& pluginId) Returns a QSettings instance scoped to the provided plugin ID. ### mainWindow() Returns the main window pointer for parenting dialogs. ### appVersion() Returns the Photoflare version string. ``` -------------------------------- ### Define plugin metadata Source: https://photoflare.github.io/photoflare/plugins.html The JSON metadata file is embedded into the compiled library at build time via Q_PLUGIN_METADATA and does not require distribution. ```json { "id": "com.example.myplugin", "name": "My Plugin", "version": "1.0.0", "description": "A short description." } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.