Update context menu with a toggle for suppress property with checkmark (checked when suppressed)

This commit is contained in:
Max
2024-04-21 16:29:52 +02:00
committed by Yorik van Havre
parent 30536de9a8
commit fd360e8fe9

View File

@@ -89,15 +89,12 @@ void ViewProviderSuppressibleExtension::extensionSetupContextMenu(QMenu* menu, Q
{
auto vp = getExtendedViewProvider();
auto obj = vp->getObject()->getExtensionByType<App::SuppressibleExtension>();
//show (Un)Suppress action if the Suppressed property is visible
//Show Suppressed toggle action if the Suppressed property is visible
if (obj && ! obj->Suppressed.testStatus(App::Property::Hidden)) {
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
QAction* act;
if (obj->Suppressed.getValue())
act = menu->addAction(QObject::tr("UnSuppress"));
else
act = menu->addAction(QObject::tr("Suppress"));
QAction* act = menu->addAction(QObject::tr("Suppressed"));
act->setCheckable(true);
act->setChecked(obj->Suppressed.getValue());
func->trigger(act, [obj](){
obj->Suppressed.setValue(! obj->Suppressed.getValue());
});