diff options
author | Tomi Korpipää <tomi.korpipaa@qt.io> | 2016-06-13 09:31:50 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2016-06-13 06:51:36 +0000 |
commit | 22af34b58ad8dd57e428215198611f27f6ac71c7 (patch) | |
tree | aa4c17200be17a6d8c9f88d4e24362991da9cb37 | |
parent | 1fbbe12f93ca82bdb3a71637db7e1002e80d48ac (diff) |
Persistent settings support added
Note: The rest will be added in a separate task
Change-Id: I0f6f0fb345e35d4fb97737d61a4c25f7aac48a11
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | editorlib/qml/EntityLibrary.qml | 5 | ||||
-rw-r--r-- | editorlib/qml/SettingsDialog.qml | 50 | ||||
-rw-r--r-- | editorlib/qml/main.qml | 18 | ||||
-rw-r--r-- | standalone/main.cpp | 4 |
4 files changed, 64 insertions, 13 deletions
diff --git a/editorlib/qml/EntityLibrary.qml b/editorlib/qml/EntityLibrary.qml index d8b53c9..eb56a30 100644 --- a/editorlib/qml/EntityLibrary.qml +++ b/editorlib/qml/EntityLibrary.qml @@ -44,8 +44,9 @@ Item { Layout.minimumHeight: entityViewHeader.height height: splitHeight // Adjust width automatically for scrollbar, unless width has been adjusted manually - width: ((gridRoot.cellHeight * (gridRoot.count / 2)) > entityView.height) - ? optimalWidth + 21 : optimalWidth + // TODO: This causes settings save problems. Do we need it, or want to save width instead? +// width: ((gridRoot.cellHeight * (gridRoot.count / 2)) > entityView.height) +// ? optimalWidth + 21 : optimalWidth ButtonViewHeader { id: entityViewHeader diff --git a/editorlib/qml/SettingsDialog.qml b/editorlib/qml/SettingsDialog.qml index bd74a1f..716fd82 100644 --- a/editorlib/qml/SettingsDialog.qml +++ b/editorlib/qml/SettingsDialog.qml @@ -28,6 +28,7 @@ import QtQuick 2.5 import QtQuick.Window 2.2 import QtQuick.Layouts 1.2 +import Qt.labs.settings 1.0 Window { id: dialog @@ -39,6 +40,28 @@ Window { minimumHeight: settingsLayout.Layout.minimumHeight + buttonRow.Layout.minimumHeight minimumWidth: buttonRow.Layout.minimumWidth property bool previousAutoSaveEnabled: autoSaveTimer.running + property string currentLanguage + property int currentGridSize + + Settings { + // Use detailed category name, as plugin saves settings under QtCreator application + category: "Qt 3D SceneEditor General" + property alias language: dialog.currentLanguage + property alias gridSize: dialog.currentGridSize + // TODO: Save autosave flag? + // TODO: Add a default save folder and default texture/mesh/import folder? + //property alias defaultSaveFolder: dialog.currentSaveFolder + //property alias defaultImportFolder: dialog.currentImportFolder + // TODO: Anything else? + } + + onCurrentLanguageChanged: { + editorScene.language = currentLanguage + } + + onCurrentGridSizeChanged: { + editorScene.gridSize = currentGridSize + } ColumnLayout { id: settingsLayout @@ -82,7 +105,7 @@ Window { RowLayout { StyledRadioButton { id: englishButton - checked: (editorScene.language === "en") + checked: (currentLanguage === "en") } StyledLabel { id: englishLabel @@ -91,7 +114,7 @@ Window { } StyledRadioButton { id: finnishButton - checked: (editorScene.language === "fi") + checked: (currentLanguage === "fi") } StyledLabel { id: finnishLabel @@ -117,7 +140,7 @@ Window { to: 20 stepSize: 1 from: 1 - value: editorScene.gridSize + value: currentGridSize Layout.leftMargin: 8 contentItem: StyledTextInput { inputMethodHints: Qt.ImhFormattedNumbersOnly @@ -151,7 +174,7 @@ Window { text: qsTr("Apply") + editorScene.emptyString onButtonClicked: { setAutoSave() - editorScene.gridSize = gridSizeSpinBox.value + currentGridSize = gridSizeSpinBox.value setLanguage() } @@ -161,12 +184,12 @@ Window { text: qsTr("Cancel") + editorScene.emptyString onButtonClicked: { saveCheckBox.checked = previousAutoSaveEnabled - if (gridSizeSpinBox.value !== editorScene.gridSize) - gridSizeSpinBox.value = editorScene.gridSize - if (editorScene.language === "en") { + if (gridSizeSpinBox.value !== currentGridSize) + gridSizeSpinBox.value = currentGridSize + if (currentLanguage === "en") { englishButton.checked = true finnishButton.checked = false - } else if (editorScene.language === "fi") { + } else if (currentLanguage === "fi") { englishButton.checked = false finnishButton.checked = true } @@ -178,7 +201,7 @@ Window { text: qsTr("Ok") + editorScene.emptyString onButtonClicked: { setAutoSave() - editorScene.gridSize = gridSizeSpinBox.value + currentGridSize = gridSizeSpinBox.value setLanguage() dialog.close() } @@ -199,8 +222,13 @@ Window { function setLanguage() { if (englishButton.checked) - editorScene.language = "en" + currentLanguage = "en" else if (finnishButton.checked) - editorScene.language = "fi" + currentLanguage = "fi" + } + + Component.onCompleted: { + currentLanguage = editorScene.language + currentGridSize = editorScene.gridSize } } diff --git a/editorlib/qml/main.qml b/editorlib/qml/main.qml index 0a043af..9cb74d3 100644 --- a/editorlib/qml/main.qml +++ b/editorlib/qml/main.qml @@ -30,7 +30,9 @@ import QtQuick.Controls 1.4 import QtQuick.Layouts 1.2 import QtQuick.Dialogs 1.2 import QtQml.Models 2.2 +import QtQml 2.2 import Qt3D.Core 2.0 +import Qt.labs.settings 1.0 import com.theqtcompany.SceneEditor3D 1.0 ApplicationWindow { @@ -43,6 +45,19 @@ ApplicationWindow { minimumHeight: 400 minimumWidth: 640 + Settings { + // Save window placement, size, and view panel sizes + // Use detailed category name, as plugin saves settings under QtCreator application + category: "Qt 3D SceneEditor Window" + property alias x: mainwindow.x + property alias y: mainwindow.y + property alias width: mainwindow.width + property alias height: mainwindow.height + property alias leftPaneWidth: entityLibrary.width + property alias rightPaneWidth: propertyPane.width + property alias entityTreeHeight: entityTree.height + } + Item { // This item is used to map global mouse position id: applicationArea @@ -662,6 +677,9 @@ ApplicationWindow { } Component.onCompleted: { + Qt.application.organization = "The Qt Company" + Qt.application.domain = "qt.io" + Qt.application.name = "Qt 3D Scene Editor" // Redraw everything to get rid of artifacts showMaximized() show() diff --git a/standalone/main.cpp b/standalone/main.cpp index 8ac802b..d76fe64 100644 --- a/standalone/main.cpp +++ b/standalone/main.cpp @@ -33,6 +33,10 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + app.setOrganizationName("The Qt Company"); + app.setOrganizationDomain("qt.io"); + app.setApplicationName("Qt 3D Scene Editor"); + register3DSceneEditorQML(); QQmlApplicationEngine engine; |