Browse Source

small changes

cl-refactor
yann300 10 years ago
parent
commit
88775de5f1
  1. 18
      mix/qml/CodeEditorView.qml
  2. 7
      mix/qml/ProjectModel.qml
  3. 2
      mix/qml/TransactionLog.qml
  4. 1
      mix/qml/html/codeeditor.js
  5. 11
      mix/qml/js/ProjectModel.js
  6. 4
      mix/qml/main.qml

18
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;
}
}

7
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();
}
}

2
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();
}

1
mix/qml/html/codeeditor.js

@ -113,7 +113,6 @@ highlightExecution = function(start, end) {
var changeId;
changeGeneration = function()
{
console.log("");
changeId = editor.changeGeneration(true);
}

11
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();
}
}
}

4
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(); })
}
}

Loading…
Cancel
Save