Review Request 119407: Use the DUChain to offer better navigation widgets
Denis Steckelmacher
steckdenis at yahoo.fr
Wed Jul 23 15:46:49 UTC 2014
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/119407/
-----------------------------------------------------------
(Updated July 23, 2014, 3:46 p.m.)
Status
------
This change has been marked as submitted.
Review request for KDevelop.
Repository: kdev-qmljs
Description
-------
The QML/JS plugin can show navigation widgets that can be used to edit specific QML properties like width/height, spacing, color, etc. This patch extends these widgets so that they know the declaration (and hence the type) of the property being modified.
This allows two things: filters can be more specific (for instance, the font-family helper widget is displayed for the "family" property of "font", and not for anything else), and filters can be created for certain property types, independently of the property names (for instance, the color picker is now shown for any property that has the type color).
This patch uses DUChainUtils::itemUnderCursor to get the declaration used at a given position in a source file. The documentation of this function says that the function can only be called from the foreground thread, or with the foreground lock held. How can I lock the foreground lock? Is KDevQmlJSPlugin::specialLanguageObjectNavigationWidget called in the foreground thread?
Diffs
-----
kdevqmljsplugin.cpp a917bf2
navigation/propertypreviewwidget.h ca416a9
navigation/propertypreviewwidget.cpp 6d39e7b
Diff: https://git.reviewboard.kde.org/r/119407/diff/
Testing
-------
Manual testing has shown that everything works as expected. Here is my test file, with the results in comments:
Item {
id: root
width: 3 // Shows the "Width" widget
property color clr // This line and the following ones don't show anything (this patch fixes a small bug: SimpleRange() does not create an invalid range, but a range from (0, 0) to (0, 0)
property float margins
property font font
property string family
clr: "#78d0aa" // Shows the color picker
anchors.margins: 13 // Shows the "Margins" widget
anchors {
margins: 13 // Shows the "Margins" widget
leftMargin: 16 // Shows the "Margins" widget
}
margins: 34 // Shows the standard navigation widget (no property is recognized because there is a filter for QQuickAnchors.margins)
opacity: 0.5 // Shows the "Opacity" widget
font.family: "Arial" // Shows the "FontFamily" widget
family: "Me" // Shows the standard navigation widget
}
This patch is already quite useful, but will be even more when the QML/JS plugin will be based on Qt5 and will be able to use QtQuick.Controls. When this will be the case, more advanced helper widgets will be possible (URL, combo boxes for font families and enumeration values, etc). Having type-dependend widgets will allow some nice things like a widget that allows the user to preview alignments (vertical/horizontal left/right/top/bottom/center) regardless of the name of the property that will contain the alignment.
Thanks,
Denis Steckelmacher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140723/20a7baa2/attachment.html>
More information about the KDevelop-devel
mailing list