summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Pope <daniel.pope@nokia.com>2012-01-17 13:55:04 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-23 00:36:35 +0100
commit5a5714584fa94ca9ff68146aa9f53a274058c979 (patch)
treeb815a49a536f72df70391d96b98ecfe3f295bbfe
parent9a015666464762d18a9c736fa61c8d5f7050eb21 (diff)
Save on exit and GUI changes.
Added fixes for Save on Exit task, as well as gui changes for QTBUG-23548. Task-number: QTBUG-22072 Change-Id: I4ff369c10d61e1ab70ce6dfd035fc60c8fb80807 Reviewed-by: Danny Pope <daniel.pope@nokia.com>
-rw-r--r--util/qt3d/modeltweak/main.cpp3
-rw-r--r--util/qt3d/modeltweak/modeltweak.pro5
-rw-r--r--util/qt3d/modeltweak/qml/BlenderValueSlider.qml2
-rw-r--r--util/qt3d/modeltweak/qml/ButtonBarPane.qml33
-rw-r--r--util/qt3d/modeltweak/qml/ModelPropertiesPane.qml16
-rw-r--r--util/qt3d/modeltweak/qml/ModelTweak.qml325
-rw-r--r--util/qt3d/modeltweak/qml/SaveButton.qml62
-rw-r--r--util/qt3d/modeltweak/qml/Widgets/BlenderToggle.qml14
-rw-r--r--util/qt3d/modeltweak/qml/fileHandling.js72
-rw-r--r--util/qt3d/modeltweak/qml/images/help.pngbin0 -> 737 bytes
-rw-r--r--util/qt3d/modeltweak/qml/images/model.pngbin0 -> 754 bytes
-rw-r--r--util/qt3d/modeltweak/qml/images/open.pngbin0 -> 596 bytes
-rw-r--r--util/qt3d/modeltweak/qml/images/save.pngbin0 -> 706 bytes
-rw-r--r--util/qt3d/modeltweak/quickfile.cpp33
-rw-r--r--util/qt3d/modeltweak/quickfile.h2
15 files changed, 350 insertions, 217 deletions
diff --git a/util/qt3d/modeltweak/main.cpp b/util/qt3d/modeltweak/main.cpp
index 9fdaea4f..619bc6c3 100644
--- a/util/qt3d/modeltweak/main.cpp
+++ b/util/qt3d/modeltweak/main.cpp
@@ -60,6 +60,9 @@ int main(int argc, char *argv[])
QString qml = q_get_qmldir(QLatin1String("qml/ModelTweak.qml"));
view.setSource(QUrl::fromLocalFile(qml));
+ //disable close button
+ // view.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint);
+
QString fn;
QStringList args = QApplication::arguments();
for (int i = 0; i < args.size(); ++i)
diff --git a/util/qt3d/modeltweak/modeltweak.pro b/util/qt3d/modeltweak/modeltweak.pro
index 1356a1c9..d77f4f1e 100644
--- a/util/qt3d/modeltweak/modeltweak.pro
+++ b/util/qt3d/modeltweak/modeltweak.pro
@@ -25,3 +25,8 @@ HEADERS += \
quickfile.h
+
+
+
+
+
diff --git a/util/qt3d/modeltweak/qml/BlenderValueSlider.qml b/util/qt3d/modeltweak/qml/BlenderValueSlider.qml
index 6203d020..e5709c5f 100644
--- a/util/qt3d/modeltweak/qml/BlenderValueSlider.qml
+++ b/util/qt3d/modeltweak/qml/BlenderValueSlider.qml
@@ -23,6 +23,7 @@ Item {
signal prev
signal gotFocus
signal fail
+ signal changed
Rectangle {
id: rect
@@ -45,6 +46,7 @@ Item {
verticalAlignment: Text.AlignVCenter
text: valueSlider.label + " " + textInput.text
visible: true
+ onTextChanged: changed();
}
diff --git a/util/qt3d/modeltweak/qml/ButtonBarPane.qml b/util/qt3d/modeltweak/qml/ButtonBarPane.qml
index ece16573..c366fb0d 100644
--- a/util/qt3d/modeltweak/qml/ButtonBarPane.qml
+++ b/util/qt3d/modeltweak/qml/ButtonBarPane.qml
@@ -1,28 +1,49 @@
import QtQuick 1.0
import Qt3D 1.0
import ModelTweak 1.0
+import "fileHandling.js" as FileHandler
import "Widgets"
Flow {
+ id: menu
+ anchors.left: parent.left
+ anchors.leftMargin: 2
+ anchors.top: parent.top
+ anchors.topMargin: 2
width: buttonWidth * 4 + spacing * 3
- spacing: 8
+ height: parent.height
+ spacing: 5
- property double buttonWidth: 80
+ property double buttonWidth: 105
SaveButton {
+ id: save
width: buttonWidth
- buttonText: "Save!"
+ buttonText: "Save QML"
+ imageSrc: "images/save.png"
}
BlenderToggle {
+ id: load
width: buttonWidth
- buttonText: "Load!"
- onClicked: quickFile.load()
+ onClicked:
+ {
+ if (outerWindow.changed)
+ {
+ FileHandler.save_qml(true);
+ }
+
+ quickFile.load()
+ }
+ buttonText: "Load Asset"
+ imageSrc: "images/model.png"
}
BlenderToggle {
+ id: help
width: buttonWidth
- buttonText: "Help!"
onClicked: helpOverlay.visible = true
+ buttonText: "Help!"
+ imageSrc: "images/help.png"
}
}
diff --git a/util/qt3d/modeltweak/qml/ModelPropertiesPane.qml b/util/qt3d/modeltweak/qml/ModelPropertiesPane.qml
index 8fa9988d..7325402b 100644
--- a/util/qt3d/modeltweak/qml/ModelPropertiesPane.qml
+++ b/util/qt3d/modeltweak/qml/ModelPropertiesPane.qml
@@ -3,6 +3,7 @@ import Qt3D 1.0
import ModelTweak 1.0
Column {
+ id: properties
width: posX.width
height: parent.height
spacing: 4
@@ -11,6 +12,8 @@ Column {
property alias scaleLocked: imageS.isLocked
property alias translateLocked: imageP.isLocked;
+ signal changed;
+
// POSITION
Item {
id: positionPanel
@@ -74,12 +77,13 @@ Column {
label: "X:"
locked: imageP.isLocked
value: transformTranslate.translate.x.toFixed(3)
- function update (f) {
+ function update (f) {
transformTranslate.translate = Qt.vector3d(f, transformTranslate.translate.y, transformTranslate.translate.z);
}
onNext: { updateMe(); focus = false; posY.focus = true; }
onPrev: { updateMe(); focus = false; scaleZ.focus = true; }
onFail: { imageP.bounce=true; }
+ onChanged: { properties.changed(); }
}
BlenderValueSlider {
id: posY
@@ -92,6 +96,7 @@ Column {
onNext: { updateMe(); focus = false; posZ.focus = true; }
onPrev: { updateMe(); focus = false; posX.focus = true; }
onFail: { imageP.bounce=true; }
+ onChanged: { properties.changed(); }
}
BlenderValueSlider {
id: posZ
@@ -104,6 +109,7 @@ Column {
onNext: { updateMe(); focus = false; rotX.focus = true; }
onPrev: { updateMe(); focus = false; posY.focus = true; }
onFail: { imageP.bounce=true; }
+ onChanged: { properties.changed(); }
}
// ROTATE
@@ -111,6 +117,7 @@ Column {
id: rotationPanel
width: parent.width
height: imageR.height
+ property bool dirty: false
Text {
anchors.left: parent.left
@@ -175,6 +182,7 @@ Column {
onNext: { updateMe(); focus = false; rotY.focus = true; }
onPrev: { updateMe(); focus = false; posZ.focus = true; }
onFail: { imageR.bounce=true; }
+ onChanged: { properties.changed(); }
}
BlenderValueSlider {
id: rotY
@@ -188,6 +196,7 @@ Column {
onNext: { updateMe(); focus = false; rotZ.focus = true; }
onPrev: { updateMe(); focus = false; rotX.focus = true; }
onFail: { imageR.bounce=true; }
+ onChanged: { properties.changed(); }
}
BlenderValueSlider {
id: rotZ
@@ -201,6 +210,7 @@ Column {
onNext: { updateMe(); focus = false; scaleX.focus = true; }
onPrev: { updateMe(); focus = false; rotY.focus = true; }
onFail: { imageR.bounce=true; }
+ onChanged: { properties.changed(); }
}
// SCALE
@@ -208,6 +218,7 @@ Column {
id: scalePanel
width: parent.width
height: imageS.height
+ property bool dirty: false
Text {
anchors.left: parent.left
@@ -270,6 +281,7 @@ Column {
onNext: { updateMe(); focus = false; scaleY.focus = true; }
onPrev: { updateMe(); focus = false; rotZ.focus = true; }
onFail: { imageS.bounce=true; }
+ onChanged: { properties.changed(); }
}
BlenderValueSlider {
id: scaleY
@@ -281,6 +293,7 @@ Column {
onNext: { updateMe(); focus = false; scaleZ.focus = true; }
onPrev: { updateMe(); focus = false; scaleX.focus = true; }
onFail: { imageS.bounce=true; }
+ onChanged: { properties.changed(); }
}
BlenderValueSlider {
id: scaleZ
@@ -292,5 +305,6 @@ Column {
onNext: { updateMe(); focus = false; posX.focus = true; }
onPrev: { updateMe(); focus = false; scaleY.focus = true; }
onFail: { imageS.bounce=true; }
+ onChanged: { properties.changed(); }
}
}
diff --git a/util/qt3d/modeltweak/qml/ModelTweak.qml b/util/qt3d/modeltweak/qml/ModelTweak.qml
index 0741a794..001ad4a3 100644
--- a/util/qt3d/modeltweak/qml/ModelTweak.qml
+++ b/util/qt3d/modeltweak/qml/ModelTweak.qml
@@ -41,179 +41,208 @@
import QtQuick 1.0
import Qt3D 1.0
import ModelTweak 1.0
+import "fileHandling.js" as FileHandler
Rectangle {
- id: mainwindow
+ id: outerWindow;
width: 1024
height: 768
- color: "#444444"
- border.color: "black"
- property alias targetMesh: quickFile.filename
- QuickFile {
- id: quickFile
- filename: "meshes/penguin.3ds"
+ property bool changed: false
+ Component.onCompleted: {
+ outerWindow.changed = false;
}
- Mesh {
- id: source_mesh
- source: quickFile.filename
- }
-
- Translation3D { id: transformTranslate; translate: Qt.vector3d(0, 0, 0); }
- Rotation3D { id: transformRotateX; axis: Qt.vector3d(1, 0, 0); angle: 0; }
- Rotation3D { id: transformRotateY; axis: Qt.vector3d(0, 1, 0); angle: 0; }
- Rotation3D { id: transformRotateZ; axis: Qt.vector3d(0, 0, 1); angle: 0; }
- Scale3D { id: transformScale; scale: Qt.vector3d(1, 1, 1); }
-
- ModelViewport {
- id: mvpZY
- x: 0;
- y: 0;
- camera.eye: Qt.vector3d(20, 0, 0);
- stateName: "ZYMaximised"
- viewportName: "Z,Y axis (right)"
-
- rightVector: Qt.vector3d(0, 0, -1)
- upVector: Qt.vector3d(0, 1, 0)
-
- property alias position: transformTranslate.translate;
-
- onMouseTranslateX: if (!modelPropertiesPane.translateLocked) position = Qt.vector3d(position.x, position.y, translate.z + (down.x - mouse.x)/translateSensitivity)
- onMouseTranslateY: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(position.x, translate.y + (down.y - mouse.y)/translateSensitivity, position.z)
- onMouseRotateX: if (!modelPropertiesPane.rotateLocked)transformRotateY.angle = rotate.y - (down.x - mouse.x)/rotateSensitivity
- onMouseRotateY: if (!modelPropertiesPane.rotateLocked)transformRotateZ.angle = rotate.z - (down.y - mouse.y)/rotateSensitivity
- onMouseScaleX: if (!modelPropertiesPane.scaleLocked) {
- var s = scale3d.z - (down.x - mouse.x)/scaleSensitivity;
- transformScale.scale = Qt.vector3d(transformScale.scale.x, transformScale.scale.y, s<0 ? 0 : s)
- }
- onMouseScaleY: if (!modelPropertiesPane.scaleLocked) {
- var s = scale3d.y + (down.y - mouse.y)/scaleSensitivity;
- transformScale.scale = Qt.vector3d(transformScale.scale.x, s<0 ? 0 : s, transformScale.scale.z)
+ Component.onDestruction: {
+ if (outerWindow.changed)
+ {
+ FileHandler.save_qml(true);
}
}
- ModelViewport {
- id: mvpXY
- x: parent.width/2
- y: 0;
- camera.eye: Qt.vector3d(0, 0, 20);
- stateName: "XYMaximised"
- viewportName: "X,Y axis (front)"
-
- rightVector: Qt.vector3d(1, 0, 0)
- upVector: Qt.vector3d(0, 1, 0)
-
- property alias position: transformTranslate.translate;
-
- onMouseTranslateX: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(translate.x - (down.x - mouse.x)/translateSensitivity, position.y, position.z)
- onMouseTranslateY: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(position.x, translate.y + (down.y - mouse.y)/translateSensitivity, position.z)
- onMouseRotateX: if (!modelPropertiesPane.rotateLocked) transformRotateY.angle = rotate.y - (down.x - mouse.x)/rotateSensitivity
- onMouseRotateY: if (!modelPropertiesPane.rotateLocked) transformRotateX.angle = rotate.x - (down.y - mouse.y)/rotateSensitivity
- onMouseScaleX: if (!modelPropertiesPane.scaleLocked) {
- var s = scale3d.x - (down.x - mouse.x)/scaleSensitivity
- transformScale.scale = Qt.vector3d(s<0 ? 0 : s, transformScale.scale.y, transformScale.scale.z)
- }
- onMouseScaleY: if (!modelPropertiesPane.scaleLocked) {
- var s = scale3d.y + (down.y - mouse.y)/scaleSensitivity
- transformScale.scale = Qt.vector3d(transformScale.scale.x, s<0 ? 0 : s, transformScale.scale.z)
- }
- }
+ Rectangle {
+ id: menu
+ x: parent.x
+ y: parent.y
+ height: 24
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+
+ color: "#B4B4B4"
+ border.color: "black"
- ModelViewport {
- id: mvpXZ
- x: parent.width/2;
- y: parent.height/2;
- camera.eye: Qt.vector3d(0, 20, 0);
- camera.upVector: Qt.vector3d(0, 0, -1);
- stateName: "XZMaximised"
- viewportName: "X,Z axis (top)"
-
- rightVector: Qt.vector3d(1, 0, 0)
- upVector: Qt.vector3d(0, 0, -1)
-
- property alias position: transformTranslate.translate;
-
- onMouseTranslateX: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(translate.x - (down.x - mouse.x)/translateSensitivity, position.y, position.z)
- onMouseTranslateY: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(position.x, position.y, translate.z - (down.y - mouse.y)/translateSensitivity)
- onMouseRotateX: if (!modelPropertiesPane.rotateLocked)transformRotateZ.angle = rotate.z + (down.x - mouse.x)/rotateSensitivity
- onMouseRotateY: if (!modelPropertiesPane.rotateLocked)transformRotateX.angle = rotate.x - (down.y - mouse.y)/rotateSensitivity
- onMouseScaleX: if (!modelPropertiesPane.scaleLocked) {
- var s = scale3d.x - (down.x - mouse.x)/scaleSensitivity;
- transformScale.scale = Qt.vector3d(s<0 ? 0 : s, transformScale.scale.y, transformScale.scale.z)
- }
- onMouseScaleY: if (!modelPropertiesPane.scaleLocked) {
- var s = scale3d.z + (down.y - mouse.y)/scaleSensitivity;
- transformScale.scale = Qt.vector3d(transformScale.scale.x, transformScale.scale.y, s<0 ? 0 : s)
+ ButtonBarPane {
+ id: buttonBarPane
+ anchors.fill: parent
}
}
Rectangle {
- id: meshName
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottomMargin: 10
- anchors.bottom: parent.bottom
- radius: 10
- border.width: 1
+ id: mainwindow
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: menu.bottom
+ anchors.bottom: outerWindow.bottom
+
+ color: "#444444"
border.color: "black"
- color: "white"
- width: parent.width - 20
- height: 20
- Text {
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- text: source_mesh.source
+ property alias targetMesh: quickFile.filename
+
+ QuickFile {
+ id: quickFile
+ filename: "meshes/penguin.3ds"
}
- }
- ModelPropertiesPane {
- id: modelPropertiesPane
- x: 16;
- y: parent.height / 2 + 16
+ Mesh {
+ id: source_mesh
+ source: quickFile.filename
+ }
- }
+ Translation3D { id: transformTranslate; translate: Qt.vector3d(0, 0, 0); }
+ Rotation3D { id: transformRotateX; axis: Qt.vector3d(1, 0, 0); angle: 0; }
+ Rotation3D { id: transformRotateY; axis: Qt.vector3d(0, 1, 0); angle: 0; }
+ Rotation3D { id: transformRotateZ; axis: Qt.vector3d(0, 0, 1); angle: 0; }
+ Scale3D { id: transformScale; scale: Qt.vector3d(1, 1, 1); }
+
+ ModelViewport {
+ id: mvpZY
+ x: 0;
+ y: 0;
+ camera.eye: Qt.vector3d(20, 0, 0);
+ stateName: "ZYMaximised"
+ viewportName: "Z,Y axis (right)"
+
+ rightVector: Qt.vector3d(0, 0, -1)
+ upVector: Qt.vector3d(0, 1, 0)
+
+ property alias position: transformTranslate.translate;
+
+ onMouseTranslateX: if (!modelPropertiesPane.translateLocked) position = Qt.vector3d(position.x, position.y, translate.z + (down.x - mouse.x)/translateSensitivity)
+ onMouseTranslateY: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(position.x, translate.y + (down.y - mouse.y)/translateSensitivity, position.z)
+ onMouseRotateX: if (!modelPropertiesPane.rotateLocked)transformRotateY.angle = rotate.y - (down.x - mouse.x)/rotateSensitivity
+ onMouseRotateY: if (!modelPropertiesPane.rotateLocked)transformRotateZ.angle = rotate.z - (down.y - mouse.y)/rotateSensitivity
+ onMouseScaleX: if (!modelPropertiesPane.scaleLocked) {
+ var s = scale3d.z - (down.x - mouse.x)/scaleSensitivity;
+ transformScale.scale = Qt.vector3d(transformScale.scale.x, transformScale.scale.y, s<0 ? 0 : s)
+ }
+ onMouseScaleY: if (!modelPropertiesPane.scaleLocked) {
+ var s = scale3d.y + (down.y - mouse.y)/scaleSensitivity;
+ transformScale.scale = Qt.vector3d(transformScale.scale.x, s<0 ? 0 : s, transformScale.scale.z)
+ }
+ }
- Item {
- width: parent.width / 2
- anchors.bottom: meshName.top
- anchors.bottomMargin: 8
- height: buttonBarPane.height
+ ModelViewport {
+ id: mvpXY
+ x: parent.width/2
+ y: 0;
+ camera.eye: Qt.vector3d(0, 0, 20);
+ stateName: "XYMaximised"
+ viewportName: "X,Y axis (front)"
+
+ rightVector: Qt.vector3d(1, 0, 0)
+ upVector: Qt.vector3d(0, 1, 0)
+
+ property alias position: transformTranslate.translate;
+
+ onMouseTranslateX: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(translate.x - (down.x - mouse.x)/translateSensitivity, position.y, position.z)
+ onMouseTranslateY: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(position.x, translate.y + (down.y - mouse.y)/translateSensitivity, position.z)
+ onMouseRotateX: if (!modelPropertiesPane.rotateLocked) transformRotateY.angle = rotate.y - (down.x - mouse.x)/rotateSensitivity
+ onMouseRotateY: if (!modelPropertiesPane.rotateLocked) transformRotateX.angle = rotate.x - (down.y - mouse.y)/rotateSensitivity
+ onMouseScaleX: if (!modelPropertiesPane.scaleLocked) {
+ var s = scale3d.x - (down.x - mouse.x)/scaleSensitivity
+ transformScale.scale = Qt.vector3d(s<0 ? 0 : s, transformScale.scale.y, transformScale.scale.z)
+ }
+ onMouseScaleY: if (!modelPropertiesPane.scaleLocked) {
+ var s = scale3d.y + (down.y - mouse.y)/scaleSensitivity
+ transformScale.scale = Qt.vector3d(transformScale.scale.x, s<0 ? 0 : s, transformScale.scale.z)
+ }
+ }
- ButtonBarPane {
- id: buttonBarPane
- anchors.centerIn: parent
+ ModelViewport {
+ id: mvpXZ
+ x: parent.width/2;
+ y: parent.height/2;
+ camera.eye: Qt.vector3d(0, 20, 0);
+ camera.upVector: Qt.vector3d(0, 0, -1);
+ stateName: "XZMaximised"
+ viewportName: "X,Z axis (top)"
+
+ rightVector: Qt.vector3d(1, 0, 0)
+ upVector: Qt.vector3d(0, 0, -1)
+
+ property alias position: transformTranslate.translate;
+
+ onMouseTranslateX: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(translate.x - (down.x - mouse.x)/translateSensitivity, position.y, position.z)
+ onMouseTranslateY: if (!modelPropertiesPane.translateLocked)position = Qt.vector3d(position.x, position.y, translate.z - (down.y - mouse.y)/translateSensitivity)
+ onMouseRotateX: if (!modelPropertiesPane.rotateLocked)transformRotateZ.angle = rotate.z + (down.x - mouse.x)/rotateSensitivity
+ onMouseRotateY: if (!modelPropertiesPane.rotateLocked)transformRotateX.angle = rotate.x - (down.y - mouse.y)/rotateSensitivity
+ onMouseScaleX: if (!modelPropertiesPane.scaleLocked) {
+ var s = scale3d.x - (down.x - mouse.x)/scaleSensitivity;
+ transformScale.scale = Qt.vector3d(s<0 ? 0 : s, transformScale.scale.y, transformScale.scale.z)
+ }
+ onMouseScaleY: if (!modelPropertiesPane.scaleLocked) {
+ var s = scale3d.z + (down.y - mouse.y)/scaleSensitivity;
+ transformScale.scale = Qt.vector3d(transformScale.scale.x, transformScale.scale.y, s<0 ? 0 : s)
+ }
}
- }
- HelpOverlay {
- id: helpOverlay
- visible: false
- }
+ Rectangle {
+ id: meshName
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottomMargin: 10
+ anchors.bottom: parent.bottom
+ radius: 10
+ border.width: 1
+ border.color: "black"
+ color: "white"
+ width: parent.width - 20
+ height: 20
+
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: source_mesh.source
+ }
+ }
- states: [
- State {
- name: "3Views"
- },
- State {
- name: "ZYMaximised"
- PropertyChanges { target: mvpZY; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; }
- PropertyChanges { target: mvpXY; x: mainwindow.width; y: 0; width: 0; height: mainwindow.height/2; }
- PropertyChanges { target: mvpXZ; x: mainwindow.width; y: mainwindow.height; width: 0; height: 0; }
- },
- State {
- name: "XYMaximised"
- PropertyChanges { target: mvpZY; x: 0; y: 0; width: 0; height: mainwindow.height/2; }
- PropertyChanges { target: mvpXY; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; }
- PropertyChanges { target: mvpXZ; x: mainwindow.width/2; y: mainwindow.height; width: mainwindow.width/2; height: 0; }
- },
- State {
- name: "XZMaximised"
- PropertyChanges { target: mvpZY; x: 0; y: 0; width: 0; height: 0; }
- PropertyChanges { target: mvpXY; x: mainwindow.width/2; y: 0; width: mainwindow.width/2; height: 0; }
- PropertyChanges { target: mvpXZ; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; }
+ ModelPropertiesPane {
+ id: modelPropertiesPane
+ x: 16;
+ y: parent.height / 2 + 16
+ onChanged: {outerWindow.changed=true}
}
- ]
- state: "3Views"
+ HelpOverlay {
+ id: helpOverlay
+ visible: false
+ }
+
+ states: [
+ State {
+ name: "3Views"
+ },
+ State {
+ name: "ZYMaximised"
+ PropertyChanges { target: mvpZY; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; }
+ PropertyChanges { target: mvpXY; x: mainwindow.width; y: 0; width: 0; height: mainwindow.height/2; }
+ PropertyChanges { target: mvpXZ; x: mainwindow.width; y: mainwindow.height; width: 0; height: 0; }
+ },
+ State {
+ name: "XYMaximised"
+ PropertyChanges { target: mvpZY; x: 0; y: 0; width: 0; height: mainwindow.height/2; }
+ PropertyChanges { target: mvpXY; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; }
+ PropertyChanges { target: mvpXZ; x: mainwindow.width/2; y: mainwindow.height; width: mainwindow.width/2; height: 0; }
+ },
+ State {
+ name: "XZMaximised"
+ PropertyChanges { target: mvpZY; x: 0; y: 0; width: 0; height: 0; }
+ PropertyChanges { target: mvpXY; x: mainwindow.width/2; y: 0; width: mainwindow.width/2; height: 0; }
+ PropertyChanges { target: mvpXZ; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; }
+ }
+ ]
+
+ state: "3Views"
+ }
}
diff --git a/util/qt3d/modeltweak/qml/SaveButton.qml b/util/qt3d/modeltweak/qml/SaveButton.qml
index 9056c293..ea52f0fe 100644
--- a/util/qt3d/modeltweak/qml/SaveButton.qml
+++ b/util/qt3d/modeltweak/qml/SaveButton.qml
@@ -2,67 +2,11 @@ import QtQuick 1.0
import Qt3D 1.0
import ModelTweak 1.0
import "Widgets"
+import "fileHandling.js" as FileHandler
+
BlenderToggle {
onClicked: {
- var saveData =
- "import QtQuick 1.0\n" +
- "import Qt3D 1.0\n" +
- "\n" +
- "Item3D {\n" +
- " Translation3D {\n" +
- " id: transformTranslate\n" +
- " translate: Qt.vector3d(" +
- transformTranslate.translate.x + ", " +
- transformTranslate.translate.y + ", " +
- transformTranslate.translate.z + ")\n" +
- " }\n" +
- "\n" +
- " Rotation3D {\n" +
- " id: transformRotateX\n" +
- " angle: " + transformRotateX.angle + "\n" +
- " axis: Qt.vector3d(1, 0, 0)\n" +
- " }\n" +
- "\n" +
- " Rotation3D {\n" +
- " id: transformRotateY\n" +
- " angle: " + transformRotateY.angle + "\n" +
- " axis: Qt.vector3d(0, 1, 0)\n" +
- " }\n" +
- "\n" +
- " Rotation3D {\n" +
- " id: transformRotateZ\n" +
- " angle: " + transformRotateZ.angle + "\n" +
- " axis: Qt.vector3d(0, 0, 1)\n" +
- " }\n" +
- "\n" +
- " Scale3D {\n" +
- " id: transformScale\n" +
- " scale: Qt.vector3d(" +
- transformScale.scale.x + ", " +
- transformScale.scale.y + ", " +
- transformScale.scale.z + ")\n" +
- " }\n" +
- "\n" +
- " Mesh {\n" +
- " id: source_mesh\n" +
- " source: \"%1\"\n" +
- " }\n" +
- "\n" +
- " mesh: source_mesh\n" +
- " transform: [\n" +
- " transformScale,\n" +
- " transformRotateX,\n" +
- " transformRotateY,\n" +
- " transformRotateZ,\n" +
- " transformTranslate,\n" +
- " ]\n" +
- "}\n";
-
- quickFile.filename = source_mesh.source
- quickFile.data = saveData
- var result = quickFile.save()
- if (result !== "")
- console.log("If there was an error it will be after here:" + result)
+ FileHandler.save_qml(false);
}
}
diff --git a/util/qt3d/modeltweak/qml/Widgets/BlenderToggle.qml b/util/qt3d/modeltweak/qml/Widgets/BlenderToggle.qml
index f2216f4f..7e397636 100644
--- a/util/qt3d/modeltweak/qml/Widgets/BlenderToggle.qml
+++ b/util/qt3d/modeltweak/qml/Widgets/BlenderToggle.qml
@@ -3,7 +3,8 @@ import Qt3D 1.0
import ModelTweak 1.0
Rectangle {
- anchors.topMargin: 8
+ anchors.topMargin: 15
+ anchors.leftMargin: 15
border.width: 1
border.color: "#191919"
radius: 8
@@ -11,13 +12,24 @@ Rectangle {
color: "#999999"
property alias buttonText: text.text
+ property alias imageSrc: img.source
signal clicked
+
+ Image {
+ id: img
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
Text {
id: text
anchors.fill: parent
font.pixelSize: 12
+ anchors.left: img.left
+ anchors.leftMargin: 5
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
diff --git a/util/qt3d/modeltweak/qml/fileHandling.js b/util/qt3d/modeltweak/qml/fileHandling.js
new file mode 100644
index 00000000..9867a90f
--- /dev/null
+++ b/util/qt3d/modeltweak/qml/fileHandling.js
@@ -0,0 +1,72 @@
+function save_qml(closePrompt) {
+
+ var saveData =
+ "// --------| WARNING |--------!!\n" +
+ "// This is a generated file. Modifying the text or layout of \n" +
+ "// this file will mean that the Model-Tweaker application will no \n" +
+ "// longer be able to read it. \n\n" +
+ "// Changing numeric values is allowable, though care should be taken\n" +
+ "// not to inadvertantly change the file structure.\n\n" +
+ "import QtQuick 1.0\n" +
+ "import Qt3D 1.0\n" +
+ "\n" +
+ "Item3D {\n" +
+ " Translation3D {\n" +
+ " id: transformTranslate\n" +
+ " translate: Qt.vector3d(" +
+ transformTranslate.translate.x + ", " +
+ transformTranslate.translate.y + ", " +
+ transformTranslate.translate.z + ")\n" +
+ " }\n" +
+ "\n" +
+ " Rotation3D {\n" +
+ " id: transformRotateX\n" +
+ " angle: " + transformRotateX.angle + "\n" +
+ " axis: Qt.vector3d(1, 0, 0)\n" +
+ " }\n" +
+ "\n" +
+ " Rotation3D {\n" +
+ " id: transformRotateY\n" +
+ " angle: " + transformRotateY.angle + "\n" +
+ " axis: Qt.vector3d(0, 1, 0)\n" +
+ " }\n" +
+ "\n" +
+ " Rotation3D {\n" +
+ " id: transformRotateZ\n" +
+ " angle: " + transformRotateZ.angle + "\n" +
+ " axis: Qt.vector3d(0, 0, 1)\n" +
+ " }\n" +
+ "\n" +
+ " Scale3D {\n" +
+ " id: transformScale\n" +
+ " scale: Qt.vector3d(" +
+ transformScale.scale.x + ", " +
+ transformScale.scale.y + ", " +
+ transformScale.scale.z + ")\n" +
+ " }\n" +
+ "\n" +
+ " Mesh {\n" +
+ " id: source_mesh\n" +
+ " source: \"%1\"\n" +
+ " }\n" +
+ "\n" +
+ " mesh: source_mesh\n" +
+ " transform: [\n" +
+ " transformScale,\n" +
+ " transformRotateX,\n" +
+ " transformRotateY,\n" +
+ " transformRotateZ,\n" +
+ " transformTranslate,\n" +
+ " ]\n" +
+ "}\n";
+
+ quickFile.filename = source_mesh.source
+ quickFile.data = saveData
+ if (closePrompt)
+ var result = quickFile.promptSave()
+ else
+ result = quickFile.save()
+
+ if (result !== "")
+ console.log("If there was an error it will be after here:" + result)
+}
diff --git a/util/qt3d/modeltweak/qml/images/help.png b/util/qt3d/modeltweak/qml/images/help.png
new file mode 100644
index 00000000..452ac525
--- /dev/null
+++ b/util/qt3d/modeltweak/qml/images/help.png
Binary files differ
diff --git a/util/qt3d/modeltweak/qml/images/model.png b/util/qt3d/modeltweak/qml/images/model.png
new file mode 100644
index 00000000..62054e3c
--- /dev/null
+++ b/util/qt3d/modeltweak/qml/images/model.png
Binary files differ
diff --git a/util/qt3d/modeltweak/qml/images/open.png b/util/qt3d/modeltweak/qml/images/open.png
new file mode 100644
index 00000000..5db00d52
--- /dev/null
+++ b/util/qt3d/modeltweak/qml/images/open.png
Binary files differ
diff --git a/util/qt3d/modeltweak/qml/images/save.png b/util/qt3d/modeltweak/qml/images/save.png
new file mode 100644
index 00000000..e1db4498
--- /dev/null
+++ b/util/qt3d/modeltweak/qml/images/save.png
Binary files differ
diff --git a/util/qt3d/modeltweak/quickfile.cpp b/util/qt3d/modeltweak/quickfile.cpp
index c6bc7bd5..52bae098 100644
--- a/util/qt3d/modeltweak/quickfile.cpp
+++ b/util/qt3d/modeltweak/quickfile.cpp
@@ -1,6 +1,7 @@
#include "quickfile.h"
#include <QFileDialog>
#include <QUrl>
+ #include <QMessageBox>
/*!
\qmlclass QuickFile QuickFile
@@ -29,12 +30,17 @@ QuickFile::QuickFile(QObject *parent) :
/*!
Prompts for a location and filename to save the qml \c{QuickFile::data} generated by ModelTweaker.
Returns an error message if the file was unsuccessfully saved,
- or an empty string if the save was successful.
+ or an empty string if the save was successful/cancelled.
*/
QString QuickFile::save() const
{
QString filename = QFileDialog::getSaveFileName(0, tr("Save QML File"), "",tr("Files (*.qml)"));
+ //If cancel button pressed (ie. filename empty), we can just drop out immediately
+ if (filename.isEmpty()) {
+ return QString();
+ }
+
// FIXME: ensure fileName is appropriate as a qml Component
if (!filename.endsWith(".qml"))
filename.append(".qml");
@@ -82,6 +88,29 @@ QString QuickFile::save() const
}
/*!
+ Save/Close dialog for unsaved changes to QML files. This is shown if the user
+ closes the app without saving the modifications they have made.
+
+ Returns an error message if the file was unsuccessfully saved,
+ or an empty string if the save was successful/cancelled.
+*/
+QString QuickFile::promptSave() const
+{
+ QMessageBox msgBox;
+ msgBox.setText("The document has been modified.");
+ msgBox.setInformativeText("Do you want to save your changes?");
+ msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
+ msgBox.setDefaultButton(QMessageBox::Save);
+ int ret = msgBox.exec();
+
+ if (ret==QMessageBox::Save) {
+ return save();
+ } else {
+ return QString();
+ }
+}
+
+/*!
Prompts for a location to load a model file from and stores it into the the \c{QuickFile::filename}
variable.
*/
@@ -92,6 +121,7 @@ void QuickFile::load()
setFilename(qmlFilename);
}
+
QString QuickFile::filename() const {
return _filename;
}
@@ -111,3 +141,4 @@ void QuickFile::setData(const QString data) {
_data = data;
emit dataChanged(data);
}
+
diff --git a/util/qt3d/modeltweak/quickfile.h b/util/qt3d/modeltweak/quickfile.h
index ba4e423e..167047de 100644
--- a/util/qt3d/modeltweak/quickfile.h
+++ b/util/qt3d/modeltweak/quickfile.h
@@ -24,11 +24,11 @@ public:
Q_INVOKABLE QString save() const;
Q_INVOKABLE void load();
+ Q_INVOKABLE QString promptSave() const;
signals:
void filenameChanged(const QString newFilename);
void dataChanged(const QString newData);
-
};
#endif // QUICKFILE_H