[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-qmljs] navigation: Display the distance property editor for all the anchor margins
From:       Denis Steckelmacher <steckdenis () yahoo ! fr>
Date:       2014-03-09 17:54:44
Message-ID: E1WMhvw-0004aw-NE () scm ! kde ! org
[Download RAW message or body]

Git commit be5575d38e21fea97385ea7a8737ec0e7d760dc0 by Denis Steckelmacher.
Committed on 09/03/2014 at 17:52.
Pushed by dsteckelmacher into branch 'master'.

Display the distance property editor for all the anchor margins

This commit adds two features to the property preview widget :

- If a property "some.long.property" is not found in the dictionary of
  supported properties, then "property" is also tried. This is useful
  because some users may want to type
  "some.long { property: foo, property2: bar}".
- margins, topMargin, bottomMargin, leftMargin and rightMargin are added.
  Due to the first point, they match "anchors.margins" and
  "anchors { topMargin: 2, bottomMargin: 4 }".

REVIEW: 116673

M  +16   -2    navigation/propertypreviewwidget.cpp

http://commits.kde.org/kdev-qmljs/be5575d38e21fea97385ea7a8737ec0e7d760dc0

diff --git a/navigation/propertypreviewwidget.cpp \
b/navigation/propertypreviewwidget.cpp index fdfbb1e..083ab65 100644
--- a/navigation/propertypreviewwidget.cpp
+++ b/navigation/propertypreviewwidget.cpp
@@ -48,15 +48,29 @@ QWidget* \
                PropertyPreviewWidget::constructIfPossible(KTextEditor::Document* \
                doc,
         supportedProperties["spacing"] = SupportedProperty(QUrl(base + \
                "Spacing.qml"));
         supportedProperties["x"] = SupportedProperty(QUrl(base + "Distance.qml"));
         supportedProperties["y"] = SupportedProperty(QUrl(base + "Distance.qml"));
-        // TODO support the other margins
-        supportedProperties["anchors.margins"] = SupportedProperty(QUrl(base + \
"Distance.qml")); +
+        supportedProperties["margins"] = SupportedProperty(QUrl(base + \
"Distance.qml"));    // matches anchors.margins and anchors { margins: } +        \
supportedProperties["leftMargin"] = SupportedProperty(QUrl(base + "Distance.qml")); + \
supportedProperties["rightMargin"] = SupportedProperty(QUrl(base + "Distance.qml")); \
+        supportedProperties["topMargin"] = SupportedProperty(QUrl(base + \
"Distance.qml")); +        supportedProperties["bottomMargin"] = \
SupportedProperty(QUrl(base + "Distance.qml")); +
         supportedProperties["opacity"] = SupportedProperty(QUrl(base + \
                "Opacity.qml"));
         supportedProperties["duration"] = SupportedProperty(QUrl(base + \
                "Duration.qml"));
         supportedProperties["font.family"] = SupportedProperty(QUrl(base + \
                "FontFamily.qml"));
         supportedProperties["font.pointSize"] = SupportedProperty(QUrl(base + \
                "FontSize.qml"));
         supportedProperties["model"] = SupportedProperty(QUrl(base + "Repeat.qml"));
     }
+
     QHash<QString, SupportedProperty>::iterator item = \
supportedProperties.find(key); +
+    if ( item == supportedProperties.end() && key.contains(QLatin1Char('.')) ) {
+        // When a property name is explicit enough (like "margins"), the name itself
+        // is put in supportedProperties, so that the user can enter \
"anchors.margins" +        // or "anchors { margins }". Change "anchors.margins" to \
"margins" +        item = supportedProperties.find(key.section(QLatin1Char('.'), -1, \
-1)); +    }
+
     if ( item != supportedProperties.end() ) {
         return new PropertyPreviewWidget(doc, keyRange, valueRange, *item, value);
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic