From b9878615361d6e28eb99074368bf0bbbaceb7f97 Mon Sep 17 00:00:00 2001 From: Tristan Youngs Date: Wed, 15 Mar 2017 12:09:21 +0000 Subject: [PATCH] Added ability for tool plugins to update main window after changing models. --- src/gui/mainwindow.h | 2 ++ src/gui/mainwindow_update.cpp | 1 + src/plugins/interfaces/toolplugin.h | 11 +++++++++++ src/plugins/tool_test/testtool.hui | 11 +++++++++++ src/plugins/tool_test/testtool_funcs.cpp | 13 +++++++++++++ 5 files changed, 38 insertions(+) diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 2d17fe8fe..25ad19cd7 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -113,6 +113,8 @@ class AtenWindow : public QMainWindow void initialUpdateAndShow(); // Return whether main window has been shown bool shown(); + + public slots: // Refreshes specified (or all) dock widgets void updateWidgets(int targets = AtenWindow::DefaultTarget); diff --git a/src/gui/mainwindow_update.cpp b/src/gui/mainwindow_update.cpp index e908176a5..51dc4b7c0 100644 --- a/src/gui/mainwindow_update.cpp +++ b/src/gui/mainwindow_update.cpp @@ -161,6 +161,7 @@ void AtenWindow::initialUpdateAndShow() menuButton->setIconSize(QSize(30, 30)); menuButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); menuButton->setToolPluginInterface(toolPlugin); + connect(toolPlugin->object(), SIGNAL(updateWidgets(int)), this, SLOT(updateWidgets(int))); menuButton->setToolTip(toolPlugin->description()); groupLayout->addWidget(menuButton, 0, groupLayout->columnCount()); } diff --git a/src/plugins/interfaces/toolplugin.h b/src/plugins/interfaces/toolplugin.h index e32817635..08cad5fd6 100644 --- a/src/plugins/interfaces/toolplugin.h +++ b/src/plugins/interfaces/toolplugin.h @@ -129,6 +129,17 @@ class ToolPluginInterface : public BasePluginInterface virtual void showDialog() = 0; // Run the tool with the current settings virtual bool runTool() = 0; + + + /* + * QObject / Signals + */ + public: + // Return interface as QObject + virtual QObject* object() = 0; + + // Derived classes must implement the following signals: + // void updateWidgets(int); }; ATEN_END_NAMESPACE diff --git a/src/plugins/tool_test/testtool.hui b/src/plugins/tool_test/testtool.hui index 11b51f674..36fd5f2de 100644 --- a/src/plugins/tool_test/testtool.hui +++ b/src/plugins/tool_test/testtool.hui @@ -86,6 +86,17 @@ class TestToolPlugin : public QObject, public ToolPluginInterface void showDialog(); // Run the tool with the current settings bool runTool(); + + + /* + * QObject / Signals + */ + public: + // Return interface as QObject + QObject* object(); + + signals: + void updateWidgets(int); }; ATEN_END_NAMESPACE diff --git a/src/plugins/tool_test/testtool_funcs.cpp b/src/plugins/tool_test/testtool_funcs.cpp index 7ce308d56..8b71dbedc 100644 --- a/src/plugins/tool_test/testtool_funcs.cpp +++ b/src/plugins/tool_test/testtool_funcs.cpp @@ -178,5 +178,18 @@ bool TestToolPlugin::runTool() model->endUndoState(); } + // Update the display + emit(updateWidgets(0)); + return true; } + +/* + * QObject / Signals + */ + +// Return interface as QObject +QObject* TestToolPlugin::object() +{ + return this; +} \ No newline at end of file