Moved definition of widget instance actions to the module so other parts of the system can no about them.
The plugin system will create the Action objects and bind them to the specified slots of the specific widget instances.
This commit is contained in:
parent
d0c4dabe8b
commit
f4f2474a81
21 changed files with 418 additions and 204 deletions
|
|
@ -32,8 +32,9 @@ namespace LMainWindow_details {
|
|||
m_window->statusBar()->showMessage(msg);
|
||||
}
|
||||
|
||||
void addContentWidget(PluginContentWidget *widget) override
|
||||
void addContentWidget(PluginModule *module, PluginContentWidget *widget) override
|
||||
{
|
||||
PluginContentWidgetContextBase::addContentWidget(module, widget);
|
||||
m_window->addPage(widget, "");
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +127,7 @@ void LMainWindow::addMenuAction(const MenuAction &ma)
|
|||
{
|
||||
ma.perform(m_context);
|
||||
},
|
||||
ma.shortCut());
|
||||
ma.shortcut());
|
||||
|
||||
|
||||
// auto ac = new QAction(this);
|
||||
|
|
@ -171,6 +172,7 @@ void LMainWindow::tabWidget_tabCloseRequested(int index)
|
|||
if (plg_page) {
|
||||
if (plg_page->canClose()) {
|
||||
m_tabWidget->removeTab(index);
|
||||
m_context->removeContentWidget(plg_page);
|
||||
delete plg_page;
|
||||
}
|
||||
}
|
||||
|
|
@ -186,7 +188,7 @@ void LMainWindow::tabWidget_currentChanged(int index)
|
|||
{
|
||||
// remove buttons of old page
|
||||
if (m_previousPage) {
|
||||
removeToolBarButtonsForPage(m_previousPage);
|
||||
removeModuleWidgetActionsForPage(m_previousPage);
|
||||
}
|
||||
|
||||
// add buttons of new page
|
||||
|
|
@ -195,26 +197,18 @@ void LMainWindow::tabWidget_currentChanged(int index)
|
|||
QWidget *widget = m_tabWidget->widget(index);
|
||||
page = dynamic_cast<PluginContentWidget*>(widget);
|
||||
if (page) {
|
||||
addToolBarButtonsForPage(page);
|
||||
addModuleWidgetActionsForPage(page);
|
||||
}
|
||||
}
|
||||
m_previousPage = page;
|
||||
}
|
||||
|
||||
void LMainWindow::addToolBarButtonsForPage(PluginContentWidget *page)
|
||||
void LMainWindow::addModuleWidgetActionsForPage(PluginContentWidget *page)
|
||||
{
|
||||
std::vector<QAction*> actions = page->getToolbarActions();
|
||||
QList<QAction*> list;
|
||||
for (auto act : actions) {
|
||||
list.append(act);
|
||||
}
|
||||
m_mainToolBar->addActions(list);
|
||||
m_context->addWidgetActionsToToolbar(page, m_mainToolBar);
|
||||
}
|
||||
|
||||
void LMainWindow::removeToolBarButtonsForPage(PluginContentWidget *page)
|
||||
void LMainWindow::removeModuleWidgetActionsForPage(PluginContentWidget *page)
|
||||
{
|
||||
std::vector<QAction*> actions = page->getToolbarActions();
|
||||
for (auto act : actions) {
|
||||
m_mainToolBar->removeAction(act);
|
||||
}
|
||||
m_context->removeWidgetActionsFromToolbar(page, m_mainToolBar);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue