forked from qt-creator/qt-creator
QmlDesigner: Implement fit selection button in 3D edit view
Shortcuts for scale and move were also updated to correct ones. Change-Id: Iffcad0c81475553003962e65dc059879a237546e Fixes: QDS-1235 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -300,7 +300,8 @@ Window {
|
||||
spacing: 5
|
||||
padding: 5
|
||||
|
||||
property var group: [btnSelectItem, btnSelectGroup, btnMove, btnRotate, btnScale]
|
||||
property var groupSelect: [btnSelectGroup, btnSelectItem]
|
||||
property var groupTransform: [btnMove, btnRotate, btnScale]
|
||||
|
||||
ToolBarButton {
|
||||
id: btnSelectItem
|
||||
@@ -309,7 +310,7 @@ Window {
|
||||
shortcut: "Q"
|
||||
currentShortcut: selected ? "" : shortcut
|
||||
tool: "item_selection"
|
||||
buttonsGroup: col.group
|
||||
buttonsGroup: col.groupSelect
|
||||
}
|
||||
|
||||
ToolBarButton {
|
||||
@@ -318,7 +319,7 @@ Window {
|
||||
shortcut: "Q"
|
||||
currentShortcut: btnSelectItem.currentShortcut === shortcut ? "" : shortcut
|
||||
tool: "group_selection"
|
||||
buttonsGroup: col.group
|
||||
buttonsGroup: col.groupSelect
|
||||
}
|
||||
|
||||
Rectangle { // separator
|
||||
@@ -330,11 +331,12 @@ Window {
|
||||
|
||||
ToolBarButton {
|
||||
id: btnMove
|
||||
selected: true
|
||||
tooltip: qsTr("Move current selection")
|
||||
shortcut: "M"
|
||||
shortcut: "W"
|
||||
currentShortcut: shortcut
|
||||
tool: "move"
|
||||
buttonsGroup: col.group
|
||||
buttonsGroup: col.groupTransform
|
||||
}
|
||||
|
||||
ToolBarButton {
|
||||
@@ -343,16 +345,37 @@ Window {
|
||||
shortcut: "E"
|
||||
currentShortcut: shortcut
|
||||
tool: "rotate"
|
||||
buttonsGroup: col.group
|
||||
buttonsGroup: col.groupTransform
|
||||
}
|
||||
|
||||
ToolBarButton {
|
||||
id: btnScale
|
||||
tooltip: qsTr("Scale current selection")
|
||||
shortcut: "T"
|
||||
shortcut: "R"
|
||||
currentShortcut: shortcut
|
||||
tool: "scale"
|
||||
buttonsGroup: col.group
|
||||
buttonsGroup: col.groupTransform
|
||||
}
|
||||
|
||||
Rectangle { // separator
|
||||
width: 25
|
||||
height: 1
|
||||
color: "#f1f1f1"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
ToolBarButton {
|
||||
id: btnFit
|
||||
tooltip: qsTr("Fit camera to current selection")
|
||||
shortcut: "F"
|
||||
currentShortcut: shortcut
|
||||
tool: "fit"
|
||||
togglable: false
|
||||
|
||||
onSelectedChanged: {
|
||||
if (selected)
|
||||
cameraControl.fitObject(viewWindow.selectedNode, editView.camera.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ Rectangle {
|
||||
property string currentShortcut
|
||||
property string tool
|
||||
property variant buttonsGroup: []
|
||||
property bool togglable: true
|
||||
|
||||
id: root
|
||||
width: img.width + 5
|
||||
@@ -71,6 +72,11 @@ Rectangle {
|
||||
root.buttonsGroup[i].selected = false;
|
||||
|
||||
root.selected = true;
|
||||
|
||||
if (!root.togglable) {
|
||||
// Deselect button after a short while (selection acts as simple click indicator)
|
||||
_generalHelper.delayedPropertySet(root, 200, "selected", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active.png
Normal file
BIN
share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 266 B |
BIN
share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active@2x.png
Normal file
BIN
share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 386 B |
BIN
share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected.png
Normal file
BIN
share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 266 B |
Binary file not shown.
After Width: | Height: | Size: 386 B |
@@ -185,6 +185,14 @@ QVector4D GeneralHelper::fitObjectToCamera(QQuick3DCamera *camera, float default
|
||||
zoomCamera(camera, 0, defaultLookAtDistance, lookAt, newZoomFactor, false));
|
||||
}
|
||||
|
||||
void GeneralHelper::delayedPropertySet(QObject *obj, int delay, const QString &property,
|
||||
const QVariant &value)
|
||||
{
|
||||
QTimer::singleShot(delay, [obj, property, value]() {
|
||||
obj->setProperty(property.toLatin1().constData(), value);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -57,6 +57,8 @@ public:
|
||||
float zoomFactor, bool relative);
|
||||
Q_INVOKABLE QVector4D fitObjectToCamera(QQuick3DCamera *camera, float defaultLookAtDistance,
|
||||
QQuick3DNode *targetObject, QQuick3DViewport *viewPort);
|
||||
Q_INVOKABLE void delayedPropertySet(QObject *obj, int delay, const QString &property,
|
||||
const QVariant& value);
|
||||
|
||||
signals:
|
||||
void overlayUpdateNeeded();
|
||||
|
@@ -64,5 +64,9 @@
|
||||
<file>mockfiles/images/point_light_gradient@2x.png</file>
|
||||
<file>mockfiles/images/area_light_gradient.png</file>
|
||||
<file>mockfiles/images/area_light_gradient@2x.png</file>
|
||||
<file>mockfiles/images/fit_active.png</file>
|
||||
<file>mockfiles/images/fit_active@2x.png</file>
|
||||
<file>mockfiles/images/fit_selected.png</file>
|
||||
<file>mockfiles/images/fit_selected@2x.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Reference in New Issue
Block a user