Skip to content

Commit

Permalink
pluginbase: Added config page.
Browse files Browse the repository at this point in the history
Plugins can now override the loadConfigPage method to create a
custom configuration widget. This widget, containing all necessary
information, is represented by m_configPage from the PluginBase class.
The widget can be accessed form outside the class using the configPage()
getter.

Signed-off-by: andreidanila1 <[email protected]>
  • Loading branch information
andreidanila1 committed Nov 28, 2024
1 parent 4f24239 commit 3177de5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pluginbase/include/pluginbase/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ class SCOPY_PLUGINBASE_EXPORT Plugin
* Default implementation in PluginBase - can be overriden
*/
virtual bool loadPage() = 0;
/**
* @brief loadConfigPage
* is called postcompatible. initialize m_configPage widget. This widget is added to the device configpage
* @return bool if page is loaded
* Default implementation in PluginBase - can be overriden
*/
virtual bool loadConfigPage() = 0;
/**
* @brief loadToolList
* is called postcompatible. initialize m_toolList. m_toolList is used to populate tool menu
Expand Down Expand Up @@ -289,6 +296,13 @@ class SCOPY_PLUGINBASE_EXPORT Plugin
*/
virtual QWidget *page() = 0;

/**
* @brief configPage
* @return plugin m_configPage getter - plugin configpage widget. used to create device configpage
* Default implementation in PluginBase - override not recommended
*/
virtual QWidget *configPage() = 0;

/**
* @brief preferencesPage
* @return plugin m_preferencesPage getter - preferences widget
Expand Down
3 changes: 3 additions & 0 deletions pluginbase/include/pluginbase/pluginbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SCOPY_PLUGINBASE_EXPORT PluginBase : public Plugin

virtual bool loadIcon() override;
virtual bool loadPage() override;
virtual bool loadConfigPage() override;
virtual void loadToolList() override;
virtual bool loadPreferencesPage() override;
virtual bool loadExtraButtons() override;
Expand All @@ -67,6 +68,7 @@ class SCOPY_PLUGINBASE_EXPORT PluginBase : public Plugin
virtual QString displayParam() override;
virtual QWidget *icon() override;
virtual QWidget *page() override;
virtual QWidget *configPage() override;
virtual QWidget *preferencesPage() override;
virtual QList<QAbstractButton *> extraButtons() override;
virtual QList<ToolMenuEntry *> toolList() override;
Expand Down Expand Up @@ -97,6 +99,7 @@ public Q_SLOTS:
QString m_displayName;
QString m_displayParam;
QWidget *m_page;
QWidget *m_configPage;
QWidget *m_preferencesPage;
QWidget *m_icon;
QList<ToolMenuEntry *> m_toolList;
Expand Down
9 changes: 9 additions & 0 deletions pluginbase/src/pluginbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ bool PluginBase::loadPage()
return false;
}

bool PluginBase::loadConfigPage()
{
m_configPage = nullptr;
return false;
}

void PluginBase::loadToolList() {}

bool PluginBase::loadPreferencesPage()
Expand Down Expand Up @@ -94,8 +100,11 @@ QString PluginBase::displayName() { return m_displayName; }
QString PluginBase::displayParam() { return m_displayParam; }

QWidget *PluginBase::icon() { return m_icon; }

QWidget *PluginBase::page() { return m_page; }

QWidget *PluginBase::configPage() { return m_configPage; }

QWidget *PluginBase::preferencesPage() { return m_preferencesPage; }

QList<QAbstractButton *> PluginBase::extraButtons() { return m_extraButtons; }
Expand Down

0 comments on commit 3177de5

Please sign in to comment.