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