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//
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt API. It exists for the convenience
34// of Qt Designer. This header
35// file may change from version to version without notice, or even be removed.
36//
37// We mean it.
38//
39
40#ifndef QDESIGNER_TOOLBOX_H
41#define QDESIGNER_TOOLBOX_H
42
43#include "shared_global_p.h"
44#include "qdesigner_propertysheet_p.h"
45#include "qdesigner_utils_p.h"
46#include <QtGui/qpalette.h>
47
48QT_BEGIN_NAMESPACE
49
50namespace qdesigner_internal {
51 class PromotionTaskMenu;
52}
53
54class QToolBox;
55
56class QAction;
57class QMenu;
58
59class QDESIGNER_SHARED_EXPORT QToolBoxHelper : public QObject
60{
61 Q_OBJECT
62
63 explicit QToolBoxHelper(QToolBox *toolbox);
64public:
65 // Install helper on QToolBox
66 static void install(QToolBox *toolbox);
67 static QToolBoxHelper *helperOf(const QToolBox *toolbox);
68 // Convenience to add a menu on a toolbox
69 static QMenu *addToolBoxContextMenuActions(const QToolBox *toolbox, QMenu *popup);
70
71 QPalette::ColorRole currentItemBackgroundRole() const;
72 void setCurrentItemBackgroundRole(QPalette::ColorRole role);
73
74 bool eventFilter(QObject *watched, QEvent *event) override;
75 // Add context menu and return page submenu or 0.
76
77 QMenu *addContextMenuActions(QMenu *popup) const;
78
79private slots:
80 void removeCurrentPage();
81 void addPage();
82 void addPageAfter();
83 void changeOrder();
84
85private:
86 QToolBox *m_toolbox;
87 QAction *m_actionDeletePage;
88 QAction *m_actionInsertPage;
89 QAction *m_actionInsertPageAfter;
90 QAction *m_actionChangePageOrder;
91 qdesigner_internal::PromotionTaskMenu* m_pagePromotionTaskMenu;
92};
93
94// PropertySheet to handle the page properties
95class QDESIGNER_SHARED_EXPORT QToolBoxWidgetPropertySheet : public QDesignerPropertySheet {
96public:
97 explicit QToolBoxWidgetPropertySheet(QToolBox *object, QObject *parent = nullptr);
98
99 void setProperty(int index, const QVariant &value) override;
100 QVariant property(int index) const override;
101 bool reset(int index) override;
102 bool isEnabled(int index) const override;
103
104 // Check whether the property is to be saved. Returns false for the page
105 // properties (as the property sheet has no concept of 'stored')
106 static bool checkProperty(const QString &propertyName);
107
108private:
109 enum ToolBoxProperty { PropertyCurrentItemText, PropertyCurrentItemName, PropertyCurrentItemIcon,
110 PropertyCurrentItemToolTip, PropertyTabSpacing, PropertyToolBoxNone };
111
112 static ToolBoxProperty toolBoxPropertyFromName(const QString &name);
113 QToolBox *m_toolBox;
114 struct PageData
115 {
116 qdesigner_internal::PropertySheetStringValue text;
117 qdesigner_internal::PropertySheetStringValue tooltip;
118 qdesigner_internal::PropertySheetIconValue icon;
119 };
120 QMap<QWidget *, PageData> m_pageToData;
121};
122
123using QToolBoxWidgetPropertySheetFactory = QDesignerPropertySheetFactory<QToolBox, QToolBoxWidgetPropertySheet>;
124
125QT_END_NAMESPACE
126
127#endif // QDESIGNER_TOOLBOX_H
128

source code of qttools/src/designer/src/lib/shared/qdesigner_toolbox_p.h