QmlDesigner: Implement effect maker preview zoom controls

Also fix a memory leak on removing a node.

Fixes: QDS-10546
Change-Id: Ifc32b6d7f6f4c6b8ce63a080b159c8ae66865a79
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Amr Elsayed <amr.elsayed@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Mahmoud Badri
2023-08-29 23:08:43 +03:00
parent 939b28a076
commit 2f2d8bf9e8
2 changed files with 38 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import QtQuick
import QtQuick.Layouts
import QtQuickDesignerTheme
import HelperWidgets as HelperWidgets
import StudioControls as StudioControls
@@ -18,18 +19,25 @@ Column {
height: StudioTheme.Values.toolbarHeight
color: StudioTheme.Values.themeToolbarBackground
Row {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: 5
RowLayout {
anchors.fill: parent
spacing: 5
anchors.rightMargin: 5
anchors.leftMargin: 5
Item {
Layout.fillWidth: true
}
HelperWidgets.AbstractButton {
style: StudioTheme.Values.viewBarButtonStyle
buttonIcon: StudioTheme.Constants.zoomOut_medium
tooltip: qsTr("Zoom out")
onClicked: {} // TODO
onClicked: {
if (previewImage.scale > .4)
previewImage.scale -= .2
}
}
HelperWidgets.AbstractButton {
@@ -37,7 +45,10 @@ Column {
buttonIcon: StudioTheme.Constants.zoomIn_medium
tooltip: qsTr("Zoom In")
onClicked: {} // TODO
onClicked: {
if (previewImage.scale < 2)
previewImage.scale += .2
}
}
HelperWidgets.AbstractButton {
@@ -45,7 +56,13 @@ Column {
buttonIcon: StudioTheme.Constants.cornersAll
tooltip: qsTr("Zoom Fit")
onClicked: {} // TODO
onClicked: {
previewImage.scale = 1
}
}
Item {
Layout.fillWidth: true
}
Column {
@@ -81,18 +98,29 @@ Column {
}
Rectangle { // preview image
id: previewImage
id: previewImageBg
color: "#dddddd"
width: parent.width
height: 200
clip: true
Image {
id: previewImage
anchors.margins: 5
anchors.fill: parent
fillMode: Image.PreserveAspectFit
smooth: true
source: "images/qt_logo.png" // TODO: update image
Behavior on scale {
NumberAnimation {
duration: 200
easing.type: Easing.OutQuad
}
}
}
}
}

View File

@@ -48,7 +48,9 @@ void EffectMakerModel::addNode(const QString &nodeQenPath)
void EffectMakerModel::removeNode(int idx)
{
beginRemoveRows({}, idx, idx);
CompositionNode *node = m_nodes.at(idx);
m_nodes.removeAt(idx);
delete node;
endRemoveRows();
}