diff options
Diffstat (limited to 'src/plugins/qmldesigner')
-rw-r--r-- | src/plugins/qmldesigner/CMakeLists.txt | 611 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/colortool/colortool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/colortool/colortool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/colortool/colortool.pri (renamed from src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.pri) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp | 10 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/componentcore_constants.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/crumblebar.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/crumblebar.h | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp | 7 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp | 11 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp | 160 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/componentcore/zoomaction.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.ui (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.ui) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/backendmodel.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/backendmodel.cpp) | 45 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/backendmodel.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/backendmodel.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.cpp) | 13 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/bindingmodel.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectioneditor.pri (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectioneditor.pri) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectioneditor.qrc (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectioneditor.qrc) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionmodel.cpp) | 37 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionmodel.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionview.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionview.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionview.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.ui (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.ui) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/delegates.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/delegates.cpp) | 8 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/delegates.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/delegates.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/dynamicpropertiesmodel.cpp) | 39 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/dynamicpropertiesmodel.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/connectioneditor/stylesheet.css (renamed from src/plugins/qmldesigner/qmldesignerextension/connectioneditor/stylesheet.css) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/animationcurve.cpp | 187 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/animationcurve.h | 69 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp | 64 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditor.h | 53 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditor.pri | 46 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp | 70 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h | 72 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h | 125 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.cpp | 101 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.h | 63 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.cpp | 267 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.h | 127 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp | 226 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/curveitem.h | 98 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.cpp | 277 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.h | 65 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp | 225 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h | 89 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp | 523 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.h | 157 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/handleitem.cpp | 104 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/handleitem.h | 56 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp | 251 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.h | 98 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/playhead.cpp | 187 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/playhead.h | 72 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.cpp | 112 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.h | 85 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp | 221 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/selector.h | 86 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/shortcut.cpp | 81 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/shortcut.h | 61 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.cpp | 146 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.h | 63 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/treemodel.cpp | 156 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/treemodel.h | 75 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/treeview.cpp | 127 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/treeview.h | 61 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/utils.cpp | 107 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/detail/utils.h | 52 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/keyframe.cpp | 88 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/keyframe.h | 65 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/treeitem.cpp | 227 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/curveeditor/treeitem.h | 137 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/backgroundaction.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/dragtool.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp | 5 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/numberseriesaction.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/importmanager/importswidget.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/integration/componentaction.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/integration/designdocument.cpp | 52 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/integration/designdocument.h | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp | 59 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/navigator/navigatortreeview.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/navigator/navigatorview.cpp | 16 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/controlpoint.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/controlpoint.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/controlpoint.h (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/controlpoint.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/cubicsegment.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/cubicsegment.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/cubicsegment.h (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/cubicsegment.h) | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathitem.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathitem.cpp) | 79 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathitem.h (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathitem.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathselectionmanipulator.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathselectionmanipulator.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathselectionmanipulator.h (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathselectionmanipulator.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathtool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathtool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathtool.pri (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.pri) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtoolview.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/pathtool/pathtoolview.h (renamed from src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtoolview.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp | 13 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp | 178 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h | 15 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.cpp | 161 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.h | 62 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.cpp | 61 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.h (renamed from src/plugins/qmldesigner/qmldesignerextension/qmldesignerextensionconstants.h) | 25 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.cpp | 206 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.h | 92 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.cpp | 113 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.h | 60 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri | 18 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp | 29 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp | 119 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h | 7 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp | 119 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h | 3 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp | 284 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp | 31 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h | 9 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.cpp | 113 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.h | 75 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp | 146 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h | 77 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.cpp | 185 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.h | 71 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/sourcetool/sourcetool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/sourcetool/sourcetool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/sourcetool/sourcetool.pri (renamed from src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.pri) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/stateseditor/stateseditorview.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/textedititem.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/textedititem.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/textedititem.h (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/textedititem.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/textedititemwidget.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/textedititemwidget.h (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/textedititemwidget.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/texttool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/texttool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/texttool/texttool.pri (renamed from src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.pri) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/canvas.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvas.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/canvas.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvas.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/canvasstyledialog.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp) | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/canvasstyledialog.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/easingcurve.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurve.cpp) | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/easingcurve.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurve.h) | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurvedialog.cpp) | 17 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurvedialog.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/add_timeline.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/add_timeline.png) | bin | 164 -> 164 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/add_timeline@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/add_timeline@2x.png) | bin | 162 -> 162 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/animation.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/animation.png) | bin | 200 -> 200 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/animation@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/animation@2x.png) | bin | 235 -> 235 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/back_one_frame.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/back_one_frame.png) | bin | 153 -> 153 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/back_one_frame@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/back_one_frame@2x.png) | bin | 231 -> 231 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/curve_editor.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_editor.png) | bin | 190 -> 190 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/curve_editor@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_editor@2x.png) | bin | 239 -> 239 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/curve_picker.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_picker.png) | bin | 163 -> 163 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/curve_picker@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_picker@2x.png) | bin | 295 -> 295 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/forward_one_frame.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/forward_one_frame.png) | bin | 147 -> 147 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/forward_one_frame@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/forward_one_frame@2x.png) | bin | 231 -> 231 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/global_record_keyframes.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/global_record_keyframes.png) | bin | 162 -> 162 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/global_record_keyframes@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/global_record_keyframes@2x.png) | bin | 281 -> 281 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/is_keyframe.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/is_keyframe.png) | bin | 237 -> 237 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/is_keyframe@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/is_keyframe@2x.png) | bin | 236 -> 236 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe-16px.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe-16px.png) | bin | 190 -> 190 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe.png) | bin | 185 -> 185 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe@2x.png) | bin | 185 -> 185 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_active.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_active.png) | bin | 268 -> 268 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_active@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_active@2x.png) | bin | 489 -> 489 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_inactive.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_inactive.png) | bin | 241 -> 241 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_inactive@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_inactive@2x.png) | bin | 414 -> 414 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_selected.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_selected.png) | bin | 273 -> 273 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_selected@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_selected@2x.png) | bin | 493 -> 493 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_active.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_active.png) | bin | 327 -> 327 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_active@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_active@2x.png) | bin | 550 -> 550 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_inactive.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_inactive.png) | bin | 371 -> 371 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_inactive@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_inactive@2x.png) | bin | 580 -> 580 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_selected.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_selected.png) | bin | 328 -> 328 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_selected@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_selected@2x.png) | bin | 557 -> 557 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_active.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_active.png) | bin | 204 -> 204 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_active@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_active@2x.png) | bin | 299 -> 299 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_inactive.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_inactive.png) | bin | 201 -> 201 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_inactive@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_inactive@2x.png) | bin | 292 -> 292 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_selected.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_selected.png) | bin | 204 -> 204 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_selected@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_selected@2x.png) | bin | 299 -> 299 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_active.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_active.png) | bin | 336 -> 336 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_active@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_active@2x.png) | bin | 542 -> 542 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_inactive.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_inactive.png) | bin | 286 -> 286 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_inactive@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_inactive@2x.png) | bin | 457 -> 457 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_selected.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_selected.png) | bin | 407 -> 407 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_selected@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_selected@2x.png) | bin | 706 -> 706 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/local_record_keyframes.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/local_record_keyframes.png) | bin | 186 -> 186 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/local_record_keyframes@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/local_record_keyframes@2x.png) | bin | 192 -> 192 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/loop_playback.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/loop_playback.png) | bin | 171 -> 171 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/loop_playback@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/loop_playback@2x.png) | bin | 291 -> 291 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/next_keyframe.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/next_keyframe.png) | bin | 133 -> 133 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/next_keyframe@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/next_keyframe@2x.png) | bin | 150 -> 150 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/pause_playback.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/pause_playback.png) | bin | 150 -> 150 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/pause_playback@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/pause_playback@2x.png) | bin | 152 -> 152 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/playhead.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/playhead.png) | bin | 289 -> 289 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/playhead@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/playhead@2x.png) | bin | 478 -> 478 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/previous_keyframe.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/previous_keyframe.png) | bin | 132 -> 132 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/previous_keyframe@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/previous_keyframe@2x.png) | bin | 152 -> 152 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/remove_timeline.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/remove_timeline.png) | bin | 190 -> 190 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/remove_timeline@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/remove_timeline@2x.png) | bin | 179 -> 179 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/start_playback.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/start_playback.png) | bin | 143 -> 143 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/start_playback@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/start_playback@2x.png) | bin | 169 -> 169 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/timeline-16px.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/timeline-16px.png) | bin | 389 -> 389 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/to_first_frame.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_first_frame.png) | bin | 135 -> 135 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/to_first_frame@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_first_frame@2x.png) | bin | 193 -> 193 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/to_last_frame.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_last_frame.png) | bin | 132 -> 132 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/to_last_frame@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_last_frame@2x.png) | bin | 191 -> 191 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_left.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_left.png) | bin | 186 -> 186 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_left@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_left@2x.png) | bin | 309 -> 309 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_right.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_right.png) | bin | 177 -> 177 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_right@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_right@2x.png) | bin | 282 -> 282 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/zoom_big.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_big.png) | bin | 202 -> 202 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/zoom_big@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_big@2x.png) | bin | 357 -> 357 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/zoom_small.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_small.png) | bin | 191 -> 191 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/images/zoom_small@2x.png (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_small@2x.png) | bin | 370 -> 370 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp) | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/preseteditor.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.ui (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.ui) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/splineeditor.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/splineeditor.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/splineeditor.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/splineeditor.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timeline.metainfo (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timeline.metainfo) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timeline.qrc (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timeline.qrc) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineabstracttool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineabstracttool.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineabstracttool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineabstracttool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineactions.cpp) | 43 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineactions.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineactions.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp) | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.ui (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.ui) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineconstants.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineconstants.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinecontext.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontext.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinecontext.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontext.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinecontrols.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontrols.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinecontrols.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontrols.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineeditor.pri (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineeditor.pri) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineform.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineform.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineform.ui (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.ui) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinegraphicslayout.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp) | 6 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinegraphicslayout.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicsscene.cpp) | 23 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicsscene.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineicons.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineicons.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineitem.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineitem.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinemovableabstractitem.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovableabstractitem.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinemovableabstractitem.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovableabstractitem.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinemovetool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp) | 14 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinemovetool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineplaceholder.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineplaceholder.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineplaceholder.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineplaceholder.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinepropertyitem.cpp) | 10 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinepropertyitem.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesectionitem.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp) | 17 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesectionitem.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineselectiontool.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineselectiontool.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineselectiontool.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineselectiontool.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.ui (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.ui) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesettingsmodel.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp) | 64 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinesettingsmodel.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinetoolbar.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbar.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinetoolbar.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbar.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinetoolbutton.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbutton.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinetoolbutton.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbutton.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinetooldelegate.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetooldelegate.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinetooldelegate.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetooldelegate.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineutils.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineutils.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineutils.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineutils.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineview.cpp) | 33 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelineview.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineview.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinewidget.cpp) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/timelineeditor/timelinewidget.h (renamed from src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinewidget.h) | 0 | ||||
-rw-r--r-- | src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/abstractview.h | 5 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/metainforeader.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/nodehints.h | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/nodemetainfo.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/qmlitemnode.h | 7 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/subcomponentmanager.h | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/include/viewmanager.h | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp | 27 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp | 24 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp | 5 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/abstractview.cpp | 15 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/modelmerger.cpp | 40 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/qmlanchors.cpp | 119 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp | 55 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp | 13 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/viewmanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.h | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designercore/rewritertransaction.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designersettings.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designersettings.h | 1 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designmodewidget.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/designmodewidget.h | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/documentmanager.cpp | 29 | ||||
-rw-r--r-- | src/plugins/qmldesigner/documentmanager.h | 4 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesigner.pro | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension.pri | 12 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension_global.h | 34 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerplugin.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerplugin.pro | 9 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerplugin.qbs | 71 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview.png | bin | 0 -> 198 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview@2x.png | bin | 0 -> 424 bytes | |||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreview.metainfo | 2 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp | 303 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.h | 135 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp | 173 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h | 69 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.json | 6 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pri | 10 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pro | 18 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.qrc | 7 | ||||
-rw-r--r-- | src/plugins/qmldesigner/shortcutmanager.cpp | 2 |
336 files changed, 9495 insertions, 1090 deletions
diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt new file mode 100644 index 0000000000..2a26bb8e7b --- /dev/null +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -0,0 +1,611 @@ +add_qtc_plugin(QmlDesigner + DEPENDS + qmljs LanguageUtils QmlEditorWidgets + Qt5::QuickWidgets Qt5::CorePrivate + DEFINES + DESIGNER_CORE_LIBRARY + IDE_LIBRARY_BASENAME=\"${IDE_LIBRARY_BASE_PATH}\" + INCLUDES + ${CMAKE_CURRENT_LIST_DIR}/designercore/include + PLUGIN_DEPENDS + Core ProjectExplorer QmlJSEditor QmakeProjectManager QmlProjectManager + QtSupport TextEditor + SOURCES + designersettings.cpp designersettings.h + designmodecontext.cpp designmodecontext.h + designmodewidget.cpp designmodewidget.h + documentmanager.cpp documentmanager.h + documentwarningwidget.cpp documentwarningwidget.h + openuiqmlfiledialog.cpp openuiqmlfiledialog.h openuiqmlfiledialog.ui + qmldesignerconstants.h + qmldesignericons.h + qmldesignerplugin.cpp qmldesignerplugin.h + settingspage.cpp settingspage.h settingspage.ui + shortcutmanager.cpp shortcutmanager.h + switchsplittabwidget.cpp switchsplittabwidget.h + EXPLICIT_MOC + components/propertyeditor/propertyeditorvalue.h + components/connectioneditor/connectionviewwidget.h + SKIP_DEBUG_CMAKE_FILE_CHECK +) + +set(QmlDesignerPluginInstallPrefix "${IDE_PLUGIN_PATH}/qmldesigner") +if (APPLE) + set(QmlDesignerPluginInstallPrefix "${IDE_PLUGIN_PATH}/QmlDesigner") +endif() + +add_qtc_plugin(componentsplugin + CONDITION TARGET QmlDesigner + DEPENDS Core QmlDesigner Utils Qt5::Qml + DEFINES COMPONENTS_LIBRARY + INCLUDES ${CMAKE_CURRENT_LIST_DIR}/designercore/include + SOURCES + componentsplugin/addtabdesigneraction.cpp componentsplugin/addtabdesigneraction.h + componentsplugin/addtabtotabviewdialog.cpp componentsplugin/addtabtotabviewdialog.h + componentsplugin/addtabtotabviewdialog.ui + componentsplugin/componentsplugin.cpp componentsplugin/componentsplugin.h + componentsplugin/componentsplugin.qrc + componentsplugin/entertabdesigneraction.cpp componentsplugin/entertabdesigneraction.h + componentsplugin/tabviewindexmodel.cpp componentsplugin/tabviewindexmodel.h + PLUGIN_PATH ${QmlDesignerPluginInstallPrefix} + SKIP_DEBUG_CMAKE_FILE_CHECK +) + +add_qtc_plugin(qmlpreviewplugin + CONDITION TARGET QmlDesigner + DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml + INCLUDES ${CMAKE_CURRENT_LIST_DIR}/designercore/include + SOURCES + qmlpreviewplugin/qmlpreviewactions.cpp qmlpreviewplugin/qmlpreviewactions.h + qmlpreviewplugin/qmlpreviewplugin.cpp qmlpreviewplugin/qmlpreviewplugin.h + qmlpreviewplugin/qmlpreviewplugin.qrc + PLUGIN_PATH ${QmlDesignerPluginInstallPrefix} + SKIP_DEBUG_CMAKE_FILE_CHECK +) + +add_qtc_plugin(qtquickplugin + CONDITION TARGET QmlDesigner + DEPENDS Core QmlDesigner Utils Qt5::Qml + DEFINES QTQUICK_LIBRARY + INCLUDES ${CMAKE_CURRENT_LIST_DIR}/designercore/include + SOURCES + qtquickplugin/qtquickplugin.cpp qtquickplugin/qtquickplugin.h + qtquickplugin/qtquickplugin.qrc + PLUGIN_PATH ${QmlDesignerPluginInstallPrefix} + SKIP_DEBUG_CMAKE_FILE_CHECK +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX ../../../share/qtcreator/qml/qmlpuppet/container + SOURCES + addimportcontainer.cpp addimportcontainer.h + idcontainer.cpp idcontainer.h + imagecontainer.cpp imagecontainer.h + informationcontainer.cpp informationcontainer.h + instancecontainer.cpp instancecontainer.h + mockuptypecontainer.cpp mockuptypecontainer.h + propertyabstractcontainer.cpp propertyabstractcontainer.h + propertybindingcontainer.cpp propertybindingcontainer.h + propertyvaluecontainer.cpp propertyvaluecontainer.h + reparentcontainer.cpp reparentcontainer.h + sharedmemory.h +) + +if (UNIX) + extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX ../../../share/qtcreator/qml/qmlpuppet/container + SOURCES sharedmemory_unix.cpp + ) + if (NOT APPLE) + extend_qtc_plugin(QmlDesigner DEPENDS rt) + endif() +else() + extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX ../../../share/qtcreator/qml/qmlpuppet/container + SOURCES sharedmemory_qt.cpp + ) +endif() + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX ../../../share/qtcreator/qml/qmlpuppet/commands + SOURCES + changeauxiliarycommand.cpp changeauxiliarycommand.h + changebindingscommand.cpp changebindingscommand.h + changefileurlcommand.cpp changefileurlcommand.h + changeidscommand.cpp changeidscommand.h + changenodesourcecommand.cpp changenodesourcecommand.h + changestatecommand.cpp changestatecommand.h + changevaluescommand.cpp changevaluescommand.h + childrenchangedcommand.cpp childrenchangedcommand.h + clearscenecommand.cpp clearscenecommand.h + completecomponentcommand.cpp completecomponentcommand.h + componentcompletedcommand.cpp componentcompletedcommand.h + createinstancescommand.cpp createinstancescommand.h + createscenecommand.cpp createscenecommand.h + debugoutputcommand.cpp debugoutputcommand.h + endpuppetcommand.cpp endpuppetcommand.h + informationchangedcommand.cpp informationchangedcommand.h + pixmapchangedcommand.cpp pixmapchangedcommand.h + puppetalivecommand.cpp puppetalivecommand.h + removeinstancescommand.cpp removeinstancescommand.h + removepropertiescommand.cpp removepropertiescommand.h + removesharedmemorycommand.cpp removesharedmemorycommand.h + reparentinstancescommand.cpp reparentinstancescommand.h + statepreviewimagechangedcommand.cpp statepreviewimagechangedcommand.h + synchronizecommand.cpp synchronizecommand.h + tokencommand.cpp tokencommand.h + valueschangedcommand.cpp valueschangedcommand.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX ../../../share/qtcreator/qml/qmlpuppet/interfaces + SOURCES + nodeinstanceserverinterface.cpp + commondefines.h + nodeinstanceclientinterface.h + nodeinstanceglobal.h + nodeinstanceserverinterface.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX ../../../share/qtcreator/qml/qmlpuppet/types + SOURCES enumeration.cpp enumeration.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/componentcore + PUBLIC_INCLUDES components/componentcore + SOURCES + abstractaction.cpp abstractaction.h + abstractactiongroup.cpp abstractactiongroup.h + actioninterface.h + addimagesdialog.cpp addimagesdialog.h + addsignalhandlerdialog.cpp addsignalhandlerdialog.h addsignalhandlerdialog.ui + changestyleaction.cpp changestyleaction.h + componentcore.qrc + componentcore_constants.h + crumblebar.cpp crumblebar.h + designeractionmanager.cpp designeractionmanager.h + designeractionmanagerview.cpp designeractionmanagerview.h + findimplementation.cpp findimplementation.h + layoutingridlayout.cpp layoutingridlayout.h + modelnodecontextmenu.cpp modelnodecontextmenu.h + modelnodecontextmenu_helper.cpp modelnodecontextmenu_helper.h + modelnodeoperations.cpp modelnodeoperations.h + qmldesignericonprovider.cpp qmldesignericonprovider.h + selectioncontext.cpp selectioncontext.h + theme.cpp theme.h + zoomaction.cpp zoomaction.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/debugview + SOURCES + debugview.cpp debugview.h + debugviewwidget.cpp debugviewwidget.h debugviewwidget.ui +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/formeditor + SOURCES + abstractcustomtool.cpp abstractcustomtool.h + abstractformeditortool.cpp abstractformeditortool.h + anchorindicator.cpp anchorindicator.h + anchorindicatorgraphicsitem.cpp anchorindicatorgraphicsitem.h + backgroundaction.cpp backgroundaction.h + bindingindicator.cpp bindingindicator.h + bindingindicatorgraphicsitem.cpp bindingindicatorgraphicsitem.h + contentnoteditableindicator.cpp contentnoteditableindicator.h + controlelement.cpp controlelement.h + dragtool.cpp dragtool.h + formeditor.qrc + formeditorgraphicsview.cpp formeditorgraphicsview.h + formeditoritem.cpp formeditoritem.h + formeditorscene.cpp formeditorscene.h + formeditorsubwindow.h + formeditortoolbutton.cpp formeditortoolbutton.h + formeditorview.cpp formeditorview.h + formeditorwidget.cpp formeditorwidget.h + itemutilfunctions.cpp itemutilfunctions.h + layeritem.cpp layeritem.h + lineeditaction.cpp lineeditaction.h + movemanipulator.cpp movemanipulator.h + movetool.cpp movetool.h + numberseriesaction.cpp numberseriesaction.h + onedimensionalcluster.cpp onedimensionalcluster.h + resizecontroller.cpp resizecontroller.h + resizehandleitem.cpp resizehandleitem.h + resizeindicator.cpp resizeindicator.h + resizemanipulator.cpp resizemanipulator.h + resizetool.cpp resizetool.h + rubberbandselectionmanipulator.cpp rubberbandselectionmanipulator.h + scaleitem.cpp scaleitem.h + scalemanipulator.cpp scalemanipulator.h + selectionindicator.cpp selectionindicator.h + selectionrectangle.cpp selectionrectangle.h + selectiontool.cpp selectiontool.h + singleselectionmanipulator.cpp singleselectionmanipulator.h + snapper.cpp snapper.h + snappinglinecreator.cpp snappinglinecreator.h + toolbox.cpp toolbox.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/importmanager + SOURCES + importlabel.cpp importlabel.h + importmanager.qrc + importmanagercombobox.cpp importmanagercombobox.h + importmanagerview.cpp importmanagerview.h + importswidget.cpp importswidget.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/integration + SOURCES + componentaction.cpp componentaction.h + componentview.cpp componentview.h + designdocument.cpp designdocument.h + designdocumentview.cpp designdocumentview.h + stackedutilitypanelcontroller.cpp stackedutilitypanelcontroller.h + utilitypanelcontroller.cpp utilitypanelcontroller.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/itemlibrary + SOURCES + customfilesystemmodel.cpp customfilesystemmodel.h + itemlibrary.qrc + itemlibraryimageprovider.cpp itemlibraryimageprovider.h + itemlibraryitem.cpp itemlibraryitem.h + itemlibrarymodel.cpp itemlibrarymodel.h + itemlibraryresourceview.cpp itemlibraryresourceview.h + itemlibrarysection.cpp itemlibrarysection.h + itemlibrarysectionmodel.cpp itemlibrarysectionmodel.h + itemlibraryview.cpp itemlibraryview.h + itemlibrarywidget.cpp itemlibrarywidget.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/navigator + SOURCES + iconcheckboxitemdelegate.cpp iconcheckboxitemdelegate.h + nameitemdelegate.cpp nameitemdelegate.h + navigator.qrc + navigatormodelinterface.h + navigatortreemodel.cpp navigatortreemodel.h + navigatortreeview.cpp navigatortreeview.h + navigatorview.cpp navigatorview.h + navigatorwidget.cpp navigatorwidget.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/propertyeditor + SOURCES + designerpropertymap.cpp designerpropertymap.h + fileresourcesmodel.cpp fileresourcesmodel.h + gradientmodel.cpp gradientmodel.h + gradientpresetcustomlistmodel.cpp gradientpresetcustomlistmodel.h + gradientpresetdefaultlistmodel.cpp gradientpresetdefaultlistmodel.h + gradientpresetitem.cpp gradientpresetitem.h + gradientpresetlistmodel.cpp gradientpresetlistmodel.h + propertyeditorcontextobject.cpp propertyeditorcontextobject.h + propertyeditorqmlbackend.cpp propertyeditorqmlbackend.h + propertyeditortransaction.cpp propertyeditortransaction.h + propertyeditorvalue.cpp propertyeditorvalue.h + propertyeditorview.cpp propertyeditorview.h + propertyeditorwidget.cpp propertyeditorwidget.h + simplecolorpalette.cpp simplecolorpalette.h + simplecolorpalettemodel.cpp simplecolorpalettemodel.h + simplecolorpalettesingleton.cpp simplecolorpalettesingleton.h + qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h + qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h + quick2propertyeditorview.cpp quick2propertyeditorview.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components + SOURCES resources/resources.qrc +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/stateseditor + SOURCES + stateseditorimageprovider.cpp stateseditorimageprovider.h + stateseditormodel.cpp stateseditormodel.h + stateseditorview.cpp stateseditorview.h + stateseditorwidget.cpp stateseditorwidget.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/texteditor + SOURCES + texteditor.qrc + texteditorstatusbar.cpp texteditorstatusbar.h + texteditorview.cpp texteditorview.h + texteditorwidget.cpp texteditorwidget.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX designercore + SOURCES + exceptions/exception.cpp + exceptions/invalidargumentexception.cpp + exceptions/invalididexception.cpp + exceptions/invalidmetainfoexception.cpp + exceptions/invalidmodelnodeexception.cpp + exceptions/invalidmodelstateexception.cpp + exceptions/invalidpropertyexception.cpp + exceptions/invalidqmlsourceexception.cpp + exceptions/invalidreparentingexception.cpp + exceptions/invalidslideindexexception.cpp + exceptions/notimplementedexception.cpp + exceptions/removebasestateexception.cpp + exceptions/rewritingexception.cpp + + filemanager/addarraymembervisitor.cpp filemanager/addarraymembervisitor.h + filemanager/addobjectvisitor.cpp filemanager/addobjectvisitor.h + filemanager/addpropertyvisitor.cpp filemanager/addpropertyvisitor.h + filemanager/astobjecttextextractor.cpp filemanager/astobjecttextextractor.h + filemanager/changeimportsvisitor.cpp filemanager/changeimportsvisitor.h + filemanager/changeobjecttypevisitor.cpp filemanager/changeobjecttypevisitor.h + filemanager/changepropertyvisitor.cpp filemanager/changepropertyvisitor.h + filemanager/firstdefinitionfinder.cpp filemanager/firstdefinitionfinder.h + filemanager/moveobjectbeforeobjectvisitor.cpp filemanager/moveobjectbeforeobjectvisitor.h + filemanager/moveobjectvisitor.cpp filemanager/moveobjectvisitor.h + filemanager/objectlengthcalculator.cpp filemanager/objectlengthcalculator.h + filemanager/qmlrefactoring.cpp filemanager/qmlrefactoring.h + filemanager/qmlrewriter.cpp filemanager/qmlrewriter.h + filemanager/removepropertyvisitor.cpp filemanager/removepropertyvisitor.h + filemanager/removeuiobjectmembervisitor.cpp filemanager/removeuiobjectmembervisitor.h + + include/abstractproperty.h + include/abstractview.h + include/anchorline.h + include/basetexteditmodifier.h + include/bindingproperty.h + include/bytearraymodifier.h + include/componenttextmodifier.h + include/customnotifications.h + include/documentmessage.h + include/exception.h + include/forwardview.h + include/import.h + include/invalidargumentexception.h + include/invalididexception.h + include/invalidmetainfoexception.h + include/invalidmodelnodeexception.h + include/invalidmodelstateexception.h + include/invalidpropertyexception.h + include/invalidqmlsourceexception.h + include/invalidreparentingexception.h + include/invalidslideindexexception.h + include/itemlibraryinfo.h + include/iwidgetplugin.h + include/mathutils.h + include/metainfo.h + include/metainforeader.h + include/model.h + include/modelmerger.h + include/modelnode.h + include/modelnodepositionstorage.h + include/modificationgroupexception.h + include/modificationgrouptoken.h + include/nodeabstractproperty.h + include/nodeanchors.h + include/nodehints.h + include/nodeinstance.h + include/nodeinstanceview.h + include/nodelistproperty.h + include/nodemetainfo.h + include/nodeproperty.h + include/notimplementedexception.h + include/objectpropertybinding.h + include/plaintexteditmodifier.h + include/propertybinding.h + include/propertycontainer.h + include/propertynode.h + include/propertyparser.h + include/qmlanchors.h + include/qmlchangeset.h + include/qmldesignercorelib_global.h + include/qmlitemnode.h + include/qmlmodelnodefacade.h + include/qmlobjectnode.h + include/qmlstate.h + include/qmltimeline.h + include/qmltimelinekeyframegroup.h + include/removebasestateexception.h + include/rewriterview.h + include/rewritingexception.h + include/signalhandlerproperty.h + include/subcomponentmanager.h + include/textmodifier.h + include/variantproperty.h + include/viewmanager.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX designercore/instances + SOURCES + nodeinstance.cpp + nodeinstanceserverproxy.cpp nodeinstanceserverproxy.h + nodeinstanceview.cpp + puppetbuildprogressdialog.cpp puppetbuildprogressdialog.h puppetbuildprogressdialog.ui + puppetcreator.cpp puppetcreator.h + puppetdialog.cpp puppetdialog.h puppetdialog.ui +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX designercore + SOURCES + metainfo/itemlibraryinfo.cpp + metainfo/metainfo.cpp + metainfo/metainforeader.cpp + metainfo/nodehints.cpp + metainfo/nodemetainfo.cpp + metainfo/subcomponentmanager.cpp + + model/abstractproperty.cpp + model/abstractview.cpp + model/anchorline.cpp + model/basetexteditmodifier.cpp + model/bindingproperty.cpp + model/componenttextmodifier.cpp + model/documentmessage.cpp + model/import.cpp + model/internalbindingproperty.cpp model/internalbindingproperty.h + model/internalnode.cpp model/internalnode_p.h + model/internalnodeabstractproperty.cpp model/internalnodeabstractproperty.h + model/internalnodelistproperty.cpp model/internalnodelistproperty.h + model/internalnodeproperty.cpp model/internalnodeproperty.h + model/internalproperty.cpp model/internalproperty.h + model/internalsignalhandlerproperty.cpp model/internalsignalhandlerproperty.h + model/internalvariantproperty.cpp model/internalvariantproperty.h + model/model.cpp model/model_p.h + model/modelmerger.cpp + model/modelnode.cpp + model/modelnodepositionrecalculator.cpp model/modelnodepositionrecalculator.h + model/modelnodepositionstorage.cpp + model/modeltotextmerger.cpp model/modeltotextmerger.h + model/nodeabstractproperty.cpp + model/nodelistproperty.cpp + model/nodeproperty.cpp + model/plaintexteditmodifier.cpp + model/propertycontainer.cpp + model/propertynode.cpp + model/propertyparser.cpp + model/qmlanchors.cpp + model/qmlchangeset.cpp + model/qmlitemnode.cpp + model/qmlmodelnodefacade.cpp + model/qmlobjectnode.cpp + model/qmlstate.cpp + model/qmltextgenerator.cpp model/qmltextgenerator.h + model/qmltimeline.cpp + model/qmltimelinekeyframegroup.cpp + model/rewriteaction.cpp model/rewriteaction.h + model/rewriteactioncompressor.cpp model/rewriteactioncompressor.h + model/rewriterview.cpp + model/signalhandlerproperty.cpp + model/textmodifier.cpp + model/texttomodelmerger.cpp model/texttomodelmerger.h + model/variantproperty.cpp + model/viewmanager.cpp + + pluginmanager/widgetpluginmanager.cpp pluginmanager/widgetpluginmanager.h + pluginmanager/widgetpluginpath.cpp pluginmanager/widgetpluginpath.h + rewritertransaction.cpp rewritertransaction.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/colortool + SOURCES colortool.cpp colortool.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/connectioneditor + SOURCES + addnewbackenddialog.cpp addnewbackenddialog.h addnewbackenddialog.ui + backendmodel.cpp backendmodel.h + bindingmodel.cpp bindingmodel.h + connectioneditor.qrc + connectionmodel.cpp connectionmodel.h + connectionview.cpp connectionview.h + connectionviewwidget.cpp connectionviewwidget.h connectionviewwidget.ui + delegates.cpp delegates.h + dynamicpropertiesmodel.cpp dynamicpropertiesmodel.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components + SOURCES + pathtool/controlpoint.cpp pathtool/controlpoint.h + pathtool/cubicsegment.cpp pathtool/cubicsegment.h + pathtool/pathitem.cpp pathtool/pathitem.h + pathtool/pathselectionmanipulator.cpp pathtool/pathselectionmanipulator.h + pathtool/pathtool.cpp pathtool/pathtool.h + pathtool/pathtoolview.cpp pathtool/pathtoolview.h + + sourcetool/sourcetool.cpp sourcetool/sourcetool.h + + texttool/textedititem.cpp texttool/textedititem.h + texttool/textedititemwidget.cpp texttool/textedititemwidget.h + texttool/texttool.cpp texttool/texttool.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/timelineeditor + SOURCES + canvas.cpp canvas.h + canvasstyledialog.cpp canvasstyledialog.h + easingcurve.cpp easingcurve.h + easingcurvedialog.cpp easingcurvedialog.h + preseteditor.cpp preseteditor.h + setframevaluedialog.cpp setframevaluedialog.h setframevaluedialog.ui + splineeditor.cpp splineeditor.h + timeline.qrc + timelineabstracttool.cpp timelineabstracttool.h + timelineactions.cpp timelineactions.h + timelineanimationform.cpp timelineanimationform.h timelineanimationform.ui + timelineconstants.h + timelinecontext.cpp timelinecontext.h + timelinecontrols.cpp timelinecontrols.h + timelineform.cpp timelineform.h timelineform.ui + timelinegraphicslayout.cpp timelinegraphicslayout.h + timelinegraphicsscene.cpp timelinegraphicsscene.h + timelineicons.h + timelineitem.cpp timelineitem.h + timelinemovableabstractitem.cpp timelinemovableabstractitem.h + timelinemovetool.cpp timelinemovetool.h + timelineplaceholder.cpp timelineplaceholder.h + timelinepropertyitem.cpp timelinepropertyitem.h + timelinesectionitem.cpp timelinesectionitem.h + timelineselectiontool.cpp timelineselectiontool.h + timelinesettingsdialog.cpp + timelinesettingsdialog.h timelinesettingsdialog.ui + timelinesettingsmodel.cpp timelinesettingsmodel.h + timelinetoolbar.cpp timelinetoolbar.h + timelinetoolbutton.cpp timelinetoolbutton.h + timelinetooldelegate.cpp timelinetooldelegate.h + timelineutils.cpp timelineutils.h + timelineview.cpp timelineview.h + timelinewidget.cpp timelinewidget.h +) + +extend_qtc_plugin(QmlDesigner + SOURCES_PREFIX components/curveeditor + SOURCES + animationcurve.cpp animationcurve.h + curveeditor.cpp curveeditor.h + curveeditormodel.cpp curveeditormodel.h + curveeditorstyle.h + keyframe.cpp keyframe.h + treeitem.cpp treeitem.h + detail/colorcontrol.cpp detail/colorcontrol.h + detail/curveeditorstyledialog.cpp detail/curveeditorstyledialog.h + detail/curveitem.cpp detail/curveitem.h + detail/curvesegment.cpp detail/curvesegment.h + detail/graphicsscene.cpp detail/graphicsscene.h + detail/graphicsview.cpp detail/graphicsview.h + detail/handleitem.cpp detail/handleitem.h + detail/keyframeitem.cpp detail/keyframeitem.h + detail/playhead.cpp detail/playhead.h + detail/selectableitem.cpp detail/selectableitem.h + detail/selector.cpp detail/selector.h + detail/shortcut.cpp detail/shortcut.h + detail/treeitemdelegate.cpp detail/treeitemdelegate.h + detail/treemodel.cpp detail/treemodel.h + detail/treeview.cpp detail/treeview.h + detail/utils.cpp detail/utils.h +) + +# Do the file comparison at the end, due to all the extend_qtc_plugin calls +if (WITH_DEBUG_CMAKE) + foreach(plugin QmlDesigner componentsplugin qtquickplugin) + unset(plugin_sources) + get_target_property(plugin_sources ${plugin} SOURCES) + list(APPEND QmlDesignerSources ${plugin_sources}) + endforeach() + compare_sources_with_existing_disk_files(QmlDesigner "${QmlDesignerSources}") +endif() diff --git a/src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.cpp b/src/plugins/qmldesigner/components/colortool/colortool.cpp index 32a5742f9f..32a5742f9f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.cpp +++ b/src/plugins/qmldesigner/components/colortool/colortool.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.h b/src/plugins/qmldesigner/components/colortool/colortool.h index 5e9e54c633..5e9e54c633 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.h +++ b/src/plugins/qmldesigner/components/colortool/colortool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.pri b/src/plugins/qmldesigner/components/colortool/colortool.pri index 602af91da5..602af91da5 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/colortool/colortool.pri +++ b/src/plugins/qmldesigner/components/colortool/colortool.pri diff --git a/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp b/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp index fa77acccb9..c2a17cd7b1 100644 --- a/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp @@ -35,10 +35,10 @@ namespace QmlDesigner { static QString styleConfigFileName(const QString &qmlFileName) { - ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(Utils::FileName::fromString(qmlFileName)); + ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(Utils::FilePath::fromString(qmlFileName)); if (currentProject) - foreach (const Utils::FileName &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) + foreach (const Utils::FilePath &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) if (fileName.endsWith("qtquickcontrols2.conf")) return fileName.toString(); @@ -90,14 +90,14 @@ QWidget *ChangeStyleWidgetAction::createWidget(QWidget *parent) }); connect(comboBox, - static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated), + QOverload<const QString &>::of(&QComboBox::activated), this, [this](const QString &style) { if (style.isEmpty()) return; - const Utils::FileName configFileName = Utils::FileName::fromString(styleConfigFileName(qmlFileName)); + const Utils::FilePath configFileName = Utils::FilePath::fromString(styleConfigFileName(qmlFileName)); if (configFileName.exists()) { QSettings infiFile(configFileName.toString(), QSettings::IniFormat); @@ -125,7 +125,7 @@ void ChangeStyleAction::currentContextChanged(const SelectionContext &selectionC const QString confFileName = styleConfigFileName(fileName); - if (Utils::FileName::fromString(confFileName).exists()) { + if (Utils::FilePath::fromString(confFileName).exists()) { QSettings infiFile(confFileName, QSettings::IniFormat); m_action->handleModelUpdate(infiFile.value("Controls/Style", "Default").toString()); } else { diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h index 028d3a21b4..0535a8f52e 100644 --- a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h +++ b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h @@ -165,6 +165,7 @@ const int priorityGenericToolBar = 50; const int priorityLast = 60; const char addImagesDisplayString[] = QT_TRANSLATE_NOOP("QmlDesignerAddResources", "Image Files"); +const char addFontsDisplayString[] = QT_TRANSLATE_NOOP("QmlDesignerAddResources", "Font Files"); } //ComponentCoreConstants diff --git a/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp b/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp index 112923c5f7..733b29ef5a 100644 --- a/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp +++ b/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp @@ -78,7 +78,7 @@ CrumbleBar::~CrumbleBar() delete m_crumblePath; } -void CrumbleBar::pushFile(const Utils::FileName &fileName) +void CrumbleBar::pushFile(const Utils::FilePath &fileName) { if (!m_isInternalCalled) { crumblePath()->clear(); diff --git a/src/plugins/qmldesigner/components/componentcore/crumblebar.h b/src/plugins/qmldesigner/components/componentcore/crumblebar.h index d29d8f594e..cd19e1faa2 100644 --- a/src/plugins/qmldesigner/components/componentcore/crumblebar.h +++ b/src/plugins/qmldesigner/components/componentcore/crumblebar.h @@ -39,7 +39,7 @@ public: explicit CrumbleBar(QObject *parent = nullptr); ~CrumbleBar() override; - void pushFile(const Utils::FileName &fileName); + void pushFile(const Utils::FilePath &fileName); void pushInFileComponent(const ModelNode &modelNode); void nextFileIsCalledInternally(); @@ -58,7 +58,7 @@ private: class CrumbleBarInfo { public: - Utils::FileName fileName; + Utils::FilePath fileName; QString displayName; ModelNode modelNode; }; diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 6edbacec36..37e1fdfd53 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -1026,6 +1026,13 @@ void DesignerActionManager::createDefaultAddResourceHandler() registerAddResourceHandler(AddResourceHandler(ComponentCoreConstants::addImagesDisplayString, "*.svg", ModelNodeOperations::addImageToProject)); + + registerAddResourceHandler(AddResourceHandler(ComponentCoreConstants::addFontsDisplayString, + "*.ttf", + ModelNodeOperations::addFontToProject)); + registerAddResourceHandler(AddResourceHandler(ComponentCoreConstants::addFontsDisplayString, + "*.otf", + ModelNodeOperations::addFontToProject)); } void DesignerActionManager::addDesignerAction(ActionInterface *newAction) diff --git a/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp b/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp index 5ec3ea557b..ba520a1ca3 100644 --- a/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp +++ b/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp @@ -185,17 +185,16 @@ void LayoutInGridLayout::doIt() if (qmlItemNode.hasInstanceParentItem()) { ModelNode layoutNode; - { - RewriterTransaction transaction(m_selectionContext.view(), QByteArrayLiteral("LayoutInGridLayout1")); + + m_selectionContext.view()->executeInTransaction("LayoutInGridLayout1",[this, &layoutNode, layoutType](){ QTC_ASSERT(m_selectionContext.view()->model()->hasNodeMetaInfo(layoutType), return); NodeMetaInfo metaInfo = m_selectionContext.view()->model()->metaInfo(layoutType); layoutNode = m_selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion()); reparentTo(layoutNode, m_parentNode); - } + }); - { - RewriterTransaction transaction(m_selectionContext.view(), QByteArrayLiteral("LayoutInGridLayout2")); + m_selectionContext.view()->executeInTransaction("LayoutInGridLayout2", [this, layoutNode](){ fillEmptyCells(); @@ -208,7 +207,7 @@ void LayoutInGridLayout::doIt() reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes); setSizeAsPreferredSize(sortedSelectedNodes); setSpanning(layoutNode); - } + }); } } } diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index f5b701e44d..9f880c453b 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -240,9 +240,7 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction) if (!modelNode.parentProperty().isNodeListProperty()) return; - try { - RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|raise")); - + selectionState.view()->executeInTransaction("DesignerActionManager|raise",[orderAction, selectionState, modelNode](){ ModelNode modelNode = selectionState.currentSingleSelectedNode(); NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty(); const int index = parentProperty.indexOf(modelNode); @@ -255,11 +253,7 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction) if (index > 0) parentProperty.slide(index, index - 1); } - - transaction.commit(); - } catch (const RewritingException &e) { //better save then sorry - e.showException(); - } + }); } void raise(const SelectionContext &selectionState) @@ -328,16 +322,13 @@ void resetSize(const SelectionContext &selectionState) if (!selectionState.view()) return; - try { - RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetSize")); + selectionState.view()->executeInTransaction("DesignerActionManager|resetSize",[selectionState](){ foreach (ModelNode node, selectionState.selectedModelNodes()) { QmlItemNode itemNode(node); itemNode.removeProperty("width"); itemNode.removeProperty("height"); } - } catch (const RewritingException &e) { //better save then sorry - e.showException(); - } + }); } void resetPosition(const SelectionContext &selectionState) @@ -345,17 +336,13 @@ void resetPosition(const SelectionContext &selectionState) if (!selectionState.view()) return; - try { - RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetPosition")); + selectionState.view()->executeInTransaction("DesignerActionManager|resetPosition",[selectionState](){ foreach (ModelNode node, selectionState.selectedModelNodes()) { QmlItemNode itemNode(node); itemNode.removeProperty("x"); itemNode.removeProperty("y"); } - transaction.commit(); - } catch (const RewritingException &e) { //better save then sorry - e.showException(); - } + }); } void goIntoComponentOperation(const SelectionContext &selectionState) @@ -372,11 +359,12 @@ void resetZ(const SelectionContext &selectionState) if (!selectionState.view()) return; - RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetZ")); - foreach (ModelNode node, selectionState.selectedModelNodes()) { - QmlItemNode itemNode(node); - itemNode.removeProperty("z"); - } + selectionState.view()->executeInTransaction("DesignerActionManager|resetZ",[selectionState](){ + foreach (ModelNode node, selectionState.selectedModelNodes()) { + QmlItemNode itemNode(node); + itemNode.removeProperty("z"); + } + }); } static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName) @@ -404,9 +392,7 @@ void anchorsFill(const SelectionContext &selectionState) if (!selectionState.view()) return; - try { - RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsFill")); - + selectionState.view()->executeInTransaction("DesignerActionManager|anchorsFill",[selectionState](){ ModelNode modelNode = selectionState.currentSingleSelectedNode(); QmlItemNode node = modelNode; @@ -417,11 +403,7 @@ void anchorsFill(const SelectionContext &selectionState) backupPropertyAndRemove(modelNode, "width"); backupPropertyAndRemove(modelNode, "height"); } - - transaction.commit(); - } catch (const RewritingException &e) { //better save then sorry - e.showException(); - } + }); } void anchorsReset(const SelectionContext &selectionState) @@ -429,19 +411,19 @@ void anchorsReset(const SelectionContext &selectionState) if (!selectionState.view()) return; - RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsReset")); - - ModelNode modelNode = selectionState.currentSingleSelectedNode(); + selectionState.view()->executeInTransaction("DesignerActionManager|anchorsReset",[selectionState](){ + ModelNode modelNode = selectionState.currentSingleSelectedNode(); - QmlItemNode node = modelNode; - if (node.isValid()) { - node.anchors().removeAnchors(); - node.anchors().removeMargins(); - restoreProperty(node, "x"); - restoreProperty(node, "y"); - restoreProperty(node, "width"); - restoreProperty(node, "height"); - } + QmlItemNode node = modelNode; + if (node.isValid()) { + node.anchors().removeAnchors(); + node.anchors().removeMargins(); + restoreProperty(node, "x"); + restoreProperty(node, "y"); + restoreProperty(node, "width"); + restoreProperty(node, "height"); + } + }); } using LessThan = std::function<bool (const ModelNode &, const ModelNode&)>; @@ -481,7 +463,7 @@ bool compareByGrid(const ModelNode &node1, const ModelNode &node2) static void layoutHelperFunction(const SelectionContext &selectionContext, const TypeName &layoutType, - LessThan lessThan) + const LessThan &lessThan) { if (!selectionContext.view() || !selectionContext.hasSingleSelectedModelNode() @@ -492,10 +474,8 @@ static void layoutHelperFunction(const SelectionContext &selectionContext, const QmlItemNode qmlItemNode = QmlItemNode(selectionContext.firstSelectedModelNode()); if (qmlItemNode.hasInstanceParentItem()) { - ModelNode layoutNode; - { - RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction1")); + selectionContext.view()->executeInTransaction("DesignerActionManager|layoutHelperFunction1",[=, &layoutNode](){ QmlItemNode parentNode = qmlItemNode.instanceParentItem(); @@ -504,10 +484,9 @@ static void layoutHelperFunction(const SelectionContext &selectionContext, layoutNode = selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion()); reparentTo(layoutNode, parentNode); - } + }); - { - RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction2")); + selectionContext.view()->executeInTransaction("DesignerActionManager|layoutHelperFunction2",[=](){ QList<ModelNode> sortedSelectedNodes = selectionContext.selectedModelNodes(); Utils::sort(sortedSelectedNodes, lessThan); @@ -516,7 +495,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext, LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes); if (layoutType.contains("Layout")) LayoutInGridLayout::setSizeAsPreferredSize(sortedSelectedNodes); - } + }); } } } @@ -662,21 +641,14 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState if (!qmlObjectNode.isRootModelNode()) { isModelNodeRoot = false; - try { - RewriterTransaction transaction = - qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem")); - - QmlObjectNode qmlObjectNode(modelNode); + qmlObjectNode.view()->executeInTransaction("NavigatorTreeModel:exportItem", [&qmlObjectNode](){ qmlObjectNode.ensureAliasExport(); - transaction.commit(); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } + }); } QString itemId = modelNode.id(); - const Utils::FileName currentDesignDocument = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName(); + const Utils::FilePath currentDesignDocument = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName(); const QString fileName = currentDesignDocument.toString(); const QString typeName = currentDesignDocument.toFileInfo().baseName(); @@ -708,14 +680,10 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState if (dialog->signal().isEmpty()) return; - try { - RewriterTransaction transaction = - qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem")); + qmlObjectNode.view()->executeInTransaction("NavigatorTreeModel:exportItem", [=](){ addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } + }); addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot); @@ -751,9 +719,7 @@ void removeLayout(const SelectionContext &selectionContext) if (!parent.isValid()) return; - { - RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|removeLayout")); - + selectionContext.view()->executeInTransaction("DesignerActionManager|removeLayout", [selectionContext, &layoutItem, parent](){ foreach (const ModelNode &modelNode, selectionContext.currentSingleSelectedNode().directSubModelNodes()) { if (QmlItemNode::isValidQmlItemNode(modelNode)) { @@ -772,7 +738,7 @@ void removeLayout(const SelectionContext &selectionContext) parent.modelNode().defaultNodeListProperty().reparentHere(modelNode); } layoutItem.destroy(); - } + }); } void removePositioner(const SelectionContext &selectionContext) @@ -826,9 +792,7 @@ void addItemToStackedContainer(const SelectionContext &selectionContext) } } - try { - RewriterTransaction transaction = - view->beginRewriterTransaction(QByteArrayLiteral("DesignerActionManager:addItemToStackedContainer")); + view->executeInTransaction("DesignerActionManager:addItemToStackedContainer", [=](){ NodeMetaInfo itemMetaInfo = view->model()->metaInfo("QtQuick.Item", -1, -1); QTC_ASSERT(itemMetaInfo.isValid(), return); @@ -853,11 +817,7 @@ void addItemToStackedContainer(const SelectionContext &selectionContext) } } - - transaction.commit(); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } + }); } PropertyName getIndexPropertyName(const ModelNode &modelNode) @@ -969,9 +929,8 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext) const PropertyName indexPropertyName = getIndexPropertyName(container); QTC_ASSERT(container.metaInfo().hasProperty(indexPropertyName), return); - try { - RewriterTransaction transaction = - view->beginRewriterTransaction(QByteArrayLiteral("DesignerActionManager:addItemToStackedContainer")); + view->executeInTransaction("DesignerActionManager:addItemToStackedContainer", + [view, container, containerItemNode, tabBarMetaInfo, tabButtonMetaInfo, indexPropertyName](){ ModelNode tabBarNode = view->createModelNode("QtQuick.Controls.TabBar", @@ -1003,13 +962,42 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext) container.removeProperty(indexPropertyName); const QString expression = id + "." + QString::fromLatin1(indexPropertyName); container.bindingProperty(indexPropertyName).setExpression(expression); + }); + +} + +bool addFontToProject(const QStringList &fileNames, const QString &defaultDirectory) +{ + QString directory = AddImagesDialog::getDirectory(fileNames, defaultDirectory); + + if (directory.isEmpty()) + return true; + + bool allSuccessful = true; + for (const QString &fileName : fileNames) { + const QString targetFile = directory + "/" + QFileInfo(fileName).fileName(); + const bool success = QFile::copy(fileName, targetFile); + + auto document = QmlDesignerPlugin::instance()->currentDesignDocument(); + + QTC_ASSERT(document, return false); - transaction.commit(); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); + if (success) { + ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(document->fileName()); + if (node) { + ProjectExplorer::FolderNode *containingFolder = node->parentFolderNode(); + if (containingFolder) + containingFolder->addFiles(QStringList(targetFile)); + } + } else { + allSuccessful = false; + } } + + return allSuccessful; } + bool addImageToProject(const QStringList &fileNames, const QString &defaultDirectory) { QString directory = AddImagesDialog::getDirectory(fileNames, defaultDirectory); diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h index e3396a303e..52dfaf6f1d 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h @@ -73,6 +73,7 @@ void increaseIndexOfStackedContainer(const SelectionContext &selectionContext); void decreaseIndexOfStackedContainer(const SelectionContext &selectionContext); void addTabBarToStackedContainer(const SelectionContext &selectionContext); bool addImageToProject(const QStringList &fileNames, const QString &directory); +bool addFontToProject(const QStringList &fileNames, const QString &directory); } // namespace ModelNodeOperationso } //QmlDesigner diff --git a/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp b/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp index e82b2a22dd..434f73c0f3 100644 --- a/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp +++ b/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp @@ -29,7 +29,6 @@ namespace QmlDesigner { - SelectionContext::SelectionContext() = default; SelectionContext::SelectionContext(AbstractView *view) : diff --git a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp index 9a1529414a..40ad483785 100644 --- a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp @@ -30,7 +30,6 @@ namespace QmlDesigner { - ZoomAction::ZoomAction(QObject *parent) : QWidgetAction(parent), m_zoomLevel(1.0), @@ -105,7 +104,7 @@ QWidget *ZoomAction::createWidget(QWidget *parent) comboBox->setCurrentIndex(m_currentComboBoxIndex); blockSignals(false); }); - connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this, comboBox](int index) { m_currentComboBoxIndex = index; diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.cpp b/src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.cpp index 9de928ae90..9de928ae90 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.h b/src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.h index 4cfa46d66e..4cfa46d66e 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.h +++ b/src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.ui b/src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.ui index 1da43f7526..1da43f7526 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/addnewbackenddialog.ui +++ b/src/plugins/qmldesigner/components/connectioneditor/addnewbackenddialog.ui diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/backendmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/backendmodel.cpp index f356788a55..4a004ca575 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/backendmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/backendmodel.cpp @@ -232,27 +232,24 @@ void BackendModel::addNewBackend() Import import = Import::createLibraryImport(importSplit.constFirst(), importSplit.constLast()); - try { - - /* We cannot add an import and add a node from that import in a single transaction. + /* We cannot add an import and add a node from that import in a single transaction. * We need the import to have the meta info available. */ - if (!model->hasImport(import)) - model->changeImports({import}, {}); + if (!model->hasImport(import)) + model->changeImports({import}, {}); - QString propertyName = m_connectionView->generateNewId(typeName); + QString propertyName = m_connectionView->generateNewId(typeName); - NodeMetaInfo metaInfo = model->metaInfo(typeName.toUtf8()); + NodeMetaInfo metaInfo = model->metaInfo(typeName.toUtf8()); - QTC_ASSERT(metaInfo.isValid(), return); + QTC_ASSERT(metaInfo.isValid(), return); - int minorVersion = metaInfo.minorVersion(); - int majorVersion = metaInfo.majorVersion(); - - /* Add a property for non singleton types. For singletons just adding the import is enough. */ - if (!dialog.isSingleton()) { - RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::addNewBackend"); + /* Add a property for non singleton types. For singletons just adding the import is enough. */ + if (!dialog.isSingleton()) { + m_connectionView->executeInTransaction("BackendModel::addNewBackend", [=, &dialog](){ + int minorVersion = metaInfo.minorVersion(); + int majorVersion = metaInfo.majorVersion(); if (dialog.localDefinition()) { ModelNode newNode = m_connectionView->createModelNode(metaInfo.typeName(), majorVersion, minorVersion); @@ -263,14 +260,9 @@ void BackendModel::addNewBackend() m_connectionView->rootModelNode().bindingProperty( propertyName.toUtf8()).setDynamicTypeNameAndExpression(typeName.toUtf8(), "null"); } - transaction.commit(); - } - - } catch (const Exception &e) { - e.showException(); + }); } } - resetModel(); } @@ -279,11 +271,9 @@ void BackendModel::updatePropertyName(int rowNumber) const PropertyName newName = data(index(rowNumber, 1)).toString().toUtf8(); const PropertyName oldName = data(index(rowNumber, 0), Qt::UserRole + 1).toString().toUtf8(); - ModelNode rootModelNode = m_connectionView->rootModelNode(); - - try { - RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::updatePropertyName"); + m_connectionView->executeInTransaction("BackendModel::updatePropertyName", [this, newName, oldName](){ + ModelNode rootModelNode = m_connectionView->rootModelNode(); if (rootModelNode.property(oldName).isNodeProperty()) { const TypeName typeName = rootModelNode.nodeProperty(oldName).dynamicTypeName(); @@ -306,12 +296,7 @@ void BackendModel::updatePropertyName(int rowNumber) qWarning() << Q_FUNC_INFO << oldName << newName << "failed..."; QTC_ASSERT(false, return); } - - transaction.commit(); - - } catch (const Exception &e) { - e.showException(); - } + }); } void BackendModel::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/backendmodel.h b/src/plugins/qmldesigner/components/connectioneditor/backendmodel.h index 8abbbe77fa..8abbbe77fa 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/backendmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/backendmodel.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp index cd8c92b82c..2cff12b044 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.cpp @@ -290,8 +290,6 @@ void BindingModel::addModelNode(const ModelNode &modelNode) void BindingModel::updateExpression(int row) { - BindingProperty bindingProperty = bindingPropertyForRow(row); - const QString sourceNode = data(index(row, SourceModelNodeRow)).toString().trimmed(); const QString sourceProperty = data(index(row, SourcePropertyNameRow)).toString().trimmed(); @@ -302,15 +300,10 @@ void BindingModel::updateExpression(int row) expression = sourceNode + QLatin1String(".") + sourceProperty; } - RewriterTransaction transaction = - connectionView()->beginRewriterTransaction(QByteArrayLiteral("BindingModel::updateExpression")); - try { + connectionView()->executeInTransaction("BindingModel::updateExpression", [this, row, expression](){ + BindingProperty bindingProperty = bindingPropertyForRow(row); bindingProperty.setExpression(expression.trimmed()); - transaction.commit(); //committing in the try block - } catch (Exception &e) { - m_exceptionError = e.description(); - QTimer::singleShot(200, this, &BindingModel::handleException); - } + }); } void BindingModel::updatePropertyName(int rowNumber) diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.h b/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.h index 480ba254ad..480ba254ad 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/bindingmodel.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectioneditor.pri b/src/plugins/qmldesigner/components/connectioneditor/connectioneditor.pri index 5dfa3160ab..5dfa3160ab 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectioneditor.pri +++ b/src/plugins/qmldesigner/components/connectioneditor/connectioneditor.pri diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectioneditor.qrc b/src/plugins/qmldesigner/components/connectioneditor/connectioneditor.qrc index a313b6648d..a313b6648d 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectioneditor.qrc +++ b/src/plugins/qmldesigner/components/connectioneditor/connectioneditor.qrc diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp index 8cd297890e..80caf51ce0 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp @@ -182,26 +182,21 @@ void ConnectionModel::updateSource(int row) void ConnectionModel::updateSignalName(int rowNumber) { SignalHandlerProperty signalHandlerProperty = signalHandlerPropertyForRow(rowNumber); - - const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8(); - const QString source = signalHandlerProperty.source(); ModelNode connectionNode = signalHandlerProperty.parentModelNode(); + const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8(); if (!newName.isEmpty()) { - RewriterTransaction transaction = - connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateSignalName")); - try { + connectionView()->executeInTransaction("ConnectionModel::updateSignalName", [=, &connectionNode](){ + + const QString source = signalHandlerProperty.source(); + connectionNode.signalHandlerProperty(newName).setSource(source); connectionNode.removeProperty(signalHandlerProperty.name()); - transaction.commit(); //committing in the try block - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); QStandardItem* idItem = item(rowNumber, 0); SignalHandlerProperty newSignalHandlerProperty = connectionNode.signalHandlerProperty(newName); updateCustomData(idItem, newSignalHandlerProperty); - } else { qWarning() << "BindingModel::updatePropertyName invalid property name"; } @@ -214,14 +209,9 @@ void ConnectionModel::updateTargetNode(int rowNumber) ModelNode connectionNode = signalHandlerProperty.parentModelNode(); if (!newTarget.isEmpty()) { - RewriterTransaction transaction = - connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateTargetNode")); - try { + connectionView()->executeInTransaction("ConnectionModel::updateTargetNode", [= ,&connectionNode](){ connectionNode.bindingProperty("target").setExpression(newTarget); - transaction.commit(); //committing in the try block - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); QStandardItem* idItem = item(rowNumber, 0); updateCustomData(idItem, signalHandlerProperty); @@ -256,12 +246,10 @@ void ConnectionModel::addConnection() if (rootModelNode.isValid() && rootModelNode.metaInfo().isValid()) { - NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections"); + NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections"); if (nodeMetaInfo.isValid()) { - RewriterTransaction transaction = - connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::addConnection")); - try { + connectionView()->executeInTransaction("ConnectionModel::addConnection", [=](){ ModelNode newNode = connectionView()->createModelNode("QtQuick.Connections", nodeMetaInfo.majorVersion(), nodeMetaInfo.minorVersion()); @@ -276,10 +264,7 @@ void ConnectionModel::addConnection() } else { newNode.bindingProperty("target").setExpression(QLatin1String("parent")); } - transaction.commit(); - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); } } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionmodel.h b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h index 2c66b2ef25..2c66b2ef25 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionview.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp index 9aef01259e..9aef01259e 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionview.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionview.h b/src/plugins/qmldesigner/components/connectioneditor/connectionview.h index da7623375a..da7623375a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionview.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionview.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp index c9b1277ce4..c9b1277ce4 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.h b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h index 2bcc3932c1..2bcc3932c1 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.ui b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.ui index 18df078ec6..18df078ec6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/connectionviewwidget.ui +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.ui diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/delegates.cpp b/src/plugins/qmldesigner/components/connectioneditor/delegates.cpp index 1a9958f916..555f448858 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/delegates.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/delegates.cpp @@ -167,7 +167,7 @@ QWidget *BindingDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt default: qWarning() << "BindingDelegate::createEditor column" << index.column(); } - connect(bindingComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() { + connect(bindingComboBox, QOverload<int>::of(&QComboBox::activated), this, [=]() { auto delegate = const_cast<BindingDelegate*>(this); emit delegate->commitData(bindingComboBox); }); @@ -214,7 +214,7 @@ QWidget *DynamicPropertiesDelegate::createEditor(QWidget *parent, const QStyleOp case DynamicPropertiesModel::PropertyTypeRow: { auto dynamicPropertiesComboBox = new PropertiesComboBox(parent); - connect(dynamicPropertiesComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() { + connect(dynamicPropertiesComboBox, QOverload<int>::of(&QComboBox::activated), this, [=]() { auto delegate = const_cast<DynamicPropertiesDelegate*>(this); emit delegate->commitData(dynamicPropertiesComboBox); }); @@ -308,7 +308,7 @@ QWidget *ConnectionDelegate::createEditor(QWidget *parent, const QStyleOptionVie default: qWarning() << "ConnectionDelegate::createEditor column" << index.column(); } - connect(connectionComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() { + connect(connectionComboBox, QOverload<int>::of(&QComboBox::activated), this, [=]() { auto delegate = const_cast<ConnectionDelegate*>(this); emit delegate->commitData(connectionComboBox); }); @@ -335,7 +335,7 @@ QWidget *BackendDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt case BackendModel::TypeNameColumn: { auto backendComboBox = new PropertiesComboBox(parent); backendComboBox->addItems(model->possibleCppTypes()); - connect(backendComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() { + connect(backendComboBox, QOverload<int>::of(&QComboBox::activated), this, [=]() { auto delegate = const_cast<BackendDelegate*>(this); emit delegate->commitData(backendComboBox); }); diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/delegates.h b/src/plugins/qmldesigner/components/connectioneditor/delegates.h index b9792293ac..b9792293ac 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/delegates.h +++ b/src/plugins/qmldesigner/components/connectioneditor/delegates.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/dynamicpropertiesmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp index 8d4186a5b5..0a08e5c883 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/dynamicpropertiesmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.cpp @@ -464,19 +464,16 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber) BindingProperty bindingProperty = bindingPropertyForRow(rowNumber); + ModelNode targetNode = bindingProperty.parentModelNode(); + if (bindingProperty.isBindingProperty()) { - const QString expression = bindingProperty.expression(); - const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName(); - ModelNode targetNode = bindingProperty.parentModelNode(); + connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [bindingProperty, newName, &targetNode](){ + const QString expression = bindingProperty.expression(); + const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName(); - RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName")); - try { targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType, expression); targetNode.removeProperty(bindingProperty.name()); - transaction.commit(); //committing in the try block - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); updateCustomData(rowNumber, targetNode.bindingProperty(newName)); return; @@ -489,14 +486,10 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber) const PropertyName dynamicPropertyType = variantProperty.dynamicTypeName(); ModelNode targetNode = variantProperty.parentModelNode(); - RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName")); - try { + connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [=](){ targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType, value); targetNode.removeProperty(variantProperty.name()); - transaction.commit(); //committing in the try block - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); updateCustomData(rowNumber, targetNode.variantProperty(newName)); } @@ -519,14 +512,10 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber) const PropertyName propertyName = bindingProperty.name(); ModelNode targetNode = bindingProperty.parentModelNode(); - RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType")); - try { + connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){ targetNode.removeProperty(bindingProperty.name()); targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, expression); - transaction.commit(); //committing in the try block - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); updateCustomData(rowNumber, targetNode.bindingProperty(propertyName)); return; @@ -539,18 +528,14 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber) ModelNode targetNode = variantProperty.parentModelNode(); const PropertyName propertyName = variantProperty.name(); - RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType")); - try { + connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){ targetNode.removeProperty(variantProperty.name()); if (newType == "alias") { //alias properties have to be bindings targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, QLatin1String("none.none")); } else { targetNode.variantProperty(propertyName).setDynamicTypeNameAndValue(newType, convertVariantForTypeName(value, newType)); } - transaction.commit(); //committing in the try block - } catch (Exception &e) { //better save then sorry - QMessageBox::warning(nullptr, tr("Error"), e.description()); - } + }); updateCustomData(rowNumber, targetNode.variantProperty(propertyName)); diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/dynamicpropertiesmodel.h b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h index e0c9617fed..e0c9617fed 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/dynamicpropertiesmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/dynamicpropertiesmodel.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/stylesheet.css b/src/plugins/qmldesigner/components/connectioneditor/stylesheet.css index aeacc63733..aeacc63733 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/connectioneditor/stylesheet.css +++ b/src/plugins/qmldesigner/components/connectioneditor/stylesheet.css diff --git a/src/plugins/qmldesigner/components/curveeditor/animationcurve.cpp b/src/plugins/qmldesigner/components/curveeditor/animationcurve.cpp new file mode 100644 index 0000000000..8e2d5224e1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/animationcurve.cpp @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "animationcurve.h" +#include "detail/curvesegment.h" + +#include <QLineF> + +namespace DesignTools { + +AnimationCurve::AnimationCurve() + : m_frames() +{} + +AnimationCurve::AnimationCurve(const std::vector<Keyframe> &frames) + : m_frames(frames) + , m_minY(std::numeric_limits<double>::max()) + , m_maxY(std::numeric_limits<double>::lowest()) +{ + if (isValid()) { + + for (auto e : extrema()) { + + if (m_minY > e.y()) + m_minY = e.y(); + + if (m_maxY < e.y()) + m_maxY = e.y(); + } + + for (auto &frame : qAsConst(m_frames)) { + if (frame.position().y() < m_minY) + m_minY = frame.position().y(); + + if (frame.position().y() > m_maxY) + m_maxY = frame.position().y(); + } + } +} + +bool AnimationCurve::isValid() const +{ + return m_frames.size() >= 2; +} + +double AnimationCurve::minimumTime() const +{ + if (!m_frames.empty()) + return m_frames.front().position().x(); + + return std::numeric_limits<double>::max(); +} + +double AnimationCurve::maximumTime() const +{ + if (!m_frames.empty()) + return m_frames.back().position().x(); + + return std::numeric_limits<double>::lowest(); +} + +double AnimationCurve::minimumValue() const +{ + return m_minY; +} + +double AnimationCurve::maximumValue() const +{ + return m_maxY; +} + +std::vector<Keyframe> AnimationCurve::keyframes() const +{ + return m_frames; +} + +std::vector<QPointF> AnimationCurve::extrema() const +{ + std::vector<QPointF> out; + + CurveSegment segment; + segment.setLeft(m_frames.at(0)); + + for (size_t i = 1; i < m_frames.size(); ++i) { + + segment.setRight(m_frames[i]); + + const auto es = segment.extrema(); + out.insert(std::end(out), std::begin(es), std::end(es)); + + segment.setLeft(m_frames[i]); + } + + return out; +} + +std::vector<double> AnimationCurve::yForX(double x) const +{ + if (m_frames.front().position().x() > x) + return std::vector<double>(); + + CurveSegment segment; + for (auto &frame : m_frames) { + if (frame.position().x() > x) { + segment.setRight(frame); + return segment.yForX(x); + } + segment.setLeft(frame); + } + return std::vector<double>(); +} + +std::vector<double> AnimationCurve::xForY(double y, uint segment) const +{ + if (m_frames.size() > segment + 1) { + CurveSegment seg(m_frames[segment], m_frames[segment + 1]); + return seg.xForY(y); + } + return std::vector<double>(); +} + +bool AnimationCurve::intersects(const QPointF &coord, double radius) +{ + if (m_frames.size() < 2) + return false; + + std::vector<CurveSegment> influencer; + + CurveSegment current; + current.setLeft(m_frames.at(0)); + + for (size_t i = 1; i < m_frames.size(); ++i) { + Keyframe &frame = m_frames.at(i); + + current.setRight(frame); + + if (current.containsX(coord.x() - radius) || + current.containsX(coord.x()) || + current.containsX(coord.x() + radius)) { + influencer.push_back(current); + } + + if (frame.position().x() > coord.x() + radius) + break; + + current.setLeft(frame); + } + + for (auto &segment : influencer) { + for (auto &y : segment.yForX(coord.x())) { + QLineF line(coord.x(), y, coord.x(), coord.y()); + if (line.length() < radius) + return true; + } + + for (auto &x : segment.xForY(coord.y())) { + QLineF line(x, coord.y(), coord.x(), coord.y()); + if (line.length() < radius) + return true; + } + } + return false; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/animationcurve.h b/src/plugins/qmldesigner/components/curveeditor/animationcurve.h new file mode 100644 index 0000000000..0533e479a1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/animationcurve.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "keyframe.h" + +#include <vector> + +namespace DesignTools { + +class AnimationCurve +{ +public: + AnimationCurve(); + + AnimationCurve(const std::vector<Keyframe> &frames); + + bool isValid() const; + + double minimumTime() const; + + double maximumTime() const; + + double minimumValue() const; + + double maximumValue() const; + + std::vector<Keyframe> keyframes() const; + + std::vector<QPointF> extrema() const; + + std::vector<double> yForX(double x) const; + + std::vector<double> xForY(double y, uint segment) const; + + bool intersects(const QPointF &coord, double radius); + +private: + std::vector<Keyframe> m_frames; + + double m_minY; + + double m_maxY; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp new file mode 100644 index 0000000000..4eba31c6bd --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditor.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "curveeditor.h" +#include "curveeditormodel.h" +#include "detail/curveitem.h" +#include "detail/graphicsview.h" +#include "detail/treeview.h" + +#include <QHBoxLayout> +#include <QSplitter> + +namespace DesignTools { + +CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent) + : QWidget(parent) + , m_tree(new TreeView(model, this)) + , m_view(new GraphicsView(model)) +{ + QSplitter *splitter = new QSplitter; + splitter->addWidget(m_tree); + splitter->addWidget(m_view); + splitter->setStretchFactor(1, 2); + + QHBoxLayout *box = new QHBoxLayout; + box->addWidget(splitter); + setLayout(box); + + connect(m_tree, &TreeView::curvesSelected, m_view, &GraphicsView::reset); +} + +void CurveEditor::zoomX(double zoom) +{ + m_view->setZoomX(zoom); +} + +void CurveEditor::zoomY(double zoom) +{ + m_view->setZoomY(zoom); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditor.h b/src/plugins/qmldesigner/components/curveeditor/curveeditor.h new file mode 100644 index 0000000000..a2c5873be0 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditor.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QWidget> + +namespace DesignTools { + +class CurveEditorModel; +class GraphicsView; +class TreeView; + +class CurveEditor : public QWidget +{ + Q_OBJECT + +public: + CurveEditor(CurveEditorModel *model, QWidget *parent = nullptr); + + void zoomX(double zoom); + + void zoomY(double zoom); + +private: + TreeView *m_tree; + + GraphicsView *m_view; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditor.pri b/src/plugins/qmldesigner/components/curveeditor/curveeditor.pri new file mode 100644 index 0000000000..31ffe5d818 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditor.pri @@ -0,0 +1,46 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/animationcurve.h \ + $$PWD/curveeditor.h \ + $$PWD/curveeditormodel.h \ + $$PWD/detail/colorcontrol.h \ + $$PWD/detail/curveeditorstyledialog.h \ + $$PWD/detail/curveitem.h \ + $$PWD/detail/curvesegment.h \ + $$PWD/detail/graphicsscene.h \ + $$PWD/detail/graphicsview.h \ + $$PWD/detail/handleitem.h \ + $$PWD/detail/keyframeitem.h \ + $$PWD/detail/playhead.h \ + $$PWD/detail/selectableitem.h \ + $$PWD/detail/selector.h \ + $$PWD/detail/shortcut.h \ + $$PWD/detail/treeitemdelegate.h \ + $$PWD/detail/treemodel.h \ + $$PWD/detail/treeview.h \ + $$PWD/keyframe.h \ + $$PWD/treeitem.h + +SOURCES += \ + $$PWD/animationcurve.cpp \ + $$PWD/curveeditor.cpp \ + $$PWD/curveeditormodel.cpp \ + $$PWD/detail/colorcontrol.cpp \ + $$PWD/detail/curveeditorstyledialog.cpp \ + $$PWD/detail/curveitem.cpp \ + $$PWD/detail/curvesegment.cpp \ + $$PWD/detail/graphicsscene.cpp \ + $$PWD/detail/graphicsview.cpp \ + $$PWD/detail/handleitem.cpp \ + $$PWD/detail/keyframeitem.cpp \ + $$PWD/detail/playhead.cpp \ + $$PWD/detail/selectableitem.cpp \ + $$PWD/detail/selector.cpp \ + $$PWD/detail/shortcut.cpp \ + $$PWD/detail/treeitemdelegate.cpp \ + $$PWD/detail/treemodel.cpp \ + $$PWD/detail/treeview.cpp \ + $$PWD/detail/utils.cpp \ + $$PWD/keyframe.cpp \ + $$PWD/treeitem.cpp diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp new file mode 100644 index 0000000000..3b8b26b763 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "curveeditormodel.h" +#include "treeitem.h" +#include "detail/graphicsview.h" + +namespace DesignTools { + +CurveEditorModel::CurveEditorModel(QObject *parent) + : TreeModel(parent) +{} + +CurveEditorModel::~CurveEditorModel() {} + + +void CurveEditorModel::setCurrentFrame(int frame) +{ + if (graphicsView()) + graphicsView()->setCurrentFrame(frame); +} + +void CurveEditorModel::setCurve(unsigned int id, const AnimationCurve &curve) +{ + if (TreeItem *item = find(id)) { + if (PropertyTreeItem *propertyItem = item->asPropertyItem()) { + propertyItem->setCurve(curve); + emit curveChanged(propertyItem); + } + } +} + +void CurveEditorModel::reset(const std::vector<TreeItem *> &items) +{ + beginResetModel(); + + initialize(); + + unsigned int counter = 0; + for (auto *item : items) { + item->setId(++counter); + root()->addChild(item); + } + + endResetModel(); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h new file mode 100644 index 0000000000..6e212d4c6a --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "detail/treemodel.h" + +#include <vector> + +QT_BEGIN_NAMESPACE +class QPointF; +QT_END_NAMESPACE + +namespace DesignTools { + +struct CurveEditorStyle; + +class AnimationCurve; +class PropertyTreeItem; +class TreeItem; + +class CurveEditorModel : public TreeModel +{ + Q_OBJECT + +signals: + void currentFrameChanged(int frame); + + void curveChanged(PropertyTreeItem *item); + +public: + virtual double minimumTime() const = 0; + + virtual double maximumTime() const = 0; + + virtual CurveEditorStyle style() const = 0; + +public: + CurveEditorModel(QObject *parent = nullptr); + + ~CurveEditorModel() override; + + void setCurrentFrame(int frame); + + void setCurve(unsigned int id, const AnimationCurve &curve); + + void reset(const std::vector<TreeItem *> &items); +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h new file mode 100644 index 0000000000..03ea11c8c1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/curveeditorstyle.h @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "detail/shortcut.h" + +#include <QBitmap> +#include <QBrush> +#include <QColor> +#include <QDialog> +#include <QIcon> +#include <QKeySequence> + +namespace DesignTools { + +struct TreeItemStyleOption +{ + double margins; + QIcon pinnedIcon = QIcon(":/ICON_PINNED"); + QIcon unpinnedIcon = QIcon(":/ICON_UNPINNED"); + QIcon lockedIcon = QIcon(":/ICON_LOCKED"); + QIcon unlockedIcon = QIcon(":/ICON_UNLOCKED"); +}; + +struct HandleItemStyleOption +{ + double size = 10.0; + double lineWidth = 1.0; + QColor color = QColor(200, 0, 0); + QColor selectionColor = QColor(200, 200, 200); +}; + +struct KeyframeItemStyleOption +{ + double size = 10.0; + QColor color = QColor(200, 200, 0); + QColor selectionColor = QColor(200, 200, 200); +}; + +struct CurveItemStyleOption +{ + double width = 1.0; + QColor color = QColor(0, 200, 0); + QColor selectionColor = QColor(200, 200, 200); +}; + +struct PlayheadStyleOption +{ + double width = 20.0; + double radius = 4.0; + QColor color = QColor(200, 200, 0); +}; + +struct Shortcuts +{ + Shortcut newSelection = Shortcut(Qt::LeftButton); + Shortcut addToSelection = Shortcut(Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier); + Shortcut removeFromSelection = Shortcut(Qt::LeftButton, Qt::ShiftModifier); + Shortcut toggleSelection = Shortcut(Qt::LeftButton, Qt::ControlModifier); + + Shortcut zoom = Shortcut(Qt::RightButton, Qt::AltModifier); + Shortcut pan = Shortcut(Qt::MiddleButton, Qt::AltModifier); + Shortcut frameAll = Shortcut(Qt::NoModifier, Qt::Key_A); +}; + +struct CurveEditorStyle +{ + Shortcuts shortcuts; + + QBrush backgroundBrush = QBrush(QColor(5, 0, 100)); + QBrush backgroundAlternateBrush = QBrush(QColor(0, 0, 50)); + QColor fontColor = QColor(200, 200, 200); + QColor gridColor = QColor(128, 128, 128); + double canvasMargin = 5.0; + int zoomInWidth = 100; + int zoomInHeight = 100; + double timeAxisHeight = 40.0; + double timeOffsetLeft = 10.0; + double timeOffsetRight = 10.0; + QColor rangeBarColor = QColor(128, 128, 128); + QColor rangeBarCapsColor = QColor(50, 50, 255); + double valueAxisWidth = 60.0; + double valueOffsetTop = 10.0; + double valueOffsetBottom = 10.0; + + HandleItemStyleOption handleStyle; + KeyframeItemStyleOption keyframeStyle; + CurveItemStyleOption curveStyle; + TreeItemStyleOption treeItemStyle; + PlayheadStyleOption playhead; +}; + +inline QPixmap pixmapFromIcon(const QIcon &icon, const QSize &size, const QColor &color) +{ + QPixmap pixmap = icon.pixmap(size); + QPixmap mask(pixmap.size()); + mask.fill(color); + mask.setMask(pixmap.createMaskFromColor(Qt::transparent)); + return mask; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.cpp new file mode 100644 index 0000000000..a833a4c6ff --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "colorcontrol.h" + +#include <QColorDialog> +#include <QEvent> +#include <QHelpEvent> +#include <QPainter> +#include <QToolTip> + +namespace DesignTools { + +ColorControl::ColorControl() + : QWidget(nullptr) + , m_color(Qt::black) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + setFixedHeight(20); +} + +ColorControl::ColorControl(const QColor &color, QWidget *parent) + : QWidget(parent) + , m_color(color) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + setFixedHeight(20); +} + +ColorControl::~ColorControl() = default; + +QColor ColorControl::value() const +{ + return m_color; +} + +void ColorControl::setValue(const QColor &val) +{ + m_color = val; +} + +bool ColorControl::event(QEvent *event) +{ + if (event->type() == QEvent::ToolTip) { + if (auto helpEvent = static_cast<const QHelpEvent *>(event)) { + QToolTip::showText(helpEvent->globalPos(), m_color.name()); + return true; + } + } + return QWidget::event(event); +} + +void ColorControl::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.fillRect(event->rect(), m_color); +} + +void ColorControl::mouseReleaseEvent(QMouseEvent *event) +{ + QColor color = QColorDialog::getColor(m_color, this); + + event->accept(); + + if (color != m_color) { + m_color = color; + update(); + emit valueChanged(); + } +} + +void ColorControl::mousePressEvent(QMouseEvent *event) +{ + // Required if embedded in a QGraphicsProxywidget + // in order to call mouseRelease properly. + QWidget::mousePressEvent(event); + event->accept(); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.h b/src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.h new file mode 100644 index 0000000000..54dfe194f8 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/colorcontrol.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QWidget> + +namespace DesignTools { + +class ColorControl : public QWidget +{ + Q_OBJECT + +public: + ColorControl(); + + ColorControl(const QColor &color, QWidget *parent = nullptr); + + ~ColorControl() override; + + QColor value() const; + + void setValue(const QColor &val); + +protected: + bool event(QEvent *event) override; + + void paintEvent(QPaintEvent *event) override; + + void mouseReleaseEvent(QMouseEvent *event) override; + + void mousePressEvent(QMouseEvent *event) override; + +signals: + void valueChanged(); + +private: + QColor m_color; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.cpp new file mode 100644 index 0000000000..a8b653a74d --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.cpp @@ -0,0 +1,267 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "curveeditorstyledialog.h" +#include "colorcontrol.h" +#include "curveeditorstyle.h" + +#include <QDebug> +#include <QDoubleSpinBox> +#include <QLabel> +#include <QPushButton> +#include <QSpinBox> +#include <QVBoxLayout> + +namespace DesignTools { + +QHBoxLayout *createRow(const QString &title, QWidget *widget) +{ + auto *label = new QLabel(title); + label->setFixedWidth(200); + label->setAlignment(Qt::AlignRight); + + auto *box = new QHBoxLayout; + box->addWidget(label); + box->addWidget(widget); + return box; +} + +CurveEditorStyleDialog::CurveEditorStyleDialog(CurveEditorStyle &style, QWidget *parent) + : QDialog(parent) + , m_printButton(new QPushButton("Print")) + , m_background(new ColorControl(style.backgroundBrush.color())) + , m_backgroundAlternate(new ColorControl(style.backgroundAlternateBrush.color())) + , m_fontColor(new ColorControl(style.fontColor)) + , m_gridColor(new ColorControl(style.gridColor)) + , m_canvasMargin(new QDoubleSpinBox()) + , m_zoomInWidth(new QSpinBox()) + , m_zoomInHeight(new QSpinBox()) + , m_timeAxisHeight(new QDoubleSpinBox()) + , m_timeOffsetLeft(new QDoubleSpinBox()) + , m_timeOffsetRight(new QDoubleSpinBox()) + , m_rangeBarColor(new ColorControl(style.rangeBarCapsColor)) + , m_rangeBarCapsColor(new ColorControl(style.rangeBarCapsColor)) + , m_valueAxisWidth(new QDoubleSpinBox()) + , m_valueOffsetTop(new QDoubleSpinBox()) + , m_valueOffsetBottom(new QDoubleSpinBox()) + , m_handleSize(new QDoubleSpinBox()) + , m_handleLineWidth(new QDoubleSpinBox()) + , m_handleColor(new ColorControl(style.handleStyle.color)) + , m_handleSelectionColor(new ColorControl(style.handleStyle.selectionColor)) + , m_keyframeSize(new QDoubleSpinBox()) + , m_keyframeColor(new ColorControl(style.keyframeStyle.color)) + , m_keyframeSelectionColor(new ColorControl(style.keyframeStyle.selectionColor)) + , m_curveWidth(new QDoubleSpinBox()) + , m_curveColor(new ColorControl(style.curveStyle.color)) + , m_curveSelectionColor(new ColorControl(style.curveStyle.selectionColor)) + , m_treeMargins(new QDoubleSpinBox()) + , m_playheadWidth(new QDoubleSpinBox()) + , m_playheadRadius(new QDoubleSpinBox()) + , m_playheadColor(new ColorControl(style.playhead.color)) + +{ + m_canvasMargin->setValue(style.canvasMargin); + m_zoomInWidth->setValue(style.zoomInWidth); + m_zoomInHeight->setValue(style.zoomInHeight); + m_zoomInHeight->setMaximum(9000); + + m_timeAxisHeight->setValue(style.timeAxisHeight); + m_timeOffsetLeft->setValue(style.timeOffsetLeft); + m_timeOffsetRight->setValue(style.timeOffsetRight); + m_valueAxisWidth->setValue(style.valueAxisWidth); + m_valueOffsetTop->setValue(style.valueOffsetTop); + m_valueOffsetBottom->setValue(style.valueOffsetBottom); + m_handleSize->setValue(style.handleStyle.size); + m_handleLineWidth->setValue(style.handleStyle.lineWidth); + m_keyframeSize->setValue(style.keyframeStyle.size); + m_curveWidth->setValue(style.curveStyle.width); + m_treeMargins->setValue(style.treeItemStyle.margins); + m_playheadWidth->setValue(style.playhead.width); + m_playheadRadius->setValue(style.playhead.radius); + + connect(m_printButton, &QPushButton::released, this, &CurveEditorStyleDialog::printStyle); + + auto intChanged = [this](int) { emitStyleChanged(); }; + auto doubleChanged = [this](double) { emitStyleChanged(); }; + auto colorChanged = [this]() { emitStyleChanged(); }; + + auto intSignal = static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged); + auto doubleSignal = static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged); + + connect(m_background, &ColorControl::valueChanged, colorChanged); + connect(m_backgroundAlternate, &ColorControl::valueChanged, colorChanged); + connect(m_fontColor, &ColorControl::valueChanged, colorChanged); + connect(m_gridColor, &ColorControl::valueChanged, colorChanged); + connect(m_canvasMargin, doubleSignal, doubleChanged); + connect(m_zoomInWidth, intSignal, intChanged); + connect(m_zoomInHeight, intSignal, intChanged); + connect(m_timeAxisHeight, doubleSignal, doubleChanged); + connect(m_timeOffsetLeft, doubleSignal, doubleChanged); + connect(m_timeOffsetRight, doubleSignal, doubleChanged); + connect(m_rangeBarColor, &ColorControl::valueChanged, colorChanged); + connect(m_rangeBarCapsColor, &ColorControl::valueChanged, colorChanged); + connect(m_valueAxisWidth, doubleSignal, doubleChanged); + connect(m_valueOffsetTop, doubleSignal, doubleChanged); + connect(m_valueOffsetBottom, doubleSignal, doubleChanged); + connect(m_handleSize, doubleSignal, doubleChanged); + connect(m_handleLineWidth, doubleSignal, doubleChanged); + connect(m_handleColor, &ColorControl::valueChanged, colorChanged); + connect(m_handleSelectionColor, &ColorControl::valueChanged, colorChanged); + connect(m_keyframeSize, doubleSignal, doubleChanged); + connect(m_keyframeColor, &ColorControl::valueChanged, colorChanged); + connect(m_keyframeSelectionColor, &ColorControl::valueChanged, colorChanged); + connect(m_curveWidth, doubleSignal, doubleChanged); + connect(m_curveColor, &ColorControl::valueChanged, colorChanged); + connect(m_curveSelectionColor, &ColorControl::valueChanged, colorChanged); + connect(m_treeMargins, doubleSignal, doubleChanged); + connect(m_playheadWidth, doubleSignal, doubleChanged); + connect(m_playheadRadius, doubleSignal, doubleChanged); + connect(m_playheadColor, &ColorControl::valueChanged, colorChanged); + + auto *box = new QVBoxLayout; + box->addLayout(createRow("Background Color", m_background)); + box->addLayout(createRow("Alternate Background Color", m_backgroundAlternate)); + box->addLayout(createRow("Font Color", m_fontColor)); + box->addLayout(createRow("Grid Color", m_gridColor)); + box->addLayout(createRow("Canvas Margin", m_canvasMargin)); + box->addLayout(createRow("Zoom In Width", m_zoomInWidth)); + box->addLayout(createRow("Zoom In Height", m_zoomInHeight)); + box->addLayout(createRow("Time Axis Height", m_timeAxisHeight)); + box->addLayout(createRow("Time Axis Left Offset", m_timeOffsetLeft)); + box->addLayout(createRow("Time Axis Right Offset", m_timeOffsetRight)); + box->addLayout(createRow("Range Bar Color", m_rangeBarColor)); + box->addLayout(createRow("Range Bar Caps Color", m_rangeBarCapsColor)); + box->addLayout(createRow("Value Axis Width", m_valueAxisWidth)); + box->addLayout(createRow("Value Axis Top Offset", m_valueOffsetTop)); + box->addLayout(createRow("Value Axis Bottom Offset", m_valueOffsetBottom)); + box->addLayout(createRow("Handle Size", m_handleSize)); + box->addLayout(createRow("Handle Line Width", m_handleLineWidth)); + box->addLayout(createRow("Handle Color", m_handleColor)); + box->addLayout(createRow("Handle Selection Color", m_handleSelectionColor)); + box->addLayout(createRow("Keyframe Size", m_keyframeSize)); + box->addLayout(createRow("Keyframe Color", m_keyframeColor)); + box->addLayout(createRow("Keyframe Selection Color", m_keyframeSelectionColor)); + box->addLayout(createRow("Curve Width", m_curveWidth)); + box->addLayout(createRow("Curve Color", m_curveColor)); + box->addLayout(createRow("Curve Selection Color", m_curveSelectionColor)); + box->addLayout(createRow("Treeview margins", m_treeMargins)); + box->addLayout(createRow("Playhead width", m_playheadWidth)); + box->addLayout(createRow("Playhead radius", m_playheadRadius)); + box->addLayout(createRow("Playhead color", m_playheadColor)); + + box->addWidget(m_printButton); + setLayout(box); +} + +CurveEditorStyle CurveEditorStyleDialog::style() const +{ + CurveEditorStyle style; + style.backgroundBrush = QBrush(m_background->value()); + style.backgroundAlternateBrush = QBrush(m_backgroundAlternate->value()); + style.fontColor = m_fontColor->value(); + style.gridColor = m_gridColor->value(); + style.canvasMargin = m_canvasMargin->value(); + style.zoomInWidth = m_zoomInWidth->value(); + style.zoomInHeight = m_zoomInHeight->value(); + style.timeAxisHeight = m_timeAxisHeight->value(); + style.timeOffsetLeft = m_timeOffsetLeft->value(); + style.timeOffsetRight = m_timeOffsetRight->value(); + style.rangeBarColor = m_rangeBarColor->value(); + style.rangeBarCapsColor = m_rangeBarCapsColor->value(); + style.valueAxisWidth = m_valueAxisWidth->value(); + style.valueOffsetTop = m_valueOffsetTop->value(); + style.valueOffsetBottom = m_valueOffsetBottom->value(); + style.handleStyle.size = m_handleSize->value(); + style.handleStyle.lineWidth = m_handleLineWidth->value(); + style.handleStyle.color = m_handleColor->value(); + style.handleStyle.selectionColor = m_handleSelectionColor->value(); + style.keyframeStyle.size = m_keyframeSize->value(); + style.keyframeStyle.color = m_keyframeColor->value(); + style.keyframeStyle.selectionColor = m_keyframeSelectionColor->value(); + style.curveStyle.width = m_curveWidth->value(); + style.curveStyle.color = m_curveColor->value(); + style.curveStyle.selectionColor = m_curveSelectionColor->value(); + style.treeItemStyle.margins = m_treeMargins->value(); + style.playhead.width = m_playheadWidth->value(); + style.playhead.radius = m_playheadRadius->value(); + style.playhead.color = m_playheadColor->value(); + + return style; +} + +void CurveEditorStyleDialog::emitStyleChanged() +{ + emit styleChanged(style()); +} + +void CurveEditorStyleDialog::printStyle() +{ + auto toString = [](const QColor &color) { + QString tmp + = QString("QColor(%1, %2, %3)").arg(color.red()).arg(color.green()).arg(color.blue()); + return qPrintable(tmp); + }; + + CurveEditorStyle s = style(); + qDebug() << ""; + qDebug().nospace() << "CurveEditorStyle out;"; + qDebug().nospace() << "out.backgroundBrush = QBrush(" << toString(s.backgroundBrush.color()) + << ");"; + qDebug().nospace() << "out.backgroundAlternateBrush = QBrush(" + << toString(s.backgroundAlternateBrush.color()) << ");"; + qDebug().nospace() << "out.fontColor = " << toString(s.fontColor) << ";"; + qDebug().nospace() << "out.gridColor = " << toString(s.gridColor) << ";"; + qDebug().nospace() << "out.canvasMargin = " << s.canvasMargin << ";"; + qDebug().nospace() << "out.zoomInWidth = " << s.zoomInWidth << ";"; + qDebug().nospace() << "out.zoomInHeight = " << s.zoomInHeight << ";"; + qDebug().nospace() << "out.timeAxisHeight = " << s.timeAxisHeight << ";"; + qDebug().nospace() << "out.timeOffsetLeft = " << s.timeOffsetLeft << ";"; + qDebug().nospace() << "out.timeOffsetRight = " << s.timeOffsetRight << ";"; + qDebug().nospace() << "out.rangeBarColor = " << toString(s.rangeBarColor) << ";"; + qDebug().nospace() << "out.rangeBarCapsColor = " << toString(s.rangeBarCapsColor) << ";"; + qDebug().nospace() << "out.valueAxisWidth = " << s.valueAxisWidth << ";"; + qDebug().nospace() << "out.valueOffsetTop = " << s.valueOffsetTop << ";"; + qDebug().nospace() << "out.valueOffsetBottom = " << s.valueOffsetBottom << ";"; + qDebug().nospace() << "out.handleStyle.size = " << s.handleStyle.size << ";"; + qDebug().nospace() << "out.handleStyle.lineWidth = " << s.handleStyle.lineWidth << ";"; + qDebug().nospace() << "out.handleStyle.color = " << toString(s.handleStyle.color) << ";"; + qDebug().nospace() << "out.handleStyle.selectionColor = " + << toString(s.handleStyle.selectionColor) << ";"; + qDebug().nospace() << "out.keyframeStyle.size = " << s.keyframeStyle.size << ";"; + qDebug().nospace() << "out.keyframeStyle.color = " << toString(s.keyframeStyle.color) << ";"; + qDebug().nospace() << "out.keyframeStyle.selectionColor = " + << toString(s.keyframeStyle.selectionColor) << ";"; + qDebug().nospace() << "out.curveStyle.width = " << s.curveStyle.width << ";"; + qDebug().nospace() << "out.curveStyle.color = " << toString(s.curveStyle.color) << ";"; + qDebug().nospace() << "out.curveStyle.selectionColor = " + << toString(s.curveStyle.selectionColor) << ";"; + qDebug().nospace() << "out.treeItemStyle.margins = " << s.treeItemStyle.margins << ";"; + qDebug().nospace() << "out.playheadStyle.width = " << s.playhead.width << ";"; + qDebug().nospace() << "out.playheadStyle.radius = " << s.playhead.radius << ";"; + qDebug().nospace() << "out.playheadStyle.color = " << toString(s.playhead.color) << ";"; + qDebug().nospace() << "return out;"; + qDebug() << ""; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.h b/src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.h new file mode 100644 index 0000000000..f1dc3bc372 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curveeditorstyledialog.h @@ -0,0 +1,127 @@ + +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QPushButton; +class QSpinBox; +class QDoubleSpinBox; +QT_END_NAMESPACE + +namespace DesignTools { + +class ColorControl; + +struct CurveEditorStyle; + +class CurveEditorStyleDialog : public QDialog +{ + Q_OBJECT + +signals: + void styleChanged(const CurveEditorStyle &style); + +public: + CurveEditorStyleDialog(CurveEditorStyle &style, QWidget *parent = nullptr); + + CurveEditorStyle style() const; + +private: + void emitStyleChanged(); + + void printStyle(); + +private: + QPushButton *m_printButton; + + ColorControl *m_background; + + ColorControl *m_backgroundAlternate; + + ColorControl *m_fontColor; + + ColorControl *m_gridColor; + + QDoubleSpinBox *m_canvasMargin; + + QSpinBox *m_zoomInWidth; + + QSpinBox *m_zoomInHeight; + + QDoubleSpinBox *m_timeAxisHeight; + + QDoubleSpinBox *m_timeOffsetLeft; + + QDoubleSpinBox *m_timeOffsetRight; + + ColorControl *m_rangeBarColor; + + ColorControl *m_rangeBarCapsColor; + + QDoubleSpinBox *m_valueAxisWidth; + + QDoubleSpinBox *m_valueOffsetTop; + + QDoubleSpinBox *m_valueOffsetBottom; + + // HandleItem + QDoubleSpinBox *m_handleSize; + + QDoubleSpinBox *m_handleLineWidth; + + ColorControl *m_handleColor; + + ColorControl *m_handleSelectionColor; + + // KeyframeItem + QDoubleSpinBox *m_keyframeSize; + + ColorControl *m_keyframeColor; + + ColorControl *m_keyframeSelectionColor; + + // CurveItem + QDoubleSpinBox *m_curveWidth; + + ColorControl *m_curveColor; + + ColorControl *m_curveSelectionColor; + + // TreeItem + QDoubleSpinBox *m_treeMargins; + + // Playhead + QDoubleSpinBox *m_playheadWidth; + + QDoubleSpinBox *m_playheadRadius; + + ColorControl *m_playheadColor; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp new file mode 100644 index 0000000000..38efd29571 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.cpp @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "curveitem.h" +#include "animationcurve.h" +#include "graphicsscene.h" +#include "keyframeitem.h" +#include "utils.h" + +#include <QPainter> +#include <QPainterPath> + +#include <cmath> + +namespace DesignTools { + +CurveItem::CurveItem(QGraphicsItem *parent) + : QGraphicsObject(parent) + , m_id(0) + , m_style() + , m_transform() + , m_keyframes() + , m_underMouse(false) + , m_itemDirty(false) + , m_pathDirty(true) +{} + +CurveItem::CurveItem(unsigned int id, const AnimationCurve &curve, QGraphicsItem *parent) + : QGraphicsObject(parent) + , m_id(id) + , m_style() + , m_transform() + , m_keyframes() + , m_underMouse(false) + , m_itemDirty(false) + , m_pathDirty(true) +{ + setAcceptHoverEvents(true); + + setFlag(QGraphicsItem::ItemIsMovable, false); + + auto emitCurveChanged = [this]() { + m_itemDirty = true; + m_pathDirty = true; + update(); + }; + + for (auto frame : curve.keyframes()) { + auto *item = new KeyframeItem(frame, this); + QObject::connect(item, &KeyframeItem::redrawCurve, emitCurveChanged); + m_keyframes.push_back(item); + } +} + +CurveItem::~CurveItem() {} + +int CurveItem::type() const +{ + return Type; +} + +QRectF CurveItem::boundingRect() const +{ + auto bbox = [](QRectF &bounds, const Keyframe &frame) { + grow(bounds, frame.position()); + grow(bounds, frame.leftHandle()); + grow(bounds, frame.rightHandle()); + }; + + QRectF bounds; + for (auto *item : m_keyframes) + bbox(bounds, item->keyframe()); + + return m_transform.mapRect(bounds); +} + +bool CurveItem::contains(const QPointF &point) const +{ + bool valid = false; + QPointF transformed(m_transform.inverted(&valid).map(point)); + + double width = std::abs(20.0 / scaleY(m_transform)); + + if (valid) + return curve().intersects(transformed, width); + + return false; +} + +void CurveItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + if (m_keyframes.size() > 1) { + QPen pen = painter->pen(); + QColor col = m_underMouse ? Qt::red : m_style.color; + + pen.setWidthF(m_style.width); + pen.setColor(hasSelection() ? m_style.selectionColor : col); + + painter->save(); + painter->setPen(pen); + painter->drawPath(path()); + + painter->restore(); + } +} + +bool CurveItem::isDirty() const +{ + return m_itemDirty; +} + +bool CurveItem::hasSelection() const +{ + for (auto *frame : m_keyframes) { + if (frame->selected()) + return true; + } + + return false; +} + +unsigned int CurveItem::id() const +{ + return m_id; +} + +QPainterPath CurveItem::path() const +{ + if (m_pathDirty) { + Keyframe previous = m_keyframes.front()->keyframe(); + Keyframe current; + + m_path = QPainterPath(m_transform.map(previous.position())); + for (size_t i = 1; i < m_keyframes.size(); ++i) { + current = m_keyframes[i]->keyframe(); + + if (previous.rightHandle().isNull() || current.leftHandle().isNull()) { + m_path.lineTo(m_transform.map(current.position())); + } else { + m_path.cubicTo( + m_transform.map(previous.rightHandle()), + m_transform.map(current.leftHandle()), + m_transform.map(current.position())); + } + + previous = current; + } + m_pathDirty = false; + } + + return m_path; +} + +AnimationCurve CurveItem::curve() const +{ + std::vector<Keyframe> out; + out.reserve(m_keyframes.size()); + for (auto item : m_keyframes) + out.push_back(item->keyframe()); + + return out; +} + +void CurveItem::setDirty(bool dirty) +{ + m_itemDirty = dirty; +} + +QRectF CurveItem::setComponentTransform(const QTransform &transform) +{ + m_pathDirty = true; + + prepareGeometryChange(); + m_transform = transform; + for (auto frame : m_keyframes) + frame->setComponentTransform(transform); + + return boundingRect(); +} + +void CurveItem::setStyle(const CurveEditorStyle &style) +{ + m_style = style.curveStyle; + + for (auto *frame : m_keyframes) + frame->setStyle(style); +} + +void CurveItem::connect(GraphicsScene *scene) +{ + for (auto *frame : m_keyframes) { + QObject::connect(frame, &KeyframeItem::keyframeMoved, scene, &GraphicsScene::keyframeMoved); + QObject::connect(frame, &KeyframeItem::handleMoved, scene, &GraphicsScene::handleMoved); + } +} + +void CurveItem::setIsUnderMouse(bool under) +{ + if (under != m_underMouse) { + m_underMouse = under; + update(); + } +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.h b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.h new file mode 100644 index 0000000000..90e68e20f1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curveitem.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "curveeditorstyle.h" +#include "selectableitem.h" + +#include <QGraphicsObject> + +namespace DesignTools { + +class AnimationCurve; +class KeyframeItem; +class GraphicsScene; + +class CurveItem : public QGraphicsObject +{ + Q_OBJECT + +public: + CurveItem(QGraphicsItem *parent = nullptr); + + CurveItem(unsigned int id, const AnimationCurve &curve, QGraphicsItem *parent = nullptr); + + ~CurveItem() override; + + enum { Type = ItemTypeCurve }; + + int type() const override; + + QRectF boundingRect() const override; + + bool contains(const QPointF &point) const override; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + + bool isDirty() const; + + bool hasSelection() const; + + unsigned int id() const; + + AnimationCurve curve() const; + + void setDirty(bool dirty); + + QRectF setComponentTransform(const QTransform &transform); + + void setStyle(const CurveEditorStyle &style); + + void connect(GraphicsScene *scene); + + void setIsUnderMouse(bool under); + +private: + QPainterPath path() const; + + unsigned int m_id; + + CurveItemStyleOption m_style; + + QTransform m_transform; + + std::vector<KeyframeItem *> m_keyframes; + + bool m_underMouse; + + bool m_itemDirty; + + mutable bool m_pathDirty; + + mutable QPainterPath m_path; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.cpp new file mode 100644 index 0000000000..40f675f3ec --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.cpp @@ -0,0 +1,277 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "curvesegment.h" +#include "utils.h" + +#include <qmath.h> + +#include <assert.h> + +namespace DesignTools { + +class CubicPolynomial +{ +public: + CubicPolynomial(double p0, double p1, double p2, double p3); + + std::vector<double> extrema() const; + + std::vector<double> roots() const; + +private: + double m_a; + double m_b; + double m_c; + double m_d; +}; + +CubicPolynomial::CubicPolynomial(double p0, double p1, double p2, double p3) + : m_a(p3 - 3.0 * p2 + 3.0 * p1 - p0) + , m_b(3.0 * p2 - 6.0 * p1 + 3.0 * p0) + , m_c(3.0 * p1 - 3.0 * p0) + , m_d(p0) +{} + +std::vector<double> CubicPolynomial::extrema() const +{ + std::vector<double> out; + + auto addValidValue = [&out](double value) { + if (!std::isnan(value) && !std::isinf(value)) + out.push_back(clamp(value, 0.0, 1.0)); + }; + + // Find the roots of the first derivative of y. + auto pd2 = (2.0 * m_b) / (3.0 * m_a) / 2.0; + auto q = m_c / (3.0 * m_a); + + auto radi = std::pow(pd2, 2.0) - q; + + auto x1 = -pd2 + std::sqrt(radi); + auto x2 = -pd2 - std::sqrt(radi); + + addValidValue(x1); + addValidValue(x2); + + return out; +} + +std::vector<double> CubicPolynomial::roots() const +{ + std::vector<double> out; + + auto addValidValue = [&out](double value) { + if (!(std::isnan(value) || std::isinf(value))) + out.push_back(value); + }; + + if (m_a == 0.0) { + // Linear + if (m_b == 0.0) { + if (m_c != 0.0) + out.push_back(-m_d / m_c); + // Quadratic + } else { + const double p = m_c / m_b / 2.0; + const double q = m_d / m_b; + addValidValue(-p + std::sqrt(std::pow(p, 2.0) - q)); + addValidValue(-p - std::sqrt(std::pow(p, 2.0) - q)); + } + // Cubic + } else { + const double p = 3.0 * m_a * m_c - std::pow(m_b, 2.0); + const double q = 2.0 * std::pow(m_b, 3.0) - 9.0 * m_a * m_b * m_c + + 27.0 * std::pow(m_a, 2.0) * m_d; + + auto disc = std::pow(q, 2.0) + 4.0 * std::pow(p, 3.0); + + auto toX = [&](double y) { return (y - m_b) / (3.0 * m_a); }; + + // One real solution. + if (disc >= 0) { + auto u = (1.0 / 2.0) + * std::cbrt(-4.0 * q + + 4.0 * std::sqrt(std::pow(q, 2.0) + 4.0 * std::pow(p, 3.0))); + auto v = (1.0 / 2.0) + * std::cbrt(-4.0 * q + - 4.0 * std::sqrt(std::pow(q, 2.0) + 4.0 * std::pow(p, 3.0))); + + addValidValue(toX(u + v)); + // Three real solutions. + } else { + auto phi = acos(-q / (2 * std::sqrt(-std::pow(p, 3.0)))); + auto y1 = std::sqrt(-p) * 2.0 * cos(phi / 3.0); + auto y2 = std::sqrt(-p) * 2.0 * cos((phi / 3.0) + (2.0 * M_PI / 3.0)); + auto y3 = std::sqrt(-p) * 2.0 * cos((phi / 3.0) + (4.0 * M_PI / 3.0)); + + addValidValue(toX(y1)); + addValidValue(toX(y2)); + addValidValue(toX(y3)); + } + } + return out; +} + +CurveSegment::CurveSegment() + : m_left() + , m_right() +{} + +CurveSegment::CurveSegment(const Keyframe &left, const Keyframe &right) + : m_left(left) + , m_right(right) +{} + +bool CurveSegment::containsX(double x) const +{ + return m_left.position().x() <= x && m_right.position().x() >= x; +} + +double evaluateForT(double t, double p0, double p1, double p2, double p3) +{ + assert(t >= 0. && t <= 1.); + + const double it = 1.0 - t; + + return p0 * std::pow(it, 3.0) + p1 * 3.0 * std::pow(it, 2.0) * t + + p2 * 3.0 * it * std::pow(t, 2.0) + p3 * std::pow(t, 3.0); +} + +QPointF CurveSegment::evaluate(double t) const +{ + const double x = evaluateForT( + t, + m_left.position().x(), + m_left.rightHandle().x(), + m_right.leftHandle().x(), + m_right.position().x()); + + const double y = evaluateForT( + t, + m_left.position().y(), + m_left.rightHandle().y(), + m_right.leftHandle().y(), + m_right.position().y()); + + return QPointF(x, y); +} + +std::vector<QPointF> CurveSegment::extrema() const +{ + std::vector<QPointF> out; + + auto polynomial = CubicPolynomial( + m_left.position().y(), + m_left.rightHandle().y(), + m_right.leftHandle().y(), + m_right.position().y()); + + for (double t : polynomial.extrema()) { + + const double x = evaluateForT( + t, + m_left.position().x(), + m_left.rightHandle().x(), + m_right.leftHandle().x(), + m_right.position().x()); + + const double y = evaluateForT( + t, + m_left.position().y(), + m_left.rightHandle().y(), + m_right.leftHandle().y(), + m_right.position().y()); + + out.push_back(QPointF(x, y)); + } + return out; +} + +std::vector<double> CurveSegment::yForX(double x) const +{ + std::vector<double> out; + + auto polynomial = CubicPolynomial( + m_left.position().x() - x, + m_left.rightHandle().x() - x, + m_right.leftHandle().x() - x, + m_right.position().x() - x); + + for (double t : polynomial.roots()) { + if (t < 0.0 || t > 1.0) + continue; + + const double y = evaluateForT( + t, + m_left.position().y(), + m_left.rightHandle().y(), + m_right.leftHandle().y(), + m_right.position().y()); + + out.push_back(y); + } + + return out; +} + +std::vector<double> CurveSegment::xForY(double y) const +{ + std::vector<double> out; + + auto polynomial = CubicPolynomial( + m_left.position().y() - y, + m_left.rightHandle().y() - y, + m_right.leftHandle().y() - y, + m_right.position().y() - y); + + for (double t : polynomial.roots()) { + if (t < 0.0 || t > 1.0) + continue; + + const double x = evaluateForT( + t, + m_left.position().x(), + m_left.rightHandle().x(), + m_right.leftHandle().x(), + m_right.position().x()); + + out.push_back(x); + } + + return out; +} + +void CurveSegment::setLeft(const Keyframe &frame) +{ + m_left = frame; +} + +void CurveSegment::setRight(const Keyframe &frame) +{ + m_right = frame; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.h b/src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.h new file mode 100644 index 0000000000..5dbce58bcc --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/curvesegment.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "keyframe.h" + +#include <vector> + +QT_BEGIN_NAMESPACE +class QPointF; +QT_END_NAMESPACE + +namespace DesignTools { + +class CurveSegment +{ +public: + CurveSegment(); + + CurveSegment(const Keyframe &first, const Keyframe &last); + + bool containsX(double x) const; + + QPointF evaluate(double t) const; + + std::vector<QPointF> extrema() const; + + std::vector<double> yForX(double x) const; + + std::vector<double> xForY(double y) const; + + void setLeft(const Keyframe &frame); + + void setRight(const Keyframe &frame); + +private: + Keyframe m_left; + + Keyframe m_right; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp new file mode 100644 index 0000000000..096e57aafa --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.cpp @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "graphicsscene.h" +#include "animationcurve.h" +#include "curveitem.h" +#include "graphicsview.h" +#include "handleitem.h" + +#include <QGraphicsSceneMouseEvent> + +namespace DesignTools { + +GraphicsScene::GraphicsScene(QObject *parent) + : QGraphicsScene(parent) + , m_dirty(true) + , m_limits() +{} + +bool GraphicsScene::empty() const +{ + return items().empty(); +} + +double GraphicsScene::minimumTime() const +{ + return limits().left(); +} + +double GraphicsScene::maximumTime() const +{ + return limits().right(); +} + +double GraphicsScene::minimumValue() const +{ + return limits().bottom(); +} + +double GraphicsScene::maximumValue() const +{ + return limits().top(); +} + +void GraphicsScene::addCurveItem(CurveItem *item) +{ + m_dirty = true; + addItem(item); + item->connect(this); +} + +void GraphicsScene::setComponentTransform(const QTransform &transform) +{ + QRectF bounds; + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) + bounds = bounds.united(curveItem->setComponentTransform(transform)); + } + + if (bounds.isNull()) { + if (GraphicsView *gview = graphicsView()) + bounds = gview->defaultRasterRect(); + } + + if (bounds.isValid()) + setSceneRect(bounds); +} + +void GraphicsScene::keyframeMoved(KeyframeItem *movedItem, const QPointF &direction) +{ + const auto itemList = items(); + for (auto *item : itemList) { + if (item == movedItem) + continue; + + if (auto *frameItem = qgraphicsitem_cast<KeyframeItem *>(item)) { + if (frameItem->selected()) + frameItem->moveKeyframe(direction); + } + } +} + +void GraphicsScene::handleMoved(KeyframeItem *frame, + HandleSlot handle, + double angle, + double deltaLength) +{ + const auto itemList = items(); + for (auto *item : itemList) { + if (item == frame) + continue; + + if (auto *frameItem = qgraphicsitem_cast<KeyframeItem *>(item)) { + if (frameItem->selected()) + frameItem->moveHandle(handle, angle, deltaLength); + } + } +} + +void GraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mouseMoveEvent(mouseEvent); + + if (hasActiveItem()) + return; + + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) + curveItem->setIsUnderMouse(curveItem->contains(mouseEvent->scenePos())); + } +} + +void GraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mouseReleaseEvent(mouseEvent); + + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) { + if (curveItem->contains(mouseEvent->scenePos())) + curveItem->setSelected(true); + + if (curveItem->isDirty()) { + emit curveChanged(curveItem->id(), curveItem->curve()); + curveItem->setDirty(false); + m_dirty = true; + } + } + } +} + +bool GraphicsScene::hasActiveKeyframe() const +{ + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *kitem = qgraphicsitem_cast<KeyframeItem *>(item)) { + if (kitem->activated()) + return true; + } + } + return false; +} + +bool GraphicsScene::hasActiveHandle() const +{ + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *hitem = qgraphicsitem_cast<HandleItem *>(item)) { + if (hitem->activated()) + return true; + } + } + return false; +} + +bool GraphicsScene::hasActiveItem() const +{ + return hasActiveKeyframe() || hasActiveHandle(); +} + +GraphicsView *GraphicsScene::graphicsView() const +{ + const QList<QGraphicsView *> viewList = views(); + for (auto &&view : viewList) { + if (GraphicsView *gview = qobject_cast<GraphicsView *>(view)) + return gview; + } + return nullptr; +} + +QRectF GraphicsScene::limits() const +{ + if (m_dirty) { + QPointF min(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()); + QPointF max(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest()); + + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) { + auto curve = curveItem->curve(); + if (min.x() > curve.minimumTime()) + min.rx() = curve.minimumTime(); + + if (min.y() > curve.minimumValue()) + min.ry() = curve.minimumValue(); + + if (max.x() < curve.maximumTime()) + max.rx() = curve.maximumTime(); + + if (max.y() < curve.maximumValue()) + max.ry() = curve.maximumValue(); + } + } + + m_limits = QRectF(QPointF(min.x(), max.y()), QPointF(max.x(), min.y())); + m_dirty = false; + } + return m_limits; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h new file mode 100644 index 0000000000..981c326b5a --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsscene.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "keyframeitem.h" + +#include <QGraphicsScene> + +namespace DesignTools { + +class AnimationCurve; +class CurveItem; +class GraphicsView; + +class GraphicsScene : public QGraphicsScene +{ + Q_OBJECT + +signals: + void curveChanged(unsigned int id, const AnimationCurve &curve); + +public: + GraphicsScene(QObject *parent = nullptr); + + bool empty() const; + + bool hasActiveKeyframe() const; + + bool hasActiveHandle() const; + + bool hasActiveItem() const; + + double minimumTime() const; + + double maximumTime() const; + + double minimumValue() const; + + double maximumValue() const; + + void addCurveItem(CurveItem *item); + + void setComponentTransform(const QTransform &transform); + + void keyframeMoved(KeyframeItem *item, const QPointF &direction); + + void handleMoved(KeyframeItem *frame, HandleSlot handle, double angle, double deltaLength); + +protected: + void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override; + + void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) override; + +private: + using QGraphicsScene::addItem; + + GraphicsView *graphicsView() const; + + QRectF limits() const; + + mutable bool m_dirty; + + mutable QRectF m_limits; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp new file mode 100644 index 0000000000..ae60888d1f --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp @@ -0,0 +1,523 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "graphicsview.h" +#include "curveeditormodel.h" +#include "curveitem.h" +#include "utils.h" + +#include <QAction> +#include <QMenu> +#include <QResizeEvent> +#include <QScrollBar> + +#include <cmath> + +namespace DesignTools { + +GraphicsView::GraphicsView(CurveEditorModel *model, QWidget *parent) + : QGraphicsView(parent) + , m_zoomX(0.0) + , m_zoomY(0.0) + , m_transform() + , m_scene() + , m_model(model) + , m_playhead(this) + , m_selector() + , m_style(model->style()) + , m_dialog(m_style) +{ + model->setGraphicsView(this); + + setScene(&m_scene); + setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + setResizeAnchor(QGraphicsView::NoAnchor); + setTransformationAnchor(QGraphicsView::NoAnchor); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + + connect(&m_dialog, &CurveEditorStyleDialog::styleChanged, this, &GraphicsView::setStyle); + + auto itemSlot = [this](unsigned int id, const AnimationCurve &curve) { + applyZoom(m_zoomX, m_zoomY); + m_model->setCurve(id, curve); + }; + + connect(&m_scene, &GraphicsScene::curveChanged, itemSlot); + + applyZoom(m_zoomX, m_zoomY); + update(); +} + +CurveEditorModel *GraphicsView::model() const +{ + return m_model; +} + +CurveEditorStyle GraphicsView::editorStyle() const +{ + return m_style; +} + +bool GraphicsView::hasActiveItem() const +{ + return m_scene.hasActiveItem(); +} + +bool GraphicsView::hasActiveHandle() const +{ + return m_scene.hasActiveHandle(); +} + +double GraphicsView::minimumTime() const +{ + bool check = m_model->minimumTime() < m_scene.minimumTime(); + return check ? m_model->minimumTime() : m_scene.minimumTime(); +} + +double GraphicsView::maximumTime() const +{ + bool check = m_model->maximumTime() > m_scene.maximumTime(); + return check ? m_model->maximumTime() : m_scene.maximumTime(); +} + +double GraphicsView::minimumValue() const +{ + return m_scene.empty() ? -1.0 : m_scene.minimumValue(); +} + +double GraphicsView::maximumValue() const +{ + return m_scene.empty() ? 1.0 : m_scene.maximumValue(); +} + +double GraphicsView::zoomX() const +{ + return m_zoomX; +} + +double GraphicsView::zoomY() const +{ + return m_zoomY; +} + +QRectF GraphicsView::canvasRect() const +{ + QRect r = viewport()->rect().adjusted( + m_style.valueAxisWidth + m_style.canvasMargin, + m_style.timeAxisHeight + m_style.canvasMargin, + -m_style.canvasMargin, + -m_style.canvasMargin); + + return mapToScene(r).boundingRect(); +} + +QRectF GraphicsView::timeScaleRect() const +{ + QRect vp(viewport()->rect()); + QPoint tl = vp.topLeft() + QPoint(m_style.valueAxisWidth, 0); + QPoint br = vp.topRight() + QPoint(0, m_style.timeAxisHeight); + return mapToScene(QRect(tl, br)).boundingRect(); +} + +QRectF GraphicsView::valueScaleRect() const +{ + QRect vp(viewport()->rect()); + QPoint tl = vp.topLeft() + QPoint(0, m_style.timeAxisHeight); + QPoint br = vp.bottomLeft() + QPoint(m_style.valueAxisWidth, 0); + return mapToScene(QRect(tl, br)).boundingRect(); +} + +QRectF GraphicsView::defaultRasterRect() const +{ + QPointF topLeft(mapTimeToX(minimumTime()), mapValueToY(maximumValue())); + QPointF bottomRight(mapTimeToX(maximumTime()), mapValueToY(minimumValue())); + return QRectF(topLeft, bottomRight); +} + +void GraphicsView::setStyle(const CurveEditorStyle &style) +{ + m_style = style; + + const auto itemList = items(); + for (auto *item : itemList) { + if (auto *curveItem = qgraphicsitem_cast<CurveItem *>(item)) + curveItem->setStyle(style); + } + + applyZoom(m_zoomX, m_zoomY); + viewport()->update(); +} + +void GraphicsView::setZoomX(double zoom, const QPoint &pivot) +{ + applyZoom(zoom, m_zoomY, pivot); + viewport()->update(); +} + +void GraphicsView::setZoomY(double zoom, const QPoint &pivot) +{ + applyZoom(m_zoomX, zoom, pivot); + viewport()->update(); +} + +void GraphicsView::setCurrentFrame(int frame) +{ + int clampedFrame = clamp(frame, m_model->minimumTime(), m_model->maximumTime()); + m_playhead.moveToFrame(clampedFrame, this); + viewport()->update(); +} + +void GraphicsView::scrollContent(double x, double y) +{ + QScrollBar *hs = horizontalScrollBar(); + QScrollBar *vs = verticalScrollBar(); + hs->setValue(hs->value() + x); + vs->setValue(vs->value() + y); +} + +void GraphicsView::reset(const std::vector<CurveItem *> &items) +{ + m_scene.clear(); + for (auto *item : items) + m_scene.addCurveItem(item); + + applyZoom(m_zoomX, m_zoomY); + viewport()->update(); +} + +void GraphicsView::resizeEvent(QResizeEvent *event) +{ + QGraphicsView::resizeEvent(event); + applyZoom(m_zoomX, m_zoomY); +} + +void GraphicsView::keyPressEvent(QKeyEvent *event) +{ + Shortcut shortcut(event->modifiers(), static_cast<Qt::Key>(event->key())); + if (shortcut == m_style.shortcuts.frameAll) + applyZoom(0.0, 0.0); +} + +void GraphicsView::mousePressEvent(QMouseEvent *event) +{ + if (m_playhead.mousePress(globalToScene(event->globalPos()))) + return; + + Shortcut shortcut(event); + if (shortcut == Shortcut(Qt::LeftButton)) { + QPointF pos = mapToScene(event->pos()); + if (timeScaleRect().contains(pos)) { + setCurrentFrame(std::round(mapXtoTime(pos.x()))); + event->accept(); + return; + } + } + + QGraphicsView::mousePressEvent(event); + + m_selector.mousePress(event, this); +} + +void GraphicsView::mouseMoveEvent(QMouseEvent *event) +{ + if (m_playhead.mouseMove(globalToScene(event->globalPos()), this)) + return; + + QGraphicsView::mouseMoveEvent(event); + + m_selector.mouseMove(event, this, m_playhead); +} + +void GraphicsView::mouseReleaseEvent(QMouseEvent *event) +{ + QGraphicsView::mouseReleaseEvent(event); + + m_playhead.mouseRelease(this); + m_selector.mouseRelease(event, this); + this->viewport()->update(); +} + +void GraphicsView::wheelEvent(QWheelEvent *event) +{ + if (event->modifiers().testFlag(Qt::AltModifier)) + return; + + QGraphicsView::wheelEvent(event); +} + +void GraphicsView::contextMenuEvent(QContextMenuEvent *event) +{ + if (event->modifiers() != Qt::NoModifier) + return; + + auto openStyleEditor = [this]() { m_dialog.show(); }; + + QMenu menu; + QAction *openEditorAction = menu.addAction(tr("Open Style Editor")); + connect(openEditorAction, &QAction::triggered, openStyleEditor); + + menu.exec(event->globalPos()); +} + +void GraphicsView::drawForeground(QPainter *painter, const QRectF &rect) +{ + QRectF abscissa = timeScaleRect(); + if (abscissa.isValid()) + drawTimeScale(painter, abscissa); + + auto ordinate = valueScaleRect(); + if (ordinate.isValid()) + drawValueScale(painter, ordinate); + + m_playhead.paint(painter, this); + + painter->fillRect(QRectF(rect.topLeft(), abscissa.bottomLeft()), + m_style.backgroundAlternateBrush); + + m_selector.paint(painter); +} + +void GraphicsView::drawBackground(QPainter *painter, const QRectF &rect) +{ + painter->fillRect(rect, m_style.backgroundBrush); + painter->fillRect(scene()->sceneRect(), m_style.backgroundAlternateBrush); + + drawGrid(painter, rect); + drawExtremaX(painter, rect); + drawExtremaY(painter, rect); +} + +int GraphicsView::mapTimeToX(double time) const +{ + return std::round(time * scaleX(m_transform)); +} + +int GraphicsView::mapValueToY(double y) const +{ + return std::round(y * scaleY(m_transform)); +} + +double GraphicsView::mapXtoTime(int x) const +{ + return static_cast<double>(x) / scaleX(m_transform); +} + +double GraphicsView::mapYtoValue(int y) const +{ + return static_cast<double>(y) / scaleY(m_transform); +} + +QPointF GraphicsView::globalToScene(const QPoint &point) const +{ + return mapToScene(viewport()->mapFromGlobal(point)); +} + +QPointF GraphicsView::globalToRaster(const QPoint &point) const +{ + QPointF scene = globalToScene(point); + return QPointF(mapXtoTime(scene.x()), mapYtoValue(scene.y())); +} + +void GraphicsView::applyZoom(double x, double y, const QPoint &pivot) +{ + QPointF pivotRaster(globalToRaster(pivot)); + + m_zoomX = clamp(x, 0.0, 1.0); + m_zoomY = clamp(y, 0.0, 1.0); + + double minTime = minimumTime(); + double maxTime = maximumTime(); + + double minValue = minimumValue(); + double maxValue = maximumValue(); + + QRectF canvas = canvasRect(); + + double xZoomedOut = canvas.width() / (maxTime - minTime); + double xZoomedIn = m_style.zoomInWidth; + double scaleX = lerp(clamp(m_zoomX, 0.0, 1.0), xZoomedOut, xZoomedIn); + + double yZoomedOut = canvas.height() / (maxValue - minValue); + double yZoomedIn = m_style.zoomInHeight; + double scaleY = lerp(clamp(m_zoomY, 0.0, 1.0), -yZoomedOut, -yZoomedIn); + + m_transform = QTransform::fromScale(scaleX, scaleY); + + m_scene.setComponentTransform(m_transform); + + QRectF sr = m_scene.sceneRect().adjusted( + -m_style.valueAxisWidth - m_style.canvasMargin, + -m_style.timeAxisHeight - m_style.canvasMargin, + m_style.canvasMargin, + m_style.canvasMargin); + + setSceneRect(sr); + + m_playhead.resize(this); + + if (!pivot.isNull()) { + QPointF deltaTransformed = pivotRaster - globalToRaster(pivot); + scrollContent(mapTimeToX(deltaTransformed.x()), mapValueToY(deltaTransformed.y())); + } +} + +void GraphicsView::drawGrid(QPainter *painter, const QRectF &rect) +{ + QRectF gridRect = rect.adjusted( + m_style.valueAxisWidth + m_style.canvasMargin, + m_style.timeAxisHeight + m_style.canvasMargin, + -m_style.canvasMargin, + -m_style.canvasMargin); + + if (!gridRect.isValid()) + return; + + auto drawVerticalLine = [painter, gridRect](double position) { + painter->drawLine(position, gridRect.top(), position, gridRect.bottom()); + }; + + painter->save(); + painter->setPen(m_style.gridColor); + + double timeIncrement = timeLabelInterval(painter, m_model->maximumTime()); + for (double i = minimumTime(); i <= maximumTime(); i += timeIncrement) + drawVerticalLine(mapTimeToX(i)); + + painter->restore(); +} + +void GraphicsView::drawExtremaX(QPainter *painter, const QRectF &rect) +{ + auto drawVerticalLine = [rect, painter](double position) { + painter->drawLine(position, rect.top(), position, rect.bottom()); + }; + + painter->save(); + painter->setPen(Qt::red); + drawVerticalLine(mapTimeToX(m_model->minimumTime())); + drawVerticalLine(mapTimeToX(m_model->maximumTime())); + painter->restore(); +} + +void GraphicsView::drawExtremaY(QPainter *painter, const QRectF &rect) +{ + if (m_scene.empty()) + return; + + auto drawHorizontalLine = [rect, painter](double position) { + painter->drawLine(rect.left(), position, rect.right(), position); + }; + + painter->save(); + painter->setPen(Qt::blue); + drawHorizontalLine(mapValueToY(m_scene.minimumValue())); + drawHorizontalLine(mapValueToY(m_scene.maximumValue())); + + drawHorizontalLine(mapValueToY(0.0)); + + painter->restore(); +} + +void GraphicsView::drawTimeScale(QPainter *painter, const QRectF &rect) +{ + painter->save(); + painter->setPen(m_style.fontColor); + painter->fillRect(rect, m_style.backgroundAlternateBrush); + + QFontMetrics fm(painter->font()); + + auto paintLabeledTick = [this, painter, rect, fm](double time) { + QString timeText = QString("%1").arg(time); + + int position = mapTimeToX(time); + + QRect textRect = fm.boundingRect(timeText); + textRect.moveCenter(QPoint(position, rect.center().y())); + + painter->drawText(textRect, Qt::AlignCenter, timeText); + painter->drawLine(position, rect.bottom() - 2, position, textRect.bottom() + 2); + }; + + double timeIncrement = timeLabelInterval(painter, maximumTime()); + for (double i = minimumTime(); i <= maximumTime(); i += timeIncrement) + paintLabeledTick(i); + + painter->restore(); +} + +void GraphicsView::drawValueScale(QPainter *painter, const QRectF &rect) +{ + painter->save(); + painter->setPen(m_style.fontColor); + painter->fillRect(rect, m_style.backgroundAlternateBrush); + + QFontMetrics fm(painter->font()); + auto paintLabeledTick = [this, painter, rect, fm](double value) { + QString valueText = QString("%1").arg(value); + + int position = mapValueToY(value); + + QRect textRect = fm.boundingRect(valueText); + textRect.moveCenter(QPoint(rect.center().x(), position)); + painter->drawText(textRect, Qt::AlignCenter, valueText); + }; + + paintLabeledTick(minimumValue()); + paintLabeledTick(maximumValue()); + painter->restore(); +} + +double GraphicsView::timeLabelInterval(QPainter *painter, double maxTime) +{ + QFontMetrics fm(painter->font()); + int minTextSpacing = fm.width(QString("X%1X").arg(maxTime)); + + int deltaTime = 1; + int nextFactor = 5; + + double tickDistance = mapTimeToX(deltaTime); + + while (true) { + if (tickDistance == 0 && deltaTime > maxTime) + return maxTime; + + if (tickDistance > minTextSpacing) + break; + + deltaTime *= nextFactor; + tickDistance = mapTimeToX(deltaTime); + + if (nextFactor == 5) + nextFactor = 2; + else + nextFactor = 5; + } + + return deltaTime; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.h b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.h new file mode 100644 index 0000000000..1975e3696d --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "curveeditorstyle.h" +#include "curveeditorstyledialog.h" +#include "graphicsscene.h" +#include "playhead.h" +#include "selector.h" + +#include <QGraphicsView> + +namespace DesignTools { + +class CurveItem; +class CurveEditorModel; +class Playhead; + +class GraphicsView : public QGraphicsView +{ + Q_OBJECT + + friend class Playhead; + +public: + GraphicsView(CurveEditorModel *model, QWidget *parent = nullptr); + + CurveEditorModel *model() const; + + CurveEditorStyle editorStyle() const; + + bool hasActiveItem() const; + + bool hasActiveHandle() const; + + int mapTimeToX(double time) const; + + int mapValueToY(double value) const; + + double mapXtoTime(int x) const; + + double mapYtoValue(int y) const; + + QPointF globalToScene(const QPoint &point) const; + + QPointF globalToRaster(const QPoint &point) const; + + double minimumTime() const; + + double maximumTime() const; + + double minimumValue() const; + + double maximumValue() const; + + double zoomX() const; + + double zoomY() const; + + QRectF canvasRect() const; + + QRectF timeScaleRect() const; + + QRectF valueScaleRect() const; + + QRectF defaultRasterRect() const; + + void setStyle(const CurveEditorStyle &style); + + void setZoomX(double zoom, const QPoint &pivot = QPoint()); + + void setZoomY(double zoom, const QPoint &pivot = QPoint()); + + void setCurrentFrame(int frame); + + void scrollContent(double x, double y); + + void reset(const std::vector<CurveItem *> &items); + +protected: + void resizeEvent(QResizeEvent *event) override; + + void keyPressEvent(QKeyEvent *event) override; + + void mousePressEvent(QMouseEvent *event) override; + + void mouseMoveEvent(QMouseEvent *event) override; + + void mouseReleaseEvent(QMouseEvent *event) override; + + void wheelEvent(QWheelEvent *event) override; + + void contextMenuEvent(QContextMenuEvent *event) override; + + void drawForeground(QPainter *painter, const QRectF &rect) override; + + void drawBackground(QPainter *painter, const QRectF &rect) override; + +private: + void applyZoom(double x, double y, const QPoint &pivot = QPoint()); + + void drawGrid(QPainter *painter, const QRectF &rect); + + void drawExtremaX(QPainter *painter, const QRectF &rect); + + void drawExtremaY(QPainter *painter, const QRectF &rect); + + void drawTimeScale(QPainter *painter, const QRectF &rect); + + void drawValueScale(QPainter *painter, const QRectF &rect); + + double timeLabelInterval(QPainter *painter, double maxTime); + +private: + double m_zoomX; + + double m_zoomY; + + QTransform m_transform; + + GraphicsScene m_scene; + + CurveEditorModel *m_model; + + Playhead m_playhead; + + Selector m_selector; + + CurveEditorStyle m_style; + + CurveEditorStyleDialog m_dialog; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.cpp new file mode 100644 index 0000000000..c54b26e279 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "handleitem.h" +#include "utils.h" + +#include <QPainter> + +namespace DesignTools { + +struct HandleGeometry +{ + HandleGeometry(const QPointF &pos, const HandleItemStyleOption &style) + { + QPointF topLeft(-style.size / 2.0, -style.size / 2.0); + handle = QRectF(topLeft, -topLeft); + toKeyframe = QLineF(QPointF(0.0, 0.0), -pos); + angle = -toKeyframe.angle() + 45.0; + } + + QRectF handle; + + QLineF toKeyframe; + + double angle; +}; + +HandleItem::HandleItem(QGraphicsItem *parent) + : SelectableItem(parent) + , m_style() +{ + setFlag(QGraphicsItem::ItemStacksBehindParent, true); +} + +HandleItem::~HandleItem() {} + +int HandleItem::type() const +{ + return Type; +} + +QRectF HandleItem::boundingRect() const +{ + HandleGeometry geom(pos(), m_style); + + QTransform transform; + transform.rotate(geom.angle); + + QRectF bounds = bbox(geom.handle, transform); + grow(bounds, -pos()); + return bounds; +} + +void HandleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + + QColor handleColor(isSelected() ? m_style.selectionColor : m_style.color); + + HandleGeometry geom(pos(), m_style); + + QPen pen = painter->pen(); + pen.setWidthF(m_style.lineWidth); + pen.setColor(handleColor); + + painter->save(); + painter->setPen(pen); + + painter->drawLine(geom.toKeyframe); + painter->rotate(geom.angle); + painter->fillRect(geom.handle, handleColor); + + painter->restore(); +} + +void HandleItem::setStyle(const CurveEditorStyle &style) +{ + m_style = style.handleStyle; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.h b/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.h new file mode 100644 index 0000000000..4c9126c629 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "curveeditorstyle.h" +#include "selectableitem.h" + +namespace DesignTools { + +class HandleItem : public SelectableItem +{ + Q_OBJECT + +public: + HandleItem(QGraphicsItem *parent); + + ~HandleItem() override; + + enum { Type = ItemTypeHandle }; + + int type() const override; + + QRectF boundingRect() const override; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + + void setStyle(const CurveEditorStyle &style); + +private: + HandleItemStyleOption m_style; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp new file mode 100644 index 0000000000..94cdbbcbb1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp @@ -0,0 +1,251 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "keyframeitem.h" +#include "handleitem.h" + +#include <QPainter> + +#include <cmath> + +namespace DesignTools { + +KeyframeItem::KeyframeItem(QGraphicsItem *parent) + : SelectableItem(parent) + , m_frame() +{} + +KeyframeItem::KeyframeItem(const Keyframe &keyframe, QGraphicsItem *parent) + : SelectableItem(parent) + , m_transform() + , m_frame(keyframe) + , m_left(keyframe.hasLeftHandle() ? new HandleItem(this) : nullptr) + , m_right(keyframe.hasRightHandle() ? new HandleItem(this) : nullptr) +{ + auto updatePosition = [this]() { this->updatePosition(true); }; + connect(this, &QGraphicsObject::xChanged, updatePosition); + connect(this, &QGraphicsObject::yChanged, updatePosition); + + if (m_left) { + m_left->setPos(m_frame.leftHandle() - m_frame.position()); + auto updateLeftHandle = [this]() { updateHandle(m_left); }; + connect(m_left, &QGraphicsObject::xChanged, updateLeftHandle); + connect(m_left, &QGraphicsObject::yChanged, updateLeftHandle); + m_left->hide(); + } + + if (m_right) { + m_right->setPos(m_frame.rightHandle() - m_frame.position()); + auto updateRightHandle = [this]() { updateHandle(m_right); }; + connect(m_right, &QGraphicsObject::xChanged, updateRightHandle); + connect(m_right, &QGraphicsObject::yChanged, updateRightHandle); + m_right->hide(); + } + + setPos(m_frame.position()); +} + +int KeyframeItem::type() const +{ + return Type; +} + +QRectF KeyframeItem::boundingRect() const +{ + QPointF topLeft(-m_style.size / 2.0, -m_style.size / 2.0); + return QRectF(topLeft, -topLeft); +} + +void KeyframeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + + QPen pen = painter->pen(); + pen.setColor(Qt::black); + + painter->save(); + painter->setPen(pen); + painter->setBrush(selected() ? Qt::red : m_style.color); + painter->drawEllipse(boundingRect()); + + painter->restore(); +} + +KeyframeItem::~KeyframeItem() {} + +Keyframe KeyframeItem::keyframe() const +{ + return m_frame; +} + +void KeyframeItem::setComponentTransform(const QTransform &transform) +{ + m_transform = transform; + + if (m_left) + m_left->setPos(m_transform.map(m_frame.leftHandle() - m_frame.position())); + + if (m_right) + m_right->setPos(m_transform.map(m_frame.rightHandle() - m_frame.position())); + + setPos(m_transform.map(m_frame.position())); +} + +void KeyframeItem::setStyle(const CurveEditorStyle &style) +{ + m_style = style.keyframeStyle; + + if (m_left) + m_left->setStyle(style); + + if (m_right) + m_right->setStyle(style); +} + +void KeyframeItem::updatePosition(bool update) +{ + bool ok = false; + QPointF position = m_transform.inverted(&ok).map(pos()); + + if (!ok) + return; + + QPointF oldPosition = m_frame.position(); + m_frame.setPosition(position); + + if (m_left) + updateHandle(m_left, false); + + if (m_right) + updateHandle(m_right, false); + + if (update) { + emit redrawCurve(); + emit keyframeMoved(this, position - oldPosition); + } +} + +void KeyframeItem::moveKeyframe(const QPointF &direction) +{ + this->blockSignals(true); + setPos(m_transform.map(m_frame.position() + direction)); + updatePosition(false); + this->blockSignals(false); + emit redrawCurve(); +} + +void KeyframeItem::moveHandle(HandleSlot handle, double deltaAngle, double deltaLength) +{ + auto move = [this, deltaAngle, deltaLength](HandleItem *item) { + QLineF current(QPointF(0.0, 0.0), item->pos()); + current.setAngle(current.angle() + deltaAngle); + current.setLength(current.length() + deltaLength); + item->setPos(current.p2()); + updateHandle(item, false); + }; + + this->blockSignals(true); + + if (handle == HandleSlot::Left) + move(m_left); + else if (handle == HandleSlot::Right) + move(m_right); + + this->blockSignals(false); + + emit redrawCurve(); +} + +void KeyframeItem::updateHandle(HandleItem *handle, bool emitChanged) +{ + bool ok = false; + + QPointF handlePosition = m_transform.inverted(&ok).map(handle->pos()); + + if (!ok) + return; + + QPointF oldPosition; + QPointF newPosition; + HandleSlot slot = HandleSlot::Undefined; + if (handle == m_left) { + slot = HandleSlot::Left; + oldPosition = m_frame.leftHandle(); + m_frame.setLeftHandle(m_frame.position() + handlePosition); + newPosition = m_frame.leftHandle(); + } else { + slot = HandleSlot::Right; + oldPosition = m_frame.rightHandle(); + m_frame.setRightHandle(m_frame.position() + handlePosition); + newPosition = m_frame.rightHandle(); + } + + if (emitChanged) { + QLineF oldLine(m_frame.position(), oldPosition); + QLineF newLine(m_frame.position(), newPosition); + + QLineF mappedOld = m_transform.map(oldLine); + QLineF mappedNew = m_transform.map(newLine); + + auto angle = mappedOld.angleTo(mappedNew); + auto deltaLength = mappedNew.length() - mappedOld.length(); + + emit redrawCurve(); + emit handleMoved(this, slot, angle, deltaLength); + } +} + +QVariant KeyframeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionChange) { + bool ok; + QPointF position = m_transform.inverted(&ok).map(value.toPointF()); + if (ok) { + position.setX(std::round(position.x())); + return QVariant(m_transform.map(position)); + } + } + + return QGraphicsItem::itemChange(change, value); +} + +void KeyframeItem::selectionCallback() +{ + auto setHandleVisibility = [](HandleItem *handle, bool visible) { + if (handle) + handle->setVisible(visible); + }; + + if (selected()) { + setHandleVisibility(m_left, true); + setHandleVisibility(m_right, true); + } else { + setHandleVisibility(m_left, false); + setHandleVisibility(m_right, false); + } +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.h b/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.h new file mode 100644 index 0000000000..ae65be1e9b --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "curveeditorstyle.h" +#include "keyframe.h" +#include "selectableitem.h" + +#include <QGraphicsObject> + +namespace DesignTools { + +class HandleItem; + +enum class HandleSlot { Undefined, Left, Right }; + +class KeyframeItem : public SelectableItem +{ + Q_OBJECT + +signals: + void redrawCurve(); + + void keyframeMoved(KeyframeItem *item, const QPointF &direction); + + void handleMoved(KeyframeItem *frame, HandleSlot handle, double angle, double deltaLength); + +public: + KeyframeItem(QGraphicsItem *parent = nullptr); + + KeyframeItem(const Keyframe &keyframe, QGraphicsItem *parent = nullptr); + + ~KeyframeItem() override; + + enum { Type = ItemTypeKeyframe }; + + int type() const override; + + QRectF boundingRect() const override; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + + Keyframe keyframe() const; + + void setComponentTransform(const QTransform &transform); + + void setStyle(const CurveEditorStyle &style); + + void moveKeyframe(const QPointF &direction); + + void moveHandle(HandleSlot handle, double deltaAngle, double deltaLength); + +protected: + QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) override; + + void selectionCallback() override; + +private: + void updatePosition(bool emit = true); + + void updateHandle(HandleItem *handle, bool emit = true); + +private: + QTransform m_transform; + + KeyframeItemStyleOption m_style; + + Keyframe m_frame; + + HandleItem *m_left; + + HandleItem *m_right; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/playhead.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/playhead.cpp new file mode 100644 index 0000000000..e2e6d21274 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/playhead.cpp @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "playhead.h" +#include "curveeditormodel.h" +#include "graphicsview.h" + +#include <QApplication> +#include <QGraphicsScene> +#include <QPainter> + +#include <cmath> + +namespace DesignTools { + +constexpr double g_playheadMargin = 5.0; + +Playhead::Playhead(GraphicsView *view) + : m_frame(0) + , m_moving(false) + , m_rect() + , m_timer() +{ + m_timer.setSingleShot(true); + m_timer.setInterval(30); + QObject::connect(&m_timer, &QTimer::timeout, view, [this, view]() { + if (QApplication::mouseButtons() == Qt::LeftButton) + mouseMoveOutOfBounds(view); + }); +} + +int Playhead::currentFrame() const +{ + return m_frame; +} + +void Playhead::moveToFrame(int frame, GraphicsView *view) +{ + m_frame = frame; + m_rect.moveCenter(QPointF(view->mapTimeToX(m_frame), m_rect.center().y())); +} + +void Playhead::resize(GraphicsView *view) +{ + QRectF viewRect = view->mapToScene(view->viewport()->rect()).boundingRect(); + + CurveEditorStyle style = view->editorStyle(); + + QPointF tlr(style.valueAxisWidth, style.timeAxisHeight - style.playhead.width); + QPointF brr(style.valueAxisWidth + style.playhead.width, -g_playheadMargin); + + QPointF tl = viewRect.topLeft() + tlr; + QPointF br = viewRect.bottomLeft() + brr; + + m_rect = QRectF(tl, br); + + moveToFrame(m_frame, view); +} + +bool Playhead::mousePress(const QPointF &pos) +{ + QRectF hitRect = m_rect; + hitRect.setBottom(hitRect.top() + hitRect.width()); + + m_moving = hitRect.contains(pos); + + return m_moving; +} + +bool Playhead::mouseMove(const QPointF &pos, GraphicsView *view) +{ + if (m_moving) { + CurveEditorStyle style = view->editorStyle(); + + QRectF canvas = view->canvasRect().adjusted(0.0, -style.timeAxisHeight, 0.0, 0.0); + + if (canvas.contains(pos)) + view->setCurrentFrame(std::round(view->mapXtoTime(pos.x()))); + else if (!m_timer.isActive()) + m_timer.start(); + } + + return m_moving; +} + +void Playhead::mouseMoveOutOfBounds(GraphicsView *view) +{ + if (QApplication::mouseButtons() != Qt::LeftButton) + return; + + CurveEditorStyle style = view->editorStyle(); + QRectF canvas = view->canvasRect(); + QPointF pos = view->globalToScene(QCursor::pos()); + + if (pos.x() > canvas.right()) { + double speed = (pos.x() - canvas.right()); + double nextCenter = m_rect.center().x() + speed; + double frame = std::round(view->mapXtoTime(nextCenter)); + view->setCurrentFrame(frame); + + double framePosition = view->mapTimeToX(frame); + double rightSideOut = framePosition + style.playhead.width / 2.0 + style.canvasMargin; + double overshoot = rightSideOut - canvas.right(); + view->scrollContent(overshoot, 0.0); + + } else if (pos.x() < canvas.left()) { + double speed = (canvas.left() - pos.x()); + double nextCenter = m_rect.center().x() - speed; + double frame = std::round(view->mapXtoTime(nextCenter)); + view->setCurrentFrame(frame); + + double framePosition = view->mapTimeToX(frame); + double leftSideOut = framePosition - style.playhead.width / 2.0 - style.canvasMargin; + double undershoot = canvas.left() - leftSideOut; + view->scrollContent(-undershoot, 0.0); + } + + m_timer.start(); +} + +void Playhead::mouseRelease(GraphicsView *view) +{ + if (m_moving) + emit view->model()->currentFrameChanged(m_frame); + + m_moving = false; +} + +void Playhead::paint(QPainter *painter, GraphicsView *view) const +{ + CurveEditorStyle style = view->editorStyle(); + + painter->save(); + painter->setPen(style.playhead.color); + painter->setRenderHint(QPainter::Antialiasing, true); + + QRectF rect = m_rect; + rect.setBottom(m_rect.top() + m_rect.width()); + + QPointF top(rect.center().x(), rect.top()); + QPointF right(rect.right(), rect.top()); + QPointF bottom(rect.center().x(), rect.bottom()); + QPointF left(rect.left(), rect.top()); + + QLineF rightToBottom(right, bottom); + rightToBottom.setLength(style.playhead.radius); + + QLineF leftToBottom(left, bottom); + leftToBottom.setLength(style.playhead.radius); + + QPainterPath path(top); + path.lineTo(right - QPointF(style.playhead.radius, 0.)); + path.quadTo(right, rightToBottom.p2()); + path.lineTo(bottom); + path.lineTo(leftToBottom.p2()); + path.quadTo(left, left + QPointF(style.playhead.radius, 0.)); + path.closeSubpath(); + + painter->fillPath(path, style.playhead.color); + painter->drawLine(top + QPointF(0., 5.), QPointF(m_rect.center().x(), m_rect.bottom())); + + painter->restore(); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/playhead.h b/src/plugins/qmldesigner/components/curveeditor/detail/playhead.h new file mode 100644 index 0000000000..28d2a21a5c --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/playhead.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QRectF> +#include <QTimer> + +QT_BEGIN_NAMESPACE +class QPainter; +QT_END_NAMESPACE + +namespace DesignTools { + +class GraphicsView; + +class Playhead +{ +public: + Playhead(GraphicsView *view); + + int currentFrame() const; + + void paint(QPainter *painter, GraphicsView *view) const; + + void moveToFrame(int frame, GraphicsView *view); + + void resize(GraphicsView *view); + + bool mousePress(const QPointF &pos); + + bool mouseMove(const QPointF &pos, GraphicsView *view); + + void mouseRelease(GraphicsView *view); + +private: + void mouseMoveOutOfBounds(GraphicsView *view); + + int m_frame; + + bool m_moving; + + QRectF m_rect; + + QTimer m_timer; + + GraphicsView *m_view; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.cpp new file mode 100644 index 0000000000..fb61682090 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "selectableitem.h" +#include "keyframeitem.h" + +#include <QDebug> + +namespace DesignTools { + +SelectableItem::SelectableItem(QGraphicsItem *parent) + : QGraphicsObject(parent) + , m_active(false) + , m_selected(false) + , m_preSelected(SelectionMode::Undefined) +{ + setFlag(QGraphicsItem::ItemIsSelectable, false); + + setFlag(QGraphicsItem::ItemIsMovable, true); + setFlag(QGraphicsItem::ItemIgnoresTransformations, true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); +} + +SelectableItem::~SelectableItem() {} + +bool SelectableItem::activated() const +{ + return m_active; +} + +bool SelectableItem::selected() const +{ + switch (m_preSelected) { + case SelectionMode::Clear: + return false; + case SelectionMode::New: + return true; + case SelectionMode::Add: + return true; + case SelectionMode::Remove: + return false; + case SelectionMode::Toggle: + return !m_selected; + default: + return m_selected; + } + + return false; +} + +void SelectableItem::setActivated(bool active) +{ + m_active = active; +} + +void SelectableItem::setPreselected(SelectionMode mode) +{ + m_preSelected = mode; + selectionCallback(); +} + +void SelectableItem::applyPreselection() +{ + m_selected = selected(); + m_preSelected = SelectionMode::Undefined; +} + +void SelectableItem::selectionCallback() {} + +void SelectableItem::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + m_active = true; + QGraphicsObject::mousePressEvent(event); +} + +void SelectableItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (type() == KeyframeItem::Type && !selected()) + return; + + QGraphicsObject::mouseMoveEvent(event); +} + +void SelectableItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + m_active = false; + QGraphicsObject::mouseReleaseEvent(event); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.h b/src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.h new file mode 100644 index 0000000000..0a2a4898a1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selectableitem.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QGraphicsObject> + +namespace DesignTools { + +enum ItemType +{ + ItemTypeKeyframe = QGraphicsItem::UserType + 1, + ItemTypeHandle = QGraphicsItem::UserType + 2, + ItemTypeCurve = QGraphicsItem::UserType + 3 +}; + +enum class SelectionMode : unsigned int +{ + Undefined, + Clear, + New, + Add, + Remove, + Toggle +}; + +class SelectableItem : public QGraphicsObject +{ + Q_OBJECT + +public: + SelectableItem(QGraphicsItem *parent = nullptr); + + ~SelectableItem() override; + + bool activated() const; + + bool selected() const; + + void setActivated(bool active); + + void setPreselected(SelectionMode mode); + + void applyPreselection(); + +protected: + virtual void selectionCallback(); + + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; + + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + +private: + bool m_active; + + bool m_selected; + + SelectionMode m_preSelected; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp new file mode 100644 index 0000000000..633c1ddd39 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "selector.h" +#include "graphicsview.h" +#include "keyframeitem.h" +#include "playhead.h" + +#include <QApplication> + +#include <cmath> + +namespace DesignTools { + +Selector::Selector() {} + +void Selector::paint(QPainter *painter) +{ + QPen pen(Qt::white); + + painter->save(); + painter->setPen(pen); + + if (!m_lasso.isEmpty()) + painter->drawPath(m_lasso); + + if (!m_rect.isNull()) + painter->drawRect(m_rect); + + painter->restore(); +} + +void Selector::mousePress(QMouseEvent *event, GraphicsView *view) +{ + m_shortcut = Shortcut(event); + + if (view->hasActiveHandle()) + return; + + if (select(SelectionTool::Undefined, view->globalToScene(event->globalPos()), view)) + applyPreSelection(view); + + m_mouseInit = event->globalPos(); + m_mouseCurr = event->globalPos(); + + QPointF click = view->globalToScene(m_mouseInit); + + m_lasso = QPainterPath(click); + m_lasso.closeSubpath(); + + m_rect = QRectF(click, click); +} + +void Selector::mouseMove(QMouseEvent *event, GraphicsView *view, Playhead &playhead) +{ + if (m_mouseInit.isNull()) + return; + + QPointF delta = event->globalPos() - m_mouseInit; + if (delta.manhattanLength() < QApplication::startDragDistance()) + return; + + if (m_shortcut == m_shortcuts.newSelection || m_shortcut == m_shortcuts.addToSelection + || m_shortcut == m_shortcuts.removeFromSelection + || m_shortcut == m_shortcuts.toggleSelection) { + if (view->hasActiveItem()) + return; + + select(m_tool, view->globalToScene(event->globalPos()), view); + + event->accept(); + view->viewport()->update(); + + } else if (m_shortcut == m_shortcuts.zoom) { + double bigger = std::abs(delta.x()) > std::abs(delta.y()) ? delta.x() : delta.y(); + double factor = bigger / view->width(); + view->setZoomX(view->zoomX() + factor, m_mouseInit); + m_mouseCurr = event->globalPos(); + event->accept(); + + } else if (m_shortcut == m_shortcuts.pan) { + view->scrollContent(-delta.x(), -delta.y()); + playhead.resize(view); + m_mouseCurr = event->globalPos(); + } +} + +void Selector::mouseRelease(QMouseEvent *event, GraphicsView *view) +{ + Q_UNUSED(event); + + applyPreSelection(view); + + m_shortcut = Shortcut(); + m_mouseInit = QPoint(); + m_mouseCurr = QPoint(); + m_lasso = QPainterPath(); + m_rect = QRectF(); +} + +bool Selector::select(const SelectionTool &tool, const QPointF &pos, GraphicsView *view) +{ + auto selectWidthTool = [this, tool](SelectionMode mode, const QPointF &pos, GraphicsView *view) { + switch (tool) { + case SelectionTool::Lasso: + return lassoSelection(mode, pos, view); + case SelectionTool::Rectangle: + return rectangleSelection(mode, pos, view); + default: + return pressSelection(mode, pos, view); + } + }; + + if (m_shortcut == m_shortcuts.newSelection) { + clearSelection(view); + return selectWidthTool(SelectionMode::New, pos, view); + } else if (m_shortcut == m_shortcuts.addToSelection) { + return selectWidthTool(SelectionMode::Add, pos, view); + } else if (m_shortcut == m_shortcuts.removeFromSelection) { + return selectWidthTool(SelectionMode::Remove, pos, view); + } else if (m_shortcut == m_shortcuts.toggleSelection) { + return selectWidthTool(SelectionMode::Toggle, pos, view); + } + + return false; +} + +bool Selector::pressSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view) +{ + bool out = false; + const auto itemList = view->items(); + for (auto *item : itemList) { + if (auto *frame = qgraphicsitem_cast<KeyframeItem *>(item)) { + QRectF itemRect = frame->mapRectToScene(frame->boundingRect()); + if (itemRect.contains(pos)) { + frame->setPreselected(mode); + out = true; + } + } + } + return out; +} + +bool Selector::rectangleSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view) +{ + bool out = false; + m_rect.setBottomRight(pos); + const auto itemList = view->items(); + for (auto *item : itemList) { + if (auto *keyframeItem = qgraphicsitem_cast<KeyframeItem *>(item)) { + if (m_rect.contains(keyframeItem->pos())) { + keyframeItem->setPreselected(mode); + out = true; + } else { + keyframeItem->setPreselected(SelectionMode::Undefined); + } + } + } + return out; +} + +bool Selector::lassoSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view) +{ + bool out = false; + m_lasso.lineTo(pos); + const auto itemList = view->items(); + for (auto *item : itemList) { + if (auto *keyframeItem = qgraphicsitem_cast<KeyframeItem *>(item)) { + if (m_lasso.contains(keyframeItem->pos())) { + keyframeItem->setPreselected(mode); + out = true; + } else { + keyframeItem->setPreselected(SelectionMode::Undefined); + } + } + } + return out; +} + +void Selector::clearSelection(GraphicsView *view) +{ + const auto itemList = view->items(); + for (auto *item : itemList) { + if (auto *frameItem = qgraphicsitem_cast<KeyframeItem *>(item)) { + frameItem->setPreselected(SelectionMode::Clear); + frameItem->applyPreselection(); + } + } +} + +void Selector::applyPreSelection(GraphicsView *view) +{ + const auto itemList = view->items(); + for (auto *item : itemList) { + if (auto *keyframeItem = qgraphicsitem_cast<KeyframeItem *>(item)) + keyframeItem->applyPreselection(); + } +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selector.h b/src/plugins/qmldesigner/components/curveeditor/detail/selector.h new file mode 100644 index 0000000000..e8f53d9d59 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selector.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "curveeditorstyle.h" +#include "selectableitem.h" + +#include <QMouseEvent> +#include <QPainterPath> +#include <QPoint> +#include <QRectF> + +namespace DesignTools { + +class GraphicsView; +class Playhead; + +enum class SelectionTool { Undefined, Lasso, Rectangle }; + +class Selector +{ +public: + Selector(); + + void paint(QPainter *painter); + + void mousePress(QMouseEvent *event, GraphicsView *view); + + void mouseMove(QMouseEvent *event, GraphicsView *view, Playhead &playhead); + + void mouseRelease(QMouseEvent *event, GraphicsView *view); + +private: + bool select(const SelectionTool &tool, const QPointF &pos, GraphicsView *view); + + bool pressSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view); + + bool rectangleSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view); + + bool lassoSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view); + + void clearSelection(GraphicsView *view); + + void applyPreSelection(GraphicsView *view); + + Shortcuts m_shortcuts = Shortcuts(); + + Shortcut m_shortcut; + + SelectionMode m_mode = SelectionMode::Undefined; + + SelectionTool m_tool = SelectionTool::Rectangle; + + QPoint m_mouseInit = QPoint(); + + QPoint m_mouseCurr = QPoint(); + + QPainterPath m_lasso = QPainterPath(); + + QRectF m_rect = QRectF(); +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/shortcut.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/shortcut.cpp new file mode 100644 index 0000000000..d6d04dbbae --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/shortcut.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "shortcut.h" + +namespace DesignTools { + +Shortcut::Shortcut() + : m_key() + , m_buttons() + , m_modifiers() +{} + +Shortcut::Shortcut(QMouseEvent *event) + : m_key() + , m_buttons(event->buttons()) + , m_modifiers(event->modifiers()) +{} + +Shortcut::Shortcut(const Qt::KeyboardModifiers &mods, const Qt::Key &key) + : m_key(key) + , m_buttons() + , m_modifiers(mods) +{} + +Shortcut::Shortcut(const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &mods) + : m_key() + , m_buttons(buttons) + , m_modifiers(mods) +{} + +Shortcut::Shortcut(const Qt::MouseButtons &buttons, + const Qt::KeyboardModifiers &mods, + const Qt::Key &key) + : m_key(key) + , m_buttons(buttons) + , m_modifiers(mods) +{} + +bool Shortcut::exactMatch(const Qt::Key &key) const +{ + return m_key == key; +} + +bool Shortcut::exactMatch(const Qt::MouseButton &button) const +{ + return static_cast<int>(m_buttons) == static_cast<int>(button); +} + +bool Shortcut::exactMatch(const Qt::KeyboardModifier &modifier) const +{ + return static_cast<int>(m_modifiers) == static_cast<int>(modifier); +} + +bool Shortcut::operator==(const Shortcut &other) const +{ + return m_key == other.m_key && m_buttons == other.m_buttons && m_modifiers == other.m_modifiers; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/shortcut.h b/src/plugins/qmldesigner/components/curveeditor/detail/shortcut.h new file mode 100644 index 0000000000..a9e075bd8b --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/shortcut.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QMouseEvent> + +namespace DesignTools { + +class Shortcut +{ +public: + Shortcut(); + + Shortcut(QMouseEvent *event); + + Shortcut(const Qt::KeyboardModifiers &mods, const Qt::Key &key); + + Shortcut(const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &mods = Qt::NoModifier); + + Shortcut(const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &mods, const Qt::Key &key); + + bool exactMatch(const Qt::Key &key) const; + + bool exactMatch(const Qt::MouseButton &button) const; + + bool exactMatch(const Qt::KeyboardModifier &modifier) const; + + bool operator==(const Shortcut &other) const; + +private: + Qt::Key m_key; + + Qt::MouseButtons m_buttons; + + Qt::KeyboardModifiers m_modifiers; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.cpp new file mode 100644 index 0000000000..21633ddce1 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "treeitemdelegate.h" +#include "treeitem.h" + +#include <QEvent> +#include <QMouseEvent> +#include <QPainter> + +namespace DesignTools { + +TreeItemDelegate::TreeItemDelegate(const CurveEditorStyle &style, QObject *parent) + : QStyledItemDelegate(parent) + , m_style(style) +{} + +QSize TreeItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QStyledItemDelegate::sizeHint(option, index); +} + +void TreeItemDelegate::paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + if (index.column() == 1 || index.column() == 2) { + + int height = option.rect.size().height(); + QRect iconRect(QPoint(0, 0), QSize(height, height)); + iconRect.moveCenter(option.rect.center()); + + auto *treeItem = static_cast<TreeItem *>(index.internalPointer()); + if (option.state & QStyle::State_MouseOver && iconRect.contains(m_mousePos)) { + + painter->fillRect(option.rect, option.backgroundBrush); + + if (index.column() == 1) { + + if (treeItem->locked()) { + + QPixmap pixmap = pixmapFromIcon( + m_style.treeItemStyle.unlockedIcon, + iconRect.size(), + m_style.fontColor); + + painter->drawPixmap(iconRect, pixmap); + + } else { + + QPixmap pixmap = pixmapFromIcon( + m_style.treeItemStyle.lockedIcon, + iconRect.size(), + m_style.fontColor); + + painter->drawPixmap(iconRect, pixmap); + } + + } else if (index.column() == 2) { + + if (treeItem->pinned()) { + + QPixmap pixmap = pixmapFromIcon( + m_style.treeItemStyle.unpinnedIcon, + iconRect.size(), + m_style.fontColor); + + painter->drawPixmap(iconRect, pixmap); + + } else { + + QPixmap pixmap = pixmapFromIcon( + m_style.treeItemStyle.pinnedIcon, + iconRect.size(), + m_style.fontColor); + + painter->drawPixmap(iconRect, pixmap); + + } + } + + } else { + + if (treeItem->locked() && index.column() == 1) { + + QPixmap pixmap = pixmapFromIcon( + m_style.treeItemStyle.lockedIcon, + iconRect.size(), + m_style.fontColor); + + painter->drawPixmap(iconRect, pixmap); + + } else if (treeItem->pinned() && index.column() == 2) { + + QPixmap pixmap = pixmapFromIcon( + m_style.treeItemStyle.pinnedIcon, + iconRect.size(), + m_style.fontColor); + + painter->drawPixmap(iconRect, pixmap); + + } + } + } else { + QStyledItemDelegate::paint(painter, option, index); + } +} + +void TreeItemDelegate::setStyle(const CurveEditorStyle &style) +{ + m_style = style; +} + +bool TreeItemDelegate::editorEvent(QEvent *event, + QAbstractItemModel *model, + const QStyleOptionViewItem &option, + const QModelIndex &index) +{ + if (event->type() == QEvent::MouseMove) + m_mousePos = static_cast<QMouseEvent *>(event)->pos(); + + return QStyledItemDelegate::editorEvent(event, model, option, index); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.h b/src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.h new file mode 100644 index 0000000000..6479f48942 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treeitemdelegate.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "curveeditorstyle.h" + +#include <QStyledItemDelegate> + +namespace DesignTools { + +class TreeItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + TreeItemDelegate(const CurveEditorStyle &style, QObject *parent = nullptr); + + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; + + void paint( + QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + + void setStyle(const CurveEditorStyle &style); + +protected: + bool editorEvent( + QEvent *event, + QAbstractItemModel *model, + const QStyleOptionViewItem &option, + const QModelIndex &index) override; + +private: + CurveEditorStyle m_style; + + QPoint m_mousePos; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treemodel.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/treemodel.cpp new file mode 100644 index 0000000000..1ea037091d --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treemodel.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "treemodel.h" +#include "treeitem.h" +#include "detail/graphicsview.h" + +#include <QIcon> + +namespace DesignTools { + +TreeModel::TreeModel(QObject *parent) + : QAbstractItemModel(parent) + , m_view(nullptr) + , m_root(new TreeItem("Root")) +{} + +TreeModel::~TreeModel() +{ + if (m_root) { + delete m_root; + m_root = nullptr; + } + + m_view = nullptr; +} + +QVariant TreeModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + TreeItem *item = static_cast<TreeItem *>(index.internalPointer()); + + if (role == Qt::DecorationRole && index.column() == 0) + return item->icon(); + + if (role != Qt::DisplayRole) + return QVariant(); + + return item->data(index.column()); +} + +QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + if (orientation == Qt::Horizontal) + return m_root->headerData(section); + + return QVariant(); +} + +QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + TreeItem *parentItem = m_root; + + if (parent.isValid()) + parentItem = static_cast<TreeItem *>(parent.internalPointer()); + + if (TreeItem *childItem = parentItem->child(row)) + return createIndex(row, column, childItem); + + return QModelIndex(); +} + +QModelIndex TreeModel::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + TreeItem *childItem = static_cast<TreeItem *>(index.internalPointer()); + + if (TreeItem *parentItem = childItem->parent()) { + if (parentItem == m_root) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); + } + return QModelIndex(); +} + +int TreeModel::rowCount(const QModelIndex &parent) const +{ + if (parent.column() > 0) + return 0; + + TreeItem *parentItem = m_root; + + if (parent.isValid()) + parentItem = static_cast<TreeItem *>(parent.internalPointer()); + + return parentItem->rowCount(); +} + +int TreeModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return m_root->columnCount(); +} + +void TreeModel::setGraphicsView(GraphicsView *view) +{ + m_view = view; +} + +GraphicsView *TreeModel::graphicsView() const +{ + return m_view; +} + +void TreeModel::initialize() +{ + if (m_root) + delete m_root; + + m_root = new TreeItem("Root"); +} + +TreeItem *TreeModel::root() +{ + return m_root; +} + +TreeItem *TreeModel::find(unsigned int id) +{ + return m_root->find(id); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treemodel.h b/src/plugins/qmldesigner/components/curveeditor/detail/treemodel.h new file mode 100644 index 0000000000..209b2ee506 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treemodel.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QAbstractItemModel> + +#include <vector> + +namespace DesignTools { + +class GraphicsView; +class TreeItem; + +class TreeModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + TreeModel(QObject *parent = nullptr); + + ~TreeModel() override; + + QVariant data(const QModelIndex &index, int role) const override; + + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + + QModelIndex parent(const QModelIndex &index) const override; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + void setGraphicsView(GraphicsView *view); + +protected: + GraphicsView *graphicsView() const; + + void initialize(); + + TreeItem *root(); + + TreeItem *find(unsigned int id); + +private: + GraphicsView *m_view; + + TreeItem *m_root; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treeview.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/treeview.cpp new file mode 100644 index 0000000000..3b9a4ef7c5 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treeview.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "treeview.h" +#include "curveeditormodel.h" +#include "curveitem.h" +#include "treeitem.h" +#include "treeitemdelegate.h" + +#include <QHeaderView> +#include <QMouseEvent> + +namespace DesignTools { + +TreeView::TreeView(CurveEditorModel *model, QWidget *parent) + : QTreeView(parent) +{ + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + setUniformRowHeights(true); + setRootIsDecorated(false); + setMouseTracking(true); + setHeaderHidden(true); + + model->setParent(this); + setModel(model); + + auto expandItems = [this]() { expandAll(); }; + connect(model, &QAbstractItemModel::modelReset, expandItems); + + auto *delegate = new TreeItemDelegate(model->style(), this); + setItemDelegate(delegate); + + setSelectionBehavior(QAbstractItemView::SelectRows); + setSelectionMode(QAbstractItemView::ExtendedSelection); + + connect(selectionModel(), &QItemSelectionModel::selectionChanged, this, &TreeView::changeSelection); + setStyle(model->style()); + + header()->setSectionResizeMode(0, QHeaderView::Stretch); + header()->setSectionResizeMode(1, QHeaderView::Fixed); + header()->setSectionResizeMode(2, QHeaderView::Fixed); + + header()->setStretchLastSection(false); + header()->resizeSection(1, 20); + header()->resizeSection(2, 20); +} + +void TreeView::setStyle(const CurveEditorStyle &style) +{ + QPalette pal = palette(); + pal.setBrush(QPalette::Base, style.backgroundBrush); + pal.setBrush(QPalette::Button, style.backgroundAlternateBrush); + pal.setBrush(QPalette::Text, style.fontColor); + + // Tmp to see what happens on windows/macOS. + pal.setBrush(backgroundRole(), Qt::white); + pal.setBrush(foregroundRole(), Qt::white); + + setPalette(pal); + + if (auto *delegate = qobject_cast<TreeItemDelegate *>(itemDelegate())) + delegate->setStyle(style); +} + +void TreeView::changeCurve(unsigned int id, const AnimationCurve &curve) +{ + if (auto *curveModel = qobject_cast<CurveEditorModel *>(model())) + curveModel->setCurve(id, curve); +} + +void TreeView::changeSelection(const QItemSelection &selected, const QItemSelection &deselected) +{ + Q_UNUSED(selected); + Q_UNUSED(deselected); + + std::vector<CurveItem *> curves; + for (auto index : selectedIndexes()) { + if (index.isValid() && index.column() == 0) { + auto *treeItem = static_cast<TreeItem *>(index.internalPointer()); + if (auto *propertyItem = treeItem->asPropertyItem()) + curves.push_back(new CurveItem(treeItem->id(), propertyItem->curve())); + } + } + + emit curvesSelected(curves); +} + +QSize TreeView::sizeHint() const +{ + return QSize(170, 300); +} + +void TreeView::mousePressEvent(QMouseEvent *event) +{ + QModelIndex index = indexAt(event->pos()); + if (index.isValid()) { + auto *treeItem = static_cast<TreeItem *>(index.internalPointer()); + if (index.column() == 1) + treeItem->setLocked(!treeItem->locked()); + else if (index.column() == 2) + treeItem->setPinned(!treeItem->pinned()); + } + QTreeView::mousePressEvent(event); +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h b/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h new file mode 100644 index 0000000000..9d3af647ad --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QTreeView> + +namespace DesignTools { + +class AnimationCurve; +class CurveEditorModel; +class CurveItem; + +struct CurveEditorStyle; + +class TreeView : public QTreeView +{ + Q_OBJECT + +signals: + void curvesSelected(const std::vector<CurveItem *> &curves); + +public: + TreeView(CurveEditorModel *model, QWidget *parent = nullptr); + + void changeCurve(unsigned int id, const AnimationCurve &curve); + + void setStyle(const CurveEditorStyle &style); + +protected: + QSize sizeHint() const override; + + void mousePressEvent(QMouseEvent *event) override; + +private: + void changeSelection(const QItemSelection &selected, const QItemSelection &deselected); +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/utils.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/utils.cpp new file mode 100644 index 0000000000..4933bcbe88 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/utils.cpp @@ -0,0 +1,107 @@ + +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include <QPalette> +#include <QPointF> +#include <QRectF> +#include <QTransform> + +namespace DesignTools { + +double clamp(double val, double lo, double hi) +{ + return val < lo ? lo : (val > hi ? hi : val); +} + +double lerp(double blend, double a, double b) +{ + return (1.0 - blend) * a + blend * b; +} + +double scaleX(const QTransform &transform) +{ + return transform.m11(); +} + +double scaleY(const QTransform &transform) +{ + return transform.m22(); +} + +void grow(QRectF &rect, const QPointF &point) +{ + if (rect.left() > point.x()) + rect.setLeft(point.x()); + + if (rect.right() < point.x()) + rect.setRight(point.x()); + + if (rect.top() > point.y()) + rect.setTop(point.y()); + + if (rect.bottom() < point.y()) + rect.setBottom(point.y()); +} + +QRectF bbox(const QRectF &rect, const QTransform &transform) +{ + QRectF out = rect; + grow(out, transform.map(rect.topLeft())); + grow(out, transform.map(rect.topRight())); + grow(out, transform.map(rect.bottomLeft())); + grow(out, transform.map(rect.bottomRight())); + return out; +} + +QPalette singleColorPalette(const QColor &color) +{ + QPalette palette; + palette.setColor(QPalette::Window, color); + palette.setColor(QPalette::Background, color); + palette.setColor(QPalette::WindowText, color); + palette.setColor(QPalette::Foreground, color); + palette.setColor(QPalette::Base, color); + palette.setColor(QPalette::AlternateBase, color); + palette.setColor(QPalette::ToolTipBase, color); + palette.setColor(QPalette::ToolTipText, color); + palette.setColor(QPalette::Text, color); + + palette.setColor(QPalette::Button, color); + palette.setColor(QPalette::ButtonText, color); + palette.setColor(QPalette::BrightText, color); + palette.setColor(QPalette::Light, color); + palette.setColor(QPalette::Midlight, color); + palette.setColor(QPalette::Dark, color); + palette.setColor(QPalette::Mid, color); + palette.setColor(QPalette::Shadow, color); + palette.setColor(QPalette::Highlight, color); + palette.setColor(QPalette::HighlightedText, color); + palette.setColor(QPalette::Link, color); + palette.setColor(QPalette::LinkVisited, color); + return palette; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/utils.h b/src/plugins/qmldesigner/components/curveeditor/detail/utils.h new file mode 100644 index 0000000000..77cbd2c7bf --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/detail/utils.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +QT_BEGIN_NAMESPACE +class QColor; +class QPalette; +class QPointF; +class QRectF; +class QTransform; +QT_END_NAMESPACE + +namespace DesignTools { + +double clamp(double val, double lo, double hi); + +double lerp(double blend, double a, double b); + +double scaleX(const QTransform &transform); + +double scaleY(const QTransform &transform); + +void grow(QRectF &rect, const QPointF &point); + +QRectF bbox(const QRectF &rect, const QTransform &transform); + +QPalette singleColorPalette(const QColor &color); + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/keyframe.cpp b/src/plugins/qmldesigner/components/curveeditor/keyframe.cpp new file mode 100644 index 0000000000..8ff577c0a5 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/keyframe.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "keyframe.h" + +namespace DesignTools { + +Keyframe::Keyframe() + : m_position() + , m_leftHandle() + , m_rightHandle() +{} + +Keyframe::Keyframe(const QPointF &position) + : m_position(position) + , m_leftHandle() + , m_rightHandle() +{} + +Keyframe::Keyframe(const QPointF &position, const QPointF &leftHandle, const QPointF &rightHandle) + : m_position(position) + , m_leftHandle(leftHandle) + , m_rightHandle(rightHandle) +{} + +bool Keyframe::hasLeftHandle() const +{ + return !m_leftHandle.isNull(); +} + +bool Keyframe::hasRightHandle() const +{ + return !m_rightHandle.isNull(); +} + +QPointF Keyframe::position() const +{ + return m_position; +} + +QPointF Keyframe::leftHandle() const +{ + return m_leftHandle; +} + +QPointF Keyframe::rightHandle() const +{ + return m_rightHandle; +} + +void Keyframe::setPosition(const QPointF &pos) +{ + m_position = pos; +} + +void Keyframe::setLeftHandle(const QPointF &pos) +{ + m_leftHandle = pos; +} + +void Keyframe::setRightHandle(const QPointF &pos) +{ + m_rightHandle = pos; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/keyframe.h b/src/plugins/qmldesigner/components/curveeditor/keyframe.h new file mode 100644 index 0000000000..5e6042531b --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/keyframe.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QPointF> + +namespace DesignTools { + +class Keyframe +{ +public: + Keyframe(); + + Keyframe(const QPointF &position); + + Keyframe(const QPointF &position, const QPointF &leftHandle, const QPointF &rightHandle); + + bool hasLeftHandle() const; + + bool hasRightHandle() const; + + QPointF position() const; + + QPointF leftHandle() const; + + QPointF rightHandle() const; + + void setPosition(const QPointF &pos); + + void setLeftHandle(const QPointF &pos); + + void setRightHandle(const QPointF &pos); + +private: + QPointF m_position; + + QPointF m_leftHandle; + + QPointF m_rightHandle; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/treeitem.cpp b/src/plugins/qmldesigner/components/curveeditor/treeitem.cpp new file mode 100644 index 0000000000..beed419e54 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/treeitem.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "treeitem.h" + +#include <QIcon> +#include <QVariant> + +namespace DesignTools { + +TreeItem::TreeItem(const QString &name) + : m_name(name) + , m_id(0) + , m_locked(false) + , m_pinned(false) + , m_parent(nullptr) + , m_children() +{} + +TreeItem::~TreeItem() +{ + m_parent = nullptr; + + qDeleteAll(m_children); +} + +QIcon TreeItem::icon() const +{ + return QIcon(); +} + +NodeTreeItem *TreeItem::asNodeItem() +{ + return nullptr; +} + +PropertyTreeItem *TreeItem::asPropertyItem() +{ + return nullptr; +} + +unsigned int TreeItem::id() const +{ + return m_id; +} + +bool TreeItem::locked() const +{ + return m_locked; +} + +bool TreeItem::pinned() const +{ + return m_pinned; +} + +int TreeItem::row() const +{ + if (m_parent) { + for (size_t i = 0; i < m_parent->m_children.size(); ++i) { + if (m_parent->m_children[i] == this) + return i; + } + } + + return 0; +} + +int TreeItem::column() const +{ + return 0; +} + +int TreeItem::rowCount() const +{ + return m_children.size(); +} + +int TreeItem::columnCount() const +{ + return 3; +} + +TreeItem *TreeItem::parent() const +{ + return m_parent; +} + +TreeItem *TreeItem::child(int row) const +{ + if (row < 0 || row >= static_cast<int>(m_children.size())) + return nullptr; + + return m_children.at(row); +} + +TreeItem *TreeItem::find(unsigned int id) const +{ + for (auto *child : m_children) { + if (child->id() == id) + return child; + + if (auto *childsChild = child->find(id)) + return childsChild; + } + + return nullptr; +} + +QVariant TreeItem::data(int column) const +{ + switch (column) { + case 0: + return QVariant(m_name); + case 1: + return QVariant(m_locked); + case 2: + return QVariant(m_pinned); + case 3: + return QVariant(m_id); + default: + return QVariant(); + } +} + +QVariant TreeItem::headerData(int column) const +{ + switch (column) { + case 0: + return QString("Name"); + case 1: + return QString("L"); + case 2: + return QString("P"); + case 3: + return QString("Id"); + default: + return QVariant(); + } +} + +void TreeItem::setId(unsigned int &id) +{ + m_id = id; + + for (auto *child : m_children) + child->setId(++id); +} + +void TreeItem::addChild(TreeItem *child) +{ + child->m_parent = this; + m_children.push_back(child); +} + +void TreeItem::setLocked(bool locked) +{ + m_locked = locked; +} + +void TreeItem::setPinned(bool pinned) +{ + m_pinned = pinned; +} + + +NodeTreeItem::NodeTreeItem(const QString &name, const QIcon &icon) + : TreeItem(name) + , m_icon(icon) +{ + Q_UNUSED(icon); +} + +NodeTreeItem *NodeTreeItem::asNodeItem() +{ + return this; +} + +QIcon NodeTreeItem::icon() const +{ + return m_icon; +} + + +PropertyTreeItem::PropertyTreeItem(const QString &name, const AnimationCurve &curve) + : TreeItem(name) + , m_curve(curve) +{} + +PropertyTreeItem *PropertyTreeItem::asPropertyItem() +{ + return this; +} + +AnimationCurve PropertyTreeItem::curve() const +{ + return m_curve; +} + +void PropertyTreeItem::setCurve(const AnimationCurve &curve) +{ + m_curve = curve; +} + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/curveeditor/treeitem.h b/src/plugins/qmldesigner/components/curveeditor/treeitem.h new file mode 100644 index 0000000000..5b31dc2fc8 --- /dev/null +++ b/src/plugins/qmldesigner/components/curveeditor/treeitem.h @@ -0,0 +1,137 @@ + +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Design Tooling +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "animationcurve.h" + +#include <QIcon> +#include <QString> + +#include <vector> + +QT_BEGIN_NAMESPACE +class QIcon; +class QVariant; +QT_END_NAMESPACE + +namespace DesignTools { + +class NodeTreeItem; +class PropertyTreeItem; + +class TreeItem +{ +public: + TreeItem(const QString &name); + + virtual ~TreeItem(); + + virtual QIcon icon() const; + + virtual NodeTreeItem *asNodeItem(); + + virtual PropertyTreeItem *asPropertyItem(); + + unsigned int id() const; + + bool locked() const; + + bool pinned() const; + + int row() const; + + int column() const; + + int rowCount() const; + + int columnCount() const; + + TreeItem *parent() const; + + TreeItem *child(int row) const; + + TreeItem *find(unsigned int row) const; + + QVariant data(int column) const; + + QVariant headerData(int column) const; + + void setId(unsigned int &id); + + void addChild(TreeItem *child); + + void setLocked(bool locked); + + void setPinned(bool pinned); + +protected: + QString m_name; + + unsigned int m_id; + + bool m_locked; + + bool m_pinned; + + TreeItem *m_parent; + + std::vector<TreeItem *> m_children; +}; + + +class NodeTreeItem : public TreeItem +{ +public: + NodeTreeItem(const QString &name, const QIcon &icon); + + NodeTreeItem *asNodeItem() override; + + QIcon icon() const override; + +private: + QIcon m_icon; +}; + + +class PropertyTreeItem : public TreeItem +{ +public: + PropertyTreeItem(const QString &name, const AnimationCurve &curve); + + PropertyTreeItem *asPropertyItem() override; + + AnimationCurve curve() const; + + void setCurve(const AnimationCurve &curve); + +private: + using TreeItem::addChild; + + AnimationCurve m_curve; +}; + +} // End namespace DesignTools. diff --git a/src/plugins/qmldesigner/components/formeditor/backgroundaction.cpp b/src/plugins/qmldesigner/components/formeditor/backgroundaction.cpp index 356fbf4f32..6d3cef0fbd 100644 --- a/src/plugins/qmldesigner/components/formeditor/backgroundaction.cpp +++ b/src/plugins/qmldesigner/components/formeditor/backgroundaction.cpp @@ -64,7 +64,7 @@ QWidget *BackgroundAction::createWidget(QWidget *parent) } comboBox->setCurrentIndex(0); - connect(comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BackgroundAction::emitBackgroundChanged); comboBox->setProperty("hideborder", true); diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp index 0737e2ab45..6446e2422f 100644 --- a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp @@ -42,7 +42,6 @@ static Q_LOGGING_CATEGORY(dragToolInfo, "qtc.qmldesigner.formeditor", QtWarningM namespace QmlDesigner { - DragTool::DragTool(FormEditorView *editorView) : AbstractFormEditorTool(editorView), m_moveManipulator(editorView->scene()->manipulatorLayerItem(), editorView), diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index 2cc524c799..9f6d3e9cd8 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -41,7 +41,6 @@ namespace QmlDesigner { - FormEditorScene *FormEditorItem::scene() const { return qobject_cast<FormEditorScene*>(QGraphicsItem::scene()); } @@ -110,7 +109,7 @@ void FormEditorItem::updateGeometry() m_boundingRect = m_paintedBoundingRect.united(m_selectionBoundingRect); setTransform(qmlItemNode().instanceTransformWithContentTransform()); //the property for zValue is called z in QGraphicsObject - if (qmlItemNode().instanceValue("z").isValid()) + if (qmlItemNode().instanceValue("z").isValid() && !qmlItemNode().isRootModelNode()) setZValue(qmlItemNode().instanceValue("z").toDouble()); } @@ -260,7 +259,7 @@ static void paintTextInPlaceHolderForInvisbleItem(QPainter *painter, QFontMetrics fm(font); painter->rotate(90); - if (fm.width(displayText) > (boundingRect.height() - 32) && displayText.length() > 4) { + if (fm.horizontalAdvance(displayText) > (boundingRect.height() - 32) && displayText.length() > 4) { displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect.height() - 32, Qt::TextShowMnemonic); } diff --git a/src/plugins/qmldesigner/components/formeditor/numberseriesaction.cpp b/src/plugins/qmldesigner/components/formeditor/numberseriesaction.cpp index 0ce0a995ba..27bfbe4f83 100644 --- a/src/plugins/qmldesigner/components/formeditor/numberseriesaction.cpp +++ b/src/plugins/qmldesigner/components/formeditor/numberseriesaction.cpp @@ -59,7 +59,7 @@ QWidget *NumberSeriesAction::createWidget(QWidget *parent) comboBox->setModel(m_comboBoxModel.data()); comboBox->setCurrentIndex(m_comboBoxModelIndex); - connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &NumberSeriesAction::emitValueChanged); return comboBox; diff --git a/src/plugins/qmldesigner/components/importmanager/importswidget.cpp b/src/plugins/qmldesigner/components/importmanager/importswidget.cpp index 0d2218a42b..07ada7c858 100644 --- a/src/plugins/qmldesigner/components/importmanager/importswidget.cpp +++ b/src/plugins/qmldesigner/components/importmanager/importswidget.cpp @@ -39,7 +39,7 @@ ImportsWidget::ImportsWidget(QWidget *parent) : { setWindowTitle(tr("Import Manager")); m_addImportComboBox = new ImportManagerComboBox(this); - connect(m_addImportComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), + connect(m_addImportComboBox, QOverload<int>::of(&QComboBox::activated), this, &ImportsWidget::addSelectedImport); } diff --git a/src/plugins/qmldesigner/components/integration/componentaction.cpp b/src/plugins/qmldesigner/components/integration/componentaction.cpp index daedbe8d7d..c3c6875d63 100644 --- a/src/plugins/qmldesigner/components/integration/componentaction.cpp +++ b/src/plugins/qmldesigner/components/integration/componentaction.cpp @@ -53,7 +53,7 @@ QWidget *ComponentAction::createWidget(QWidget *parent) comboBox->setToolTip(tr("Edit sub components defined in this file.")); comboBox->setModel(m_componentView->standardItemModel()); comboBox->setCurrentIndex(-1); - connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), + connect(comboBox, QOverload<int>::of(&QComboBox::activated), this, &ComponentAction::emitCurrentComponentChanged); connect(this, &ComponentAction::currentIndexChanged, comboBox, &QComboBox::setCurrentIndex); diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 7a0f1f10b5..4f23154945 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -64,7 +64,6 @@ enum { namespace QmlDesigner { - /** \class QmlDesigner::DesignDocument @@ -197,7 +196,7 @@ QString DesignDocument::simplfiedDisplayName() const return rootModelNode().simplifiedTypeName(); } -void DesignDocument::updateFileName(const Utils::FileName & /*oldFileName*/, const Utils::FileName &newFileName) +void DesignDocument::updateFileName(const Utils::FilePath & /*oldFileName*/, const Utils::FilePath &newFileName) { if (m_documentModel) m_documentModel->setFileUrl(QUrl::fromLocalFile(newFileName.toString())); @@ -210,11 +209,11 @@ void DesignDocument::updateFileName(const Utils::FileName & /*oldFileName*/, con emit displayNameChanged(displayName()); } -Utils::FileName DesignDocument::fileName() const +Utils::FilePath DesignDocument::fileName() const { if (editor()) return editor()->document()->filePath(); - return Utils::FileName(); + return Utils::FilePath(); } Kit *DesignDocument::currentKit() const @@ -251,7 +250,7 @@ void DesignDocument::loadDocument(QPlainTextEdit *edit) m_inFileComponentTextModifier.reset(); - updateFileName(Utils::FileName(), fileName()); + updateFileName(Utils::FilePath(), fileName()); updateQrcFiles(); @@ -288,7 +287,7 @@ void DesignDocument::updateQrcFiles() ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName()); if (currentProject) { - for (const Utils::FileName &fileName : currentProject->files(ProjectExplorer::Project::SourceFiles)) { + for (const Utils::FilePath &fileName : currentProject->files(ProjectExplorer::Project::SourceFiles)) { if (fileName.endsWith(".qrc")) QmlJS::ModelManagerInterface::instance()->updateQrcFile(fileName.toString()); } @@ -366,18 +365,13 @@ void DesignDocument::deleteSelected() if (!currentModel()) return; - try { - RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::deleteSelected")); + rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this](){ QList<ModelNode> toDelete = view()->selectedModelNodes(); foreach (ModelNode node, toDelete) { if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node)) QmlObjectNode(node).destroy(); } - - transaction.commit(); - } catch (const RewritingException &e) { - e.showException(); - } + }); } void DesignDocument::copySelected() @@ -466,10 +460,8 @@ void DesignDocument::paste() } } - QList<ModelNode> pastedNodeList; - - try { - RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste1")); + rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, targetNode](){ + QList<ModelNode> pastedNodeList; int offset = double(qrand()) / RAND_MAX * 20 - 10; @@ -482,14 +474,10 @@ void DesignDocument::paste() } view.setSelectedModelNodes(pastedNodeList); - transaction.commit(); - } catch (const RewritingException &e) { - qWarning() << e.description(); //silent error - } - } else { - try { - RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2")); + }); + } else { + rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, rootNode](){ currentModel()->attachView(&view); ModelNode pastedNode(view.insertModel(rootNode)); ModelNode targetNode; @@ -501,9 +489,9 @@ void DesignDocument::paste() targetNode = view.rootModelNode(); if (targetNode.hasParentProperty() && - (pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) && - (pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) && - (pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value())) + (pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) && + (pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) && + (pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value())) targetNode = targetNode.parentProperty().parentModelNode(); @@ -515,15 +503,9 @@ void DesignDocument::paste() } else { qWarning() << "Cannot reparent to" << targetNode; } - - transaction.commit(); - NodeMetaInfo::clearCache(); - view.setSelectedModelNodes({pastedNode}); - transaction.commit(); - } catch (const RewritingException &e) { - qWarning() << e.description(); //silent error - } + }); + NodeMetaInfo::clearCache(); } } diff --git a/src/plugins/qmldesigner/components/integration/designdocument.h b/src/plugins/qmldesigner/components/integration/designdocument.h index 0bb5377c6d..eba0cf4060 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.h +++ b/src/plugins/qmldesigner/components/integration/designdocument.h @@ -90,7 +90,7 @@ public: TextEditor::BaseTextEditor *textEditor() const; QPlainTextEdit *plainTextEdit() const; - Utils::FileName fileName() const; + Utils::FilePath fileName() const; ProjectExplorer::Kit *currentKit() const; bool isDocumentLoaded() const; @@ -121,7 +121,7 @@ public: void changeToMaster(); private: // functions - void updateFileName(const Utils::FileName &oldFileName, const Utils::FileName &newFileName); + void updateFileName(const Utils::FilePath &oldFileName, const Utils::FilePath &newFileName); void changeToInFileComponentModel(ComponentTextModifier *textModifer); diff --git a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp index 089a540b8f..8739ec64a8 100644 --- a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp +++ b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp @@ -137,7 +137,7 @@ static QRect drawText(QPainter *painter, displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace); displayStringOffset = QPoint(5 + iconOffset, -5); - width = styleOption.fontMetrics.width(displayString); + width = styleOption.fontMetrics.horizontalAdvance(displayString); QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset; painter->drawText(textPosition, displayString); diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp index 126fed8e68..8c89acb7c8 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp @@ -246,14 +246,29 @@ Qt::ItemFlags NavigatorTreeModel::flags(const QModelIndex &index) const | Qt::ItemNeverHasChildren; } +void static appendForcedNodes(const NodeListProperty &property, QList<ModelNode> &list) +{ + const QStringList visibleProperties = NodeHints::fromModelNode(property.parentModelNode()).visibleNonDefaultProperties(); + for (const ModelNode &node : property.parentModelNode().directSubModelNodes()) { + if (!list.contains(node) && visibleProperties.contains(QString::fromUtf8(node.parentProperty().name()))) + list.append(node); + } +} + QList<ModelNode> filteredList(const NodeListProperty &property, bool filter) { if (!filter) return property.toModelNodeList(); - return Utils::filtered(property.toModelNodeList(), [] (const ModelNode &arg) { + QList<ModelNode> list; + + list.append(Utils::filtered(property.toModelNodeList(), [] (const ModelNode &arg) { return QmlItemNode::isValidQmlItemNode(arg) || NodeHints::fromModelNode(arg).visibleInNavigator(); - }); + })); + + appendForcedNodes(property, list); + + return list; } QModelIndex NavigatorTreeModel::index(int row, int column, @@ -431,7 +446,8 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *mimeData, static bool findTargetProperty(const QModelIndex &rowModelIndex, NavigatorTreeModel *navigatorTreeModel, NodeAbstractProperty *targetProperty, - int *targetRowNumber) + int *targetRowNumber, + const PropertyName &propertyName = {}) { QModelIndex targetItemIndex; PropertyName targetPropertyName; @@ -445,7 +461,10 @@ static bool findTargetProperty(const QModelIndex &rowModelIndex, if (!targetNode.metaInfo().hasDefaultProperty()) return false; - targetPropertyName = targetNode.metaInfo().defaultPropertyName(); + if (propertyName.isEmpty() || !targetNode.metaInfo().hasProperty(propertyName)) + targetPropertyName = targetNode.metaInfo().defaultPropertyName(); + else + targetPropertyName = propertyName; } // Disallow dropping items between properties, which are listed first. @@ -494,26 +513,30 @@ void NavigatorTreeModel::handleItemLibraryItemDrop(const QMimeData *mimeData, in int targetRowNumber = rowNumber; NodeAbstractProperty targetProperty; - bool foundTarget = findTargetProperty(rowModelIndex, this, &targetProperty, &targetRowNumber); + const ItemLibraryEntry itemLibraryEntry = + createItemLibraryEntryFromMimeData(mimeData->data("application/vnd.bauhaus.itemlibraryinfo")); - if (foundTarget) { - const ItemLibraryEntry itemLibraryEntry = - createItemLibraryEntryFromMimeData(mimeData->data("application/vnd.bauhaus.itemlibraryinfo")); + const NodeHints hints = NodeHints::fromItemLibraryEntry(itemLibraryEntry); + + const QString targetPropertyName = hints.forceNonDefaultProperty(); + bool foundTarget = findTargetProperty(rowModelIndex, this, &targetProperty, &targetRowNumber, targetPropertyName.toUtf8()); + + if (foundTarget) { if (!NodeHints::fromItemLibraryEntry(itemLibraryEntry).canBeDroppedInNavigator()) return; - const QmlItemNode newQmlItemNode = QmlItemNode::createQmlItemNode(m_view, itemLibraryEntry, QPointF(), targetProperty); + const QmlObjectNode newQmlObjectNode = QmlItemNode::createQmlObjectNode(m_view, itemLibraryEntry, QPointF(), targetProperty); - if (newQmlItemNode.isValid() && targetProperty.isNodeListProperty()) { + if (newQmlObjectNode.isValid() && targetProperty.isNodeListProperty()) { QList<ModelNode> newModelNodeList; - newModelNodeList.append(newQmlItemNode); + newModelNodeList.append(newQmlObjectNode); moveNodesInteractive(targetProperty, newModelNodeList, targetRowNumber); } - if (newQmlItemNode.isValid()) - m_view->selectModelNode(newQmlItemNode.modelNode()); + if (newQmlObjectNode.isValid()) + m_view->selectModelNode(newQmlObjectNode.modelNode()); } } @@ -545,10 +568,9 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex) { QTC_ASSERT(m_view, return); - try { - const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name()); - RewriterTransaction transaction = m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel::moveNodesInteractive")); + m_view->executeInTransaction("NavigatorTreeModel::moveNodesInteractive",[this, &parentProperty, modelNodes, targetIndex](){ + const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name()); foreach (const ModelNode &modelNode, modelNodes) { if (modelNode.isValid() && modelNode != parentProperty.parentModelNode() @@ -565,10 +587,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProper } } } - transaction.commit(); - } catch (const RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } + }); } Qt::DropActions NavigatorTreeModel::supportedDropActions() const diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreeview.h b/src/plugins/qmldesigner/components/navigator/navigatortreeview.h index cc5a0e344d..1001977b8f 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreeview.h +++ b/src/plugins/qmldesigner/components/navigator/navigatortreeview.h @@ -29,7 +29,6 @@ namespace QmlDesigner { - class NavigatorTreeView : public QTreeView { Q_OBJECT diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index 07434102fc..57578d866f 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -198,16 +198,10 @@ void NavigatorView::handleChangedExport(const ModelNode &modelNode, bool exporte if (rootNode.hasProperty(modelNodeId)) rootNode.removeProperty(modelNodeId); if (exported) { - try { - RewriterTransaction transaction = - beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem")); - + executeInTransaction("NavigatorTreeModel:exportItem", [this, modelNode](){ QmlObjectNode qmlObjectNode(modelNode); qmlObjectNode.ensureAliasExport(); - transaction.commit(); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } + }); } } @@ -400,7 +394,8 @@ void NavigatorView::upButtonClicked() index--; if (index < 0) index = node.parentProperty().count() - 1; //wrap around - node.parentProperty().toNodeListProperty().slide(oldIndex, index); + if (oldIndex != index) + node.parentProperty().toNodeListProperty().slide(oldIndex, index); } } updateItemSelection(); @@ -417,7 +412,8 @@ void NavigatorView::downButtonClicked() index++; if (index >= node.parentProperty().count()) index = 0; //wrap around - node.parentProperty().toNodeListProperty().slide(oldIndex, index); + if (oldIndex != index) + node.parentProperty().toNodeListProperty().slide(oldIndex, index); } } updateItemSelection(); diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/controlpoint.cpp b/src/plugins/qmldesigner/components/pathtool/controlpoint.cpp index d2a8bf75c3..d2a8bf75c3 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/controlpoint.cpp +++ b/src/plugins/qmldesigner/components/pathtool/controlpoint.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/controlpoint.h b/src/plugins/qmldesigner/components/pathtool/controlpoint.h index 39dc184978..39dc184978 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/controlpoint.h +++ b/src/plugins/qmldesigner/components/pathtool/controlpoint.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/cubicsegment.cpp b/src/plugins/qmldesigner/components/pathtool/cubicsegment.cpp index 0005514339..0005514339 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/cubicsegment.cpp +++ b/src/plugins/qmldesigner/components/pathtool/cubicsegment.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/cubicsegment.h b/src/plugins/qmldesigner/components/pathtool/cubicsegment.h index 260dcd2a6d..e22b4e1aa3 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/cubicsegment.h +++ b/src/plugins/qmldesigner/components/pathtool/cubicsegment.h @@ -36,7 +36,6 @@ namespace QmlDesigner { - class CubicSegmentData : public QSharedData { public: diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathitem.cpp b/src/plugins/qmldesigner/components/pathtool/pathitem.cpp index ad5437f34e..76fe6f0b90 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathitem.cpp +++ b/src/plugins/qmldesigner/components/pathtool/pathitem.cpp @@ -133,70 +133,61 @@ void PathItem::writePathToProperty() ModelNode pathNode = pathModelNode(formEditorItem()); - RewriterTransaction rewriterTransaction = pathNode.view()->beginRewriterTransaction(QByteArrayLiteral("PathItem::writePathToProperty")); + pathNode.view()->executeInTransaction("PathItem::writePathToProperty", [this, &pathNode](){ + QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList(); - QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList(); + foreach (ModelNode pathSegment, pathSegmentNodes) + pathSegment.destroy(); - foreach (ModelNode pathSegment, pathSegmentNodes) - pathSegment.destroy(); + if (!m_cubicSegments.isEmpty()) { + pathNode.variantProperty("startX").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().x()); + pathNode.variantProperty("startY").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().y()); - if (!m_cubicSegments.isEmpty()) { - pathNode.variantProperty("startX").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().x()); - pathNode.variantProperty("startY").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().y()); + foreach (const CubicSegment &cubicSegment, m_cubicSegments) { + writePathAttributes(pathNode, cubicSegment.attributes()); + writePathPercent(pathNode, cubicSegment.percent()); - foreach (const CubicSegment &cubicSegment, m_cubicSegments) { - writePathAttributes(pathNode, cubicSegment.attributes()); - writePathPercent(pathNode, cubicSegment.percent()); + if (cubicSegment.canBeConvertedToLine()) + writeLinePath(pathNode, cubicSegment); + else if (cubicSegment.canBeConvertedToQuad()) + writeQuadPath(pathNode, cubicSegment); + else + writeCubicPath(pathNode, cubicSegment); + } - if (cubicSegment.canBeConvertedToLine()) - writeLinePath(pathNode, cubicSegment); - else if (cubicSegment.canBeConvertedToQuad()) - writeQuadPath(pathNode, cubicSegment); - else - writeCubicPath(pathNode, cubicSegment); + writePathAttributes(pathNode, m_lastAttributes); + writePathPercent(pathNode, m_lastPercent); } - - writePathAttributes(pathNode, m_lastAttributes); - writePathPercent(pathNode, m_lastPercent); - } - - rewriterTransaction.commit(); + }); } void PathItem::writePathAsCubicSegmentsOnly() { - try { PathUpdateDisabler pathUpdateDisabler(this); ModelNode pathNode = pathModelNode(formEditorItem()); + pathNode.view()->executeInTransaction("PathItem::writePathAsCubicSegmentsOnly", [this, &pathNode](){ - RewriterTransaction rewriterTransaction = - pathNode.view()->beginRewriterTransaction(QByteArrayLiteral("PathItem::writePathAsCubicSegmentsOnly")); + QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList(); - QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList(); + foreach (ModelNode pathSegment, pathSegmentNodes) + pathSegment.destroy(); - foreach (ModelNode pathSegment, pathSegmentNodes) - pathSegment.destroy(); + if (!m_cubicSegments.isEmpty()) { + pathNode.variantProperty("startX").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().x()); + pathNode.variantProperty("startY").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().y()); - if (!m_cubicSegments.isEmpty()) { - pathNode.variantProperty("startX").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().x()); - pathNode.variantProperty("startY").setValue(m_cubicSegments.constFirst().firstControlPoint().coordinate().y()); + foreach (const CubicSegment &cubicSegment, m_cubicSegments) { + writePathAttributes(pathNode, cubicSegment.attributes()); + writePathPercent(pathNode, cubicSegment.percent()); + writeCubicPath(pathNode, cubicSegment); + } - foreach (const CubicSegment &cubicSegment, m_cubicSegments) { - writePathAttributes(pathNode, cubicSegment.attributes()); - writePathPercent(pathNode, cubicSegment.percent()); - writeCubicPath(pathNode, cubicSegment); + writePathAttributes(pathNode, m_lastAttributes); + writePathPercent(pathNode, m_lastPercent); } - - writePathAttributes(pathNode, m_lastAttributes); - writePathPercent(pathNode, m_lastPercent); - } - - rewriterTransaction.commit(); - } catch (const RewritingException &e) { - e.showException(); - } + }); } void PathItem::setFormEditorItem(FormEditorItem *formEditorItem) diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathitem.h b/src/plugins/qmldesigner/components/pathtool/pathitem.h index 17981283a6..17981283a6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathitem.h +++ b/src/plugins/qmldesigner/components/pathtool/pathitem.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathselectionmanipulator.cpp b/src/plugins/qmldesigner/components/pathtool/pathselectionmanipulator.cpp index 6df6976233..6df6976233 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathselectionmanipulator.cpp +++ b/src/plugins/qmldesigner/components/pathtool/pathselectionmanipulator.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathselectionmanipulator.h b/src/plugins/qmldesigner/components/pathtool/pathselectionmanipulator.h index def0148367..def0148367 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathselectionmanipulator.h +++ b/src/plugins/qmldesigner/components/pathtool/pathselectionmanipulator.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.cpp b/src/plugins/qmldesigner/components/pathtool/pathtool.cpp index a01ae050ac..a01ae050ac 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.cpp +++ b/src/plugins/qmldesigner/components/pathtool/pathtool.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.h b/src/plugins/qmldesigner/components/pathtool/pathtool.h index a2a65db27d..a2a65db27d 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.h +++ b/src/plugins/qmldesigner/components/pathtool/pathtool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.pri b/src/plugins/qmldesigner/components/pathtool/pathtool.pri index eba35315fe..eba35315fe 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtool.pri +++ b/src/plugins/qmldesigner/components/pathtool/pathtool.pri diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtoolview.cpp b/src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp index ea1e28832a..ea1e28832a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtoolview.cpp +++ b/src/plugins/qmldesigner/components/pathtool/pathtoolview.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtoolview.h b/src/plugins/qmldesigner/components/pathtool/pathtoolview.h index 46b688923e..46b688923e 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/pathtool/pathtoolview.h +++ b/src/plugins/qmldesigner/components/pathtool/pathtoolview.h diff --git a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp index 5d7b1aeaaf..245d604707 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp @@ -85,6 +85,11 @@ QUrl FileResourcesModel::path() const return m_path; } +QUrl FileResourcesModel::dirPath() const +{ + return QUrl::fromLocalFile(m_dirPath.path()); +} + void FileResourcesModel::setFilter(const QString &filter) { if (m_filter != filter) { @@ -162,16 +167,14 @@ void FileResourcesModel::setupModel() m_lock = true; m_model.clear(); - QDir dir; - - dir = QFileInfo(m_path.toLocalFile()).dir(); + m_dirPath = QFileInfo(m_path.toLocalFile()).dir(); QStringList filterList = m_filter.split(QLatin1Char(' ')); - QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories); + QDirIterator it(m_dirPath.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories); while (it.hasNext()) { QString absolutePath = it.next(); - m_model.append(dir.relativeFilePath(absolutePath)); + m_model.append(m_dirPath.relativeFilePath(absolutePath)); } m_lock = false; diff --git a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h index e0d6fc9725..f686631079 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h +++ b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.h @@ -27,6 +27,7 @@ #include <qmlitemnode.h> +#include <QDir> #include <QObject> #include <QStringList> #include <QUrl> @@ -40,6 +41,7 @@ class FileResourcesModel : public QObject Q_PROPERTY(QString filter READ filter WRITE setFilter) Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged) Q_PROPERTY(QUrl path READ path WRITE setPath) + Q_PROPERTY(QUrl dirPath READ dirPath) Q_PROPERTY(QStringList fileModel READ fileModel NOTIFY fileModelChanged) public: @@ -51,6 +53,7 @@ public: void setFileNameStr(const QString &fileName); void setPath(const QUrl &url); QUrl path() const; + QUrl dirPath() const; void setFilter(const QString &filter); QString filter() const; QStringList fileModel() const; @@ -71,6 +74,7 @@ private: private: QUrl m_fileName; QUrl m_path; + QDir m_dirPath; QString m_filter; bool m_lock; QString m_currentPath; diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp index 6bb3153bea..d4b1f47184 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp @@ -27,6 +27,8 @@ #include "qmlanchorbindingproxy.h" #include "propertyeditorview.h" +#include "gradientpresetitem.h" +#include "gradientpresetcustomlistmodel.h" #include <exception.h> #include <nodeproperty.h> @@ -34,14 +36,14 @@ #include <variantproperty.h> #include <abstractview.h> #include <nodemetainfo.h> -#include <rewritertransaction.h> +#include <exception.h> #include <utils/qtcassert.h> #include <QTimer> GradientModel::GradientModel(QObject *parent) : - QAbstractListModel(parent), m_gradientTypeName("Gradient"), m_locked(false) + QAbstractListModel(parent) { } @@ -145,18 +147,16 @@ void GradientModel::addGradient() return; if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) { - try { + if (m_gradientTypeName != "Gradient") + ensureShapesImport(); + + view()->executeInTransaction("GradientModel::addGradient", [this](){ QColor color = m_itemNode.instanceValue("color").value<QColor>(); if (!color.isValid()) color = QColor(Qt::white); - if (m_gradientTypeName != "Gradient") - ensureShapesImport(); - - QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient")); - QmlDesigner::ModelNode gradientNode = createGradientNode(); m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).reparentHere(gradientNode); @@ -170,16 +170,12 @@ void GradientModel::addGradient() gradientStopNode.variantProperty("position").setValue(1.0); gradientStopNode.variantProperty("color").setValue(QColor(Qt::black)); gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode); - - } catch (const QmlDesigner::Exception &e) { - e.showException(); - } - + }); } setupModel(); if (m_gradientTypeName != "Gradient") - QTimer::singleShot(100, [this](){ view()->resetPuppet(); }); /*Unfortunately required */ + resetPuppet(); /*Unfortunately required */ emit hasGradientChanged(); emit gradientTypeChanged(); } @@ -242,18 +238,18 @@ qreal GradientModel::getPosition(int index) const void GradientModel::removeStop(int index) { if (index < rowCount() - 1 && index != 0) { - QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop")); - QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode(); - QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index); - if (stop.isValid()) { - stop.destroy(); - setupModel(); - } + view()->executeInTransaction("GradientModel::removeStop", [this, index](){ + QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode(); + QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index); + if (stop.isValid()) { + stop.destroy(); + setupModel(); + } + }); } qWarning() << Q_FUNC_INFO << "invalid index"; } - void GradientModel::deleteGradient() { if (!m_itemNode.isValid()) @@ -262,16 +258,7 @@ void GradientModel::deleteGradient() if (!m_itemNode.modelNode().metaInfo().hasProperty(gradientPropertyName().toUtf8())) return; - QmlDesigner::ModelNode modelNode = m_itemNode.modelNode(); - - if (m_itemNode.isInBaseState()) { - if (modelNode.hasProperty(gradientPropertyName().toUtf8())) { - QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::deleteGradient")); - QmlDesigner::ModelNode gradientNode = modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode(); - if (QmlDesigner::QmlObjectNode(gradientNode).isValid()) - QmlDesigner::QmlObjectNode(gradientNode).destroy(); - } - } + deleteGradientNode(true); emit hasGradientChanged(); emit gradientTypeChanged(); @@ -392,7 +379,11 @@ void GradientModel::ensureShapesImport() { if (!hasShapesImport()) { QmlDesigner::Import timelineImport = QmlDesigner::Import::createLibraryImport("QtQuick.Shapes", "1.0"); - model()->changeImports({timelineImport}, {}); + try { + model()->changeImports({timelineImport}, {}); + } catch (const QmlDesigner::Exception &) { + QTC_ASSERT(false, return); + } } } @@ -444,6 +435,11 @@ QmlDesigner::AbstractView *GradientModel::view() const return m_itemNode.view(); } +void GradientModel::resetPuppet() +{ + QTimer::singleShot(1000, [this]() { view()->resetPuppet(); }); +} + QmlDesigner::ModelNode GradientModel::createGradientNode() { QByteArray fullTypeName = m_gradientTypeName.toUtf8(); @@ -477,6 +473,23 @@ QmlDesigner::ModelNode GradientModel::createGradientStopNode() return view()->createModelNode(fullTypeName, majorVersion, minorVersion); } +void GradientModel::deleteGradientNode(bool saveTransaction) +{ + QmlDesigner::ModelNode modelNode = m_itemNode.modelNode(); + + if (m_itemNode.isInBaseState()) { + if (modelNode.hasProperty(gradientPropertyName().toUtf8())) { + if (saveTransaction) + QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction( + QByteArrayLiteral("GradientModel::deleteGradient")); + QmlDesigner::ModelNode gradientNode + = modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode(); + if (QmlDesigner::QmlObjectNode(gradientNode).isValid()) + QmlDesigner::QmlObjectNode(gradientNode).destroy(); + } + } +} + void GradientModel::setGradientProperty(const QString &propertyName, qreal value) { QTC_ASSERT(m_itemNode.isValid(), return); @@ -494,3 +507,102 @@ void GradientModel::setGradientProperty(const QString &propertyName, qreal value e.showException(); } } + +void GradientModel::setPresetByID(int presetID) +{ + const QGradient gradient(GradientPresetItem::createGradientFromPreset( + static_cast<GradientPresetItem::Preset>(presetID))); + const QList<QGradientStop> gradientStops = gradient.stops().toList(); + + QList<qreal> stopsPositions; + QList<QString> stopsColors; + for (const QGradientStop &stop : gradientStops) { + stopsPositions.append(stop.first); + stopsColors.append(stop.second.name()); + } + + setPresetByStops(stopsPositions, stopsColors, gradientStops.size()); +} + +void GradientModel::setPresetByStops(const QList<qreal> &stopsPositions, + const QList<QString> &stopsColors, + int stopsCount) +{ + if (m_locked) + return; + + if (!m_itemNode.isValid() || gradientPropertyName().isEmpty()) + return; + + QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction( + QByteArrayLiteral("GradientModel::setCustomPreset")); + + deleteGradientNode(false); + + if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) { + try { + + if (m_gradientTypeName != "Gradient") + ensureShapesImport(); + + QmlDesigner::ModelNode gradientNode = createGradientNode(); + + m_itemNode.modelNode() + .nodeProperty(gradientPropertyName().toUtf8()) + .reparentHere(gradientNode); + + for (int i = 0; i < stopsCount; i++) { + QmlDesigner::ModelNode gradientStopNode = createGradientStopNode(); + gradientStopNode.variantProperty("position").setValue(stopsPositions.at(i)); + gradientStopNode.variantProperty("color").setValue(stopsColors.at(i)); + gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode); + } + + } catch (const QmlDesigner::Exception &e) { + e.showException(); + } + } + setupModel(); + + if (m_gradientTypeName != "Gradient") + resetPuppet(); /*Unfortunately required */ + + emit hasGradientChanged(); + emit gradientTypeChanged(); +} + +void GradientModel::savePreset() +{ + //preparing qgradient: + QGradient currentGradient; + QGradientStops currentStops; + QGradientStop stop; //double, color + + for (int i = 0; i < rowCount(); i++) { + stop.first = getPosition(i); + stop.second = getColor(i); + currentStops.append(stop); + } + currentGradient.setStops(currentStops); + const GradientPresetItem item(currentGradient, "Custom Gradient"); + + //reading the custom gradient file + //filling the file with old data + new data + const QString filename(GradientPresetCustomListModel::getFilename()); + QList<GradientPresetItem> items = GradientPresetCustomListModel::storedPresets(filename); + items.append(item); + GradientPresetCustomListModel::storePresets(filename, items); +} + +void GradientModel::updateGradient() +{ + QList<qreal> stops; + QList<QString> colors; + int stopsCount = rowCount(); + for (int i = 0; i < stopsCount; i++) { + stops.append(getPosition(i)); + colors.append(getColor(i).name(QColor::HexArgb)); + } + + setPresetByStops(stops, colors, stopsCount); +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h index 48514ae688..c54526838e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.h @@ -70,6 +70,15 @@ public: Q_INVOKABLE void setGradientProperty(const QString &propertyName, qreal value); + Q_INVOKABLE void setPresetByID(int presetID); + Q_INVOKABLE void setPresetByStops(const QList<qreal> &stopsPositions, + const QList<QString> &stopsColors, + int stopsCount); + + Q_INVOKABLE void savePreset(); + + Q_INVOKABLE void updateGradient(); + signals: void anchorBackendChanged(); void hasGradientChanged(); @@ -87,17 +96,19 @@ private: bool locked() const; QmlDesigner::ModelNode createGradientNode(); QmlDesigner::ModelNode createGradientStopNode(); + void deleteGradientNode(bool saveTransaction); private: QmlDesigner::QmlItemNode m_itemNode; QString m_gradientPropertyName; - QString m_gradientTypeName; - bool m_locked; + QString m_gradientTypeName = {"Gradient"}; + bool m_locked = false; bool hasShapesImport() const; void ensureShapesImport(); void setupGradientProperties(const QmlDesigner::ModelNode &gradient); QmlDesigner::Model *model() const; QmlDesigner::AbstractView *view() const; + void resetPuppet(); }; QML_DECLARE_TYPE(GradientModel) diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.cpp new file mode 100644 index 0000000000..a1599a7099 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "gradientpresetcustomlistmodel.h" +#include "gradientpresetitem.h" + +#include <coreplugin/icore.h> +#include <utils/qtcassert.h> +#include <utils/algorithm.h> + +#include <QHash> +#include <QByteArray> +#include <QDebug> +#include <QSettings> +#include <QFile> + +namespace Internal { + +static const char settingsKey[] = "GradientPresetCustomList"; +static const char settingsFileName[] = "/GradientPresets.ini"; + +QString settingsFullFilePath(const QSettings::Scope &scope) +{ + if (scope == QSettings::SystemScope) + return Core::ICore::installerResourcePath() + settingsFileName; + + return Core::ICore::userResourcePath() + settingsFileName; +} + +} // namespace Internal + +GradientPresetCustomListModel::GradientPresetCustomListModel(QObject *parent) + : GradientPresetListModel(parent) + , m_filename(getFilename()) +{ + qRegisterMetaTypeStreamOperators<GradientPresetItem>("GradientPresetItem"); + readPresets(); +} + +GradientPresetCustomListModel::~GradientPresetCustomListModel() {} + +void GradientPresetCustomListModel::registerDeclarativeType() +{ + qmlRegisterType<GradientPresetCustomListModel>("HelperWidgets", + 2, + 0, + "GradientPresetCustomListModel"); +} + +QString GradientPresetCustomListModel::getFilename() +{ + return Internal::settingsFullFilePath(QSettings::UserScope); +} + +void GradientPresetCustomListModel::storePresets(const QString &filename, + const QList<GradientPresetItem> &items) +{ + const QList<QVariant> presets + = Utils::transform<QList<QVariant>>(items, [](const GradientPresetItem &item) { + return QVariant::fromValue(item); + }); + + QSettings settings(filename, QSettings::IniFormat); + settings.clear(); + settings.setValue(Internal::settingsKey, QVariant::fromValue(presets)); +} + +QList<GradientPresetItem> GradientPresetCustomListModel::storedPresets(const QString &filename) +{ + const QSettings settings(filename, QSettings::IniFormat); + const QVariant presetSettings = settings.value(Internal::settingsKey); + + if (!presetSettings.isValid()) + return {}; + + const QList<QVariant> presets = presetSettings.toList(); + + QList<GradientPresetItem> out; + for (const QVariant &preset : presets) { + if (preset.isValid()) { + out.append(preset.value<GradientPresetItem>()); + } + } + + return out; +} + +void GradientPresetCustomListModel::addGradient(const QList<qreal> &stopsPositions, + const QList<QString> &stopsColors, + int stopsCount) +{ + QGradient tempGradient; + QGradientStops gradientStops; + QGradientStop gradientStop; + for (int i = 0; i < stopsCount; i++) { + gradientStop.first = stopsPositions.at(i); + gradientStop.second = stopsColors.at(i); + gradientStops.push_back(gradientStop); + } + + tempGradient.setStops(gradientStops); + + addItem(GradientPresetItem(tempGradient)); +} + +void GradientPresetCustomListModel::changePresetName(int id, const QString &newName) +{ + QTC_ASSERT(id >= 0, return); + QTC_ASSERT(id < m_items.size(), return); + m_items[id].setPresetName(newName); + writePresets(); +} + +void GradientPresetCustomListModel::deletePreset(int id) +{ + QTC_ASSERT(id >= 0, return); + QTC_ASSERT(id < m_items.size(), return); + beginResetModel(); + m_items.removeAt(id); + writePresets(); + endResetModel(); +} + +void GradientPresetCustomListModel::writePresets() +{ + storePresets(m_filename, m_items); +} + +void GradientPresetCustomListModel::readPresets() +{ + const QList<GradientPresetItem> presets = storedPresets(m_filename); + beginResetModel(); + m_items.clear(); + + for (const GradientPresetItem &preset : presets) { + addItem(preset); + } + endResetModel(); +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.h b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.h new file mode 100644 index 0000000000..382b651e3b --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetcustomlistmodel.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "gradientpresetlistmodel.h" + +#include <QObject> +#include <QAbstractListModel> +#include <QtQml/qqml.h> + +class GradientPresetCustomListModel : public GradientPresetListModel +{ + Q_OBJECT + +public: + explicit GradientPresetCustomListModel(QObject *parent = nullptr); + ~GradientPresetCustomListModel() override; + + static void registerDeclarativeType(); + + static QString getFilename(); + static void storePresets(const QString &filename, const QList<GradientPresetItem> &items); + static QList<GradientPresetItem> storedPresets(const QString &filename); + + Q_INVOKABLE void addGradient(const QList<qreal> &stopsPositions, + const QList<QString> &stopsColors, + int stopsCount); + + Q_INVOKABLE void changePresetName(int id, const QString &newName); + Q_INVOKABLE void deletePreset(int id); + + Q_INVOKABLE void writePresets(); + Q_INVOKABLE void readPresets(); + +private: + QString m_filename; +}; + +QML_DECLARE_TYPE(GradientPresetCustomListModel) diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.cpp new file mode 100644 index 0000000000..8237390de9 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "gradientpresetdefaultlistmodel.h" +#include "gradientpresetitem.h" + +#include <QHash> +#include <QByteArray> +#include <QDebug> +#include <QFile> + +GradientPresetDefaultListModel::GradientPresetDefaultListModel(QObject *parent) + : GradientPresetListModel(parent) +{ + addAllPresets(); +} + +GradientPresetDefaultListModel::~GradientPresetDefaultListModel() {} + +void GradientPresetDefaultListModel::registerDeclarativeType() +{ + qmlRegisterType<GradientPresetDefaultListModel>("HelperWidgets", + 2, + 0, + "GradientPresetDefaultListModel"); +} + +void GradientPresetDefaultListModel::addAllPresets() +{ + const QMetaObject &metaObj = QGradient::staticMetaObject; + const QMetaEnum metaEnum = metaObj.enumerator(metaObj.indexOfEnumerator("Preset")); + + if (!metaEnum.isValid()) + return; + + for (int i = 0; i < metaEnum.keyCount(); i++) { + addItem(GradientPresetItem(GradientPresetItem::Preset(metaEnum.value(i)))); + } +} diff --git a/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextensionconstants.h b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.h index 9bf41a2f54..831135e052 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextensionconstants.h +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetdefaultlistmodel.h @@ -25,11 +25,24 @@ #pragma once -namespace QmlDesignerExtension { -namespace Constants { +#include "gradientpresetlistmodel.h" -const char ACTION_ID[] = "QmlDesignerExtension.Action"; -const char MENU_ID[] = "QmlDesignerExtension.Menu"; +#include <QObject> +#include <QAbstractListModel> +#include <QtQml/qqml.h> -} // namespace QmlDesignerExtension -} // namespace Constants +class GradientPresetDefaultListModel : public GradientPresetListModel +{ + Q_OBJECT + +public: + explicit GradientPresetDefaultListModel(QObject *parent = nullptr); + ~GradientPresetDefaultListModel() override; + + static void registerDeclarativeType(); + +private: + void addAllPresets(); +}; + +QML_DECLARE_TYPE(GradientPresetDefaultListModel) diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.cpp new file mode 100644 index 0000000000..9d2454c4e9 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "gradientpresetitem.h" + +#include <utils/qtcassert.h> +#include <utils/algorithm.h> + +#include <QVariant> +#include <QMetaObject> +#include <QMetaEnum> +#include <algorithm> +#include <QDebug> + + +GradientPresetItem::GradientPresetItem() + : m_gradientVal(QGradient()) + , m_gradientID(Preset(0)) + , m_presetName(QString()) +{} + +GradientPresetItem::GradientPresetItem(const QGradient &value, const QString &name) + : m_gradientVal(value) + , m_gradientID(Preset(0)) + , m_presetName(name) +{} + +GradientPresetItem::GradientPresetItem(const Preset value) + : m_gradientVal(createGradientFromPreset(value)) + , m_gradientID(value) + , m_presetName(getNameByPreset(value)) +{} + +GradientPresetItem::~GradientPresetItem() = default; + +QVariant GradientPresetItem::getProperty(GradientPresetItem::Property id) const +{ + QVariant out; + + switch (id) { + case objectNameRole: + out.setValue(QString()); + break; + case stopsPosListRole: + out.setValue(stopsPosList()); + break; + case stopsColorListRole: + out.setValue(stopsColorList()); + break; + case stopListSizeRole: + out.setValue(stopListSize()); + break; + case presetNameRole: + out.setValue(presetName()); + break; + case presetIDRole: + out.setValue(presetID()); + break; + default: + qWarning() << "GradientPresetItem Property switch default case"; + break; //replace with assert before switch? + } + + return out; +} + +QGradient GradientPresetItem::gradientVal() const +{ + return m_gradientVal; +} + +void GradientPresetItem::setGradient(const QGradient &value) +{ + m_gradientVal = value; + m_gradientID = Preset(0); + m_presetName = QString(); +} + +void GradientPresetItem::setGradient(const Preset value) +{ + m_gradientID = value; + m_gradientVal = createGradientFromPreset(value); + m_presetName = getNameByPreset(value); +} + +QList<qreal> GradientPresetItem::stopsPosList() const +{ + const QList<QPair<qreal, QColor>> subres = m_gradientVal.stops().toList(); + const QList<qreal> result = Utils::transform<QList<qreal>>(subres, + [](const QPair<qreal, QColor> &item) { + return item.first; + }); + return result; +} + +QList<QString> GradientPresetItem::stopsColorList() const +{ + const QList<QPair<qreal, QColor>> subres = m_gradientVal.stops().toList(); + const QList<QString> result + = Utils::transform<QList<QString>>(subres, [](const QPair<qreal, QColor> &item) { + return item.second.name(); + }); + return result; +} + +int GradientPresetItem::stopListSize() const +{ + return m_gradientVal.stops().size(); +} + +void GradientPresetItem::setPresetName(const QString &value) +{ + m_presetName = value; +} + +QString GradientPresetItem::presetName() const +{ + return m_presetName; +} + +int GradientPresetItem::presetID() const +{ + return static_cast<int>(m_gradientID); +} + +QString GradientPresetItem::getNameByPreset(Preset value) +{ + const QMetaObject &metaObj = QGradient::staticMetaObject; + const QMetaEnum metaEnum = metaObj.enumerator(metaObj.indexOfEnumerator("Preset")); + + if (!metaEnum.isValid()) + return QString("Custom"); + + QString enumName = QString::fromUtf8(metaEnum.valueToKey(static_cast<int>(value))); + + const QStringList sl = enumName.split(QRegExp("(?=[A-Z])"), QString::SkipEmptyParts); + + enumName.clear(); + std::for_each(sl.begin(), sl.end(), [&enumName](const QString &s) { enumName += (s + " "); }); + enumName.chop(1); //let's remove the last empty space + + return (enumName.isEmpty() ? QString("Custom") : enumName); +} + +QGradient GradientPresetItem::createGradientFromPreset(Preset value) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + return QGradient(value); +#else + Q_UNUSED(value); + return {}; +#endif +} + +QDebug &operator<<(QDebug &stream, const GradientPresetItem &gradient) +{ + stream << "\"stops:" << gradient.m_gradientVal.stops() << "\""; + stream << "\"preset:" << gradient.m_gradientID << "\""; + stream << "\"name:" << gradient.m_presetName << "\""; + return stream; +} + +QDataStream &operator<<(QDataStream &stream, const GradientPresetItem &gradient) +{ + stream << gradient.m_gradientVal.stops(); + + stream << static_cast<int>(gradient.m_gradientID); + stream << gradient.m_presetName; + return stream; +} + +QDataStream &operator>>(QDataStream &stream, GradientPresetItem &gradient) +{ + QGradientStops stops; + stream >> stops; + gradient.m_gradientVal.setStops(stops); + + int gradientID; + stream >> gradientID; + gradient.m_gradientID = static_cast<GradientPresetItem::Preset>(gradientID); + + stream >> gradient.m_presetName; + return stream; +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.h b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.h new file mode 100644 index 0000000000..cd0f0017e0 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetitem.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QObject> +#include <QGradient> + +class GradientPresetItem +{ + Q_GADGET + + Q_PROPERTY(QList<qreal> stopsPosList READ stopsPosList FINAL) + Q_PROPERTY(QList<QString> stopsColorList READ stopsColorList FINAL) + Q_PROPERTY(int stopListSize READ stopListSize FINAL) + Q_PROPERTY(QString presetName READ presetName FINAL) + Q_PROPERTY(int presetID READ presetID FINAL) + +public: +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + using Preset = QGradient::Preset; +#else + enum Preset {}; +#endif + + explicit GradientPresetItem(); + explicit GradientPresetItem(const QGradient &value, const QString &name = QString()); + explicit GradientPresetItem(const Preset number); + ~GradientPresetItem(); + + enum Property { + objectNameRole = 0, + stopsPosListRole = 1, + stopsColorListRole = 2, + stopListSizeRole = 3, + presetNameRole = 4, + presetIDRole = 5 + }; + + QVariant getProperty(Property id) const; + + QGradient gradientVal() const; + + void setGradient(const QGradient &value); + void setGradient(const Preset value); + + QList<qreal> stopsPosList() const; + QList<QString> stopsColorList() const; + int stopListSize() const; + + void setPresetName(const QString &value); + QString presetName() const; + int presetID() const; + + static QString getNameByPreset(Preset value); + + friend QDebug &operator<<(QDebug &stream, const GradientPresetItem &gradient); + + friend QDataStream &operator<<(QDataStream &stream, const GradientPresetItem &gradient); + friend QDataStream &operator>>(QDataStream &stream, GradientPresetItem &gradient); + + static QGradient createGradientFromPreset(Preset value); + +private: + QGradient m_gradientVal; + Preset m_gradientID; + QString m_presetName; +}; + +Q_DECLARE_METATYPE(GradientPresetItem) diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.cpp new file mode 100644 index 0000000000..1ed95f8719 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "gradientpresetlistmodel.h" +#include "gradientpresetitem.h" + +#include <QHash> +#include <QByteArray> +#include <QDebug> +#include <QSettings> + +GradientPresetListModel::GradientPresetListModel(QObject *parent) + : QAbstractListModel(parent) +{ + m_roleNames + = {{static_cast<int>(GradientPresetItem::Property::objectNameRole), "objectName"}, + {static_cast<int>(GradientPresetItem::Property::stopsPosListRole), "stopsPosList"}, + {static_cast<int>(GradientPresetItem::Property::stopsColorListRole), "stopsColorList"}, + {static_cast<int>(GradientPresetItem::Property::stopListSizeRole), "stopListSize"}, + {static_cast<int>(GradientPresetItem::Property::presetNameRole), "presetName"}, + {static_cast<int>(GradientPresetItem::Property::presetIDRole), "presetID"}}; +} + +GradientPresetListModel::~GradientPresetListModel() +{ + clearItems(); +} + +int GradientPresetListModel::rowCount(const QModelIndex & /*parent*/) const +{ + return m_items.count(); +} + +QVariant GradientPresetListModel::data(const QModelIndex &index, int role) const +{ + if (index.isValid() && (index.row() >= 0) && (index.row() < m_items.count())) { + if (m_roleNames.contains(role)) { + QVariant value = m_items.at(index.row()) + .getProperty(static_cast<GradientPresetItem::Property>(role)); + + if (auto model = qobject_cast<GradientPresetListModel *>(value.value<QObject *>())) + return QVariant::fromValue(model); + + return value; + } + + qWarning() << Q_FUNC_INFO << "invalid role requested"; + return QVariant(); + } + + qWarning() << Q_FUNC_INFO << "invalid index requested"; + return QVariant(); +} + +QHash<int, QByteArray> GradientPresetListModel::roleNames() const +{ + return m_roleNames; +} + +void GradientPresetListModel::clearItems() +{ + beginResetModel(); + m_items.clear(); + endResetModel(); +} + +void GradientPresetListModel::addItem(const GradientPresetItem &element) +{ + beginResetModel(); + m_items.append(element); + endResetModel(); +} + +const QList<GradientPresetItem> &GradientPresetListModel::items() const +{ + return m_items; +} + +void GradientPresetListModel::sortItems() +{ + auto itemSort = [](const GradientPresetItem &first, const GradientPresetItem &second) { + return (static_cast<int>(first.presetID()) < static_cast<int>(second.presetID())); + }; + + std::sort(m_items.begin(), m_items.end(), itemSort); +} + +void GradientPresetListModel::registerDeclarativeType() +{ + qmlRegisterType<GradientPresetListModel>("HelperWidgets", 2, 0, "GradientPresetListModel"); +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.h b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.h new file mode 100644 index 0000000000..7fce2243dd --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/gradientpresetlistmodel.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QObject> +#include <QAbstractListModel> +#include <QtQml/qqml.h> + +class GradientPresetItem; + +class GradientPresetListModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit GradientPresetListModel(QObject *parent = nullptr); + ~GradientPresetListModel() override; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash<int, QByteArray> roleNames() const override; + + void clearItems(); + void addItem(const GradientPresetItem &element); + + const QList<GradientPresetItem> &items() const; + + void sortItems(); + + static void registerDeclarativeType(); + +protected: + QList<GradientPresetItem> m_items; + QHash<int, QByteArray> m_roleNames; +}; + +//QML_DECLARE_TYPE(GradientPresetListModel) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri index d822fbb70d..b32a744016 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri @@ -11,7 +11,14 @@ SOURCES += propertyeditorview.cpp \ propertyeditorwidget.cpp \ fileresourcesmodel.cpp \ gradientmodel.cpp \ - qmlmodelnodeproxy.cpp + qmlmodelnodeproxy.cpp \ + gradientpresetitem.cpp \ + gradientpresetlistmodel.cpp \ + gradientpresetdefaultlistmodel.cpp \ + gradientpresetcustomlistmodel.cpp \ + simplecolorpalette.cpp \ + simplecolorpalettemodel.cpp \ + simplecolorpalettesingleton.cpp HEADERS += propertyeditorview.h \ qmlanchorbindingproxy.h \ @@ -24,6 +31,13 @@ HEADERS += propertyeditorview.h \ propertyeditorwidget.h \ fileresourcesmodel.h \ gradientmodel.h \ - qmlmodelnodeproxy.h + qmlmodelnodeproxy.h \ + gradientpresetitem.h \ + gradientpresetlistmodel.h \ + gradientpresetdefaultlistmodel.h \ + gradientpresetcustomlistmodel.h \ + simplecolorpalette.h \ + simplecolorpalettemodel.h \ + simplecolorpalettesingleton.h QT += qml quick diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index dc8243e1c8..8fdab5a821 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -152,22 +152,14 @@ void PropertyEditorContextObject::toogleExportAlias() PropertyName modelNodeId = selectedNode.id().toUtf8(); ModelNode rootModelNode = rewriterView->rootModelNode(); - try { - RewriterTransaction transaction = - rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:toogleExportAlias")); - + rewriterView->executeInTransaction("PropertyEditorContextObject:toogleExportAlias", [&objectNode, &rootModelNode, modelNodeId](){ if (!objectNode.isAliasExported()) objectNode.ensureAliasExport(); else if (rootModelNode.hasProperty(modelNodeId)) rootModelNode.removeProperty(modelNodeId); - - transaction.commit(); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } + }); } - } void PropertyEditorContextObject::changeTypeName(const QString &typeName) @@ -181,11 +173,8 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName) QTC_ASSERT(!rewriterView->selectedModelNodes().isEmpty(), return); - ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst(); - - try { - RewriterTransaction transaction = - rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:changeTypeName")); + rewriterView->executeInTransaction("PropertyEditorContextObject:changeTypeName", [this, rewriterView, typeName](){ + ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst(); NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1()); if (!metaInfo.isValid()) { @@ -193,16 +182,10 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName) return; } if (selectedNode.isRootNode()) - rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion()); + rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion()); else selectedNode.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion()); - - transaction.commit(); - } catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail - exception.showException(); - } - - + }); } void PropertyEditorContextObject::insertKeyframe(const QString &propertyName) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index 284b6948ee..12f12ed2bc 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -40,6 +40,7 @@ #include <coreplugin/icore.h> #include <qmljs/qmljssimplereader.h> +#include <utils/qtcassert.h> #include <utils/algorithm.h> #include <utils/fileutils.h> @@ -281,13 +282,17 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q setupLayoutAttachedProperties(qmlObjectNode, propertyEditor); + // model node + m_backendModelNode.setup(qmlObjectNode.modelNode()); + context()->setContextProperty(QLatin1String("modelNodeBackend"), &m_backendModelNode); + // className auto valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value(QLatin1String("className")))); if (!valueObject) valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap); valueObject->setName("className"); valueObject->setModelNode(qmlObjectNode.modelNode()); - valueObject->setValue(qmlObjectNode.modelNode().simplifiedTypeName()); + valueObject->setValue(m_backendModelNode.simplifiedTypeName()); QObject::connect(valueObject, &PropertyEditorValue::valueChanged, &backendValuesPropertyMap(), &DesignerPropertyMap::valueChanged); m_backendValuesPropertyMap.insert(QLatin1String("className"), QVariant::fromValue(valueObject)); @@ -296,7 +301,7 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q if (!valueObject) valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap); valueObject->setName("id"); - valueObject->setValue(qmlObjectNode.id()); + valueObject->setValue(m_backendModelNode.nodeId()); QObject::connect(valueObject, &PropertyEditorValue::valueChanged, &backendValuesPropertyMap(), &DesignerPropertyMap::valueChanged); m_backendValuesPropertyMap.insert(QLatin1String("id"), QVariant::fromValue(valueObject)); @@ -310,10 +315,6 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q qCInfo(propertyEditorBenchmark) << "anchors:" << time.elapsed(); - // model node - m_backendModelNode.setup(qmlObjectNode.modelNode()); - context()->setContextProperty(QLatin1String("modelNodeBackend"), &m_backendModelNode); - qCInfo(propertyEditorBenchmark) << "context:" << time.elapsed(); contextObject()->setSpecificsUrl(qmlSpecificsFile); @@ -402,23 +403,49 @@ QString PropertyEditorQmlBackend::propertyEditorResourcesPath() { QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type, const NodeMetaInfo &superType, - const QmlObjectNode &objectNode) + const QmlObjectNode &node) { if (!templateConfiguration() || !templateConfiguration()->isValid()) return QString(); + const auto nodes = templateConfiguration()->children(); + + QStringList sectorTypes; + + for (const QmlJS::SimpleReaderNode::Ptr &node : nodes) { + if (node->propertyNames().contains("separateSection")) + sectorTypes.append(variantToStringList(node->property("typeNames"))); + } + QStringList imports = variantToStringList(templateConfiguration()->property(QStringLiteral("imports"))); QString qmlTemplate = imports.join(QLatin1Char('\n')) + QLatin1Char('\n'); - qmlTemplate += QStringLiteral("Section {\n"); - qmlTemplate += QStringLiteral("caption: \"%1\"\n").arg(objectNode.modelNode().simplifiedTypeName()); - qmlTemplate += QStringLiteral("SectionLayout {\n"); + + qmlTemplate += "Column {\n"; + qmlTemplate += "anchors.left: parent.left\n"; + qmlTemplate += "anchors.right: parent.right\n"; QList<PropertyName> orderedList = type.propertyNames(); - Utils::sort(orderedList); + Utils::sort(orderedList, [type, §orTypes](const PropertyName &left, const PropertyName &right){ + const QString typeNameLeft = QString::fromLatin1(type.propertyTypeName(left)); + const QString typeNameRight = QString::fromLatin1(type.propertyTypeName(right)); + if (typeNameLeft == typeNameRight) + return left > right; + + if (sectorTypes.contains(typeNameLeft)) { + if (sectorTypes.contains(typeNameRight)) + return left > right; + return true; + } else if (sectorTypes.contains(typeNameRight)) { + return false; + } + return left > right; + }); bool emptyTemplate = true; + bool sectionStarted = false; + foreach (const PropertyName &name, orderedList) { if (name.startsWith("__")) @@ -429,18 +456,38 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type, TypeName typeName = type.propertyTypeName(name); //alias resolution only possible with instance - if (typeName == "alias" && objectNode.isValid()) - typeName = objectNode.instanceType(name); + if (typeName == "alias" && node.isValid()) + typeName = node.instanceType(name); + + auto nodes = templateConfiguration()->children(); if (!superType.hasProperty(name) && type.propertyIsWritable(name) && !name.contains(".")) { - foreach (const QmlJS::SimpleReaderNode::Ptr &node, templateConfiguration()->children()) + + foreach (const QmlJS::SimpleReaderNode::Ptr &node, nodes) if (variantToStringList(node->property(QStringLiteral("typeNames"))).contains(QString::fromLatin1(typeName))) { const QString fileName = propertyTemplatesPath() + node->property(QStringLiteral("sourceFile")).toString(); QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QString source = QString::fromUtf8(file.readAll()); file.close(); + const bool section = node->propertyNames().contains("separateSection"); + if (section) { + qmlTemplate += "Section {\n"; + qmlTemplate += "anchors.left: parent.left\n"; + qmlTemplate += "anchors.right: parent.right\n"; + qmlTemplate += QString("caption: \"%1\"\n").arg(QString::fromUtf8(properName)); + } else if (!sectionStarted) { + qmlTemplate += QStringLiteral("Section {\n"); + qmlTemplate += QStringLiteral("caption: \"%1\"\n").arg(QString::fromUtf8(type.simplifiedTypeName())); + qmlTemplate += "anchors.left: parent.left\n"; + qmlTemplate += "anchors.right: parent.right\n"; + qmlTemplate += QStringLiteral("SectionLayout {\n"); + sectionStarted = true; + } + qmlTemplate += source.arg(QString::fromUtf8(name)).arg(QString::fromUtf8(properName)); + if (section) + qmlTemplate += "}\n"; emptyTemplate = false; } else { qWarning().nospace() << "template definition source file not found:" << fileName; @@ -448,8 +495,12 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type, } } } - qmlTemplate += QStringLiteral("}\n"); //Section - qmlTemplate += QStringLiteral("}\n"); //SectionLayout + if (sectionStarted) { + qmlTemplate += QStringLiteral("}\n"); //Section + qmlTemplate += QStringLiteral("}\n"); //SectionLayout + } + + qmlTemplate += "}\n"; if (emptyTemplate) return QString(); @@ -469,6 +520,36 @@ TypeName PropertyEditorQmlBackend::fixTypeNameForPanes(const TypeName &typeName) return fixedTypeName; } +static NodeMetaInfo findCommonSuperClass(const NodeMetaInfo &first, const NodeMetaInfo &second) +{ + for (const NodeMetaInfo &info : first.superClasses()) { + if (second.isSubclassOf(info.typeName())) + return info; + } + return first; +} + +NodeMetaInfo PropertyEditorQmlBackend::findCommonAncestor(const ModelNode &node) +{ + if (!node.isValid()) + return {}; + + QTC_ASSERT(node.metaInfo().isValid(), return {}); + + AbstractView *view = node.view(); + + if (view->selectedModelNodes().count() > 1) { + NodeMetaInfo commonClass = node.metaInfo(); + for (const ModelNode ¤tNode : view->selectedModelNodes()) { + if (currentNode.metaInfo().isValid() && !currentNode.isSubclassOf(commonClass.typeName(), -1, -1)) + commonClass = findCommonSuperClass(currentNode.metaInfo(), commonClass); + } + return commonClass; + } + + return node.metaInfo(); +} + TypeName PropertyEditorQmlBackend::qmlFileName(const NodeMetaInfo &nodeInfo) { const TypeName fixedTypeName = fixTypeNameForPanes(nodeInfo.typeName()); @@ -526,10 +607,10 @@ void PropertyEditorQmlBackend::setValueforLayoutAttachedProperties(const QmlObje setValue(qmlObjectNode, name, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName)); } -QUrl PropertyEditorQmlBackend::getQmlUrlForModelNode(const ModelNode &modelNode, TypeName &className) +QUrl PropertyEditorQmlBackend::getQmlUrlForMetaInfo(const NodeMetaInfo &metaInfo, TypeName &className) { - if (modelNode.isValid()) { - foreach (const NodeMetaInfo &info, modelNode.metaInfo().classHierarchy()) { + if (metaInfo.isValid()) { + foreach (const NodeMetaInfo &info, metaInfo.classHierarchy()) { QUrl fileUrl = fileToUrl(locateQmlFile(info, QString::fromUtf8(qmlFileName(info)))); if (fileUrl.isValid()) { className = info.typeName(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h index a0012a1cc1..51279a1fc6 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h @@ -68,11 +68,10 @@ public: PropertyEditorValue *propertyValueForName(const QString &propertyName); static QString propertyEditorResourcesPath(); - static QString templateGeneration(const NodeMetaInfo &type, const NodeMetaInfo &superType, - const QmlObjectNode &objectNode); + static QString templateGeneration(const NodeMetaInfo &type, const NodeMetaInfo &superType, const QmlObjectNode &node); static QUrl getQmlFileUrl(const TypeName &relativeTypeName, const NodeMetaInfo &info = NodeMetaInfo()); - static QUrl getQmlUrlForModelNode(const ModelNode &modelNode, TypeName &className); + static QUrl getQmlUrlForMetaInfo(const NodeMetaInfo &modelNode, TypeName &className); static bool checkIfUrlExists(const QUrl &url); @@ -83,6 +82,8 @@ public: void setupLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, PropertyEditorView *propertyEditor); + static NodeMetaInfo findCommonAncestor(const ModelNode &node); + private: void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode, const PropertyName &name, const QVariant &value, diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index 0467355bf4..9dd0a2da24 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -213,20 +213,13 @@ void PropertyEditorView::changeValue(const QString &name) castedValue = QVariant(newColor); } - try { - if (!value->value().isValid()) { //reset - qmlObjectNode.removeProperty(propertyName); - } else { - if (castedValue.isValid() && !castedValue.isNull()) { - m_locked = true; - qmlObjectNode.setVariantProperty(propertyName, castedValue); - m_locked = false; - } + if (!value->value().isValid()) { //reset + removePropertyFromModel(propertyName); + } else { + if (castedValue.isValid() && !castedValue.isNull()) { + commitVariantValueToModel(propertyName, castedValue); } } - catch (const RewritingException &e) { - e.showException(); - } } void PropertyEditorView::changeExpression(const QString &propertyName) @@ -242,9 +235,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName) if (!m_selectedNode.isValid()) return; - RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression")); - - try { + executeInTransaction("PropertyEditorView::changeExpression", [this, name](){ PropertyName underscoreName(name); underscoreName.replace('.', '_'); @@ -260,7 +251,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName) if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") { if (QColor(value->expression().remove('"')).isValid()) { qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"'))); - transaction.commit(); //committing in the try block return; } } else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") { @@ -270,7 +260,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName) qmlObjectNode.setVariantProperty(name, true); else qmlObjectNode.setVariantProperty(name, false); - transaction.commit(); //committing in the try block return; } } else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") { @@ -278,7 +267,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName) int intValue = value->expression().toInt(&ok); if (ok) { qmlObjectNode.setVariantProperty(name, intValue); - transaction.commit(); //committing in the try block return; } } else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") { @@ -286,7 +274,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName) qreal realValue = value->expression().toDouble(&ok); if (ok) { qmlObjectNode.setVariantProperty(name, realValue); - transaction.commit(); //committing in the try block return; } } @@ -298,12 +285,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName) if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name)) qmlObjectNode.setBindingProperty(name, value->expression()); - transaction.commit(); //committing in the try block - } - - catch (const RewritingException &e) { - e.showException(); - } + }); /* end of transaction */ } void PropertyEditorView::exportPopertyAsAlias(const QString &name) @@ -317,9 +299,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name) if (!m_selectedNode.isValid()) return; - RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias")); - - try { + executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){ const QString id = m_selectedNode.validId(); QString upperCasePropertyName = name; upperCasePropertyName.replace(0, 1, upperCasePropertyName.at(0).toUpper()); @@ -333,11 +313,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name) return; } rootModelNode().bindingProperty(propertyName).setDynamicTypeNameAndExpression("alias", id + "." + name); - - transaction.commit(); //committing in the try block - } catch (const RewritingException &e) { - e.showException(); - } + }); } void PropertyEditorView::removeAliasExport(const QString &name) @@ -351,9 +327,7 @@ void PropertyEditorView::removeAliasExport(const QString &name) if (!m_selectedNode.isValid()) return; - RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias")); - - try { + executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){ const QString id = m_selectedNode.validId(); for (const BindingProperty &property : rootModelNode().bindingProperties()) @@ -361,10 +335,7 @@ void PropertyEditorView::removeAliasExport(const QString &name) rootModelNode().removeProperty(property.name()); break; } - transaction.commit(); //committing in the try block - } catch (const RewritingException &e) { - e.showException(); - } + }); } bool PropertyEditorView::locked() const @@ -446,13 +417,16 @@ void PropertyEditorView::resetView() void PropertyEditorView::setupQmlBackend() { TypeName specificsClassName; - QUrl qmlFile(PropertyEditorQmlBackend::getQmlUrlForModelNode(m_selectedNode, specificsClassName)); + + const NodeMetaInfo commonAncestor = PropertyEditorQmlBackend::findCommonAncestor(m_selectedNode); + + const QUrl qmlFile(PropertyEditorQmlBackend::getQmlUrlForMetaInfo(commonAncestor, specificsClassName)); QUrl qmlSpecificsFile; TypeName diffClassName; - if (m_selectedNode.isValid()) { - diffClassName = m_selectedNode.metaInfo().typeName(); - foreach (const NodeMetaInfo &metaInfo, m_selectedNode.metaInfo().classHierarchy()) { + if (commonAncestor.isValid()) { + diffClassName = commonAncestor.typeName(); + foreach (const NodeMetaInfo &metaInfo, commonAncestor.classHierarchy()) { if (PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsFile)) break; qmlSpecificsFile = PropertyEditorQmlBackend::getQmlFileUrl(metaInfo.typeName() + "Specifics", metaInfo); @@ -465,8 +439,8 @@ void PropertyEditorView::setupQmlBackend() QString specificQmlData; - if (m_selectedNode.isValid() && m_selectedNode.metaInfo().isValid() && diffClassName != m_selectedNode.type()) - specificQmlData = PropertyEditorQmlBackend::templateGeneration(m_selectedNode.metaInfo(), model()->metaInfo(diffClassName), m_selectedNode); + if (commonAncestor.isValid() && m_selectedNode.metaInfo().isValid() && diffClassName != m_selectedNode.type()) + specificQmlData = PropertyEditorQmlBackend::templateGeneration(commonAncestor, model()->metaInfo(diffClassName), m_selectedNode); PropertyEditorQmlBackend *currentQmlBackend = m_qmlBackendHash.value(qmlFile.toString()); @@ -515,14 +489,51 @@ void PropertyEditorView::setupQmlBackend() } +void PropertyEditorView::commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value) +{ + m_locked = true; + try { + RewriterTransaction transaction = beginRewriterTransaction("PropertyEditorView::commitVariantValueToMode"); + + for (const ModelNode &node : m_selectedNode.view()->selectedModelNodes()) { + if (QmlObjectNode::isValidQmlObjectNode(node)) + QmlObjectNode(node).setVariantProperty(propertyName, value); + } + transaction.commit(); + } + catch (const RewritingException &e) { + e.showException(); + } + m_locked = false; +} + +void PropertyEditorView::removePropertyFromModel(const PropertyName &propertyName) +{ + m_locked = true; + try { + RewriterTransaction transaction = beginRewriterTransaction("PropertyEditorView::removePropertyFromModel"); + + for (const ModelNode &node : m_selectedNode.view()->selectedModelNodes()) { + if (QmlObjectNode::isValidQmlObjectNode(node)) + QmlObjectNode(node).removeProperty(propertyName); + } + + transaction.commit(); + } + catch (const RewritingException &e) { + e.showException(); + } + m_locked = false; +} + void PropertyEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList) { Q_UNUSED(lastSelectedNodeList); - if (selectedNodeList.isEmpty() || selectedNodeList.count() > 1) + if (selectedNodeList.isEmpty()) select(ModelNode()); - else if (m_selectedNode != selectedNodeList.constFirst()) + else select(selectedNodeList.constFirst()); } @@ -542,10 +553,11 @@ void PropertyEditorView::modelAttached(Model *model) m_locked = true; if (!m_setupCompleted) { - m_singleShotTimer->setSingleShot(true); - m_singleShotTimer->setInterval(100); - connect(m_singleShotTimer, &QTimer::timeout, this, &PropertyEditorView::setupPanes); - m_singleShotTimer->start(); + QTimer::singleShot(50, this, [this]{ + PropertyEditorView::setupPanes(); + /* workaround for QTBUG-75847 */ + reloadQml(); + }); } m_locked = false; @@ -648,6 +660,9 @@ void PropertyEditorView::instanceInformationsChanged(const QMultiHash<ModelNode, if (!m_selectedNode.isValid()) return; + if (!m_qmlBackEndForCurrentType) + return; + m_locked = true; QList<InformationName> informationNameList = informationChangedHash.values(m_selectedNode); if (informationNameList.contains(Anchor) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h index 85bd8286f5..e7f57cf186 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h @@ -110,6 +110,9 @@ private: //functions void delayedResetView(); void setupQmlBackend(); + void commitVariantValueToModel(const PropertyName &propertyName, const QVariant &value); + void removePropertyFromModel(const PropertyName &propertyName); + private: //variables ModelNode m_selectedNode; QWidget *m_parent; diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp index bc6b4376b6..7a38f74f34 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp @@ -292,9 +292,9 @@ void QmlAnchorBindingProxy::setDefaultRelativeRightTarget() } } -RewriterTransaction QmlAnchorBindingProxy::beginRewriterTransaction(const QByteArray &identifier) +bool QmlAnchorBindingProxy::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda) { - return m_qmlItemNode.modelNode().view()->beginRewriterTransaction(identifier); + return m_qmlItemNode.modelNode().view()->executeInTransaction(identifier, lambda); } bool QmlAnchorBindingProxy::hasParent() const @@ -361,20 +361,11 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target) if (!newTarget.isValid()) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget")); - + executeInTransaction("QmlAnchorBindingProxy::setTopTarget", [this, newTarget](){ m_topTarget = newTarget; - setDefaultRelativeTopTarget(); - anchorTop(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit topTargetChanged(); } @@ -393,18 +384,12 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target) if (!newTarget.isValid()) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget")); - + executeInTransaction("QmlAnchorBindingProxy::setBottomTarget", [this, newTarget](){ m_bottomTarget = newTarget; setDefaultRelativeBottomTarget(); anchorBottom(); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit bottomTargetChanged(); } @@ -422,18 +407,11 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target) if (!newTarget.isValid()) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget")); - + executeInTransaction("QmlAnchorBindingProxy::setLeftTarget", [this, newTarget](){ m_leftTarget = newTarget; setDefaultRelativeLeftTarget(); anchorLeft(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit leftTargetChanged(); } @@ -451,18 +429,11 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target) if (!newTarget.isValid()) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget")); - + executeInTransaction("QmlAnchorBindingProxy::setRightTarget", [this, newTarget](){ m_rightTarget = newTarget; setDefaultRelativeRightTarget(); anchorRight(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit rightTargetChanged(); } @@ -480,17 +451,10 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target) if (!newTarget.isValid()) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget")); - + executeInTransaction("QmlAnchorBindingProxy::setVerticalTarget", [this, newTarget](){ m_verticalTarget = newTarget; anchorVertical(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit verticalTargetChanged(); } @@ -508,17 +472,10 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target) if (!newTarget.isValid()) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget")); - + executeInTransaction("QmlAnchorBindingProxy::setHorizontalTarget", [this, newTarget](){ m_horizontalTarget = newTarget; - anchorHorizontal();\ - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + anchorHorizontal(); + }); emit horizontalTargetChanged(); } @@ -531,18 +488,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetTop(QmlAnchorBindingProxy::Re if (target == m_relativeTopTarget) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetTop")); - + executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetTop", [this, target](){ m_relativeTopTarget = target; - anchorTop(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetTopChanged(); } @@ -555,19 +504,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetBottom(QmlAnchorBindingProxy: if (target == m_relativeBottomTarget) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom")); - + executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom", [this, target](){ m_relativeBottomTarget = target; - - anchorBottom(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetBottomChanged(); } @@ -580,18 +520,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetLeft(QmlAnchorBindingProxy::R if (target == m_relativeLeftTarget) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft")); - + executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft", [this, target](){ m_relativeLeftTarget = target; - anchorLeft(); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetLeftChanged(); } @@ -604,18 +537,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetRight(QmlAnchorBindingProxy:: if (target == m_relativeRightTarget) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetRight")); - + executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetRight", [this, target](){ m_relativeRightTarget = target; - anchorRight(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetRightChanged(); @@ -629,18 +554,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetVertical(QmlAnchorBindingProx if (target == m_relativeVerticalTarget) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical")); + executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical", [this, target](){ m_relativeVerticalTarget = target; - anchorVertical(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetVerticalChanged(); } @@ -653,18 +571,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal(QmlAnchorBindingPr if (target == m_relativeHorizontalTarget) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal")); - + executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal", [this, target](){ m_relativeHorizontalTarget = target; - anchorHorizontal(); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetHorizontalChanged(); } @@ -709,12 +619,10 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName) return possibleTargetItems().indexOf(targetName); } -void QmlAnchorBindingProxy::resetLayout() { - - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout")); +void QmlAnchorBindingProxy::resetLayout() +{ + executeInTransaction("QmlAnchorBindingProxy::resetLayout", [this](){ m_qmlItemNode.anchors().removeAnchors(); m_qmlItemNode.anchors().removeMargins(); @@ -722,11 +630,7 @@ void QmlAnchorBindingProxy::resetLayout() { restoreProperty(modelNode(), "y"); restoreProperty(modelNode(), "width"); restoreProperty(modelNode(), "height"); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit topAnchorChanged(); emit bottomAnchorChanged(); @@ -743,10 +647,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor) if (bottomAnchored() == anchor) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor")); - + executeInTransaction("QmlAnchorBindingProxy::setBottomAnchor", [this, anchor](){ if (!anchor) { removeBottomAnchor(); } else { @@ -756,10 +657,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor) backupPropertyAndRemove(modelNode(), "height"); } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetBottomChanged(); emit bottomAnchorChanged(); @@ -776,10 +674,8 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor) if (leftAnchored() == anchor) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor")); + executeInTransaction("QmlAnchorBindingProxy::setLeftAnchor", [this, anchor](){ if (!anchor) { removeLeftAnchor(); } else { @@ -791,10 +687,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor) backupPropertyAndRemove(modelNode(), "width"); } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetLeftChanged(); emit leftAnchorChanged(); @@ -810,10 +703,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor) if (rightAnchored() == anchor) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor")); - + executeInTransaction("QmlAnchorBindingProxy::setRightAnchor", [this, anchor](){ if (!anchor) { removeRightAnchor(); } else { @@ -824,10 +714,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor) backupPropertyAndRemove(modelNode(), "width"); } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetRightChanged(); emit rightAnchorChanged(); @@ -1026,10 +913,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor) if (topAnchored() == anchor) return; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor")); - + executeInTransaction("QmlAnchorBindingProxy::setTopAnchor", [this, anchor](){ if (!anchor) { removeTopAnchor(); } else { @@ -1040,10 +924,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor) if (bottomAnchored()) backupPropertyAndRemove(modelNode(), "height"); } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit relativeAnchorTargetTopChanged(); emit topAnchorChanged(); @@ -1052,70 +933,44 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor) } void QmlAnchorBindingProxy::removeTopAnchor() { - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor")); - + executeInTransaction("QmlAnchorBindingProxy::removeTopAnchor", [this](){ m_qmlItemNode.anchors().removeAnchor(AnchorLineTop); m_qmlItemNode.anchors().removeMargin(AnchorLineTop); restoreProperty(modelNode(), "y"); restoreProperty(modelNode(), "height"); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } -void QmlAnchorBindingProxy::removeBottomAnchor() { - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor")); - +void QmlAnchorBindingProxy::removeBottomAnchor() +{ + executeInTransaction("QmlAnchorBindingProxy::removeBottomAnchor", [this](){ m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom); m_qmlItemNode.anchors().removeMargin(AnchorLineBottom); - restoreProperty(modelNode(), "height"); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } -void QmlAnchorBindingProxy::removeLeftAnchor() { - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor")); - +void QmlAnchorBindingProxy::removeLeftAnchor() +{ + executeInTransaction("QmlAnchorBindingProxy::removeLeftAnchor", [this](){ m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft); m_qmlItemNode.anchors().removeMargin(AnchorLineLeft); restoreProperty(modelNode(), "x"); restoreProperty(modelNode(), "width"); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } -void QmlAnchorBindingProxy::removeRightAnchor() { - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor")); - +void QmlAnchorBindingProxy::removeRightAnchor() +{ + executeInTransaction("QmlAnchorBindingProxy::removeRightAnchor", [this](){ m_qmlItemNode.anchors().removeAnchor(AnchorLineRight); m_qmlItemNode.anchors().removeMargin(AnchorLineRight); restoreProperty(modelNode(), "width"); - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } void QmlAnchorBindingProxy::setVerticalCentered(bool centered) @@ -1128,10 +983,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered) m_locked = true; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered")); - + executeInTransaction("QmlAnchorBindingProxy::setVerticalCentered", [this, centered](){ if (!centered) { m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter); m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter); @@ -1141,10 +993,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered) anchorVertical(); } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); m_locked = false; emit relativeAnchorTargetVerticalChanged(); @@ -1161,10 +1010,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered) m_locked = true; - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered")); - + executeInTransaction("QmlAnchorBindingProxy::setHorizontalCentered", [this, centered](){ if (!centered) { m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter); m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter); @@ -1173,11 +1019,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered) anchorHorizontal(); } - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); m_locked = false; emit relativeAnchorTargetHorizontalChanged(); @@ -1256,12 +1098,7 @@ bool QmlAnchorBindingProxy::horizontalCentered() void QmlAnchorBindingProxy::fill() { - - try { - RewriterTransaction transaction = beginRewriterTransaction( - QByteArrayLiteral("QmlAnchorBindingProxy::fill")); - - + executeInTransaction("QmlAnchorBindingProxy::fill", [this](){ backupPropertyAndRemove(modelNode(), "x"); backupPropertyAndRemove(modelNode(), "y"); backupPropertyAndRemove(modelNode(), "width"); @@ -1277,10 +1114,7 @@ void QmlAnchorBindingProxy::fill() m_qmlItemNode.anchors().removeMargin(AnchorLineTop); m_qmlItemNode.anchors().removeMargin(AnchorLineBottom); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); emit topAnchorChanged(); emit bottomAnchorChanged(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h index cf42ea055a..0bd562add2 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h @@ -210,7 +210,7 @@ private: void setDefaultRelativeLeftTarget(); void setDefaultRelativeRightTarget(); - RewriterTransaction beginRewriterTransaction(const QByteArray &identifier); + bool executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda); QmlItemNode targetIdToNode(const QString &id) const; QString idForNode(const QmlItemNode &qmlItemNode) const; diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp index 6f56b055c8..934c284691 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp @@ -23,6 +23,7 @@ ** ****************************************************************************/ +#include "abstractview.h" #include "qmlmodelnodeproxy.h" #include <QtQml> @@ -66,4 +67,34 @@ ModelNode QmlModelNodeProxy::modelNode() const return m_qmlItemNode.modelNode(); } +bool QmlModelNodeProxy::multiSelection() const +{ + if (!m_qmlItemNode.isValid()) + return false; + + return m_qmlItemNode.view()->selectedModelNodes().count() > 1; +} + +QString QmlModelNodeProxy::nodeId() const +{ + if (!m_qmlItemNode.isValid()) + return {}; + + if (multiSelection()) + return tr("multiselection"); + + return m_qmlItemNode.id(); +} + +QString QmlModelNodeProxy::simplifiedTypeName() const +{ + if (!m_qmlItemNode.isValid()) + return {}; + + if (multiSelection()) + return tr("multiselection"); + + return m_qmlItemNode.simplifiedTypeName(); +} + } diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h index 0a73583355..6037f32752 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h @@ -35,7 +35,8 @@ class QmlModelNodeProxy : public QObject { Q_OBJECT - Q_PROPERTY(QmlDesigner::ModelNode modelNode READ modelNode NOTIFY modelNodeChanged) + Q_PROPERTY(QmlDesigner::ModelNode modelNode READ modelNode NOTIFY modelNodeChanged) + Q_PROPERTY(bool multiSelection READ multiSelection NOTIFY modelNodeChanged) public: explicit QmlModelNodeProxy(QObject *parent = nullptr); @@ -51,6 +52,12 @@ public: ModelNode modelNode() const; + bool multiSelection() const; + + QString nodeId() const; + + QString simplifiedTypeName() const; + signals: void modelNodeChanged(); void selectionToBeChanged(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 4e58374759..862d16ba22 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -28,6 +28,9 @@ #include "propertyeditorvalue.h" #include "fileresourcesmodel.h" #include "gradientmodel.h" +#include "gradientpresetdefaultlistmodel.h" +#include "gradientpresetcustomlistmodel.h" +#include "simplecolorpalettemodel.h" #include "qmlanchorbindingproxy.h" #include "theme.h" @@ -48,6 +51,9 @@ void Quick2PropertyEditorView::registerQmlTypes() PropertyEditorValue::registerDeclarativeTypes(); FileResourcesModel::registerDeclarativeType(); GradientModel::registerDeclarativeType(); + GradientPresetDefaultListModel::registerDeclarativeType(); + GradientPresetCustomListModel::registerDeclarativeType(); + SimpleColorPaletteModel::registerDeclarativeType(); Internal::QmlAnchorBindingProxy::registerDeclarativeType(); } } diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.cpp b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.cpp new file mode 100644 index 0000000000..c88d83aa0a --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "simplecolorpalette.h" + +#include "designersettings.h" + +#include <QDebug> + +namespace QmlDesigner { + +PaletteColor::PaletteColor() + : m_color(QColor()) + , m_colorCode(QColor().name()) + , m_isFavorite(false) +{} + +PaletteColor::PaletteColor(const QString &colorCode) + : m_color(colorCode) + , m_colorCode(colorCode) + , m_isFavorite(false) +{} + +PaletteColor::PaletteColor(const QColor &color) + : m_color(color) + , m_colorCode(color.name(QColor::HexArgb)) + , m_isFavorite(false) +{} + +QVariant PaletteColor::getProperty(Property id) const +{ + QVariant out; + + switch (id) { + case objectNameRole: + out.setValue(QString()); + break; + case colorRole: + out.setValue(color()); + break; + case colorCodeRole: + out.setValue(colorCode()); + break; + case isFavoriteRole: + out.setValue(isFavorite()); + break; + default: + qWarning() << "PaletteColor Property switch default case"; + break; //replace with assert before switch? + } + + return out; +} + +QColor PaletteColor::color() const +{ + return m_color; +} + +void PaletteColor::setColor(const QColor &value) +{ + m_color = value; + m_colorCode = m_color.name(QColor::HexArgb); +} + +QString PaletteColor::colorCode() const +{ + return m_colorCode; +} + +bool PaletteColor::isFavorite() const +{ + return m_isFavorite; +} + +void PaletteColor::setFavorite(bool favorite) +{ + m_isFavorite = favorite; +} + +bool PaletteColor::toggleFavorite() +{ + return m_isFavorite = !m_isFavorite; +} + +bool PaletteColor::operator==(const PaletteColor &other) const +{ + return (m_color == other.m_color); +} + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.h b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.h new file mode 100644 index 0000000000..342c9832e7 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalette.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QObject> +#include <QtQml/qqml.h> +#include <QColor> + +namespace QmlDesigner { + +class PaletteColor +{ + Q_GADGET + + Q_PROPERTY(QColor color READ color FINAL) + Q_PROPERTY(QString colorCode READ colorCode FINAL) + Q_PROPERTY(bool isFavorite READ isFavorite FINAL) +public: + PaletteColor(); + PaletteColor(const QString &colorCode); + PaletteColor(const QColor &value); + ~PaletteColor() = default; + + enum Property { + objectNameRole = 0, + colorRole = 1, + colorCodeRole = 2, + isFavoriteRole = 3 + }; + + QVariant getProperty(Property id) const; + + QColor color() const; + void setColor(const QColor &value); + + QString colorCode() const; + + bool isFavorite() const; + void setFavorite(bool favorite); + bool toggleFavorite(); + + bool operator==(const PaletteColor &other) const; + +private: + QColor m_color; + QString m_colorCode; + bool m_isFavorite; +}; + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::PaletteColor) diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp new file mode 100644 index 0000000000..b3207f0006 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "simplecolorpalettemodel.h" +#include "simplecolorpalette.h" +#include "simplecolorpalettesingleton.h" + +#include "designersettings.h" + +#include <QHash> +#include <QByteArray> +#include <QDebug> +#include <QSettings> + +namespace QmlDesigner { + +SimpleColorPaletteModel::SimpleColorPaletteModel(QObject *parent) + : QAbstractListModel(parent) +{ + connect(&SimpleColorPaletteSingleton::getInstance(), + &SimpleColorPaletteSingleton::paletteChanged, + this, + &SimpleColorPaletteModel::setPalette); + m_roleNames = {{static_cast<int>(PaletteColor::Property::objectNameRole), "objectName"}, + {static_cast<int>(PaletteColor::Property::colorRole), "color"}, + {static_cast<int>(PaletteColor::Property::colorCodeRole), "colorCode"}, + {static_cast<int>(PaletteColor::Property::isFavoriteRole), "isFavorite"}}; + + setPalette(); +} + +SimpleColorPaletteModel::~SimpleColorPaletteModel() +{ + clearItems(); +} + +int SimpleColorPaletteModel::rowCount(const QModelIndex & /*parent*/) const +{ + return m_items.count(); +} + +QVariant SimpleColorPaletteModel::data(const QModelIndex &index, int role) const +{ + if (index.isValid() && (index.row() >= 0) && (index.row() < m_items.count())) { + if (m_roleNames.contains(role)) { + QVariant value = m_items.at(index.row()) + .getProperty(static_cast<PaletteColor::Property>(role)); + if (auto model = qobject_cast<SimpleColorPaletteModel *>(value.value<QObject *>())) + return QVariant::fromValue(model); + + return value; + } + + qWarning() << Q_FUNC_INFO << "invalid role requested"; + return QVariant(); + } + + qWarning() << Q_FUNC_INFO << "invalid index requested"; + return QVariant(); +} + +QHash<int, QByteArray> SimpleColorPaletteModel::roleNames() const +{ + return m_roleNames; +} + +void SimpleColorPaletteModel::clearItems() +{ + beginResetModel(); + m_items.clear(); + endResetModel(); +} + +void SimpleColorPaletteModel::addItem(const QString &item) +{ + PaletteColor palette(item); + addItem(palette); +} + +void SimpleColorPaletteModel::addItem(const PaletteColor &item) +{ + SimpleColorPaletteSingleton::getInstance().addItem(item); +} + +const QList<PaletteColor> &SimpleColorPaletteModel::items() const +{ + return m_items; +} + +void SimpleColorPaletteModel::sortItems() +{ + SimpleColorPaletteSingleton::getInstance().sortItems(); +} + +void SimpleColorPaletteModel::registerDeclarativeType() +{ + qmlRegisterType<SimpleColorPaletteModel>("HelperWidgets", 2, 0, "SimpleColorPaletteModel"); +} + +void SimpleColorPaletteModel::toggleFavorite(int id) +{ + SimpleColorPaletteSingleton::getInstance().toggleFavorite(id); +} + +void SimpleColorPaletteModel::setPalette() +{ + beginResetModel(); + m_items = SimpleColorPaletteSingleton::getInstance().getItems(); + m_favoriteOffset = SimpleColorPaletteSingleton::getInstance().getFavoriteOffset(); + m_paletteSize = SimpleColorPaletteSingleton::getInstance().getPaletteSize(); + endResetModel(); +} + +bool SimpleColorPaletteModel::read() +{ + return SimpleColorPaletteSingleton::getInstance().readPalette(); +} + +void SimpleColorPaletteModel::write() +{ + SimpleColorPaletteSingleton::getInstance().writePalette(); +} + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h new file mode 100644 index 0000000000..3ed2cc8a31 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettemodel.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QAbstractListModel> +#include <QtQml/qqml.h> +#include <QList> + +namespace QmlDesigner { + +class PaletteColor; + +class SimpleColorPaletteModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit SimpleColorPaletteModel(QObject *parent = nullptr); + ~SimpleColorPaletteModel() override; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash<int, QByteArray> roleNames() const override; + + void clearItems(); + Q_INVOKABLE void addItem(const QString &item); + void addItem(const PaletteColor &item); + + const QList<PaletteColor> &items() const; + + void sortItems(); + + static void registerDeclarativeType(); + + Q_INVOKABLE void toggleFavorite(int id); + + bool read(); + void write(); + +private slots: + void setPalette(); + +private: + void enqueue(const PaletteColor &item); + +private: + int m_paletteSize; + int m_favoriteOffset; + QList<PaletteColor> m_items; + QHash<int, QByteArray> m_roleNames; +}; + +} // namespace QmlDesigner + +QML_DECLARE_TYPE(QmlDesigner::SimpleColorPaletteModel) diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.cpp b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.cpp new file mode 100644 index 0000000000..ccea50bbf2 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "simplecolorpalettesingleton.h" +#include "simplecolorpalette.h" + +#include "designersettings.h" + +#include <QDebug> +#include <QSettings> + +namespace QmlDesigner { + +SimpleColorPaletteSingleton::SimpleColorPaletteSingleton() + : m_items() + , m_favoriteOffset(0) +{ + if (!readPalette()) { + for (int i = 0; i < m_paletteSize; i++) + m_items.append(PaletteColor()); + } +} + +SimpleColorPaletteSingleton &SimpleColorPaletteSingleton::getInstance() +{ + static SimpleColorPaletteSingleton singleton; + + return singleton; +} + +void SimpleColorPaletteSingleton::addItem(const PaletteColor &item) +{ + if (m_favoriteOffset >= m_paletteSize) + return; + + if (item.isFavorite()) { + int contains = m_items.indexOf(item); + if (contains != -1) { + if (m_items.at(contains).isFavorite()) + return; + else + m_items.removeAt(contains); + } + m_items.insert(0, item); + m_favoriteOffset++; + } else if (m_items.contains(item)) + return; + else + m_items.insert(m_favoriteOffset, item); + + while (m_items.size() > m_paletteSize) { + m_items.removeLast(); + } + + writePalette(); + + emit paletteChanged(); +} + +QList<PaletteColor> SimpleColorPaletteSingleton::getItems() const +{ + return m_items; +} + +int SimpleColorPaletteSingleton::getPaletteSize() const +{ + return m_paletteSize; +} + +int SimpleColorPaletteSingleton::getFavoriteOffset() const +{ + return m_favoriteOffset; +} + +void SimpleColorPaletteSingleton::sortItems() +{ + auto itemSort = [](const PaletteColor &first, const PaletteColor &second) { + return (static_cast<int>(first.isFavorite()) < static_cast<int>(second.isFavorite())); + }; + + std::sort(m_items.begin(), m_items.end(), itemSort); + + emit paletteChanged(); +} + +void SimpleColorPaletteSingleton::toggleFavorite(int id) +{ + bool toggleResult = m_items[id].toggleFavorite(); + + if (toggleResult) { + m_favoriteOffset++; + m_items.move(id, 0); + } else { + m_favoriteOffset--; + m_items.move(id, m_favoriteOffset); + } + + if (m_favoriteOffset < 0) + m_favoriteOffset = 0; + else if (m_favoriteOffset > m_paletteSize) + m_favoriteOffset = m_paletteSize; + + emit paletteChanged(); +} + +bool SimpleColorPaletteSingleton::readPalette() +{ + QList<PaletteColor> proxy; + const QStringList stringData = QmlDesigner::DesignerSettings::getValue( + QmlDesigner::DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT) + .toStringList(); + + int favCounter = 0; + + for (int i = 0; i < stringData.size(); i++) { + const QStringList strsep = stringData.at(i).split(";"); + if (strsep.size() != 2) { + continue; + } + PaletteColor colorItem(strsep.at(0)); + bool isFav = static_cast<bool>(strsep.at(1).toInt()); + colorItem.setFavorite(isFav); + if (isFav) + favCounter++; + proxy.append(colorItem); + } + + if (proxy.size() == 0) { + return false; + } + + while (proxy.size() > m_paletteSize) { + proxy.removeLast(); + } + while (proxy.size() < m_paletteSize) { + proxy.append(PaletteColor()); + } + + m_items.clear(); + m_items = proxy; + m_favoriteOffset = favCounter; + + return true; +} + +void SimpleColorPaletteSingleton::writePalette() +{ + QStringList output; + QString subres; + + for (int i = 0; i < m_items.size(); i++) { + subres = m_items.at(i).color().name(QColor::HexArgb); + subres += ";"; + subres += QString::number(static_cast<int>(m_items.at(i).isFavorite())); + output.push_back(subres); + subres.clear(); + } + + QmlDesigner::DesignerSettings::setValue( + QmlDesigner::DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, output); +} + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.h b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.h new file mode 100644 index 0000000000..77ad2b0732 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/simplecolorpalettesingleton.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QObject> +#include <QAbstractListModel> +#include <QtQml/qqml.h> +#include <QList> +#include <QColor> +#include <simplecolorpalette.h> + +namespace QmlDesigner { + +class SimpleColorPaletteSingleton : public QObject +{ + Q_OBJECT +public: + static SimpleColorPaletteSingleton &getInstance(); + + bool readPalette(); + void writePalette(); + + void addItem(const PaletteColor &item); + QList<PaletteColor> getItems() const; + + int getPaletteSize() const; + int getFavoriteOffset() const; + + void sortItems(); + + void toggleFavorite(int id); + + SimpleColorPaletteSingleton(const SimpleColorPaletteSingleton &) = delete; + void operator=(const SimpleColorPaletteSingleton &) = delete; + +signals: + void paletteChanged(); + +private: + SimpleColorPaletteSingleton(); + +private: + QList<PaletteColor> m_items; + const int m_paletteSize = 6; + int m_favoriteOffset; +}; + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.cpp b/src/plugins/qmldesigner/components/sourcetool/sourcetool.cpp index d121e60c73..d121e60c73 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.cpp +++ b/src/plugins/qmldesigner/components/sourcetool/sourcetool.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.h b/src/plugins/qmldesigner/components/sourcetool/sourcetool.h index 16797b3912..16797b3912 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.h +++ b/src/plugins/qmldesigner/components/sourcetool/sourcetool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.pri b/src/plugins/qmldesigner/components/sourcetool/sourcetool.pri index 8117fd73e9..8117fd73e9 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/sourcetool/sourcetool.pri +++ b/src/plugins/qmldesigner/components/sourcetool/sourcetool.pri diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index 07e758b35a..ae7400e382 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -185,6 +185,7 @@ void StatesEditorModel::renameState(int internalNodeId, const QString &newName) newName.isEmpty() ? tr("The empty string as a name is reserved for the base state.") : tr("Name already used in another state")); + reset(); } else { m_statesEditorView->renameState(internalNodeId, newName); } diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 2f8bc56650..572b454892 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -31,7 +31,6 @@ namespace QmlDesigner { - class StatesEditorModel; class StatesEditorWidget; diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititem.cpp b/src/plugins/qmldesigner/components/texttool/textedititem.cpp index 1ce3244cbc..1ce3244cbc 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititem.cpp +++ b/src/plugins/qmldesigner/components/texttool/textedititem.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititem.h b/src/plugins/qmldesigner/components/texttool/textedititem.h index 5497dadbe1..5497dadbe1 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititem.h +++ b/src/plugins/qmldesigner/components/texttool/textedititem.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititemwidget.cpp b/src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp index 40efb67e77..40efb67e77 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititemwidget.cpp +++ b/src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititemwidget.h b/src/plugins/qmldesigner/components/texttool/textedititemwidget.h index 7ff2909919..7ff2909919 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/textedititemwidget.h +++ b/src/plugins/qmldesigner/components/texttool/textedititemwidget.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.cpp b/src/plugins/qmldesigner/components/texttool/texttool.cpp index 76dc414c03..76dc414c03 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.cpp +++ b/src/plugins/qmldesigner/components/texttool/texttool.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.h b/src/plugins/qmldesigner/components/texttool/texttool.h index b7c352c917..b7c352c917 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.h +++ b/src/plugins/qmldesigner/components/texttool/texttool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.pri b/src/plugins/qmldesigner/components/texttool/texttool.pri index 0cfdfb7629..0cfdfb7629 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/texttool/texttool.pri +++ b/src/plugins/qmldesigner/components/texttool/texttool.pri diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvas.cpp b/src/plugins/qmldesigner/components/timelineeditor/canvas.cpp index eab3d0bf56..eab3d0bf56 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvas.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/canvas.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvas.h b/src/plugins/qmldesigner/components/timelineeditor/canvas.h index c4491e4b79..c4491e4b79 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvas.h +++ b/src/plugins/qmldesigner/components/timelineeditor/canvas.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/canvasstyledialog.cpp index f9a948fb14..88d78615ca 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/canvasstyledialog.cpp @@ -54,7 +54,7 @@ CanvasStyleDialog::CanvasStyleDialog(const CanvasStyle &style, QWidget *parent) m_handleLineWidth->setValue(style.handleLineWidth); m_curveWidth->setValue(style.curveWidth); - int labelWidth = QFontMetrics(this->font()).width("Inter Handle ColorXX"); + int labelWidth = QFontMetrics(this->font()).horizontalAdvance("Inter Handle ColorXX"); auto addControl = [labelWidth](QVBoxLayout *layout, const QString &name, QWidget *control) { auto *hbox = new QHBoxLayout; @@ -100,7 +100,7 @@ CanvasStyleDialog::CanvasStyleDialog(const CanvasStyle &style, QWidget *parent) emit styleChanged(out); }; - auto doubleValueChanged = static_cast<void (QDoubleSpinBox::*)(double)>( + auto doubleValueChanged = QOverload<double>::of( &QDoubleSpinBox::valueChanged); auto colorValueChanged = &ColorControl::valueChanged; diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.h b/src/plugins/qmldesigner/components/timelineeditor/canvasstyledialog.h index b3b1a86c95..b3b1a86c95 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/canvasstyledialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/canvasstyledialog.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurve.cpp b/src/plugins/qmldesigner/components/timelineeditor/easingcurve.cpp index 3437d3bd68..cae0bfab09 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurve.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurve.cpp @@ -58,6 +58,8 @@ EasingCurve::EasingCurve(const QPointF &start, const QVector<QPointF> &points) fromCubicSpline(points); } +EasingCurve &EasingCurve::operator=(const EasingCurve &curve) = default; + EasingCurve::~EasingCurve() = default; bool EasingCurve::IsValidIndex(int idx) diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurve.h b/src/plugins/qmldesigner/components/timelineeditor/easingcurve.h index bc27d17884..d46f5600aa 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurve.h +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurve.h @@ -46,6 +46,8 @@ public: virtual ~EasingCurve(); + EasingCurve &operator=(const EasingCurve &curve); + static bool IsValidIndex(int idx); static void registerStreamOperators(); diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurvedialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp index 5d6d66a472..a069dc187b 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurvedialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp @@ -146,7 +146,7 @@ EasingCurveDialog::EasingCurveDialog(const QList<ModelNode> &frames, QWidget *pa connect(m_presets, &PresetEditor::presetChanged, m_splineEditor, &SplineEditor::setEasingCurve); connect(durationEdit, - static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + QOverload<int>::of(&QSpinBox::valueChanged), m_splineEditor, &SplineEditor::setDuration); @@ -202,22 +202,13 @@ bool EasingCurveDialog::apply() msgBox.exec(); return false; } + AbstractView *view = m_frames.first().view(); - try { - AbstractView *view = m_frames.first().view(); - RewriterTransaction transaction(view->beginRewriterTransaction("EasingCurveDialog::apply")); - + return view->executeInTransaction("EasingCurveDialog::apply", [this, view](){ auto expression = m_splineEditor->easingCurve().toString(); for (const auto &frame : m_frames) frame.bindingProperty("easing.bezierCurve").setExpression(expression); - - transaction.commit(); - return true; - } catch (const RewritingException &e) { - e.showException(); - } - - return false; + }); } void EasingCurveDialog::textChanged() diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurvedialog.h b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h index a8c026989c..a8c026989c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/easingcurvedialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/add_timeline.png b/src/plugins/qmldesigner/components/timelineeditor/images/add_timeline.png Binary files differindex af651276ed..af651276ed 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/add_timeline.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/add_timeline.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/add_timeline@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/add_timeline@2x.png Binary files differindex 58a7174288..58a7174288 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/add_timeline@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/add_timeline@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/animation.png b/src/plugins/qmldesigner/components/timelineeditor/images/animation.png Binary files differindex 20ad0273b5..20ad0273b5 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/animation.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/animation.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/animation@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/animation@2x.png Binary files differindex 1ecf1857c7..1ecf1857c7 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/animation@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/animation@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/back_one_frame.png b/src/plugins/qmldesigner/components/timelineeditor/images/back_one_frame.png Binary files differindex 69c93ebe3e..69c93ebe3e 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/back_one_frame.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/back_one_frame.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/back_one_frame@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/back_one_frame@2x.png Binary files differindex 9bd8a52e59..9bd8a52e59 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/back_one_frame@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/back_one_frame@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_editor.png b/src/plugins/qmldesigner/components/timelineeditor/images/curve_editor.png Binary files differindex bda4dc0095..bda4dc0095 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_editor.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/curve_editor.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_editor@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/curve_editor@2x.png Binary files differindex 3d5c3abe05..3d5c3abe05 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_editor@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/curve_editor@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_picker.png b/src/plugins/qmldesigner/components/timelineeditor/images/curve_picker.png Binary files differindex 4842ac0738..4842ac0738 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_picker.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/curve_picker.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_picker@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/curve_picker@2x.png Binary files differindex 0d99fc180c..0d99fc180c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/curve_picker@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/curve_picker@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/forward_one_frame.png b/src/plugins/qmldesigner/components/timelineeditor/images/forward_one_frame.png Binary files differindex 0846f194e0..0846f194e0 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/forward_one_frame.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/forward_one_frame.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/forward_one_frame@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/forward_one_frame@2x.png Binary files differindex 8e5ddc3930..8e5ddc3930 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/forward_one_frame@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/forward_one_frame@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/global_record_keyframes.png b/src/plugins/qmldesigner/components/timelineeditor/images/global_record_keyframes.png Binary files differindex 64a28ca075..64a28ca075 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/global_record_keyframes.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/global_record_keyframes.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/global_record_keyframes@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/global_record_keyframes@2x.png Binary files differindex 534737f385..534737f385 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/global_record_keyframes@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/global_record_keyframes@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/is_keyframe.png b/src/plugins/qmldesigner/components/timelineeditor/images/is_keyframe.png Binary files differindex 5655e0b278..5655e0b278 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/is_keyframe.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/is_keyframe.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/is_keyframe@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/is_keyframe@2x.png Binary files differindex 2f522c22b6..2f522c22b6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/is_keyframe@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/is_keyframe@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe-16px.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe-16px.png Binary files differindex 6e1c9f912a..6e1c9f912a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe-16px.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe-16px.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe.png Binary files differindex 6bf7d1ad53..6bf7d1ad53 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe@2x.png Binary files differindex 5102e279a1..5102e279a1 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_active.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_active.png Binary files differindex 8a3eaa7888..8a3eaa7888 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_active.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_active.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_active@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_active@2x.png Binary files differindex e0168a097a..e0168a097a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_active@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_active@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_inactive.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_inactive.png Binary files differindex 2c12d98e01..2c12d98e01 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_inactive.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_inactive.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_inactive@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_inactive@2x.png Binary files differindex 4bbbe6cd3f..4bbbe6cd3f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_inactive@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_inactive@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_selected.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_selected.png Binary files differindex 58ccb7c765..58ccb7c765 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_selected.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_selected.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_selected@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_selected@2x.png Binary files differindex 829dd99391..829dd99391 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_autobezier_selected@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_autobezier_selected@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_active.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_active.png Binary files differindex a195ac5fca..a195ac5fca 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_active.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_active.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_active@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_active@2x.png Binary files differindex fd879e5837..fd879e5837 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_active@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_active@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_inactive.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_inactive.png Binary files differindex b84a800097..b84a800097 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_inactive.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_inactive.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_inactive@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_inactive@2x.png Binary files differindex 0ad868dcd6..0ad868dcd6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_inactive@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_inactive@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_selected.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_selected.png Binary files differindex e840819f2d..e840819f2d 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_selected.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_selected.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_selected@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_selected@2x.png Binary files differindex e5f63f1fc9..e5f63f1fc9 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_linear_selected@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_linear_selected@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_active.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_active.png Binary files differindex f85d3f78fd..f85d3f78fd 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_active.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_active.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_active@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_active@2x.png Binary files differindex 2f65f7970c..2f65f7970c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_active@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_active@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_inactive.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_inactive.png Binary files differindex 9798c76115..9798c76115 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_inactive.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_inactive.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_inactive@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_inactive@2x.png Binary files differindex b4ee45a566..b4ee45a566 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_inactive@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_inactive@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_selected.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_selected.png Binary files differindex 1e39f84502..1e39f84502 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_selected.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_selected.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_selected@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_selected@2x.png Binary files differindex b99474718c..b99474718c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_lineartobezier_selected@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_lineartobezier_selected@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_active.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_active.png Binary files differindex 4b6a7c8978..4b6a7c8978 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_active.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_active.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_active@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_active@2x.png Binary files differindex fd85a10758..fd85a10758 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_active@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_active@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_inactive.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_inactive.png Binary files differindex 9c0a1fd550..9c0a1fd550 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_inactive.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_inactive.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_inactive@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_inactive@2x.png Binary files differindex 1299a370fc..1299a370fc 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_inactive@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_inactive@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_selected.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_selected.png Binary files differindex 7b5faebae0..7b5faebae0 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_selected.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_selected.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_selected@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_selected@2x.png Binary files differindex 726ead7a43..726ead7a43 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/keyframe_manualbezier_selected@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/keyframe_manualbezier_selected@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/local_record_keyframes.png b/src/plugins/qmldesigner/components/timelineeditor/images/local_record_keyframes.png Binary files differindex d68aa73214..d68aa73214 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/local_record_keyframes.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/local_record_keyframes.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/local_record_keyframes@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/local_record_keyframes@2x.png Binary files differindex f5265a2218..f5265a2218 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/local_record_keyframes@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/local_record_keyframes@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/loop_playback.png b/src/plugins/qmldesigner/components/timelineeditor/images/loop_playback.png Binary files differindex f38fbef1d4..f38fbef1d4 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/loop_playback.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/loop_playback.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/loop_playback@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/loop_playback@2x.png Binary files differindex b760a04133..b760a04133 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/loop_playback@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/loop_playback@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/next_keyframe.png b/src/plugins/qmldesigner/components/timelineeditor/images/next_keyframe.png Binary files differindex 415ec0127f..415ec0127f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/next_keyframe.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/next_keyframe.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/next_keyframe@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/next_keyframe@2x.png Binary files differindex 3f1e24e04a..3f1e24e04a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/next_keyframe@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/next_keyframe@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/pause_playback.png b/src/plugins/qmldesigner/components/timelineeditor/images/pause_playback.png Binary files differindex 001ca37b1c..001ca37b1c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/pause_playback.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/pause_playback.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/pause_playback@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/pause_playback@2x.png Binary files differindex 95e8567ccb..95e8567ccb 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/pause_playback@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/pause_playback@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/playhead.png b/src/plugins/qmldesigner/components/timelineeditor/images/playhead.png Binary files differindex 518a77f404..518a77f404 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/playhead.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/playhead.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/playhead@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/playhead@2x.png Binary files differindex 7f6778556b..7f6778556b 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/playhead@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/playhead@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/previous_keyframe.png b/src/plugins/qmldesigner/components/timelineeditor/images/previous_keyframe.png Binary files differindex 52ba668973..52ba668973 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/previous_keyframe.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/previous_keyframe.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/previous_keyframe@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/previous_keyframe@2x.png Binary files differindex df151051fc..df151051fc 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/previous_keyframe@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/previous_keyframe@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/remove_timeline.png b/src/plugins/qmldesigner/components/timelineeditor/images/remove_timeline.png Binary files differindex 0589f982a7..0589f982a7 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/remove_timeline.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/remove_timeline.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/remove_timeline@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/remove_timeline@2x.png Binary files differindex 9eed9ce3c3..9eed9ce3c3 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/remove_timeline@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/remove_timeline@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/start_playback.png b/src/plugins/qmldesigner/components/timelineeditor/images/start_playback.png Binary files differindex 0cf0865c48..0cf0865c48 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/start_playback.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/start_playback.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/start_playback@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/start_playback@2x.png Binary files differindex f05dfcd9ed..f05dfcd9ed 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/start_playback@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/start_playback@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/timeline-16px.png b/src/plugins/qmldesigner/components/timelineeditor/images/timeline-16px.png Binary files differindex d4ecf00031..d4ecf00031 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/timeline-16px.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/timeline-16px.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_first_frame.png b/src/plugins/qmldesigner/components/timelineeditor/images/to_first_frame.png Binary files differindex 910b856638..910b856638 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_first_frame.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/to_first_frame.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_first_frame@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/to_first_frame@2x.png Binary files differindex abefa72fb3..abefa72fb3 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_first_frame@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/to_first_frame@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_last_frame.png b/src/plugins/qmldesigner/components/timelineeditor/images/to_last_frame.png Binary files differindex d6bc429196..d6bc429196 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_last_frame.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/to_last_frame.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_last_frame@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/to_last_frame@2x.png Binary files differindex affc3c9848..affc3c9848 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/to_last_frame@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/to_last_frame@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_left.png b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_left.png Binary files differindex 83d441d64f..83d441d64f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_left.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_left.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_left@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_left@2x.png Binary files differindex 0fec4b269e..0fec4b269e 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_left@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_left@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_right.png b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_right.png Binary files differindex 611684a7f6..611684a7f6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_right.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_right.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_right@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_right@2x.png Binary files differindex c1dbdbc56c..c1dbdbc56c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/work_area_handle_right@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/work_area_handle_right@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_big.png b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_big.png Binary files differindex eec61eb86c..eec61eb86c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_big.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_big.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_big@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_big@2x.png Binary files differindex 1706de0bb4..1706de0bb4 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_big@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_big@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_small.png b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_small.png Binary files differindex 20433d99c4..20433d99c4 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_small.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_small.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_small@2x.png b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_small@2x.png Binary files differindex 326ea32c25..326ea32c25 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/images/zoom_small@2x.png +++ b/src/plugins/qmldesigner/components/timelineeditor/images/zoom_small@2x.png diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp index 4e6f9c9f17..8ea7692e3d 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp @@ -367,7 +367,7 @@ void PresetList::dataChanged(const QModelIndex &topLeft, const QVector<int> &roles) { if (topLeft == bottomRight && roles.contains(0)) { - const QVariant name = model()->data(topLeft, 0); + QVariant name = model()->data(topLeft, 0); model()->setData(topLeft, name, Qt::ToolTipRole); } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.h index 6fab3e7adb..6fab3e7adb 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h +++ b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.cpp index 4120aaee21..4120aaee21 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.h b/src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.h index e7ed226b67..e7ed226b67 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.ui b/src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.ui index 2fa1241e4a..2fa1241e4a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/setframevaluedialog.ui +++ b/src/plugins/qmldesigner/components/timelineeditor/setframevaluedialog.ui diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/splineeditor.cpp b/src/plugins/qmldesigner/components/timelineeditor/splineeditor.cpp index 44ef1f194c..44ef1f194c 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/splineeditor.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/splineeditor.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/splineeditor.h b/src/plugins/qmldesigner/components/timelineeditor/splineeditor.h index 8b454943ad..8b454943ad 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/splineeditor.h +++ b/src/plugins/qmldesigner/components/timelineeditor/splineeditor.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timeline.metainfo b/src/plugins/qmldesigner/components/timelineeditor/timeline.metainfo index c1d7e92bf5..c1d7e92bf5 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timeline.metainfo +++ b/src/plugins/qmldesigner/components/timelineeditor/timeline.metainfo diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timeline.qrc b/src/plugins/qmldesigner/components/timelineeditor/timeline.qrc index b793c1f8da..b793c1f8da 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timeline.qrc +++ b/src/plugins/qmldesigner/components/timelineeditor/timeline.qrc diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineabstracttool.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineabstracttool.cpp index 485bb8dbb0..485bb8dbb0 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineabstracttool.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineabstracttool.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineabstracttool.h b/src/plugins/qmldesigner/components/timelineeditor/timelineabstracttool.h index 0411a8d166..0411a8d166 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineabstracttool.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineabstracttool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineactions.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp index 419e9294a2..4751765874 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineactions.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp @@ -48,28 +48,18 @@ TimelineActions::TimelineActions() = default; void TimelineActions::deleteAllKeyframesForTarget(const ModelNode &targetNode, const QmlTimeline &timeline) { - try { - RewriterTransaction transaction(targetNode.view()->beginRewriterTransaction( - "TimelineActions::deleteAllKeyframesForTarget")); - + targetNode.view()->executeInTransaction("TimelineActions::deleteAllKeyframesForTarget", [=](){ if (timeline.isValid()) { for (auto frames : timeline.keyframeGroupsForTarget(targetNode)) frames.destroy(); } - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode, const QmlTimeline &timeline) { - try { - RewriterTransaction transaction(targetNode.view()->beginRewriterTransaction( - "TimelineGraphicsScene::insertAllKeyframesForTarget")); - + targetNode.view()->executeInTransaction("TimelineActions::insertAllKeyframesForTarget", [=](){ auto object = QmlObjectNode(targetNode); if (timeline.isValid() && object.isValid()) { for (auto frames : timeline.keyframeGroupsForTarget(targetNode)) { @@ -78,10 +68,7 @@ void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode, } } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } void TimelineActions::copyAllKeyframesForTarget(const ModelNode &targetNode, @@ -117,11 +104,10 @@ void TimelineActions::pasteKeyframesToTarget(const ModelNode &targetNode, pasteModel->detachView(&view); - try { - targetNode.view()->model()->attachView(&view); + view.executeInTransaction("TimelineActions::pasteKeyframesToTarget", [=, &view](){ - RewriterTransaction transaction( - view.beginRewriterTransaction("TimelineActions::pasteKeyframesToTarget")); + + targetNode.view()->model()->attachView(&view); ModelNode nonConstTargetNode = targetNode; nonConstTargetNode.validId(); @@ -144,11 +130,7 @@ void TimelineActions::pasteKeyframesToTarget(const ModelNode &targetNode, timeline.modelNode().defaultNodeListProperty().reparentHere(newNode); } } - - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } } @@ -296,9 +278,7 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli ModelNode rootNode = view.rootModelNode(); - try { - RewriterTransaction transaction( - timelineView->beginRewriterTransaction("TimelineActions::pasteKeyframes")); + timelineView->executeInTransaction("TimelineActions::pasteKeyframes", [=](){ if (isKeyframe(rootNode)) pasteKeyframe(currentTime, rootNode, timelineView, timeline); else @@ -308,10 +288,7 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli timelineView, timeline); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } bool TimelineActions::clipboardContainsKeyframes() diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineactions.h b/src/plugins/qmldesigner/components/timelineeditor/timelineactions.h index bae09b110f..bae09b110f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineactions.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineactions.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.cpp index 65f77a0e5f..032a133f89 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.cpp @@ -56,7 +56,7 @@ TimelineAnimationForm::TimelineAnimationForm(QWidget *parent) connectSpinBox(ui->startFrame, "from"); connectSpinBox(ui->endFrame, "to"); - connect(ui->loops, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this]() { + connect(ui->loops, QOverload<int>::of(&QSpinBox::valueChanged), [this]() { ui->continuous->setChecked(ui->loops->value() == -1); }); @@ -122,7 +122,7 @@ TimelineAnimationForm::TimelineAnimationForm(QWidget *parent) }); connect(ui->transitionToState, - static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), + QOverload<int>::of(&QComboBox::activated), [this](int index) { if (!m_animation.isValid()) return; diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.h b/src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.h index 1b5eaf6cab..1b5eaf6cab 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.ui b/src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.ui index 5d13cfa726..5d13cfa726 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineanimationform.ui +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineanimationform.ui diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineconstants.h b/src/plugins/qmldesigner/components/timelineeditor/timelineconstants.h index 6c012beec1..6c012beec1 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineconstants.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineconstants.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontext.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinecontext.cpp index b3e2e12a3f..b3e2e12a3f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontext.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinecontext.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontext.h b/src/plugins/qmldesigner/components/timelineeditor/timelinecontext.h index a8a6ca3b8f..a8a6ca3b8f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontext.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinecontext.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontrols.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinecontrols.cpp index 682a14f1c7..682a14f1c7 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontrols.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinecontrols.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontrols.h b/src/plugins/qmldesigner/components/timelineeditor/timelinecontrols.h index 4c30357be9..4c30357be9 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinecontrols.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinecontrols.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineeditor.pri b/src/plugins/qmldesigner/components/timelineeditor/timelineeditor.pri index 8001748fb0..8001748fb0 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineeditor.pri +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineeditor.pri diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineform.cpp index eb63ad4883..eb63ad4883 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineform.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.h b/src/plugins/qmldesigner/components/timelineeditor/timelineform.h index 7745de3a0f..7745de3a0f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineform.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.ui b/src/plugins/qmldesigner/components/timelineeditor/timelineform.ui index b8b47e4c70..b8b47e4c70 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineform.ui +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineform.ui diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicslayout.cpp index 57daef4966..af0f26d249 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicslayout.cpp @@ -120,8 +120,10 @@ void TimelineGraphicsLayout::setTimeline(const QmlTimeline &timeline) if (timeline.isValid()) { for (const ModelNode &target : timeline.allTargets()) { - auto item = TimelineSectionItem::create(timeline, target, this); - m_layout->addItem(item); + if (target.isValid()) { + auto item = TimelineSectionItem::create(timeline, target, this); + m_layout->addItem(item); + } } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.h b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicslayout.h index d5b7c4debc..d5b7c4debc 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicslayout.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicslayout.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicsscene.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp index eb09492397..99cc486710 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicsscene.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.cpp @@ -663,26 +663,16 @@ void TimelineGraphicsScene::deleteKeyframeGroup(const ModelNode &group) if (!QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(group)) return; - ModelNode nonConst = group; - - try { - RewriterTransaction transaction(timelineView()->beginRewriterTransaction( - "TimelineGraphicsScene::handleKeyframeGroupDeletion")); - + timelineView()->executeInTransaction("TimelineGraphicsScene::handleKeyframeGroupDeletion", [group](){ + ModelNode nonConst = group; nonConst.destroy(); + }); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } } void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames) { - try { - RewriterTransaction transaction(timelineView()->beginRewriterTransaction( - "TimelineGraphicsScene::handleKeyframeDeletion")); - + timelineView()->executeInTransaction("TimelineGraphicsScene::handleKeyframeDeletion", [frames](){ for (auto keyframe : frames) { if (keyframe.isValid()) { ModelNode frame = keyframe; @@ -692,10 +682,7 @@ void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames) parent.destroy(); } } - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } void TimelineGraphicsScene::activateLayout() diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicsscene.h b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.h index b8f93595c4..b8f93595c4 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinegraphicsscene.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinegraphicsscene.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineicons.h b/src/plugins/qmldesigner/components/timelineeditor/timelineicons.h index 641d4e77b6..641d4e77b6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineicons.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineicons.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineitem.cpp index ebe3644e4e..ebe3644e4e 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineitem.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.h b/src/plugins/qmldesigner/components/timelineeditor/timelineitem.h index 87fb9e3ec8..87fb9e3ec8 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineitem.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineitem.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovableabstractitem.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinemovableabstractitem.cpp index 4db4567fd6..4db4567fd6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovableabstractitem.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinemovableabstractitem.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovableabstractitem.h b/src/plugins/qmldesigner/components/timelineeditor/timelinemovableabstractitem.h index 4bc11675c2..4bc11675c2 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovableabstractitem.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinemovableabstractitem.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinemovetool.cpp index 49d35b781b..0384d7c0a3 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinemovetool.cpp @@ -136,15 +136,12 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item, } } - try { - RewriterTransaction transaction(scene()->timelineView()->beginRewriterTransaction( - "TimelineMoveTool::mouseReleaseEvent")); - + scene()->timelineView()->executeInTransaction("TimelineMoveTool::mouseReleaseEvent", [this, current](){ current->commitPosition(mapToItem(current, current->rect().center())); if (current->asTimelineKeyframeItem()) { double frame = std::round( - current->mapFromSceneToFrame(current->rect().center().x())); + current->mapFromSceneToFrame(current->rect().center().x())); scene()->statusBarMessageChanged(QObject::tr("Frame %1").arg(frame)); @@ -152,12 +149,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item, if (keyframe != current) keyframe->commitPosition(mapToItem(current, keyframe->rect().center())); } - - transaction.commit(); - - } catch (const Exception &e) { - e.showException(); - } + }); } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.h b/src/plugins/qmldesigner/components/timelineeditor/timelinemovetool.h index 55b9a39417..55b9a39417 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinemovetool.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinemovetool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineplaceholder.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineplaceholder.cpp index 7e7cb69fc9..7e7cb69fc9 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineplaceholder.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineplaceholder.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineplaceholder.h b/src/plugins/qmldesigner/components/timelineeditor/timelineplaceholder.h index 14d6d8a2fc..14d6d8a2fc 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineplaceholder.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineplaceholder.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinepropertyitem.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp index d0b89dfef4..beeca23183 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinepropertyitem.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp @@ -534,15 +534,9 @@ void TimelineKeyframeItem::commitPosition(const QPointF &point) blockUpdates(); - try { - RewriterTransaction transaction( - m_frame.view()->beginRewriterTransaction("TimelineKeyframeItem::commitPosition")); - + m_frame.view()->executeInTransaction("TimelineKeyframeItem::commitPosition", [this, frame](){ m_frame.variantProperty("frame").setValue(frame); - transaction.commit(); - } catch (const RewritingException &e) { - e.showException(); - } + }); enableUpdates(); } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinepropertyitem.h b/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.h index 2b8c00c59b..2b8c00c59b 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinepropertyitem.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinesectionitem.cpp index 3c24b38d35..7bd784a7dd 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesectionitem.cpp @@ -705,7 +705,7 @@ void TimelineRulerSectionItem::paintTicks(QPainter *painter) QFontMetrics fm(painter->font()); - int minSpacingText = fm.width(QString("X%1X").arg(rulerDuration())); + int minSpacingText = fm.horizontalAdvance(QString("X%1X").arg(rulerDuration())); int minSpacingLine = 5; int deltaText = 0; @@ -821,20 +821,15 @@ void TimelineBarItem::commitPosition(const QPointF & /*point*/) { if (sectionItem()->view()) { if (m_handle != Location::Undefined) { - qreal scaleFactor = rect().width() / m_oldRect.width(); + sectionItem()->view()->executeInTransaction("TimelineBarItem::commitPosition", [this](){ + qreal scaleFactor = rect().width() / m_oldRect.width(); - qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling(); - qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved); + qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling(); + qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved); - try { - RewriterTransaction transaction(sectionItem()->view()->beginRewriterTransaction( - "TimelineBarItem::commitPosition")); sectionItem()->scaleAllFrames(scaleFactor); sectionItem()->moveAllFrames(supposedFirstFrame - sectionItem()->firstFrame()); - transaction.commit(); - } catch (const RewritingException &e) { - e.showException(); - } + }); } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.h b/src/plugins/qmldesigner/components/timelineeditor/timelinesectionitem.h index 26db04f757..26db04f757 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesectionitem.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesectionitem.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineselectiontool.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineselectiontool.cpp index 53367c9b67..53367c9b67 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineselectiontool.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineselectiontool.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineselectiontool.h b/src/plugins/qmldesigner/components/timelineeditor/timelineselectiontool.h index 3485e087ec..3485e087ec 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineselectiontool.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineselectiontool.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.cpp index 960c409553..960c409553 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.h b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.h index da4ddac4f6..da4ddac4f6 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.ui b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.ui index f3dfa6f094..f3dfa6f094 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsdialog.ui +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsdialog.ui diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsmodel.cpp index 509a8878e8..f75d129983 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsmodel.cpp @@ -126,7 +126,7 @@ QWidget *TimelineEditorDelegate::createEditor(QWidget *parent, } if (comboBox) { - connect(comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() { + connect(comboBox, QOverload<int>::of(&QComboBox::activated), this, [=]() { auto delegate = const_cast<TimelineEditorDelegate *>(this); emit delegate->commitData(comboBox); }); @@ -266,15 +266,13 @@ ModelNode TimelineSettingsModel::animationForTimelineAndState(const QmlTimeline void TimelineSettingsModel::updateTimeline(int row) { - QmlModelState modelState(stateForRow(row)); - QmlTimeline timeline(timelineForRow(row)); - ModelNode animation(animationForRow(row)); - QmlTimeline oldTimeline = timelineView()->timelineForState(modelState); - RewriterTransaction transaction = timelineView()->beginRewriterTransaction( - QByteArrayLiteral("TimelineSettingsModel::updateTimeline")); + timelineView()->executeInTransaction("TimelineSettingsModel::updateTimeline", [this, row](){ + QmlModelState modelState(stateForRow(row)); + QmlTimeline timeline(timelineForRow(row)); + ModelNode animation(animationForRow(row)); + QmlTimeline oldTimeline = timelineView()->timelineForState(modelState); - try { if (modelState.isBaseState()) { if (oldTimeline.isValid()) oldTimeline.modelNode().variantProperty("enabled").setValue(false); @@ -295,33 +293,26 @@ void TimelineSettingsModel::updateTimeline(int row) propertyChanges.modelNode().variantProperty("enabled").setValue(false); } - if (timeline.isValid()) { + if (timeline.isValid()) { /* If timeline is invalid 'none' was selected */ QmlPropertyChanges propertyChanges(modelState.propertyChanges(timeline)); if (propertyChanges.isValid()) propertyChanges.modelNode().variantProperty("enabled").setValue(true); } } - - } catch (Exception &e) { - m_exceptionError = e.description(); - QTimer::singleShot(200, this, &TimelineSettingsModel::handleException); - } + }); resetRow(row); } void TimelineSettingsModel::updateAnimation(int row) { - QmlModelState modelState(stateForRow(row)); - QmlTimeline timeline(timelineForRow(row)); - ModelNode animation(animationForRow(row)); - QmlTimeline oldTimeline = timelineView()->timelineForState(modelState); - ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState); + timelineView()->executeInTransaction("TimelineSettingsModel::updateAnimation", [this, row](){ + QmlModelState modelState(stateForRow(row)); + QmlTimeline timeline(timelineForRow(row)); + ModelNode animation(animationForRow(row)); + QmlTimeline oldTimeline = timelineView()->timelineForState(modelState); + ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState); - RewriterTransaction transaction = timelineView()->beginRewriterTransaction( - QByteArrayLiteral("TimelineSettingsModel::updateAnimation")); - - try { if (modelState.isBaseState()) { if (oldAnimation.isValid()) oldAnimation.variantProperty("running").setValue(false); @@ -347,33 +338,26 @@ void TimelineSettingsModel::updateAnimation(int row) } } - if (animation.isValid()) { + if (animation.isValid()) { /* If animation is invalid 'none' was selected */ QmlPropertyChanges propertyChanges(modelState.propertyChanges(animation)); if (propertyChanges.isValid()) propertyChanges.modelNode().variantProperty("running").setValue(true); } } - } catch (Exception &e) { - m_exceptionError = e.description(); - QTimer::singleShot(200, this, &TimelineSettingsModel::handleException); - } - + }); resetRow(row); } void TimelineSettingsModel::updateFixedFrameRow(int row) { - QmlModelState modelState(stateForRow(row)); - QmlTimeline timeline(timelineForRow(row)); + timelineView()->executeInTransaction("TimelineSettingsModel::updateFixedFrameRow", [this, row](){ + QmlModelState modelState(stateForRow(row)); + QmlTimeline timeline(timelineForRow(row)); - ModelNode animation = animationForTimelineAndState(timeline, modelState); + ModelNode animation = animationForTimelineAndState(timeline, modelState); - RewriterTransaction transaction = timelineView()->beginRewriterTransaction( - QByteArrayLiteral("TimelineSettingsModel::updateFixedFrameRow")); + int fixedFrame = fixedFrameForRow(row); - int fixedFrame = fixedFrameForRow(row); - - try { if (modelState.isBaseState()) { if (animation.isValid()) animation.variantProperty("running").setValue(false); @@ -390,10 +374,8 @@ void TimelineSettingsModel::updateFixedFrameRow(int row) if (propertyChanges.isValid()) propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame); } - } catch (Exception &e) { - m_exceptionError = e.description(); - QTimer::singleShot(200, this, &TimelineSettingsModel::handleException); - } + + }); resetRow(row); } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.h b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsmodel.h index afd4b58e1b..afd4b58e1b 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinesettingsmodel.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinesettingsmodel.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbar.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbar.cpp index adc49a97b1..adc49a97b1 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbar.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbar.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbar.h b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbar.h index 43d42b83f9..43d42b83f9 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbar.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbar.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbutton.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbutton.cpp index e6a9454186..e6a9454186 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbutton.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbutton.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbutton.h b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbutton.h index cdf024c0b2..cdf024c0b2 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetoolbutton.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinetoolbutton.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetooldelegate.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinetooldelegate.cpp index 51c5a7d088..51c5a7d088 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetooldelegate.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinetooldelegate.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetooldelegate.h b/src/plugins/qmldesigner/components/timelineeditor/timelinetooldelegate.h index f945c1a61b..f945c1a61b 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinetooldelegate.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinetooldelegate.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineutils.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineutils.cpp index 6873fc0b65..6873fc0b65 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineutils.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineutils.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineutils.h b/src/plugins/qmldesigner/components/timelineeditor/timelineutils.h index 0758733769..0758733769 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineutils.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineutils.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineview.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp index 653ed27ba7..f39a17db2f 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineview.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp @@ -264,9 +264,7 @@ const QmlTimeline TimelineView::addNewTimeline() ModelNode timelineNode; - try { - RewriterTransaction transaction(beginRewriterTransaction("TimelineView::addNewTimeline")); - + executeInTransaction("TimelineView::addNewTimeline", [=, &timelineNode](){ bool hasTimelines = getTimelines().isEmpty(); timelineNode = createModelNode(timelineType, @@ -279,10 +277,7 @@ const QmlTimeline TimelineView::addNewTimeline() timelineNode.variantProperty("enabled").setValue(hasTimelines); rootModelNode().defaultNodeListProperty().reparentHere(timelineNode); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); return QmlTimeline(timelineNode); } @@ -300,10 +295,8 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline) QTC_ASSERT(metaInfo.isValid(), return ModelNode()); ModelNode animationNode; - try { - RewriterTransaction transaction( - beginRewriterTransaction("TimelineSettingsDialog::addAnimation")); + executeInTransaction("TimelineView::addAnimation", [=, &animationNode](){ animationNode = createModelNode(animationType, metaInfo.majorVersion(), metaInfo.minorVersion()); @@ -321,10 +314,7 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline) if (timeline.modelNode().hasProperty("currentFrame")) timeline.modelNode().removeProperty("currentFrame"); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); return animationNode; } @@ -390,28 +380,23 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p QmlTimeline timeline = widget()->graphicsScene()->currentTimeline(); ModelNode targetNode = target; if (timeline.isValid() && targetNode.isValid() - && QmlObjectNode::isValidQmlObjectNode(targetNode)) { - try { - RewriterTransaction transaction( - beginRewriterTransaction("TimelineView::insertKeyframe")); + && QmlObjectNode::isValidQmlObjectNode(targetNode)) { + executeInTransaction("TimelineView::insertKeyframe", [=, &timeline, &targetNode](){ targetNode.validId(); QmlTimelineKeyframeGroup timelineFrames( - timeline.keyframeGroup(targetNode, propertyName)); + timeline.keyframeGroup(targetNode, propertyName)); QTC_ASSERT(timelineFrames.isValid(), return ); const qreal frame - = timeline.modelNode().auxiliaryData("currentFrame@NodeInstance").toReal(); + = timeline.modelNode().auxiliaryData("currentFrame@NodeInstance").toReal(); const QVariant value = QmlObjectNode(targetNode).instanceValue(propertyName); timelineFrames.setValue(value, frame); - transaction.commit(); - } catch (const Exception &e) { - e.showException(); - } + }); } } diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineview.h b/src/plugins/qmldesigner/components/timelineeditor/timelineview.h index 057ff3047b..057ff3047b 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelineview.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineview.h diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinewidget.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp index 8a58eb7dcf..8a58eb7dcf 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinewidget.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.cpp diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinewidget.h b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.h index 3fd299a88a..3fd299a88a 100644 --- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/timelinewidget.h +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinewidget.h diff --git a/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp b/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp index 21c27f4d13..ab65a44162 100644 --- a/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp +++ b/src/plugins/qmldesigner/componentsplugin/componentsplugin.cpp @@ -36,7 +36,6 @@ namespace QmlDesigner { - ComponentsPlugin::ComponentsPlugin() { TabViewIndexModel::registerDeclarativeType(); diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp index 809fe37ed4..7b30dcd179 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp @@ -111,7 +111,7 @@ bool QmlRefactoring::addProperty(int parentLocation, const TypeName &dynamicTypeName) { if (parentLocation < 0) - return false; + return true; /* Node is not in hierarchy, yet and operation can be ignored. */ AddPropertyVisitor visit(*textModifier, parentLocation, name, value, propertyType, m_propertyOrder, dynamicTypeName); return visit(qmlDocument->qmlProgram()); diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h index d32a403e5c..dcbeb5ee74 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/designercore/include/abstractview.h @@ -39,6 +39,8 @@ #include <QObject> #include <QPointer> +#include <functional> + QT_BEGIN_NAMESPACE class QStyle; class QToolButton; @@ -263,6 +265,9 @@ public: void activateTimelineRecording(const ModelNode &timeline); void deactivateTimelineRecording(); + using OperationBlock = std::function<void()>; + bool executeInTransaction(const QByteArray &identifier, const OperationBlock &lambda); + protected: void setModel(Model * model); void removeModel(); diff --git a/src/plugins/qmldesigner/designercore/include/metainforeader.h b/src/plugins/qmldesigner/designercore/include/metainforeader.h index 20672e0e05..eb725b5f86 100644 --- a/src/plugins/qmldesigner/designercore/include/metainforeader.h +++ b/src/plugins/qmldesigner/designercore/include/metainforeader.h @@ -39,7 +39,6 @@ class ItemLibraryEntry; namespace Internal { - class MetaInfoReader : protected QmlJS::SimpleAbstractStreamReader { Q_DECLARE_TR_FUNCTIONS(QmlDesigner::Internal::MetaInfoReader) diff --git a/src/plugins/qmldesigner/designercore/include/nodehints.h b/src/plugins/qmldesigner/designercore/include/nodehints.h index 1e8b7d99e4..7fed390ee0 100644 --- a/src/plugins/qmldesigner/designercore/include/nodehints.h +++ b/src/plugins/qmldesigner/designercore/include/nodehints.h @@ -64,9 +64,11 @@ public: bool isStackedContainer() const; bool canBeReparentedTo(const ModelNode &potenialParent); QString indexPropertyForStackedContainer() const; + QStringList visibleNonDefaultProperties() const; bool takesOverRenderingOfChildren() const; bool visibleInNavigator() const; bool visibleInLibrary() const; + QString forceNonDefaultProperty() const; QHash<QString, QString> hints() const; static NodeHints fromModelNode(const ModelNode &modelNode); diff --git a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h index 5d2d171ae7..09daa924aa 100644 --- a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h +++ b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h @@ -85,6 +85,7 @@ public: bool defaultPropertyIsComponent() const; TypeName typeName() const; + TypeName simplifiedTypeName() const; int majorVersion() const; int minorVersion() const; diff --git a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h index f857a36432..1560ebb3ff 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h @@ -53,10 +53,15 @@ public: static bool isItemOrWindow(const ModelNode &modelNode); static QmlItemNode createQmlItemNode(AbstractView *view, + const ItemLibraryEntry &itemLibraryEntry, + const QPointF &position, + QmlItemNode parentQmlItemNode); + + static QmlObjectNode createQmlObjectNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentQmlItemNode); - static QmlItemNode createQmlItemNode(AbstractView *view, + static QmlObjectNode createQmlObjectNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, NodeAbstractProperty parentproperty); diff --git a/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h b/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h index dc2f0732ee..da21c17cd9 100644 --- a/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h +++ b/src/plugins/qmldesigner/designercore/include/subcomponentmanager.h @@ -60,7 +60,7 @@ private: // functions void addImport(int pos, const Import &import); void removeImport(int pos); void parseDirectories(); - QList<QFileInfo> watchedFiles(const QString &canonicalDirPath); + QFileInfoList watchedFiles(const QString &canonicalDirPath); void unregisterQmlFile(const QFileInfo &fileInfo, const QString &qualifier); void registerQmlFile(const QFileInfo &fileInfo, const QString &qualifier, bool addToLibrary); Model *model() const; diff --git a/src/plugins/qmldesigner/designercore/include/viewmanager.h b/src/plugins/qmldesigner/designercore/include/viewmanager.h index 4673e341cc..71c869916e 100644 --- a/src/plugins/qmldesigner/designercore/include/viewmanager.h +++ b/src/plugins/qmldesigner/designercore/include/viewmanager.h @@ -80,7 +80,7 @@ public: void disableWidgets(); void enableWidgets(); - void pushFileOnCrumbleBar(const Utils::FileName &fileName); + void pushFileOnCrumbleBar(const Utils::FilePath &fileName); void pushInFileComponentOnCrumbleBar(const ModelNode &modelNode); void nextFileIsCalledInternally(); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 609db1fe95..c0723bf751 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -143,17 +143,17 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV const int second = 1000; const int waitConstant = 8 * second; if (m_qmlPuppetEditorProcess->waitForStarted(waitConstant)) { - connect(m_qmlPuppetEditorProcess.data(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(m_qmlPuppetEditorProcess.data(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), m_qmlPuppetEditorProcess.data(), &QProcess::deleteLater); qCInfo(instanceViewBenchmark) << "puppets started:" << m_benchmarkTimer.elapsed(); if (runModus == NormalModus) { m_qmlPuppetPreviewProcess->waitForStarted(waitConstant / 2); - connect(m_qmlPuppetPreviewProcess.data(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(m_qmlPuppetPreviewProcess.data(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), m_qmlPuppetPreviewProcess.data(), &QProcess::deleteLater); m_qmlPuppetRenderProcess->waitForStarted(waitConstant / 2); - connect(m_qmlPuppetRenderProcess.data(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(m_qmlPuppetRenderProcess.data(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), m_qmlPuppetRenderProcess.data(), &QProcess::deleteLater); } diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h index d0309aacaa..60565261d2 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h @@ -29,8 +29,8 @@ #include <QPointer> #include <QProcess> +#include <QElapsedTimer> #include <QFile> -#include <QTime> #include <QTimer> QT_BEGIN_NAMESPACE @@ -127,7 +127,7 @@ private: quint32 m_thirdLastReadCommandCounter = 0; RunModus m_runModus; int m_synchronizeId = -1; - QTime m_benchmarkTimer; + QElapsedTimer m_benchmarkTimer; bool m_destructing = false; }; diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp index 8ab932e8b1..0959dd4a9e 100644 --- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp +++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp @@ -90,7 +90,7 @@ QHash<Core::Id, PuppetCreator::PuppetType> PuppetCreator::m_qml2PuppetForKitPupp QByteArray PuppetCreator::qtHash() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); if (currentQtVersion) { return QCryptographicHash::hash(currentQtVersion->qmakeProperty("QT_INSTALL_DATA").toUtf8(), QCryptographicHash::Sha1) @@ -102,7 +102,7 @@ QByteArray PuppetCreator::qtHash() const QDateTime PuppetCreator::qtLastModified() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); if (currentQtVersion) return QFileInfo(currentQtVersion->qmakeProperty("QT_INSTALL_LIBS")).lastModified(); @@ -153,7 +153,7 @@ QString PuppetCreator::getStyleConfigFileName() const { #ifndef QMLDESIGNER_TEST if (m_currentProject) { - for (const Utils::FileName &fileName : m_currentProject->files(ProjectExplorer::Project::SourceFiles)) { + for (const Utils::FilePath &fileName : m_currentProject->files(ProjectExplorer::Project::SourceFiles)) { if (fileName.fileName() == "qtquickcontrols2.conf") return fileName.toString(); } @@ -419,10 +419,10 @@ QProcessEnvironment PuppetCreator::processEnvironment() const Utils::Environment environment = Utils::Environment::systemEnvironment(); if (!useOnlyFallbackPuppet()) m_kit->addToEnvironment(environment); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(m_kit); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(m_kit); if (QTC_GUARD(qt)) { // Kits without a Qt version should not have a puppet! // Update PATH to include QT_HOST_BINS - const Utils::FileName qtBinPath = qt->binPath(); + const Utils::FilePath qtBinPath = qt->binPath(); environment.prependOrSetPath(qtBinPath.toString()); } environment.set("QML_BAD_GUI_RENDER_LOOP", "true"); @@ -472,10 +472,15 @@ QProcessEnvironment PuppetCreator::processEnvironment() const if (!styleConfigFileName.isEmpty()) environment.appendOrSet("QT_QUICK_CONTROLS_CONF", styleConfigFileName); + QStringList customFileSelectors; + if (m_currentProject && m_currentProject->activeTarget()) { QStringList designerImports = m_currentProject->activeTarget() ->additionalData("QmlDesignerImportPath").toStringList(); importPaths.append(designerImports); + + customFileSelectors = m_currentProject->activeTarget() + ->additionalData("CustomFileSelectorsData").toStringList(); } if (m_availablePuppetType == FallbackPuppet) @@ -483,10 +488,14 @@ QProcessEnvironment PuppetCreator::processEnvironment() const environment.appendOrSet("QML2_IMPORT_PATH", importPaths.join(pathSep), pathSep); + if (!customFileSelectors.isEmpty()) + environment.appendOrSet("QML_FILE_SELECTORS", customFileSelectors.join(","), pathSep); + qCInfo(puppetStart) << Q_FUNC_INFO; qCInfo(puppetStart) << "Puppet qrc mapping" << m_qrcMapping; qCInfo(puppetStart) << "Puppet import paths:" << importPaths; qCInfo(puppetStart) << "Puppet environment:" << environment.toStringList(); + qCInfo(puppetStart) << "Puppet selectors:" << customFileSelectors; return environment.toProcessEnvironment(); } @@ -497,18 +506,18 @@ QString PuppetCreator::buildCommand() const m_kit->addToEnvironment(environment); ProjectExplorer::ToolChain *toolChain - = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit, + = ProjectExplorer::ToolChainKitAspect::toolChain(m_kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (toolChain) - return toolChain->makeCommand(environment); + return toolChain->makeCommand(environment).toString(); return QString(); } QString PuppetCreator::qmakeCommand() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); if (currentQtVersion) return currentQtVersion->qmakeCommand().toString(); @@ -595,7 +604,7 @@ static bool nonEarlyQt5Version(const QtSupport::QtVersionNumber ¤tQtVersio bool PuppetCreator::qtIsSupported() const { - QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); + QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit); return currentQtVersion && currentQtVersion->isValid() diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp index be7623323d..dcb350c448 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodehints.cpp @@ -51,7 +51,6 @@ namespace QmlDesigner { - static bool isSwipeView(const ModelNode &node) { if (node.metaInfo().isValid() @@ -193,6 +192,19 @@ QString NodeHints::indexPropertyForStackedContainer() const return Internal::evaluateExpression(expression, modelNode(), ModelNode()).toString(); } +QStringList NodeHints::visibleNonDefaultProperties() const +{ + if (!isValid()) + return {}; + + const QString expression = m_hints.value("visibleNonDefaultProperties"); + + if (expression.isEmpty()) + return {}; + + return Internal::evaluateExpression(expression, modelNode(), ModelNode()).toString().split(","); +} + bool NodeHints::takesOverRenderingOfChildren() const { if (!isValid()) @@ -214,6 +226,16 @@ bool NodeHints::visibleInLibrary() const return evaluateBooleanExpression("visibleInLibrary", true); } +QString NodeHints::forceNonDefaultProperty() const +{ + const QString expression = m_hints.value("forceNonDefaultProperty"); + + if (expression.isEmpty()) + return {}; + + return Internal::evaluateExpression(expression, modelNode(), ModelNode()).toString(); +} + QHash<QString, QString> NodeHints::hints() const { return m_hints; diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 9c88cd130a..25ff950644 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -1483,6 +1483,11 @@ TypeName NodeMetaInfo::typeName() const return m_privateData->qualfiedTypeName(); } +TypeName NodeMetaInfo::simplifiedTypeName() const +{ + return typeName().split('.').constLast(); +} + int NodeMetaInfo::majorVersion() const { return m_privateData->majorVersion(); diff --git a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp index bc9dd3c184..85a84af9a3 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp @@ -202,8 +202,8 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a dir.setNameFilters(QStringList(s_qmlFilePattern)); dir.setFilter(QDir::Files | QDir::Readable | QDir::CaseSensitive); - QList<QFileInfo> monitoredList = watchedFiles(canonicalDirPath); - QList<QFileInfo> newList; + QFileInfoList monitoredList = watchedFiles(canonicalDirPath); + QFileInfoList newList; foreach (const QFileInfo &qmlFile, dir.entryInfoList()) { if (QFileInfo(m_filePath.toLocalFile()) == qmlFile) { // do not parse main file @@ -280,9 +280,9 @@ void SubComponentManager::parseFile(const QString &canonicalFilePath) } // dirInfo must already contain a canonical path -QList<QFileInfo> SubComponentManager::watchedFiles(const QString &canonicalDirPath) +QFileInfoList SubComponentManager::watchedFiles(const QString &canonicalDirPath) { - QList<QFileInfo> files; + QFileInfoList files; foreach (const QString &monitoredFile, m_watcher.files()) { QFileInfo fileInfo(monitoredFile); diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index 68e11782df..eb7ed16b9a 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -44,7 +44,6 @@ namespace QmlDesigner { - /*! \class QmlDesigner::AbstractView \ingroup CoreModel @@ -617,6 +616,20 @@ void AbstractView::deactivateTimelineRecording() model()->d->notifyCurrentTimelineChanged(ModelNode()); } +bool AbstractView::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda) +{ + try { + RewriterTransaction transaction = beginRewriterTransaction(identifier); + lambda(); + transaction.commit(); + } catch (const Exception &e) { + e.showException(); + return false; + } + + return true; +} + QList<ModelNode> AbstractView::allModelNodes() const { return toModelNodeList(model()->d->allNodes()); diff --git a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp index 161cf1f9f5..8517f9cb82 100644 --- a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp @@ -178,29 +178,23 @@ void ModelMerger::replaceModel(const ModelNode &modelNode) view()->model()->changeImports(modelNode.model()->imports(), {}); view()->model()->setFileUrl(modelNode.model()->fileUrl()); - try { - RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::replaceModel"))); - - ModelNode rootNode(view()->rootModelNode()); - - foreach (const PropertyName &propertyName, rootNode.propertyNames()) - rootNode.removeProperty(propertyName); - - QHash<QString, QString> idRenamingHash; - setupIdRenamingHash(modelNode, idRenamingHash, view()); - - syncAuxiliaryProperties(rootNode, modelNode); - syncVariantProperties(rootNode, modelNode); - syncBindingProperties(rootNode, modelNode, idRenamingHash); - syncId(rootNode, modelNode, idRenamingHash); - syncNodeProperties(rootNode, modelNode, idRenamingHash, view()); - syncNodeListProperties(rootNode, modelNode, idRenamingHash, view()); - m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion()); - - transaction.commit(); - } catch (const RewritingException &e) { - qWarning() << e.description(); //silent error - } + view()->executeInTransaction("ModelMerger::replaceModel", [this, modelNode](){ + ModelNode rootNode(view()->rootModelNode()); + + foreach (const PropertyName &propertyName, rootNode.propertyNames()) + rootNode.removeProperty(propertyName); + + QHash<QString, QString> idRenamingHash; + setupIdRenamingHash(modelNode, idRenamingHash, view()); + + syncAuxiliaryProperties(rootNode, modelNode); + syncVariantProperties(rootNode, modelNode); + syncBindingProperties(rootNode, modelNode, idRenamingHash); + syncId(rootNode, modelNode, idRenamingHash); + syncNodeProperties(rootNode, modelNode, idRenamingHash, view()); + syncNodeListProperties(rootNode, modelNode, idRenamingHash, view()); + m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion()); + }); } } //namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp index c7a9e5aa28..ba821dd788 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp @@ -31,7 +31,6 @@ namespace QmlDesigner { - static PropertyName lineTypeToString(AnchorLineType lineType) { switch (lineType) { @@ -162,22 +161,23 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine, const QmlItemNode &targetQmlItemNode, AnchorLineType targetAnchorLine) { - RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::setAnchor")); - if (qmlItemNode().isInBaseState()) { - if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) - || ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)))) { - removeAnchor(sourceAnchorLine); - } + qmlItemNode().view()->executeInTransaction("QmlAnchors::setAnchor", [this, sourceAnchorLine, targetQmlItemNode, targetAnchorLine](){ + if (qmlItemNode().isInBaseState()) { + if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) + || ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)))) { + removeAnchor(sourceAnchorLine); + } - const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); - ModelNode targetModelNode = targetQmlItemNode.modelNode(); - QString targetExpression = targetModelNode.validId(); - if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode()) - targetExpression = QLatin1String("parent"); - if (sourceAnchorLine != AnchorLineCenter && sourceAnchorLine != AnchorLineFill) - targetExpression = targetExpression + QLatin1Char('.') + QString::fromLatin1(lineTypeToString(targetAnchorLine)); - qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression); - } + const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); + ModelNode targetModelNode = targetQmlItemNode.modelNode(); + QString targetExpression = targetModelNode.validId(); + if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode()) + targetExpression = QLatin1String("parent"); + if (sourceAnchorLine != AnchorLineCenter && sourceAnchorLine != AnchorLineFill) + targetExpression = targetExpression + QLatin1Char('.') + QString::fromLatin1(lineTypeToString(targetAnchorLine)); + qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression); + } + }); } bool detectHorizontalCycle(const ModelNode &node, QList<ModelNode> knownNodeList) @@ -316,47 +316,49 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLineType sourceAnchorLine) const void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine) { - RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchor")); - if (qmlItemNode().isInBaseState()) { - const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) { - qmlItemNode().modelNode().removeProperty("anchors.fill"); - qmlItemNode().modelNode().bindingProperty("anchors.top").setExpression(QLatin1String("parent.top")); - qmlItemNode().modelNode().bindingProperty("anchors.left").setExpression(QLatin1String("parent.left")); - qmlItemNode().modelNode().bindingProperty("anchors.bottom").setExpression(QLatin1String("parent.bottom")); - qmlItemNode().modelNode().bindingProperty("anchors.right").setExpression(QLatin1String("parent.right")); + qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchor", [this, sourceAnchorLine](){ + if (qmlItemNode().isInBaseState()) { + const PropertyName propertyName = anchorPropertyName(sourceAnchorLine); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) { + qmlItemNode().modelNode().removeProperty("anchors.fill"); + qmlItemNode().modelNode().bindingProperty("anchors.top").setExpression(QLatin1String("parent.top")); + qmlItemNode().modelNode().bindingProperty("anchors.left").setExpression(QLatin1String("parent.left")); + qmlItemNode().modelNode().bindingProperty("anchors.bottom").setExpression(QLatin1String("parent.bottom")); + qmlItemNode().modelNode().bindingProperty("anchors.right").setExpression(QLatin1String("parent.right")); + + } else if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)) { + qmlItemNode().modelNode().removeProperty("anchors.centerIn"); + qmlItemNode().modelNode().bindingProperty("anchors.horizontalCenter").setExpression(QLatin1String("parent.horizontalCenter")); + qmlItemNode().modelNode().bindingProperty("anchors.verticalCenter").setExpression(QLatin1String("parent.verticalCenter")); + } - } else if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)) { - qmlItemNode().modelNode().removeProperty("anchors.centerIn"); - qmlItemNode().modelNode().bindingProperty("anchors.horizontalCenter").setExpression(QLatin1String("parent.horizontalCenter")); - qmlItemNode().modelNode().bindingProperty("anchors.verticalCenter").setExpression(QLatin1String("parent.verticalCenter")); + qmlItemNode().modelNode().removeProperty(propertyName); } - - qmlItemNode().modelNode().removeProperty(propertyName); - } + }); } void QmlAnchors::removeAnchors() { - RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchors")); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill")) - qmlItemNode().modelNode().removeProperty("anchors.fill"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn")) - qmlItemNode().modelNode().removeProperty("anchors.centerIn"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.top")) - qmlItemNode().modelNode().removeProperty("anchors.top"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.left")) - qmlItemNode().modelNode().removeProperty("anchors.left"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.right")) - qmlItemNode().modelNode().removeProperty("anchors.right"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.bottom")) - qmlItemNode().modelNode().removeProperty("anchors.bottom"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.horizontalCenter")) - qmlItemNode().modelNode().removeProperty("anchors.horizontalCenter"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.verticalCenter")) - qmlItemNode().modelNode().removeProperty("anchors.verticalCenter"); - if (qmlItemNode().nodeInstance().hasAnchor("anchors.baseline")) - qmlItemNode().modelNode().removeProperty("anchors.baseline"); + qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchors", [this](){ + if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill")) + qmlItemNode().modelNode().removeProperty("anchors.fill"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn")) + qmlItemNode().modelNode().removeProperty("anchors.centerIn"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.top")) + qmlItemNode().modelNode().removeProperty("anchors.top"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.left")) + qmlItemNode().modelNode().removeProperty("anchors.left"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.right")) + qmlItemNode().modelNode().removeProperty("anchors.right"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.bottom")) + qmlItemNode().modelNode().removeProperty("anchors.bottom"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.horizontalCenter")) + qmlItemNode().modelNode().removeProperty("anchors.horizontalCenter"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.verticalCenter")) + qmlItemNode().modelNode().removeProperty("anchors.verticalCenter"); + if (qmlItemNode().nodeInstance().hasAnchor("anchors.baseline")) + qmlItemNode().modelNode().removeProperty("anchors.baseline"); + }); } bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const @@ -533,13 +535,14 @@ void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType) void QmlAnchors::removeMargins() { - RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeMargins")); - removeMargin(AnchorLineLeft); - removeMargin(AnchorLineRight); - removeMargin(AnchorLineTop); - removeMargin(AnchorLineBottom); - removeMargin(AnchorLineHorizontalCenter); - removeMargin(AnchorLineVerticalCenter); + qmlItemNode().view()->executeInTransaction("QmlAnchors::removeMargins", [this](){ + removeMargin(AnchorLineLeft); + removeMargin(AnchorLineRight); + removeMargin(AnchorLineTop); + removeMargin(AnchorLineBottom); + removeMargin(AnchorLineHorizontalCenter); + removeMargin(AnchorLineVerticalCenter); + }); } void QmlAnchors::fill() diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index f02ca1ead7..65b34f1de4 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -85,8 +85,15 @@ static QmlItemNode createQmlItemNodeFromSource(AbstractView *view, const QString return QmlItemNode(); } +QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, + const ItemLibraryEntry &itemLibraryEntry, + const QPointF &position, + QmlItemNode parentQmlItemNode) +{ + return QmlItemNode(createQmlObjectNode(view, itemLibraryEntry, position, parentQmlItemNode)); +} -QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentQmlItemNode) +QmlObjectNode QmlItemNode::createQmlObjectNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentQmlItemNode) { if (!parentQmlItemNode.isValid()) parentQmlItemNode = QmlItemNode(view->rootModelNode()); @@ -95,16 +102,14 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary NodeAbstractProperty parentProperty = parentQmlItemNode.defaultNodeAbstractProperty(); - return QmlItemNode::createQmlItemNode(view, itemLibraryEntry, position, parentProperty); + return QmlItemNode::createQmlObjectNode(view, itemLibraryEntry, position, parentProperty); } -QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, NodeAbstractProperty parentproperty) +QmlObjectNode QmlItemNode::createQmlObjectNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, NodeAbstractProperty parentproperty) { - QmlItemNode newQmlItemNode; - - try { - RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNode")); + QmlObjectNode newQmlObjectNode; + view->executeInTransaction("QmlItemNode::createQmlItemNode", [=, &newQmlObjectNode, &parentproperty](){ NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName()); int minorVersion = metaInfo.minorVersion(); @@ -130,34 +135,31 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary } } - newQmlItemNode = QmlItemNode(view->createModelNode(itemLibraryEntry.typeName(), majorVersion, minorVersion, propertyPairList)); + newQmlObjectNode = QmlItemNode(view->createModelNode(itemLibraryEntry.typeName(), majorVersion, minorVersion, propertyPairList)); } else { - newQmlItemNode = createQmlItemNodeFromSource(view, itemLibraryEntry.qmlSource(), position); + newQmlObjectNode = createQmlItemNodeFromSource(view, itemLibraryEntry.qmlSource(), position); } if (parentproperty.isValid()) - parentproperty.reparentHere(newQmlItemNode); + parentproperty.reparentHere(newQmlObjectNode); - if (!newQmlItemNode.isValid()) - return newQmlItemNode; + if (!newQmlObjectNode.isValid()) + return; - newQmlItemNode.setId(view->generateNewId(itemLibraryEntry.name())); + newQmlObjectNode.setId(view->generateNewId(itemLibraryEntry.name())); for (const auto &propertyBindingEntry : propertyBindingList) - newQmlItemNode.modelNode().bindingProperty(propertyBindingEntry.first).setExpression(propertyBindingEntry.second); + newQmlObjectNode.modelNode().bindingProperty(propertyBindingEntry.first).setExpression(propertyBindingEntry.second); for (const auto &propertyBindingEntry : propertyEnumList) - newQmlItemNode.modelNode().variantProperty(propertyBindingEntry.first).setEnumeration(propertyBindingEntry.second.toUtf8()); + newQmlObjectNode.modelNode().variantProperty(propertyBindingEntry.first).setEnumeration(propertyBindingEntry.second.toUtf8()); - Q_ASSERT(newQmlItemNode.isValid()); - } - catch (const RewritingException &e) { - e.showException(); - } + Q_ASSERT(newQmlObjectNode.isValid()); + }); - Q_ASSERT(newQmlItemNode.isValid()); + Q_ASSERT(newQmlObjectNode.isValid()); - return newQmlItemNode; + return newQmlObjectNode; } QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QString &imageName, const QPointF &position, QmlItemNode parentQmlItemNode) @@ -174,10 +176,8 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS { QmlItemNode newQmlItemNode; - if (parentproperty.isValid()) { - RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNodeFromImage")); - - if (view->model()->hasNodeMetaInfo("QtQuick.Image")) { + if (parentproperty.isValid() && view->model()->hasNodeMetaInfo("QtQuick.Image")) { + view->executeInTransaction("QmlItemNode::createQmlItemNodeFromImage", [=, &newQmlItemNode, &parentproperty](){ NodeMetaInfo metaInfo = view->model()->metaInfo("QtQuick.Image"); QList<QPair<PropertyName, QVariant> > propertyPairList; propertyPairList.append({PropertyName("x"), QVariant(qRound(position.x()))}); @@ -200,8 +200,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS newQmlItemNode.modelNode().variantProperty("fillMode").setEnumeration("Image.PreserveAspectFit"); Q_ASSERT(newQmlItemNode.isValid()); - } - Q_ASSERT(newQmlItemNode.isValid()); + }); } return newQmlItemNode; diff --git a/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp index 65ed482bfb..53e29b7157 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp @@ -263,7 +263,7 @@ QString QmlObjectNode::stripedTranslatableText(const PropertyName &name) const return regularExpressionPatter.cap(2); return instanceValue(name).toString(); } - return modelNode().variantProperty(name).value().toString(); + return instanceValue(name).toString(); } QString QmlObjectNode::expression(const PropertyName &name) const diff --git a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp index 08105bf2be..8ab244fe2b 100644 --- a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp @@ -41,12 +41,10 @@ using namespace QmlDesigner::Internal; inline static QString properColorName(const QColor &color) { - QString s; if (color.alpha() == 255) - s.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); + return QString::asprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); else - s.sprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue()); - return s; + return QString::asprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue()); } inline static QString doubleToString(double d) diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index 739011f092..b9b82f5714 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -48,10 +48,10 @@ #include <qmljs/qmljscheck.h> #include <qmljs/qmljsutils.h> #include <qmljs/qmljsmodelmanagerinterface.h> -#include <qmljs/qmljsqrcparser.h> #include <qmljs/qmljsinterpreter.h> #include <qmljs/qmljsvalueowner.h> +#include <utils/qrcparser.h> #include <utils/qtcassert.h> #include <QSet> @@ -372,6 +372,13 @@ bool smartVeryFuzzyCompare(const QVariant &value1, const QVariant &value2) return false; } +bool smartColorCompare(const QVariant &value1, const QVariant &value2) +{ + if ((value1.type() == QVariant::Color) || (value2.type() == QVariant::Color)) + return value1.value<QColor>().rgba() == value2.value<QColor>().rgba(); + return false; +} + bool equals(const QVariant &a, const QVariant &b) { if (a.canConvert<QmlDesigner::Enumeration>() && b.canConvert<QmlDesigner::Enumeration>()) @@ -380,6 +387,8 @@ bool equals(const QVariant &a, const QVariant &b) return true; if (smartVeryFuzzyCompare(a, b)) return true; + if (smartColorCompare(a, b)) + return true; return false; } @@ -457,7 +466,7 @@ public: if (!name.isEmpty() && name != QLatin1String(".")) typeName.prepend(name + QLatin1Char('.')); } else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) { - QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path()); + QString path = Utils::QrcParser::normalizedQrcDirectoryPath(importInfo.path()); path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1)); const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.')); if (!name.isEmpty()) diff --git a/src/plugins/qmldesigner/designercore/model/viewmanager.cpp b/src/plugins/qmldesigner/designercore/model/viewmanager.cpp index c22ce39ad1..c2f36fad90 100644 --- a/src/plugins/qmldesigner/designercore/model/viewmanager.cpp +++ b/src/plugins/qmldesigner/designercore/model/viewmanager.cpp @@ -384,7 +384,7 @@ void ViewManager::enableWidgets() view->enableWidget(); } -void ViewManager::pushFileOnCrumbleBar(const Utils::FileName &fileName) +void ViewManager::pushFileOnCrumbleBar(const Utils::FilePath &fileName) { crumbleBar()->pushFile(fileName); } diff --git a/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp b/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp index 149a76ef51..9b319a814d 100644 --- a/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp +++ b/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp @@ -190,7 +190,7 @@ QStandardItem *WidgetPluginPath::createModelItem() QStandardItem *failedCategory = nullptr; const auto end = m_plugins.end(); for (auto it = m_plugins.begin(); it != end; ++it) { - QStandardItem *pluginItem = new QStandardItem(Utils::FileName::fromString(it->path).fileName()); + QStandardItem *pluginItem = new QStandardItem(Utils::FilePath::fromString(it->path).fileName()); if (instance(*it)) { pluginItem->appendRow(new QStandardItem(QString::fromUtf8(it->instanceGuard->metaObject()->className()))); pathItem->appendRow(pluginItem); diff --git a/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.h b/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.h index 13ad38fcd3..2ad7d554f4 100644 --- a/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.h +++ b/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.h @@ -40,8 +40,6 @@ namespace QmlDesigner { class IWidgetPlugin; namespace Internal { - - // Dumb plugin data structure. Note that whereas QObjects can // casted to an interface, QPointer does not work with the // interface class, so, we need a separate QPointer as a guard diff --git a/src/plugins/qmldesigner/designercore/rewritertransaction.cpp b/src/plugins/qmldesigner/designercore/rewritertransaction.cpp index 1cbe8f8cac..1bae709e0c 100644 --- a/src/plugins/qmldesigner/designercore/rewritertransaction.cpp +++ b/src/plugins/qmldesigner/designercore/rewritertransaction.cpp @@ -39,8 +39,6 @@ namespace QmlDesigner { - - QList<QByteArray> RewriterTransaction::m_identifierList; bool RewriterTransaction::m_activeIdentifier = qEnvironmentVariableIsSet("QML_DESIGNER_TRACE_REWRITER_TRANSACTION"); diff --git a/src/plugins/qmldesigner/designersettings.cpp b/src/plugins/qmldesigner/designersettings.cpp index 7df99bd59b..5870927d52 100644 --- a/src/plugins/qmldesigner/designersettings.cpp +++ b/src/plugins/qmldesigner/designersettings.cpp @@ -76,6 +76,7 @@ void DesignerSettings::fromSettings(QSettings *settings) restoreValue(settings, DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS, true); restoreValue(settings, DesignerSettingsKey::STANDALONE_MODE, false); restoreValue(settings, DesignerSettingsKey::ENABLE_TIMELINEVIEW, false); + restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList()); settings->endGroup(); settings->endGroup(); diff --git a/src/plugins/qmldesigner/designersettings.h b/src/plugins/qmldesigner/designersettings.h index bdaa22bb4b..410abc267e 100644 --- a/src/plugins/qmldesigner/designersettings.h +++ b/src/plugins/qmldesigner/designersettings.h @@ -65,6 +65,7 @@ const char REFORMAT_UI_QML_FILES[] = "ReformatUiQmlFiles"; /* These setti const char IGNORE_DEVICE_PIXEL_RATIO[] = "IgnoreDevicePixelRaio"; /* The settings can be used to turn off the feature, if there are serious issues */ const char STANDALONE_MODE[] = "StandAloneMode"; const char ENABLE_TIMELINEVIEW[] = "EnableTimelineView"; +const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent"; } class DesignerSettings : public QHash<QByteArray, QVariant> diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 8bce47b012..f171c89c0f 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -435,7 +435,7 @@ void DesignModeWidget::setupNavigatorHistory(Core::IEditor *editor) m_toolBar->setCurrentEditor(editor); } -void DesignModeWidget::addNavigatorHistoryEntry(const Utils::FileName &fileName) +void DesignModeWidget::addNavigatorHistoryEntry(const Utils::FilePath &fileName) { if (m_navigatorHistoryCounter > 0) m_navigatorHistory.insert(m_navigatorHistoryCounter + 1, fileName.toString()); diff --git a/src/plugins/qmldesigner/designmodewidget.h b/src/plugins/qmldesigner/designmodewidget.h index 0642727cbe..b446cdf2e1 100644 --- a/src/plugins/qmldesigner/designmodewidget.h +++ b/src/plugins/qmldesigner/designmodewidget.h @@ -95,7 +95,7 @@ private: // functions void setup(); bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const; QmlDesigner::ModelNode nodeForPosition(int cursorPos) const; - void addNavigatorHistoryEntry(const Utils::FileName &fileName); + void addNavigatorHistoryEntry(const Utils::FilePath &fileName); QWidget *createCenterWidget(); QWidget *createCrumbleBarFrame(); diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp index 7ce3bf7c4d..d264f286cc 100644 --- a/src/plugins/qmldesigner/documentmanager.cpp +++ b/src/plugins/qmldesigner/documentmanager.cpp @@ -316,19 +316,19 @@ void DocumentManager::addFileToVersionControl(const QString &directoryPath, cons } } -Utils::FileName DocumentManager::currentFilePath() +Utils::FilePath DocumentManager::currentFilePath() { return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName(); } -Utils::FileName DocumentManager::currentProjectDirPath() +Utils::FilePath DocumentManager::currentProjectDirPath() { QTC_ASSERT(QmlDesignerPlugin::instance(), return {}); if (!QmlDesignerPlugin::instance()->currentDesignDocument()) return {}; - Utils::FileName qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); + Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName); if (!project) return {}; @@ -338,7 +338,7 @@ Utils::FileName DocumentManager::currentProjectDirPath() QStringList DocumentManager::isoIconsQmakeVariableValue(const QString &proPath) { - ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FileName::fromString(proPath)); + ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FilePath::fromString(proPath)); if (!node) { qCWarning(documentManagerLog) << "No node for .pro:" << proPath; return QStringList(); @@ -361,7 +361,7 @@ QStringList DocumentManager::isoIconsQmakeVariableValue(const QString &proPath) bool DocumentManager::setIsoIconsQmakeVariableValue(const QString &proPath, const QStringList &value) { - ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FileName::fromString(proPath)); + ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FilePath::fromString(proPath)); if (!node) { qCWarning(documentManagerLog) << "No node for .pro:" << proPath; return false; @@ -389,27 +389,24 @@ bool DocumentManager::setIsoIconsQmakeVariableValue(const QString &proPath, cons void DocumentManager::findPathToIsoProFile(bool *iconResourceFileAlreadyExists, QString *resourceFilePath, QString *resourceFileProPath, const QString &isoIconsQrcFile) { - Utils::FileName qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); + Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName); ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(qmlFileName)->parentFolderNode(); ProjectExplorer::Node *iconQrcFileNode = nullptr; while (node && !iconQrcFileNode) { - qCDebug(documentManagerLog) << "Checking" << node->displayName() - << "(" << node << static_cast<int>(node->nodeType()) << ")"; + qCDebug(documentManagerLog) << "Checking" << node->displayName() << "(" << node << ")"; - if (node->nodeType() == ProjectExplorer::NodeType::VirtualFolder && node->displayName() == "Resources") { + if (node->isVirtualFolderType() && node->displayName() == "Resources") { auto virtualFolderNode = dynamic_cast<ProjectExplorer::VirtualFolderNode*>(node); for (int subFolderIndex = 0; subFolderIndex < virtualFolderNode->folderNodes().size() && !iconQrcFileNode; ++subFolderIndex) { ProjectExplorer::FolderNode *subFolderNode = virtualFolderNode->folderNodes().at(subFolderIndex); qCDebug(documentManagerLog) << "Checking if" << subFolderNode->displayName() << "(" - << subFolderNode << static_cast<int>(subFolderNode->nodeType()) - << ") is" << isoIconsQrcFile; + << subFolderNode << ") is" << isoIconsQrcFile; - if (subFolderNode->nodeType() == ProjectExplorer::NodeType::Folder - && subFolderNode->displayName() == isoIconsQrcFile) { + if (subFolderNode->isFolderNodeType() && subFolderNode->displayName() == isoIconsQrcFile) { qCDebug(documentManagerLog) << "Found" << isoIconsQrcFile << "in" << virtualFolderNode->filePath(); iconQrcFileNode = subFolderNode; @@ -443,7 +440,7 @@ void DocumentManager::findPathToIsoProFile(bool *iconResourceFileAlreadyExists, bool DocumentManager::isoProFileSupportsAddingExistingFiles(const QString &resourceFileProPath) { - ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FileName::fromString(resourceFileProPath)); + ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FilePath::fromString(resourceFileProPath)); if (!node || !node->parentFolderNode()) return false; ProjectExplorer::ProjectNode *projectNode = node->parentFolderNode()->asProjectNode(); @@ -459,7 +456,7 @@ bool DocumentManager::isoProFileSupportsAddingExistingFiles(const QString &resou bool DocumentManager::addResourceFileToIsoProject(const QString &resourceFileProPath, const QString &resourceFilePath) { - ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FileName::fromString(resourceFileProPath)); + ProjectExplorer::Node *node = ProjectExplorer::ProjectTree::nodeForFile(Utils::FilePath::fromString(resourceFileProPath)); if (!node || !node->parentFolderNode()) return false; ProjectExplorer::ProjectNode *projectNode = node->parentFolderNode()->asProjectNode(); @@ -480,7 +477,7 @@ bool DocumentManager::belongsToQmakeProject() if (!QmlDesignerPlugin::instance()->currentDesignDocument()) return false; - Utils::FileName qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); + Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName); if (!project) return false; diff --git a/src/plugins/qmldesigner/documentmanager.h b/src/plugins/qmldesigner/documentmanager.h index 0c5bd20043..bb3b13c9ac 100644 --- a/src/plugins/qmldesigner/documentmanager.h +++ b/src/plugins/qmldesigner/documentmanager.h @@ -55,8 +55,8 @@ public: static bool createFile(const QString &filePath, const QString &contents); static void addFileToVersionControl(const QString &directoryPath, const QString &newFilePath); - static Utils::FileName currentFilePath(); - static Utils::FileName currentProjectDirPath(); + static Utils::FilePath currentFilePath(); + static Utils::FilePath currentProjectDirPath(); static QStringList isoIconsQmakeVariableValue(const QString &proPath); static bool setIsoIconsQmakeVariableValue(const QString &proPath, const QStringList &value); diff --git a/src/plugins/qmldesigner/qmldesigner.pro b/src/plugins/qmldesigner/qmldesigner.pro index 039c228fe5..1986677fac 100644 --- a/src/plugins/qmldesigner/qmldesigner.pro +++ b/src/plugins/qmldesigner/qmldesigner.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = qmldesignerplugin.pro qtquickplugin componentsplugin +SUBDIRS = qmldesignerplugin.pro qtquickplugin componentsplugin qmlpreviewplugin diff --git a/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension.pri b/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension.pri deleted file mode 100644 index 597bd85338..0000000000 --- a/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension.pri +++ /dev/null @@ -1,12 +0,0 @@ -DEFINES += QMLDESIGNEREXTENSION_LIBRARY - -INCLUDEPATH *= $$PWD - -# QmlDesignerExtension files - -include(sourcetool/sourcetool.pri) -include(colortool/colortool.pri) -include(texttool/texttool.pri) -include(pathtool/pathtool.pri) -include(timelineeditor/timelineeditor.pri) -include(connectioneditor/connectioneditor.pri) diff --git a/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension_global.h b/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension_global.h deleted file mode 100644 index 82ed1b076c..0000000000 --- a/src/plugins/qmldesigner/qmldesignerextension/qmldesignerextension_global.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <QtGlobal> - -#if defined(QMLDESIGNEREXTENSION_LIBRARY) -# define QMLDESIGNEREXTENSIONSHARED_EXPORT Q_DECL_EXPORT -#else -# define QMLDESIGNEREXTENSIONSHARED_EXPORT Q_DECL_IMPORT -#endif diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index 42fd9fbefa..eb16cbedd1 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -217,13 +217,13 @@ void QmlDesignerPlugin::extensionsInitialized() }); } -static QStringList allUiQmlFilesforCurrentProject(const Utils::FileName &fileName) +static QStringList allUiQmlFilesforCurrentProject(const Utils::FilePath &fileName) { QStringList list; ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName); if (currentProject) { - foreach (const Utils::FileName &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) { + foreach (const Utils::FilePath &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) { if (fileName.endsWith(".ui.qml")) list.append(fileName.toString()); } @@ -232,7 +232,7 @@ static QStringList allUiQmlFilesforCurrentProject(const Utils::FileName &fileNam return list; } -static QString projectPath(const Utils::FileName &fileName) +static QString projectPath(const Utils::FilePath &fileName) { QString path; ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName); @@ -304,7 +304,7 @@ void QmlDesignerPlugin::showDesigner() d->mainWidget.initialize(); - const Utils::FileName fileName = Core::EditorManager::currentEditor()->document()->filePath(); + const Utils::FilePath fileName = Core::EditorManager::currentEditor()->document()->filePath(); const QStringList allUiQmlFiles = allUiQmlFilesforCurrentProject(fileName); if (warningsForQmlFilesInsteadOfUiQmlEnabled() && !fileName.endsWith(".ui.qml") && !allUiQmlFiles.isEmpty()) { OpenUiQmlFileDialog dialog(&d->mainWidget); diff --git a/src/plugins/qmldesigner/qmldesignerplugin.pro b/src/plugins/qmldesigner/qmldesignerplugin.pro index cc78fdc5db..52e3e19a44 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.pro +++ b/src/plugins/qmldesigner/qmldesignerplugin.pro @@ -2,6 +2,7 @@ QT += quickwidgets core-private CONFIG += exceptions INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD/components unix:!openbsd:!osx: LIBS += -lrt # posix shared memory @@ -20,7 +21,13 @@ include(components/stateseditor/stateseditor.pri) include(components/resources/resources.pri) include(components/debugview/debugview.pri) include(components/importmanager/importmanager.pri) -include(qmldesignerextension/qmldesignerextension.pri) +include(components/sourcetool/sourcetool.pri) +include(components/colortool/colortool.pri) +include(components/texttool/texttool.pri) +include(components/pathtool/pathtool.pri) +include(components/timelineeditor/timelineeditor.pri) +include(components/connectioneditor/connectioneditor.pri) +include(components/curveeditor/curveeditor.pri) BUILD_PUPPET_IN_CREATOR_BINPATH = $$(BUILD_PUPPET_IN_CREATOR_BINPATH) diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 3360a53214..4cba901e20 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -29,7 +29,7 @@ Project { cpp.defines: base.concat([ "DESIGNER_CORE_LIBRARY", - "TIMELINE_QML_PATH=\"" + FileInfo.joinPaths(path, "qmldesignerextension", + "TIMELINE_QML_PATH=\"" + FileInfo.joinPaths(path, "components", "timelineeditor", "qml") + "\"" ]) cpp.enableExceptions: true @@ -42,7 +42,10 @@ Project { "../../../share/qtcreator/qml/qmlpuppet/container", "../../../share/qtcreator/qml/qmlpuppet/commands", "../../../share/qtcreator/qml/qmlpuppet/types", + "components", "components/componentcore", + "components/curveeditor", + "components/connectioneditor", "components/debugview", "components/importmanager", "components/integration", @@ -52,10 +55,7 @@ Project { "components/navigator", "components/pluginmanager", "components/stateseditor", - "components/texteditor", - "qmldesignerextension", - "qmldesignerextension/connectioneditor", - "qmldesignerextension/timelineeditor", + "components/texteditor" ]) Properties { @@ -562,6 +562,14 @@ Project { "propertyeditor/fileresourcesmodel.h", "propertyeditor/gradientmodel.cpp", "propertyeditor/gradientmodel.h", + "propertyeditor/gradientpresetcustomlistmodel.cpp", + "propertyeditor/gradientpresetcustomlistmodel.h", + "propertyeditor/gradientpresetdefaultlistmodel.cpp", + "propertyeditor/gradientpresetdefaultlistmodel.h", + "propertyeditor/gradientpresetitem.cpp", + "propertyeditor/gradientpresetitem.h", + "propertyeditor/gradientpresetlistmodel.cpp", + "propertyeditor/gradientpresetlistmodel.h", "propertyeditor/propertyeditorcontextobject.cpp", "propertyeditor/propertyeditorcontextobject.h", "propertyeditor/propertyeditortransaction.cpp", @@ -580,6 +588,12 @@ Project { "propertyeditor/qmlanchorbindingproxy.h", "propertyeditor/qmlmodelnodeproxy.cpp", "propertyeditor/qmlmodelnodeproxy.h", + "propertyeditor/simplecolorpalette.cpp", + "propertyeditor/simplecolorpalette.h", + "propertyeditor/simplecolorpalettemodel.cpp", + "propertyeditor/simplecolorpalettemodel.h", + "propertyeditor/simplecolorpalettesingleton.cpp", + "propertyeditor/simplecolorpalettesingleton.h", "resources/resources.qrc", "stateseditor/stateseditorimageprovider.cpp", "stateseditor/stateseditorimageprovider.h", @@ -594,7 +608,7 @@ Project { Group { name: "extension" - prefix: "qmldesignerextension/" + prefix: "components/" files: [ "colortool/colortool.cpp", "colortool/colortool.h", @@ -618,6 +632,49 @@ Project { "connectioneditor/dynamicpropertiesmodel.cpp", "connectioneditor/dynamicpropertiesmodel.h", "connectioneditor/stylesheet.css", + "curveeditor/animationcurve.cpp", + "curveeditor/animationcurve.h", + "curveeditor/curveeditor.cpp", + "curveeditor/curveeditor.h", + "curveeditor/curveeditormodel.cpp", + "curveeditor/curveeditormodel.h", + "curveeditor/curveeditorstyle.h", + "curveeditor/keyframe.cpp", + "curveeditor/keyframe.h", + "curveeditor/treeitem.cpp", + "curveeditor/treeitem.h", + "curveeditor/detail/colorcontrol.cpp", + "curveeditor/detail/colorcontrol.h", + "curveeditor/detail/curveeditorstyledialog.cpp", + "curveeditor/detail/curveeditorstyledialog.h", + "curveeditor/detail/curveitem.cpp", + "curveeditor/detail/curveitem.h", + "curveeditor/detail/curvesegment.cpp", + "curveeditor/detail/curvesegment.h", + "curveeditor/detail/graphicsscene.cpp", + "curveeditor/detail/graphicsscene.h", + "curveeditor/detail/graphicsview.cpp", + "curveeditor/detail/graphicsview.h", + "curveeditor/detail/handleitem.cpp", + "curveeditor/detail/handleitem.h", + "curveeditor/detail/keyframeitem.cpp", + "curveeditor/detail/keyframeitem.h", + "curveeditor/detail/playhead.cpp", + "curveeditor/detail/playhead.h", + "curveeditor/detail/selectableitem.cpp", + "curveeditor/detail/selectableitem.h", + "curveeditor/detail/selector.cpp", + "curveeditor/detail/selector.h", + "curveeditor/detail/shortcut.cpp", + "curveeditor/detail/shortcut.h", + "curveeditor/detail/treeitemdelegate.cpp", + "curveeditor/detail/treeitemdelegate.h", + "curveeditor/detail/treemodel.cpp", + "curveeditor/detail/treemodel.h", + "curveeditor/detail/treeview.cpp", + "curveeditor/detail/treeview.h", + "curveeditor/detail/utils.cpp", + "curveeditor/detail/utils.h", "pathtool/controlpoint.cpp", "pathtool/controlpoint.h", "pathtool/cubicsegment.cpp", @@ -630,8 +687,6 @@ Project { "pathtool/pathtool.h", "pathtool/pathtoolview.cpp", "pathtool/pathtoolview.h", - "qmldesignerextensionconstants.h", - "qmldesignerextension_global.h", "sourcetool/sourcetool.cpp", "sourcetool/sourcetool.h", "texttool/textedititem.cpp", diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview.png b/src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview.png Binary files differnew file mode 100644 index 0000000000..b56467d4ea --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview.png diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview@2x.png b/src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview@2x.png Binary files differnew file mode 100644 index 0000000000..93c49a04eb --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/images/live_preview@2x.png diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreview.metainfo b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreview.metainfo new file mode 100644 index 0000000000..5bfe70cffd --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreview.metainfo @@ -0,0 +1,2 @@ +MetaInfo { +} diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp new file mode 100644 index 0000000000..1fe99825c3 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.cpp @@ -0,0 +1,303 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "qmlpreviewplugin.h" +#include "qmlpreviewactions.h" + +#include <zoomaction.h> + +#include <utils/utilsicons.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/session.h> +#include <projectexplorer/project.h> + +#include <QLabel> +#include <QComboBox> +#include <QPointer> + +namespace QmlDesigner { + +using namespace ProjectExplorer; + +const Utils::Icon previewIcon({ + {":/qmlpreviewplugin/images/live_preview.png", Utils::Theme::IconsBaseColor}}); + +static void handleAction(const SelectionContext &context) +{ + if (context.view()->isAttached()) { + if (context.toggled()) { + ProjectExplorerPlugin::runStartupProject(Constants::QML_PREVIEW_RUN_MODE); + QmlPreviewPlugin::setQmlFile(); + } else { + QmlPreviewPlugin::stopAllRunControls(); + } + } +} + +QmlPreviewAction::QmlPreviewAction() : ModelNodeAction("LivePreview", + "Live Preview", + previewIcon.icon(), + QmlPreviewPlugin::tr("Show Live Preview"), + ComponentCoreConstants::qmlPreviewCategory, + QKeySequence("Alt+p"), + 20, + &handleAction, + &SelectionContextFunctors::always) +{ + if (!QmlPreviewPlugin::getPreviewPlugin()) + defaultAction()->setVisible(false); + + defaultAction()->setCheckable(true); +} + +void QmlPreviewAction::updateContext() +{ + if (selectionContext().view()->isAttached()) + QmlPreviewPlugin::setQmlFile(); + + defaultAction()->setSelectionContext(selectionContext()); +} + +ActionInterface::Type QmlPreviewAction::type() const +{ + return ToolBarAction; +} + +ZoomPreviewAction::ZoomPreviewAction() + : m_zoomAction(new ZoomAction(nullptr)) +{ + QObject::connect(m_zoomAction.get(), &ZoomAction::zoomLevelChanged, [=](float d) { + QmlPreviewPlugin::setZoomFactor(d); + }); + if (!QmlPreviewPlugin::getPreviewPlugin()) + m_zoomAction->setVisible(false); +} + +ZoomPreviewAction::~ZoomPreviewAction() += default; + +QAction *ZoomPreviewAction::action() const +{ + return m_zoomAction.get(); +} + +QByteArray ZoomPreviewAction::category() const +{ + return ComponentCoreConstants::qmlPreviewCategory; +} + +QByteArray ZoomPreviewAction::menuId() const +{ + return QByteArray(); +} + +int ZoomPreviewAction::priority() const +{ + return 19; +} + +ActionInterface::Type ZoomPreviewAction::type() const +{ + return ToolBarAction; +} + +void ZoomPreviewAction::currentContextChanged(const SelectionContext &) +{} + +quint16 FpsLabelAction::lastValidFrames = 0; +QList<QPointer<QLabel>> FpsLabelAction::fpsHandlerLabelList; + +FpsLabelAction::FpsLabelAction(QObject *parent) + : QWidgetAction(parent) +{ +} + +void FpsLabelAction::fpsHandler(quint16 fpsValues[8]) +{ + quint16 frames = fpsValues[0]; + if (frames != 0) + lastValidFrames = frames; + QString fpsText("%1 FPS"); + if (lastValidFrames == 0 || (frames == 0 && lastValidFrames < 2)) + fpsText = fpsText.arg("--"); + else + fpsText = fpsText.arg(lastValidFrames); + for (QPointer<QLabel> label : fpsHandlerLabelList) { + if (label) + label->setText(fpsText); + } +} + +void FpsLabelAction::cleanFpsCounter() +{ + lastValidFrames = 0; + quint16 nullInitialized[8] = {0}; + fpsHandler(nullInitialized); +} + +QWidget *FpsLabelAction::createWidget(QWidget *parent) +{ + auto label = new QLabel(parent); + auto originList = fpsHandlerLabelList; + fpsHandlerLabelList.clear(); + fpsHandlerLabelList.append(label); + for (const auto &labelPointer : originList) { + if (labelPointer) + fpsHandlerLabelList.append(labelPointer); + } + + return label; +} + +void FpsLabelAction::refreshFpsLabel(quint16 frames) +{ + for (const auto &labelPointer : fpsHandlerLabelList) { + if (labelPointer) + labelPointer->setText(QString("%1 FPS").arg(frames)); + } +} + +FpsAction::FpsAction() : m_fpsLabelAction(new FpsLabelAction(nullptr)) +{} + +QAction *FpsAction::action() const +{ + return m_fpsLabelAction.get(); +} + +QByteArray FpsAction::category() const +{ + return ComponentCoreConstants::qmlPreviewCategory; +} + +QByteArray FpsAction::menuId() const +{ + return QByteArray(); +} + +int FpsAction::priority() const +{ + return 19; +} + +ActionInterface::Type FpsAction::type() const +{ + return ToolBarAction; +} + +void FpsAction::currentContextChanged(const SelectionContext &) +{} + +SwitchLanguageComboboxAction::SwitchLanguageComboboxAction(QObject *parent) + : QWidgetAction(parent) +{ + connect(ProjectExplorer::SessionManager::instance(), + &ProjectExplorer::SessionManager::startupProjectChanged, + this, + &SwitchLanguageComboboxAction::refreshProjectLocales); +} + +QWidget *SwitchLanguageComboboxAction::createWidget(QWidget *parent) +{ + QPointer<QComboBox> comboBox = new QComboBox(parent); + comboBox->setToolTip(tr("Switch the language used by preview.")); + connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this, comboBox](int index) { + if (index == 0) + emit currentLocaleChanged(""); + else + emit currentLocaleChanged(comboBox->currentText()); + }); + + auto refreshComboBoxFunction = [this, comboBox] (ProjectExplorer::Project *project) { + if (comboBox) { + refreshProjectLocales(project); + comboBox->clear(); + comboBox->addItem(tr("Default")); + comboBox->addItems(m_localeStrings); + } + }; + connect(ProjectExplorer::SessionManager::instance(), + &ProjectExplorer::SessionManager::startupProjectChanged, + refreshComboBoxFunction); + + if (auto project = SessionManager::startupProject()) + refreshComboBoxFunction(project); + + return comboBox; +} + +void SwitchLanguageComboboxAction::refreshProjectLocales(Project *project) +{ + if (!project) + return; + m_localeStrings.clear(); + const auto projectDirectory = project->rootProjectDirectory().toFileInfo().absoluteFilePath(); + const QDir languageDirectory(projectDirectory + "/i18n"); + const auto qmFiles = languageDirectory.entryList({"qml_*.qm"}); + m_localeStrings = Utils::transform(qmFiles, [](const QString &qmFile) { + const int localeStartPosition = qmFile.lastIndexOf("_") + 1; + const int localeEndPosition = qmFile.size() - QString(".qm").size(); + const QString locale = qmFile.left(localeEndPosition).mid(localeStartPosition); + return locale; + }); +} + +SwitchLanguageAction::SwitchLanguageAction() + : m_switchLanguageAction(new SwitchLanguageComboboxAction(nullptr)) +{ + QObject::connect(m_switchLanguageAction.get(), &SwitchLanguageComboboxAction::currentLocaleChanged, + &QmlPreviewPlugin::setLanguageLocale); +} + +QAction *SwitchLanguageAction::action() const +{ + return m_switchLanguageAction.get(); +} + +QByteArray SwitchLanguageAction::category() const +{ + return ComponentCoreConstants::qmlPreviewCategory; +} + +QByteArray SwitchLanguageAction::menuId() const +{ + return QByteArray(); +} + +int SwitchLanguageAction::priority() const +{ + return 10; +} + +ActionInterface::Type SwitchLanguageAction::type() const +{ + return ToolBarAction; +} + +void SwitchLanguageAction::currentContextChanged(const SelectionContext &) +{} + + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.h b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.h new file mode 100644 index 0000000000..8a71ee07c2 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewactions.h @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <actioninterface.h> +#include <modelnodecontextmenu_helper.h> + +#include <QByteArray> + +#include <QWidgetAction> +#include <memory> + +QT_FORWARD_DECLARE_CLASS(QAction) +QT_FORWARD_DECLARE_CLASS(QLabel) + + +namespace QmlPreview { +using QmlPreviewFpsHandler = void (*)(quint16 *); +} + +namespace ProjectExplorer { +class Project; +} + +namespace QmlDesigner { +class ZoomAction; + +class QmlPreviewAction : public ModelNodeAction +{ +public: + QmlPreviewAction(); + + void updateContext() override; + + Type type() const override; +}; + +class ZoomPreviewAction : public ActionInterface +{ +public: + ZoomPreviewAction(); + ~ZoomPreviewAction() override; + QAction *action() const override; + QByteArray category() const override; + QByteArray menuId() const override; + int priority() const override; + Type type() const override; + void currentContextChanged(const SelectionContext &) override; + +private: + std::unique_ptr<ZoomAction> m_zoomAction; +}; + +class FpsLabelAction : public QWidgetAction +{ +public: + explicit FpsLabelAction(QObject *parent = nullptr); + static void fpsHandler(quint16 fpsValues[8]); + static void cleanFpsCounter(); +protected: + QWidget *createWidget(QWidget *parent) override; +private: + static void refreshFpsLabel(quint16 frames); + static QPointer<QLabel> m_labelInstance; + static QList<QPointer<QLabel>> fpsHandlerLabelList; + static quint16 lastValidFrames; +}; + +class FpsAction : public ActionInterface +{ +public: + FpsAction(); + QAction *action() const override; + QByteArray category() const override; + QByteArray menuId() const override; + int priority() const override; + Type type() const override; + void currentContextChanged(const SelectionContext &) override; +private: + std::unique_ptr<FpsLabelAction> m_fpsLabelAction; +}; + +class SwitchLanguageComboboxAction : public QWidgetAction +{ + Q_OBJECT +public: + explicit SwitchLanguageComboboxAction(QObject *parent = nullptr); +signals: + void currentLocaleChanged(const QString& string); +protected: + QWidget *createWidget(QWidget *parent) override; +private: + void refreshProjectLocales(ProjectExplorer::Project *project); + QStringList m_localeStrings; +}; + +class SwitchLanguageAction : public ActionInterface +{ +public: + SwitchLanguageAction(); + QAction *action() const override; + QByteArray category() const override; + QByteArray menuId() const override; + int priority() const override; + Type type() const override; + void currentContextChanged(const SelectionContext &) override; +private: + std::unique_ptr<SwitchLanguageComboboxAction> m_switchLanguageAction; +}; + +} // namespace QmlDesigner +Q_DECLARE_METATYPE(QmlPreview::QmlPreviewFpsHandler); diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp new file mode 100644 index 0000000000..5a3c1c4e09 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "qmlpreviewplugin.h" +#include "qmlpreviewactions.h" + +#include <modelnodecontextmenu_helper.h> +#include <componentcore_constants.h> +#include <qmldesignerplugin.h> +#include <viewmanager.h> +#include <actioninterface.h> +#include <zoomaction.h> + +#include <extensionsystem/pluginmanager.h> +#include <extensionsystem/pluginspec.h> + +#include <utils/algorithm.h> +#include <utils/qtcassert.h> +#include <utils/utilsicons.h> + +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> + +namespace QmlPreview { +using QmlPreviewRunControlList = QList<ProjectExplorer::RunControl *>; +} + +Q_DECLARE_METATYPE(QmlPreview::QmlPreviewRunControlList) + +namespace QmlDesigner { +static QObject *s_previewPlugin = nullptr; + +QmlPreviewPlugin::QmlPreviewPlugin() +{ + DesignerActionManager &designerActionManager = + QmlDesignerPlugin::instance()->designerActionManager(); + auto previewAction = new QmlPreviewAction(); + designerActionManager.addDesignerAction(new ActionGroup( + QString(), + ComponentCoreConstants::qmlPreviewCategory, + ComponentCoreConstants::priorityQmlPreviewCategory, + &SelectionContextFunctors::always)); + s_previewPlugin = getPreviewPlugin(); + + if (s_previewPlugin) { + bool connected = connect(s_previewPlugin, SIGNAL(runningPreviewsChanged(const QmlPreviewRunControlList &)), + this, SLOT(handleRunningPreviews())); + QTC_ASSERT(connected, qWarning() << "something wrong with the runningPreviewsChanged signal"); + } + + designerActionManager.addDesignerAction(previewAction); + + auto zoomAction = new ZoomPreviewAction; + designerActionManager.addDesignerAction(zoomAction); + + auto separator = new SeperatorDesignerAction(ComponentCoreConstants::qmlPreviewCategory, 0); + designerActionManager.addDesignerAction(separator); + + m_previewToggleAction = previewAction->defaultAction(); + + if (s_previewPlugin) { + auto fpsAction = new FpsAction; + designerActionManager.addDesignerAction(fpsAction); + s_previewPlugin->setProperty("fpsHandler", QVariant::fromValue<QmlPreview::QmlPreviewFpsHandler>(FpsLabelAction::fpsHandler)); + auto switchLanguageAction = new SwitchLanguageAction; + designerActionManager.addDesignerAction(switchLanguageAction); + } +} + +QString QmlPreviewPlugin::pluginName() const +{ + return QLatin1String("QmlPreviewPlugin"); +} + +void QmlPreviewPlugin::stopAllRunControls() +{ + QTC_ASSERT(s_previewPlugin, return); + + const QVariant variant = s_previewPlugin->property("runningPreviews"); + auto runControls = variant.value<QmlPreview::QmlPreviewRunControlList>(); + + for (ProjectExplorer::RunControl *runControl : runControls) + runControl->initiateStop(); + +} + +void QmlPreviewPlugin::handleRunningPreviews() +{ + QTC_ASSERT(s_previewPlugin, return); + + const QVariant variant = s_previewPlugin->property("runningPreviews"); + if (variant.isValid()) { + // the QmlPreview::QmlPreviewRunControlList type have to be available and used in the qmlpreview plugin + QTC_ASSERT(variant.canConvert<QmlPreview::QmlPreviewRunControlList>(), return); + auto runControls = variant.value<QmlPreview::QmlPreviewRunControlList>(); + m_previewToggleAction->setChecked(!runControls.isEmpty()); + if (runControls.isEmpty()) + FpsLabelAction::cleanFpsCounter(); + } +} + +QString QmlPreviewPlugin::metaInfo() const +{ + return QLatin1String(":/qmlpreviewplugin/qmlpreview.metainfo"); +} + +void QmlPreviewPlugin::setQmlFile() +{ + if (s_previewPlugin) { + const Utils::FileName qmlFileName = + QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); + s_previewPlugin->setProperty("previewedFile", qmlFileName.toString()); + } +} + +float QmlPreviewPlugin::zoomFactor() +{ + QVariant zoomFactorVariant = 1.0; + if (s_previewPlugin && !s_previewPlugin->property("zoomFactor").isNull()) + zoomFactorVariant = s_previewPlugin->property("zoomFactor"); + return zoomFactorVariant.toFloat(); +} + +void QmlPreviewPlugin::setZoomFactor(float zoomFactor) +{ + if (s_previewPlugin) + s_previewPlugin->setProperty("zoomFactor", zoomFactor); +} + +void QmlPreviewPlugin::setLanguageLocale(const QString &locale) +{ + if (s_previewPlugin) + s_previewPlugin->setProperty("locale", locale); +} + +QObject *QmlPreviewPlugin::getPreviewPlugin() +{ + auto pluginIt = std::find_if(ExtensionSystem::PluginManager::plugins().begin(), + ExtensionSystem::PluginManager::plugins().end(), + [](const ExtensionSystem::PluginSpec *p) { + return p->name() == "QmlPreview"; + }); + + if (pluginIt != ExtensionSystem::PluginManager::plugins().constEnd()) + return (*pluginIt)->plugin(); + + return nullptr; +} + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h new file mode 100644 index 0000000000..7f50d76696 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <iwidgetplugin.h> + +#include <QMetaType> + +QT_FORWARD_DECLARE_CLASS(QAction) + +namespace QmlDesigner { + +class QmlPreviewPlugin : public QObject, QmlDesigner::IWidgetPlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QmlDesignerPlugin" FILE "qmlpreviewplugin.json") + + Q_DISABLE_COPY(QmlPreviewPlugin) + Q_INTERFACES(QmlDesigner::IWidgetPlugin) + +public: + QmlPreviewPlugin(); + ~QmlPreviewPlugin() override = default; + + QString metaInfo() const override; + QString pluginName() const override; + + static void stopAllRunControls(); + static void setQmlFile(); + static QObject *getPreviewPlugin(); + + static float zoomFactor(); + static void setZoomFactor(float zoomFactor); + static void setLanguageLocale(const QString &locale); +signals: + void fpsChanged(quint16 frames); + +private slots: + void handleRunningPreviews(); + +private: + QAction *m_previewToggleAction = nullptr; +}; + +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.json b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.json new file mode 100644 index 0000000000..72a2c27087 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.json @@ -0,0 +1,6 @@ +{ + "Vendor" : "The Qt Company Ltd", + "Category" : "Qt Quick", + "Description" : "Plugin for integrating QmlPreview into QmlDesigner", + "Url" : "http://www.qt.io" +} diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pri b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pri new file mode 100644 index 0000000000..1808b69266 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pri @@ -0,0 +1,10 @@ +QT *= qml quick core + +VPATH += $$PWD + +SOURCES += qmlpreviewplugin.cpp +HEADERS += qmlpreviewplugin.h +SOURCES += qmlpreviewactions.cpp +HEADERS += qmlpreviewactions.h + +RESOURCES += qmlpreviewplugin.qrc diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pro b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pro new file mode 100644 index 0000000000..ec8c9b1d63 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.pro @@ -0,0 +1,18 @@ +TARGET = qmlpreviewplugin +TEMPLATE = lib +CONFIG += plugin + +include(../../../../qtcreator.pri)\ + +include (../designercore/iwidgetplugin.pri) +include (../qmldesigner_dependencies.pri) + +LIBS += -L$$IDE_PLUGIN_PATH +LIBS += -l$$qtLibraryName(QmlDesigner) +LIBS += -l$$qtLibraryName(ExtensionSystem) +LIBS += -l$$qtLibraryName(Core) +LIBS += -l$$qtLibraryName(ProjectExplorer) +LIBS += -l$$qtLibraryName(Utils) + +include(qmlpreviewplugin.pri) +include(../plugindestdir.pri) diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.qrc b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.qrc new file mode 100644 index 0000000000..3f8cc2a077 --- /dev/null +++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/qmlpreviewplugin"> + <file>qmlpreview.metainfo</file> + <file>images/live_preview.png</file> + <file>images/live_preview@2x.png</file> + </qresource> +</RCC> diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp index c3936edf5b..4100d451ee 100644 --- a/src/plugins/qmldesigner/shortcutmanager.cpp +++ b/src/plugins/qmldesigner/shortcutmanager.cpp @@ -159,7 +159,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex //Close All Core::ActionManager::registerAction(&m_closeAllEditorsAction, Core::Constants::CLOSEALL, qmlDesignerMainContext); - connect(&m_closeAllEditorsAction, &QAction::triggered, em, &Core::EditorManager::closeAllEditors); + connect(&m_closeAllEditorsAction, &QAction::triggered, em, &Core::EditorManager::closeAllDocuments); //Close All Others Action Core::ActionManager::registerAction(&m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, qmlDesignerMainContext); |