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
qdesigner_propertyeditor.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
6
7#include <QtDesigner/abstractformeditor.h>
8#include <QtDesigner/dynamicpropertysheet.h>
9#include <QtDesigner/propertysheet.h>
10#include <QtDesigner/qextensionmanager.h>
11#include <widgetfactory_p.h>
12
13#include <QtWidgets/qlineedit.h>
14#include <QtWidgets/qabstractbutton.h>
15
16#include <QtGui/qaction.h>
17
19
20using namespace Qt::StringLiterals;
21
22namespace qdesigner_internal {
24// A map of property name to type
26
27// Compile a map of hard-coded string property types
29{
30 static PropertyNameTypeMap propertyNameTypeMap;
31 if (propertyNameTypeMap.isEmpty()) {
32 const StringPropertyParameters richtext(ValidationRichText, true);
33 // Accessibility. Both are texts the narrator reads
34 propertyNameTypeMap.insert(u"accessibleDescription"_s, richtext);
35 propertyNameTypeMap.insert(u"accessibleName"_s, richtext);
36 // object names
37 const StringPropertyParameters objectName(ValidationObjectName, false);
38 propertyNameTypeMap.insert(u"buddy"_s, objectName);
39 propertyNameTypeMap.insert(u"currentItemName"_s, objectName);
40 propertyNameTypeMap.insert(u"currentPageName"_s, objectName);
41 propertyNameTypeMap.insert(u"currentTabName"_s, objectName);
42 propertyNameTypeMap.insert(u"layoutName"_s, objectName);
43 propertyNameTypeMap.insert(u"spacerName"_s, objectName);
44 // Style sheet
45 propertyNameTypeMap.insert(u"styleSheet"_s, StringPropertyParameters(ValidationStyleSheet, false));
46 // Buttons/ QCommandLinkButton
47 const StringPropertyParameters multiline(ValidationMultiLine, true);
48 propertyNameTypeMap.insert(u"description"_s, multiline);
49 propertyNameTypeMap.insert(u"iconText"_s, multiline);
50 // Tooltips, etc.
51 propertyNameTypeMap.insert(u"toolTip"_s, richtext);
52 propertyNameTypeMap.insert(u"whatsThis"_s, richtext);
53 propertyNameTypeMap.insert(u"windowIconText"_s, richtext);
54 propertyNameTypeMap.insert(u"html"_s, richtext);
55 // A QWizard page id
56 propertyNameTypeMap.insert(u"pageId"_s, StringPropertyParameters(ValidationSingleLine, false));
57 // QPlainTextEdit
58 propertyNameTypeMap.insert(u"plainText"_s, StringPropertyParameters(ValidationMultiLine, true));
59 }
60 return propertyNameTypeMap;
61}
62
70
71static inline bool isDynamicProperty(QDesignerFormEditorInterface *core, QObject *object,
72 const QString &propertyName)
73{
74 if (const QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), object)) {
75 if (dynamicSheet->dynamicPropertiesAllowed()) {
76 if (QDesignerPropertySheetExtension *propertySheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), object)) {
77 const int index = propertySheet->indexOf(propertyName);
78 return index >= 0 && dynamicSheet->isDynamicProperty(index);
79 }
80 }
81 }
82 return false;
83}
84
88{
89 // object name - no comment
90 if (propertyName == "objectName"_L1) {
92 return StringPropertyParameters(vm, false);
93 }
94
95 // Check custom widgets by class.
98 if (!customData.isNull()) {
101 return customType;
102 }
103
104 if (isDynamicProperty(core, const_cast<QObject *>(object), propertyName))
106
107 // Check hardcoded property ames
110 return hit.value();
111
112 // text: Check according to widget type.
113 if (propertyName == "text"_L1) {
114 if (qobject_cast<const QAction *>(object) || qobject_cast<const QLineEdit *>(object))
116 if (qobject_cast<const QAbstractButton *>(object))
119 }
120
121 // Fuzzy matching
122 if (propertyName.endsWith("Name"_L1))
124
125 if (propertyName.endsWith("ToolTip"_L1))
127
128#ifdef Q_OS_WIN // No translation for the active X "control" property
129 if (propertyName == "control"_L1 && className == "QAxWidget"_L1)
131#endif
132
133 // default to single
135}
136
145
147{
148 // Forward signal from Integration using the old interfaces.
151}
152
153}
154
155QT_END_NAMESPACE
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static bool isDynamicProperty(QDesignerFormEditorInterface *core, QObject *object, const QString &propertyName)
static const PropertyNameTypeMap & stringPropertyTypes()