From 88775de5f1fb0cb95399e5d6e641495c5aa5f8c6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 16 Mar 2015 12:24:45 +0100 Subject: [PATCH] small changes --- mix/qml/CodeEditorView.qml | 18 +++++++++++++++++- mix/qml/ProjectModel.qml | 7 +++++-- mix/qml/TransactionLog.qml | 2 ++ mix/qml/html/codeeditor.js | 1 - mix/qml/js/ProjectModel.js | 11 +++++++++-- mix/qml/main.qml | 4 ++-- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/mix/qml/CodeEditorView.qml b/mix/qml/CodeEditorView.qml index 431f6c046..a490fbcb2 100644 --- a/mix/qml/CodeEditorView.qml +++ b/mix/qml/CodeEditorView.qml @@ -117,6 +117,15 @@ Item { { var doc = editorListModel.get(i); fileIo.writeFile(doc.path, editors.itemAt(i).item.getText()); + } + } + + onProjectSaved: { + if (projectModel.appIsClosing) + return; + for (var i = 0; i < editorListModel.count; i++) + { + var doc = editorListModel.get(i); resetEditStatus(doc.documentId); } } @@ -128,6 +137,14 @@ Item { currentDocumentId = ""; } + onDocumentSaved: { + resetEditStatus(documentId); + } + + onContractSaved: { + resetEditStatus(documentId); + } + onDocumentSaving: { for (var i = 0; i < editorListModel.count; i++) { @@ -135,7 +152,6 @@ Item { if (doc.path === document) { fileIo.writeFile(document, editors.itemAt(i).item.getText()); - resetEditStatus(doc.documentId); break; } } diff --git a/mix/qml/ProjectModel.qml b/mix/qml/ProjectModel.qml index 73c5901fe..e5075e608 100644 --- a/mix/qml/ProjectModel.qml +++ b/mix/qml/ProjectModel.qml @@ -32,6 +32,7 @@ Item { property bool isEmpty: (projectPath === "") readonly property string projectFileName: ".mix" + property bool appIsClosing: false property string projectPath: "" property string projectTitle: "" property string currentDocumentId: "" @@ -46,7 +47,7 @@ Item { function saveAll() { ProjectModelCode.saveAll(); } function saveCurrentDocument() { ProjectModelCode.saveCurrentDocument(); } function createProject() { ProjectModelCode.createProject(); } - function closeProject() { ProjectModelCode.closeProject(); } + function closeProject(callBack) { ProjectModelCode.closeProject(callBack); } function saveProject() { ProjectModelCode.saveProject(); } function loadProject(path) { ProjectModelCode.loadProject(path); } function newHtmlFile() { ProjectModelCode.newHtmlFile(); } @@ -84,7 +85,6 @@ Item { if (!isClean) unsavedFiles.push(documentId); isCleanChanged(isClean, documentId); - console.log(JSON.stringify(unsavedFiles)); } } @@ -116,13 +116,16 @@ Item { text: qsTr("Some files require to be saved. Do you want to save changes?"); standardButtons: StandardButton.Yes | StandardButton.No | StandardButton.Cancel icon: StandardIcon.Question + property var callBack; onYes: { projectModel.saveAll(); ProjectModelCode.doCloseProject(); + callBack(); } onRejected: {} onNo: { ProjectModelCode.doCloseProject(); + callBack(); } } diff --git a/mix/qml/TransactionLog.qml b/mix/qml/TransactionLog.qml index 7d30356e1..86d48a829 100644 --- a/mix/qml/TransactionLog.qml +++ b/mix/qml/TransactionLog.qml @@ -44,6 +44,8 @@ Item { target: projectModel onProjectSaved: { + if (projectModel.appIsClosing) + return; if (compilationStatus.compilationComplete && codeModel.hasContract && !clientModel.running) projectModel.stateListModel.debugDefaultState(); } diff --git a/mix/qml/html/codeeditor.js b/mix/qml/html/codeeditor.js index ff16ae34b..30c70867b 100644 --- a/mix/qml/html/codeeditor.js +++ b/mix/qml/html/codeeditor.js @@ -113,7 +113,6 @@ highlightExecution = function(start, end) { var changeId; changeGeneration = function() { - console.log(""); changeId = editor.changeGeneration(true); } diff --git a/mix/qml/js/ProjectModel.js b/mix/qml/js/ProjectModel.js index 75b6a6f75..c591b9522 100644 --- a/mix/qml/js/ProjectModel.js +++ b/mix/qml/js/ProjectModel.js @@ -31,7 +31,8 @@ function saveCurrentDocument() var doc = projectListModel.get(getDocumentIndex(currentDocumentId)); if (doc.isContract) contractSaved(currentDocumentId); - documentSaved(currentDocumentId); + else + documentSaved(currentDocumentId); } function saveAll() { @@ -42,12 +43,18 @@ function createProject() { newProjectDialog.open(); } -function closeProject() { +function closeProject(callBack) { if (!isEmpty) { if (unsavedFiles.length > 0) + { + saveMessageDialog.callBack = callBack; saveMessageDialog.open(); + } else + { doCloseProject(); + callBack(); + } } } diff --git a/mix/qml/main.qml b/mix/qml/main.qml index db173bf85..fdb94c78b 100644 --- a/mix/qml/main.qml +++ b/mix/qml/main.qml @@ -95,9 +95,9 @@ ApplicationWindow { shortcut: "Ctrl+Q" onTriggered: { + projectModel.appIsClosing = true; if (projectModel.projectPath !== "") - projectModel.closeProject() - Qt.quit(); + projectModel.closeProject(function() { Qt.quit(); }) } }