1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #include "menutaskmenu.h" |
30 | |
31 | #include <promotiontaskmenu_p.h> |
32 | |
33 | #include <QtWidgets/qaction.h> |
34 | #include <QtCore/qdebug.h> |
35 | |
36 | QT_BEGIN_NAMESPACE |
37 | |
38 | namespace qdesigner_internal { |
39 | // ------------ MenuTaskMenu |
40 | MenuTaskMenu::(QDesignerMenu *, QObject *parent) : |
41 | QObject(parent), |
42 | m_menu(menu), |
43 | m_removeAction(new QAction(tr(s: "Remove" ), this)), |
44 | m_promotionTaskMenu(new PromotionTaskMenu(menu, PromotionTaskMenu::ModeSingleWidget, this)) |
45 | { |
46 | connect(sender: m_removeAction, signal: &QAction::triggered, receiver: this, slot: &MenuTaskMenu::removeMenu); |
47 | } |
48 | |
49 | QAction *MenuTaskMenu::() const |
50 | { |
51 | return nullptr; |
52 | } |
53 | |
54 | QList<QAction*> MenuTaskMenu::() const |
55 | { |
56 | QList<QAction*> rc; |
57 | rc.push_back(t: m_removeAction); |
58 | m_promotionTaskMenu->addActions(flags: PromotionTaskMenu::LeadingSeparator, actionList&: rc); |
59 | return rc; |
60 | } |
61 | |
62 | void MenuTaskMenu::() |
63 | { |
64 | // Are we on a menu bar or on a menu? |
65 | QWidget *pw = m_menu->parentWidget(); |
66 | if (QDesignerMenuBar *mb = qobject_cast<QDesignerMenuBar *>(object: pw)) { |
67 | mb->deleteMenuAction(action: m_menu->menuAction()); |
68 | return; |
69 | } |
70 | if (QDesignerMenu *m = qobject_cast<QDesignerMenu *>(object: pw)) { |
71 | m->deleteAction(a: m_menu->menuAction()); |
72 | } |
73 | } |
74 | |
75 | // ------------- MenuBarTaskMenu |
76 | MenuBarTaskMenu::(QDesignerMenuBar *bar, QObject *parent) : |
77 | QObject(parent), |
78 | m_bar(bar) |
79 | { |
80 | } |
81 | |
82 | QAction *MenuBarTaskMenu::() const |
83 | { |
84 | return nullptr; |
85 | } |
86 | |
87 | QList<QAction*> MenuBarTaskMenu::() const |
88 | { |
89 | return m_bar->contextMenuActions(); |
90 | } |
91 | } |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | |