Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Gui: [skip ci] add convenience function updateActions() to Application
Use updateActions() in ViewProvider::onChanged() to also trigger an update on pure view property changes
  • Loading branch information
wwmayer committed Feb 9, 2021
1 parent 53c5852 commit 7c708ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Gui/Application.cpp
Expand Up @@ -709,7 +709,7 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
if (view) {
const char* ret = nullptr;
if (view->onMsg("ViewFit", &ret))
getMainWindow()->updateActions(true);
updateActions(true);
}
}
}
Expand Down Expand Up @@ -927,7 +927,7 @@ void Application::slotActiveDocument(const App::Document& Doc)
}
}
signalActiveDocument(*doc->second);
getMainWindow()->updateActions();
updateActions();
}
}

Expand All @@ -944,7 +944,7 @@ void Application::slotDeletedObject(const ViewProvider& vp)
void Application::slotChangedObject(const ViewProvider& vp, const App::Property& prop)
{
this->signalChangedObject(vp,prop);
getMainWindow()->updateActions(true);
updateActions(true);
}

void Application::slotRelabelObject(const ViewProvider& vp)
Expand All @@ -955,7 +955,7 @@ void Application::slotRelabelObject(const ViewProvider& vp)
void Application::slotActivatedObject(const ViewProvider& vp)
{
this->signalActivatedObject(vp);
getMainWindow()->updateActions();
updateActions();
}

void Application::slotInEdit(const Gui::ViewProviderDocumentObject& vp)
Expand Down Expand Up @@ -1011,7 +1011,7 @@ bool Application::sendMsgToActiveView(const char* pMsg, const char** ppReturn)
{
MDIView* pView = getMainWindow()->activeWindow();
bool res = pView ? pView->onMsg(pMsg,ppReturn) : false;
getMainWindow()->updateActions(true);
updateActions(true);
return res;
}

Expand All @@ -1030,7 +1030,7 @@ bool Application::sendMsgToFocusView(const char* pMsg, const char** ppReturn)
for(auto focus=qApp->focusWidget();focus;focus=focus->parentWidget()) {
if(focus == pView) {
bool res = pView->onMsg(pMsg,ppReturn);
getMainWindow()->updateActions(true);
updateActions(true);
return res;
}
}
Expand Down Expand Up @@ -1104,15 +1104,15 @@ void Application::setEditDocument(Gui::Document *doc) {
for(auto &v : d->documents)
v.second->_resetEdit();
d->editDocument = doc;
getMainWindow()->updateActions();
updateActions();
}

void Application::setActiveDocument(Gui::Document* pcDocument)
{
if (d->activeDocument == pcDocument)
return; // nothing needs to be done

getMainWindow()->updateActions();
updateActions();

if (pcDocument) {
// This happens if a document with more than one view is about being
Expand Down Expand Up @@ -1264,6 +1264,11 @@ void Application::updateActive(void)
activeDocument()->onUpdate();
}

void Application::updateActions(bool delay)
{
getMainWindow()->updateActions(delay);
}

void Application::tryClose(QCloseEvent * e)
{
e->setAccepted(getMainWindow()->closeAllDocuments(false));
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/Application.h
Expand Up @@ -91,6 +91,8 @@ class GuiExport Application
void onUpdate(void);
/// call update to all views of the active document
void updateActive(void);
/// call update to all command actions
void updateActions(bool delay = false);
//@}

/** @name Signals of the Application */
Expand Down
1 change: 1 addition & 0 deletions src/Gui/ViewProvider.cpp
Expand Up @@ -539,6 +539,7 @@ void ViewProvider::onBeforeChange(const App::Property* prop)
void ViewProvider::onChanged(const App::Property* prop)
{
Application::Instance->signalChangedObject(*this, *prop);
Application::Instance->updateActions();

App::TransactionalObject::onChanged(prop);
}
Expand Down

0 comments on commit 7c708ee

Please sign in to comment.