Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
menutaskmenu.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant reason:default
4
5#include "menutaskmenu.h"
6
7#include <promotiontaskmenu_p.h>
8
9#include <QtGui/qaction.h>
10
11#include <QtCore/qdebug.h>
12
14
15namespace qdesigner_internal {
16 // ------------ MenuTaskMenu
17 MenuTaskMenu::MenuTaskMenu(QDesignerMenu *menu, QObject *parent) :
18 QObject(parent),
19 m_menu(menu),
20 m_removeAction(new QAction(tr("Remove"), this)),
21 m_promotionTaskMenu(new PromotionTaskMenu(menu, PromotionTaskMenu::ModeSingleWidget, this))
22 {
23 connect(m_removeAction, &QAction::triggered, this, &MenuTaskMenu::removeMenu);
24 }
25
27 {
28 return nullptr;
29 }
30
32 {
33 QList<QAction*> rc;
34 rc.push_back(m_removeAction);
35 m_promotionTaskMenu->addActions(PromotionTaskMenu::LeadingSeparator, rc);
36 return rc;
37 }
38
39 void MenuTaskMenu::removeMenu()
40 {
41 // Are we on a menu bar or on a menu?
42 QWidget *pw = m_menu->parentWidget();
43 if (QDesignerMenuBar *mb = qobject_cast<QDesignerMenuBar *>(pw)) {
44 mb->deleteMenuAction(m_menu->menuAction());
45 return;
46 }
47 if (QDesignerMenu *m = qobject_cast<QDesignerMenu *>(pw)) {
48 m->deleteAction(m_menu->menuAction());
49 }
50 }
51
52 // ------------- MenuBarTaskMenu
53 MenuBarTaskMenu::MenuBarTaskMenu(QDesignerMenuBar *bar, QObject *parent) :
54 QObject(parent),
55 m_bar(bar)
56 {
57 }
58
60 {
61 return nullptr;
62 }
63
65 {
66 return m_bar->contextMenuActions();
67 }
68}
69
70QT_END_NAMESPACE
friend class QWidget
Definition qpainter.h:432
QList< QAction * > taskActions() const override
QAction * preferredEditAction() const override
QAction * preferredEditAction() const override
QList< QAction * > taskActions() const override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.