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
4#include "menutaskmenu.h"
5
6#include <promotiontaskmenu_p.h>
7
8#include <QtGui/qaction.h>
9
10#include <QtCore/qdebug.h>
11
13
14namespace qdesigner_internal {
15 // ------------ MenuTaskMenu
16 MenuTaskMenu::MenuTaskMenu(QDesignerMenu *menu, QObject *parent) :
17 QObject(parent),
18 m_menu(menu),
19 m_removeAction(new QAction(tr("Remove"), this)),
20 m_promotionTaskMenu(new PromotionTaskMenu(menu, PromotionTaskMenu::ModeSingleWidget, this))
21 {
22 connect(m_removeAction, &QAction::triggered, this, &MenuTaskMenu::removeMenu);
23 }
24
26 {
27 return nullptr;
28 }
29
31 {
32 QList<QAction*> rc;
33 rc.push_back(m_removeAction);
34 m_promotionTaskMenu->addActions(PromotionTaskMenu::LeadingSeparator, rc);
35 return rc;
36 }
37
38 void MenuTaskMenu::removeMenu()
39 {
40 // Are we on a menu bar or on a menu?
41 QWidget *pw = m_menu->parentWidget();
42 if (QDesignerMenuBar *mb = qobject_cast<QDesignerMenuBar *>(pw)) {
43 mb->deleteMenuAction(m_menu->menuAction());
44 return;
45 }
46 if (QDesignerMenu *m = qobject_cast<QDesignerMenu *>(pw)) {
47 m->deleteAction(m_menu->menuAction());
48 }
49 }
50
51 // ------------- MenuBarTaskMenu
52 MenuBarTaskMenu::MenuBarTaskMenu(QDesignerMenuBar *bar, QObject *parent) :
53 QObject(parent),
54 m_bar(bar)
55 {
56 }
57
59 {
60 return nullptr;
61 }
62
64 {
65 return m_bar->contextMenuActions();
66 }
67}
68
69QT_END_NAMESPACE
friend class QWidget
Definition qpainter.h:421
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.