MLPlugin(3)

MLPlugin(3) Library Functions Manual MLPlugin(3)

NAME

MLPlugin - The MLPlugin class.

SYNOPSIS

#include <MLPlugin.h>

Public Member Functions


MLPlugin (void *bases, void *plugin_path)
MLPlugin constructor. virtual void createWindow (QWidget *parent)
QString getPluginName ()
QString getPluginDescription ()
std::filesystem::path getPluginPath ()
std::shared_ptr< MLBookProc > getMLBookProc ()

Protected Attributes


Bases bases
std::filesystem::path plugin_path
QString plugin_name
QString plugin_description

Detailed Description

The MLPlugin class.

MLPlugin is base class for plugins creation. To create plugin inherit your plugin base class from MLPlugin and override createWindow() method. Also set plugin_name and plugin_description if needed. Your plugin base header file must include C function create (see example).

#ifndef EXAMPLEPLUGIN_H
#define EXAMPLEPLUGIN_H
#include <MLPlugin.h>
#include <QWidget>
class ExamplePlugin : public MLPlugin
{
public:

ExamplePlugin(void *bases, void *plugin_path);
void
createWindow(QWidget *parent) override; }; extern "C" {
#if defined(__linux)
MLPlugin *
create(void *bases, void *plugin_path)
{
return new ExamplePlugin(bases, plugin_path);
}
#elif defined(_WIN32)
__declspec(dllexport) MLPlugin *
create(void *bases, void *plugin_path)
{
return new ExamplePlugin(bases, plugin_path);
}
#endif } #endif // EXAMPLEPLUGIN_H

#include <Examplelugin.h>
#include <QApplication>
#include <QObject>
#include <QTranslator>
#include <QVBoxLayout>
#include <QLabel>
ExamplePlugin::ExamplePlugin(void *bases, void *plugin_path)
: MLPlugin(bases, plugin_path)
{

QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for(const QString &locale : uiLanguages)
{
const QString baseName = "ExamplePlugin_" + QLocale(locale).name();
if(translator.load(":/i18n/" + baseName))
{
qApp->installTranslator(&translator);
break;
}
}
plugin_name = "ExamplePlugin";
plugin_description = QObject::tr("Example plugin"); } void ExamplePlugin::createWindow(QWidget *parent) {
QWidget *window = new QWidget(parent);
window->setWindowFlag(Qt::Window);
window->setAttribute(Qt::WA_DeleteOnClose);
window->setWindowModality(Qt::WindowModal);
window->setWindowTitle(QObject::tr("Example plugin"));
QVBoxLayout *main_box = new QVBoxLayout;
window->setLayout(main_box);
QLabel *lab = new QLabel;
lab->setObjectName("Label");
QFont font = lab->font();
font.setBold(true);
lab->setFont(font);
lab->setText(QObject::tr("Example plugin"));
main_box->addWidget(lab, 0, Qt::AlignCenter);
window->show(); }

Constructor & Destructor Documentation

MLPlugin::MLPlugin (void * bases, void * plugin_path)

MLPlugin constructor.

Parameters

bases pointer to Bases object.
plugin_path Pointer to std::filesystem::path object.

Member Function Documentation

virtual void MLPlugin::createWindow (QWidget * parent) [virtual]

This method will be called when user requests to show plugin window.

Parameters

parent Pointer to parent window widget.

std::shared_ptr< MLBookProc > MLPlugin::getMLBookProc ()

Returns smart pointer to MLBookProc object, set in internal bases object.

Returns

Smart pointer to MLBookProc object.

QString MLPlugin::getPluginDescription ()

Returns plugin description set on plugin_description.

Returns

Value of plugin_description.

QString MLPlugin::getPluginName ()

Returns plugin name set in plugin_name.

Returns

Value of plugin_name.

std::filesystem::path MLPlugin::getPluginPath ()

Returns plugin library file path.

Returns

Absolute path, set in plugin_path.

Member Data Documentation

Bases MLPlugin::bases [protected]

Bases object.

Warning

Do not try to set or modify this object.

QString MLPlugin::plugin_description [protected]

Plugin description. You can set or modify this object on your need.

QString MLPlugin::plugin_name [protected]

Plugin name. You can set or modify this object on your need.

std::filesystem::path MLPlugin::plugin_path [protected]

Path to plugin library.

Warning

Do not try to set or modify this object.

Author

Generated automatically by Doxygen for MLPlugin from the source code.

Version 1.0 MLPlugin