From ebc5b7bf33092271df33343ec7ebea172e88efe2 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Fri, 4 Jul 2025 16:28:19 +0200 Subject: [PATCH] Use readme as help menu entry --- src/ImageLoaderPlugin.cpp | 24 ++++++++++++++++++++++++ src/ImageLoaderPlugin.h | 17 ++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/ImageLoaderPlugin.cpp b/src/ImageLoaderPlugin.cpp index 8f222ff..3f0d2ce 100644 --- a/src/ImageLoaderPlugin.cpp +++ b/src/ImageLoaderPlugin.cpp @@ -3,6 +3,8 @@ #include +#include + #include using namespace mv; @@ -56,9 +58,31 @@ QModelIndexList ImageLoaderPlugin::getSelectedRows() const ImageLoaderPluginFactory::ImageLoaderPluginFactory() { setIconByName("images"); + + connect(&getPluginMetadata().getTriggerHelpAction(), &TriggerAction::triggered, this, [this]() -> void { + if (!getReadmeMarkdownUrl().isValid() || _helpMarkdownDialog.get()) + return; + + _helpMarkdownDialog = new util::MarkdownDialog(getReadmeMarkdownUrl()); + + _helpMarkdownDialog->setWindowTitle(QString("%1").arg(getKind())); + _helpMarkdownDialog->setAttribute(Qt::WA_DeleteOnClose); + _helpMarkdownDialog->setWindowModality(Qt::NonModal); + _helpMarkdownDialog->show(); + }); } LoaderPlugin* ImageLoaderPluginFactory::produce() { return new ImageLoaderPlugin(this); } + +QUrl ImageLoaderPluginFactory::getReadmeMarkdownUrl() const +{ + return QUrl("https://raw.githubusercontent.com/ManiVaultStudio/ImageLoaderPlugin/master/README.md"); +} + +QUrl ImageLoaderPluginFactory::getRepositoryUrl() const +{ + return QUrl("https://github.com/ManiVaultStudio/ImageLoaderPlugin"); +} diff --git a/src/ImageLoaderPlugin.h b/src/ImageLoaderPlugin.h index cfba800..9c9ef22 100644 --- a/src/ImageLoaderPlugin.h +++ b/src/ImageLoaderPlugin.h @@ -1,6 +1,5 @@ #pragma once -#include "Common.h" #include "ImageCollectionScanner.h" #include "ImageCollectionsModel.h" #include "ConversionAction.h" @@ -8,9 +7,16 @@ #include #include +#include +#include + using mv::plugin::LoaderPluginFactory; using mv::plugin::LoaderPlugin; +namespace mv::util { + class MarkdownDialog; +} + /** * Image loader plugin class * @@ -65,9 +71,18 @@ class ImageLoaderPluginFactory : public LoaderPluginFactory /** Destructor */ ~ImageLoaderPluginFactory() override {} + QUrl getReadmeMarkdownUrl() const override; + + bool hasHelp() const override { return true; } + + QUrl getRepositoryUrl() const override; + /** * Produces the plugin * @return Pointer to the produced plugin */ LoaderPlugin* produce() override; + +private: + QPointer _helpMarkdownDialog = {}; };