From 96eea43d3be0dac71d2fde6645ddc87143f096cd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 19 Feb 2020 12:30:13 +0100 Subject: [PATCH] Do not trigger actions disabled directly or on group level Only allow actions disabled due not being visible to trigger, when enabled is not true. This matches QQuickAction behavior, and doesn't apppear to affect QtGui or QtWidgets. Change-Id: I1a00b80213598ef1560be4c9ee9e65cd6fa6d760 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qaction.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 171ef0f40d..0da5667c1d 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -1112,9 +1112,12 @@ void QAction::setData(const QVariant &data) void QAction::activate(ActionEvent event) { Q_D(QAction); - if(event == Trigger) { + if (event == Trigger) { + // Ignore even explicit triggers when explicitly disabled + if ((d->explicitEnabled && !d->explicitEnabledValue) || (d->group && !d->group->isEnabled())) + return; QPointer guard = this; - if(d->checkable) { + if (d->checkable) { // the checked action of an exclusive group may not be unchecked if (d->checked && (d->group && d->group->exclusionPolicy() == QActionGroup::ExclusionPolicy::Exclusive