269 */ |
269 */ |
270 bool QDesignerPropertySheetPrivate::isReloadableProperty(int index) const |
270 bool QDesignerPropertySheetPrivate::isReloadableProperty(int index) const |
271 { |
271 { |
272 return isResourceProperty(index) |
272 return isResourceProperty(index) |
273 || propertyType(index) == QDesignerPropertySheet::PropertyStyleSheet |
273 || propertyType(index) == QDesignerPropertySheet::PropertyStyleSheet |
|
274 || propertyType(index) == QDesignerPropertySheet::PropertyText |
274 || q->property(index).type() == QVariant::Url; |
275 || q->property(index).type() == QVariant::Url; |
275 } |
276 } |
276 |
277 |
277 /* |
278 /* |
278 Resource properties are those which: |
279 Resource properties are those which: |
547 propertyTypeHash.insert(QLatin1String("windowOpacity"), PropertyWindowOpacity); |
548 propertyTypeHash.insert(QLatin1String("windowOpacity"), PropertyWindowOpacity); |
548 propertyTypeHash.insert(QLatin1String("windowIconText"), PropertyWindowIconText); |
549 propertyTypeHash.insert(QLatin1String("windowIconText"), PropertyWindowIconText); |
549 propertyTypeHash.insert(QLatin1String("windowModality"), PropertyWindowModality); |
550 propertyTypeHash.insert(QLatin1String("windowModality"), PropertyWindowModality); |
550 propertyTypeHash.insert(QLatin1String("windowModified"), PropertyWindowModified); |
551 propertyTypeHash.insert(QLatin1String("windowModified"), PropertyWindowModified); |
551 propertyTypeHash.insert(QLatin1String("styleSheet"), PropertyStyleSheet); |
552 propertyTypeHash.insert(QLatin1String("styleSheet"), PropertyStyleSheet); |
|
553 propertyTypeHash.insert(QLatin1String("text"), PropertyText); |
552 } |
554 } |
553 return propertyTypeHash.value(name, PropertyNone); |
555 return propertyTypeHash.value(name, PropertyNone); |
554 } |
556 } |
555 |
557 |
556 QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) : |
558 QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) : |
608 createFakeProperty(QLatin1String("cursor")); |
610 createFakeProperty(QLatin1String("cursor")); |
609 createFakeProperty(QLatin1String("toolTip")); |
611 createFakeProperty(QLatin1String("toolTip")); |
610 createFakeProperty(QLatin1String("whatsThis")); |
612 createFakeProperty(QLatin1String("whatsThis")); |
611 createFakeProperty(QLatin1String("acceptDrops")); |
613 createFakeProperty(QLatin1String("acceptDrops")); |
612 createFakeProperty(QLatin1String("dragEnabled")); |
614 createFakeProperty(QLatin1String("dragEnabled")); |
613 // windowModality is visible only for the main container, in which case the form windows enables it on loading |
615 // windowModality/Opacity is visible only for the main container, in which case the form windows enables it on loading |
614 setVisible(createFakeProperty(QLatin1String("windowModality")), false); |
616 setVisible(createFakeProperty(QLatin1String("windowModality")), false); |
|
617 setVisible(createFakeProperty(QLatin1String("windowOpacity"), double(1.0)), false); |
615 if (qobject_cast<const QToolBar *>(d->m_object)) { // prevent toolbars from being dragged off |
618 if (qobject_cast<const QToolBar *>(d->m_object)) { // prevent toolbars from being dragged off |
616 createFakeProperty(QLatin1String("floatable"), QVariant(true)); |
619 createFakeProperty(QLatin1String("floatable"), QVariant(true)); |
617 } else { |
620 } else { |
618 if (qobject_cast<const QMenuBar *>(d->m_object)) { |
621 if (qobject_cast<const QMenuBar *>(d->m_object)) { |
619 // Keep the menu bar editable in the form even if a native menu bar is used. |
622 // Keep the menu bar editable in the form even if a native menu bar is used. |
717 if (value.type() == QVariant::Icon) |
720 if (value.type() == QVariant::Icon) |
718 v = qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); |
721 v = qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); |
719 else if (value.type() == QVariant::Pixmap) |
722 else if (value.type() == QVariant::Pixmap) |
720 v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); |
723 v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); |
721 else if (value.type() == QVariant::String) |
724 else if (value.type() == QVariant::String) |
722 v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); |
725 v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString())); |
723 else if (value.type() == QVariant::KeySequence) |
726 else if (value.type() == QVariant::KeySequence) { |
724 v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue()); |
727 const QKeySequence keySequence = qVariantValue<QKeySequence>(value); |
725 |
728 v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); |
|
729 } |
726 |
730 |
727 if (d->m_addIndex.contains(propName)) { |
731 if (d->m_addIndex.contains(propName)) { |
728 const int idx = d->m_addIndex.value(propName); |
732 const int idx = d->m_addIndex.value(propName); |
729 // have to be invisible, this was checked in canAddDynamicProperty() method |
733 // have to be invisible, this was checked in canAddDynamicProperty() method |
730 setVisible(idx, true); |
734 setVisible(idx, true); |
1125 layoutPropertySheet->setProperty(newIndex, value); |
1129 layoutPropertySheet->setProperty(newIndex, value); |
1126 } |
1130 } |
1127 } |
1131 } |
1128 } |
1132 } |
1129 |
1133 |
1130 if (isDynamicProperty(index)) { |
1134 if (isDynamicProperty(index) || isDefaultDynamicProperty(index)) { |
1131 if (d->isResourceProperty(index)) |
1135 if (d->isResourceProperty(index)) |
1132 d->setResourceProperty(index, value); |
1136 d->setResourceProperty(index, value); |
1133 if (d->isStringProperty(index)) |
1137 if (d->isStringProperty(index)) |
1134 d->setStringProperty(index, qVariantValue<qdesigner_internal::PropertySheetStringValue>(value)); |
1138 d->setStringProperty(index, qVariantValue<qdesigner_internal::PropertySheetStringValue>(value)); |
1135 if (d->isKeySequenceProperty(index)) |
1139 if (d->isKeySequenceProperty(index)) |
1195 setProperty(index, d->emptyResourceProperty(index)); |
1199 setProperty(index, d->emptyResourceProperty(index)); |
1196 return true; |
1200 return true; |
1197 } else if (isDynamic(index)) { |
1201 } else if (isDynamic(index)) { |
1198 const QString propName = propertyName(index); |
1202 const QString propName = propertyName(index); |
1199 const QVariant oldValue = d->m_addProperties.value(index); |
1203 const QVariant oldValue = d->m_addProperties.value(index); |
1200 const QVariant newValue = d->m_info.value(index).defaultValue; |
1204 const QVariant defaultValue = d->m_info.value(index).defaultValue; |
|
1205 QVariant newValue = defaultValue; |
|
1206 if (d->isStringProperty(index)) { |
|
1207 newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString())); |
|
1208 } else if (d->isKeySequenceProperty(index)) { |
|
1209 const QKeySequence keySequence = qVariantValue<QKeySequence>(newValue); |
|
1210 newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); |
|
1211 } |
1201 if (oldValue == newValue) |
1212 if (oldValue == newValue) |
1202 return true; |
1213 return true; |
1203 d->m_object->setProperty(propName.toUtf8(), newValue); |
1214 d->m_object->setProperty(propName.toUtf8(), defaultValue); |
1204 d->m_addProperties[index] = newValue; |
1215 d->m_addProperties[index] = newValue; |
1205 return true; |
1216 return true; |
1206 } else if (!d->m_info.value(index).defaultValue.isNull()) { |
1217 } else if (!d->m_info.value(index).defaultValue.isNull()) { |
1207 setProperty(index, d->m_info.value(index).defaultValue); |
1218 setProperty(index, d->m_info.value(index).defaultValue); |
1208 return true; |
1219 return true; |
1449 } |
1460 } |
1450 return d->m_info.value(index).visible; |
1461 return d->m_info.value(index).visible; |
1451 } |
1462 } |
1452 |
1463 |
1453 if (isFakeProperty(index)) { |
1464 if (isFakeProperty(index)) { |
1454 if (type == PropertyWindowModality) // Hidden for child widgets |
1465 switch (type) { |
|
1466 case PropertyWindowModality: // Hidden for child widgets |
|
1467 case PropertyWindowOpacity: |
1455 return d->m_info.value(index).visible; |
1468 return d->m_info.value(index).visible; |
|
1469 default: |
|
1470 break; |
|
1471 } |
1456 return true; |
1472 return true; |
1457 } |
1473 } |
1458 |
1474 |
1459 const bool visible = d->m_info.value(index).visible; |
1475 const bool visible = d->m_info.value(index).visible; |
1460 switch (type) { |
1476 switch (type) { |