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#ifndef CONTAINERWIDGER_TASKMENU_H
30#define CONTAINERWIDGER_TASKMENU_H
31
32#include <qdesigner_taskmenu_p.h>
33#include <shared_enums_p.h>
34
35#include <extensionfactory_p.h>
36
37#include <QtCore/qpointer.h>
38
39QT_BEGIN_NAMESPACE
40
41class QDesignerFormWindowInterface;
42class QDesignerFormEditorInterface;
43class QDesignerContainerExtension;
44class QAction;
45class QMdiArea;
46class QMenu;
47class QWizard;
48
49namespace qdesigner_internal {
50
51class PromotionTaskMenu;
52
53// ContainerWidgetTaskMenu: Task menu for containers with extension
54
55class ContainerWidgetTaskMenu: public QDesignerTaskMenu
56{
57 Q_OBJECT
58public:
59 explicit ContainerWidgetTaskMenu(QWidget *widget, ContainerType type, QObject *parent = nullptr);
60 ~ContainerWidgetTaskMenu() override;
61
62 QAction *preferredEditAction() const override;
63 QList<QAction*> taskActions() const override;
64
65private slots:
66 void removeCurrentPage();
67 void addPage();
68 void addPageAfter();
69
70protected:
71 QDesignerContainerExtension *containerExtension() const;
72 QList<QAction*> &containerActions() { return m_taskActions; }
73 int pageCount() const;
74
75private:
76 QDesignerFormWindowInterface *formWindow() const;
77
78private:
79 static QString pageMenuText(ContainerType ct, int index, int count);
80 bool canDeletePage() const;
81
82 const ContainerType m_type;
83 QWidget *m_containerWidget;
84 QDesignerFormEditorInterface *m_core;
85 PromotionTaskMenu *m_pagePromotionTaskMenu;
86 QAction *m_pageMenuAction;
87 QMenu *m_pageMenu;
88 QList<QAction*> m_taskActions;
89 QAction *m_actionInsertPageAfter;
90 QAction *m_actionInsertPage;
91 QAction *m_actionDeletePage;
92};
93
94// WizardContainerWidgetTaskMenu: Provide next/back since QWizard
95// has modes in which the "Back" button is not visible.
96
97class WizardContainerWidgetTaskMenu : public ContainerWidgetTaskMenu {
98 Q_OBJECT
99public:
100 explicit WizardContainerWidgetTaskMenu(QWizard *w, QObject *parent = nullptr);
101
102 QList<QAction*> taskActions() const override;
103
104private:
105 QAction *m_nextAction;
106 QAction *m_previousAction;
107};
108
109
110// MdiContainerWidgetTaskMenu: Provide tile/cascade for MDI containers in addition
111
112class MdiContainerWidgetTaskMenu : public ContainerWidgetTaskMenu {
113 Q_OBJECT
114public:
115 explicit MdiContainerWidgetTaskMenu(QMdiArea *m, QObject *parent = nullptr);
116
117 QList<QAction*> taskActions() const override;
118private:
119 void initializeActions();
120
121 QAction *m_nextAction = nullptr;
122 QAction *m_previousAction = nullptr;
123 QAction *m_tileAction = nullptr;
124 QAction *m_cascadeAction = nullptr;
125};
126
127class ContainerWidgetTaskMenuFactory: public QExtensionFactory
128{
129 Q_OBJECT
130public:
131 explicit ContainerWidgetTaskMenuFactory(QDesignerFormEditorInterface *core, QExtensionManager *extensionManager = nullptr);
132
133protected:
134 QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const override;
135
136private:
137 QDesignerFormEditorInterface *m_core;
138};
139
140} // namespace qdesigner_internal
141
142QT_END_NAMESPACE
143
144#endif // CONTAINERWIDGER_TASKMENU_H
145

source code of qttools/src/designer/src/components/taskmenu/containerwidget_taskmenu.h