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 "abstractpropertyeditor.h" |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | /*! |
34 | \class QDesignerPropertyEditorInterface |
35 | |
36 | \brief The QDesignerPropertyEditorInterface class allows you to |
37 | query and manipulate the current state of Qt Designer's property |
38 | editor. |
39 | |
40 | \inmodule QtDesigner |
41 | |
42 | QDesignerPropertyEditorInterface contains a collection of |
43 | functions that is typically used to query the property editor for |
44 | its current state, and several slots manipulating it's state. The |
45 | interface also provide a signal, propertyChanged(), which is |
46 | emitted whenever a property changes in the property editor. The |
47 | signal's arguments are the property that changed and its new |
48 | value. |
49 | |
50 | For example, when implementing a custom widget plugin, you can |
51 | connect the signal to a custom slot: |
52 | |
53 | \snippet lib/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 0 |
54 | |
55 | Then the custom slot can check if the new value is within the |
56 | range we want when a specified property, belonging to a particular |
57 | widget, changes: |
58 | |
59 | \snippet lib/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 1 |
60 | |
61 | The QDesignerPropertyEditorInterface class is not intended to be |
62 | instantiated directly. You can retrieve an interface to \QD's |
63 | property editor using the |
64 | QDesignerFormEditorInterface::propertyEditor() function. A pointer |
65 | to \QD's current QDesignerFormEditorInterface object (\c |
66 | formEditor in the examples above) is provided by the |
67 | QDesignerCustomWidgetInterface::initialize() function's |
68 | parameter. When implementing a custom widget plugin, you must |
69 | subclass the QDesignerCustomWidgetInterface to expose your plugin |
70 | to \QD. |
71 | |
72 | The functions accessing the property editor are the core() |
73 | function that you can use to retrieve an interface to the form |
74 | editor, the currentPropertyName() function that returns the name |
75 | of the currently selected property in the property editor, the |
76 | object() function that returns the currently selected object in |
77 | \QD's workspace, and the isReadOnly() function that returns true |
78 | if the property editor is write proteced (otherwise false). |
79 | |
80 | The slots manipulating the property editor's state are the |
81 | setObject() slot that you can use to change the currently selected |
82 | object in \QD's workspace, the setPropertyValue() slot that |
83 | changes the value of a given property and the setReadOnly() slot |
84 | that control the write protection of the property editor. |
85 | |
86 | \sa QDesignerFormEditorInterface |
87 | */ |
88 | |
89 | /*! |
90 | Constructs a property editor interface with the given \a parent and |
91 | the specified window \a flags. |
92 | */ |
93 | QDesignerPropertyEditorInterface::QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags) |
94 | : QWidget(parent, flags) |
95 | { |
96 | } |
97 | |
98 | /*! |
99 | Destroys the property editor interface. |
100 | */ |
101 | QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface() = default; |
102 | |
103 | /*! |
104 | Returns a pointer to \QD's current QDesignerFormEditorInterface |
105 | object. |
106 | */ |
107 | QDesignerFormEditorInterface *QDesignerPropertyEditorInterface::core() const |
108 | { |
109 | return nullptr; |
110 | } |
111 | |
112 | /*! |
113 | \fn bool QDesignerPropertyEditorInterface::isReadOnly() const |
114 | |
115 | Returns true if the property editor is write protected; otherwise |
116 | false. |
117 | |
118 | \sa setReadOnly() |
119 | */ |
120 | |
121 | /*! |
122 | \fn QObject *QDesignerPropertyEditorInterface::object() const |
123 | |
124 | Returns the currently selected object in \QD's workspace. |
125 | |
126 | \sa setObject() |
127 | */ |
128 | |
129 | /*! |
130 | \fn QString QDesignerPropertyEditorInterface::currentPropertyName() const |
131 | |
132 | Returns the name of the currently selected property in the |
133 | property editor. |
134 | |
135 | \sa setPropertyValue() |
136 | */ |
137 | |
138 | /*! |
139 | \fn void QDesignerPropertyEditorInterface::propertyChanged(const QString &name, const QVariant &value) |
140 | |
141 | This signal is emitted whenever a property changes in the property |
142 | editor. The property that changed and its new value are specified |
143 | by \a name and \a value respectively. |
144 | |
145 | \sa setPropertyValue() |
146 | */ |
147 | |
148 | /*! |
149 | \fn void QDesignerPropertyEditorInterface::setObject(QObject *object) |
150 | |
151 | Changes the currently selected object in \QD's workspace, to \a |
152 | object. |
153 | |
154 | \sa object() |
155 | */ |
156 | |
157 | /*! |
158 | \fn void QDesignerPropertyEditorInterface::setPropertyValue(const QString &name, const QVariant &value, bool changed = true) |
159 | |
160 | Sets the value of the property specified by \a name to \a |
161 | value. |
162 | |
163 | In addition, the property is marked as \a changed in the property |
164 | editor, i.e. its value is different from the default value. |
165 | |
166 | \sa currentPropertyName(), propertyChanged() |
167 | */ |
168 | |
169 | /*! |
170 | \fn void QDesignerPropertyEditorInterface::setReadOnly(bool readOnly) |
171 | |
172 | If \a readOnly is true, the property editor is made write |
173 | protected; otherwise the write protection is removed. |
174 | |
175 | \sa isReadOnly() |
176 | */ |
177 | |
178 | QT_END_NAMESPACE |
179 | |