aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/edit3d/edit3dvisibilitytogglesmenu.cpp
blob: 0f3a3c3e634f3f937580e59a894d5ebf02dff73b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "edit3dvisibilitytogglesmenu.h"

namespace QmlDesigner {

Edit3DVisibilityTogglesMenu::Edit3DVisibilityTogglesMenu(QWidget *parent) :
    QMenu(parent)
{
    setToolTipsVisible(true);
}

void Edit3DVisibilityTogglesMenu::mouseReleaseEvent(QMouseEvent *e)
{
    QAction *action = activeAction();
    if (action && action->isEnabled()) {
        // Prevent the menu from closing on click on any item
        action->setEnabled(false);
        QMenu::mouseReleaseEvent(e);
        action->setEnabled(true);
        action->trigger();
    } else {
        QMenu::mouseReleaseEvent(e);
    }
}

} // namespace QmlDesigner