tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -271,6 +271,7 @@
 {
     return isResourceProperty(index)
            || propertyType(index) == QDesignerPropertySheet::PropertyStyleSheet
+           || propertyType(index) == QDesignerPropertySheet::PropertyText
            || q->property(index).type() == QVariant::Url;
 }
 
@@ -549,6 +550,7 @@
         propertyTypeHash.insert(QLatin1String("windowModality"),          PropertyWindowModality);
         propertyTypeHash.insert(QLatin1String("windowModified"),          PropertyWindowModified);
         propertyTypeHash.insert(QLatin1String("styleSheet"),              PropertyStyleSheet);
+        propertyTypeHash.insert(QLatin1String("text"),                    PropertyText);
     }
     return propertyTypeHash.value(name, PropertyNone);
 }
@@ -610,8 +612,9 @@
         createFakeProperty(QLatin1String("whatsThis"));
         createFakeProperty(QLatin1String("acceptDrops"));
         createFakeProperty(QLatin1String("dragEnabled"));
-        // windowModality is visible only for the main container, in which case the form windows enables it on loading
+        // windowModality/Opacity is visible only for the main container, in which case the form windows enables it on loading
         setVisible(createFakeProperty(QLatin1String("windowModality")), false);
+        setVisible(createFakeProperty(QLatin1String("windowOpacity"), double(1.0)), false);
         if (qobject_cast<const QToolBar *>(d->m_object)) { // prevent toolbars from being dragged off
             createFakeProperty(QLatin1String("floatable"), QVariant(true));
         } else {
@@ -719,10 +722,11 @@
     else if (value.type() == QVariant::Pixmap)
         v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue());
     else if (value.type() == QVariant::String)
-        v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
-    else if (value.type() == QVariant::KeySequence)
-        v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue());
-
+        v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString()));
+    else if (value.type() == QVariant::KeySequence) {
+        const QKeySequence keySequence = qVariantValue<QKeySequence>(value);
+        v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+    }
 
     if (d->m_addIndex.contains(propName)) {
         const int idx = d->m_addIndex.value(propName);
@@ -1127,7 +1131,7 @@
             }
         }
 
-        if (isDynamicProperty(index)) {
+        if (isDynamicProperty(index) || isDefaultDynamicProperty(index)) {
             if (d->isResourceProperty(index))
                 d->setResourceProperty(index, value);
             if (d->isStringProperty(index))
@@ -1197,10 +1201,17 @@
     } else if (isDynamic(index)) {
         const QString propName = propertyName(index);
         const QVariant oldValue = d->m_addProperties.value(index);
-        const QVariant newValue = d->m_info.value(index).defaultValue;
+        const QVariant defaultValue = d->m_info.value(index).defaultValue;
+        QVariant newValue = defaultValue;
+        if (d->isStringProperty(index)) {
+            newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString()));
+        } else if (d->isKeySequenceProperty(index)) {
+            const QKeySequence keySequence = qVariantValue<QKeySequence>(newValue);
+            newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+        }
         if (oldValue == newValue)
             return true;
-        d->m_object->setProperty(propName.toUtf8(), newValue);
+        d->m_object->setProperty(propName.toUtf8(), defaultValue);
         d->m_addProperties[index] = newValue;
         return true;
     } else if (!d->m_info.value(index).defaultValue.isNull()) {
@@ -1451,8 +1462,13 @@
     }
 
     if (isFakeProperty(index)) {
-        if (type == PropertyWindowModality) // Hidden for child widgets
+        switch (type) {
+        case PropertyWindowModality: // Hidden for child widgets
+        case PropertyWindowOpacity:
             return d->m_info.value(index).visible;
+        default:
+            break;
+        }
         return true;
     }