Skip to content

Commit

Permalink
Added ability for tool plugins to update main window after changing m…
Browse files Browse the repository at this point in the history
…odels.
  • Loading branch information
trisyoungs committed Mar 15, 2017
1 parent aaacb74 commit b987861
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/gui/mainwindow_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/interfaces/toolplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/tool_test/testtool.hui
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/tool_test/testtool_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit b987861

Please sign in to comment.