Browse Source

various ux improvements

cl-refactor
arkpar 10 years ago
parent
commit
360301eb0a
  1. 4
      mix/qml/CodeEditor.qml
  2. 2
      mix/qml/CodeEditorView.qml
  3. 23
      mix/qml/MainContent.qml
  4. 5
      mix/qml/ProjectList.qml
  5. 4
      mix/qml/ProjectModel.qml
  6. 4
      mix/qml/WebCodeEditor.qml
  7. 3
      mix/qml/WebPreview.qml
  8. 2
      mix/qml/html/cm/solidity.js
  9. 41
      mix/qml/js/ProjectModel.js
  10. 38
      mix/qml/main.qml

4
mix/qml/CodeEditor.qml

@ -15,6 +15,10 @@ Item {
return codeEditor.text; return codeEditor.text;
} }
function setFocus() {
codeEditor.forceActiveFocus();
}
anchors.fill: parent anchors.fill: parent
id: contentView id: contentView
width: parent.width width: parent.width

2
mix/qml/CodeEditorView.qml

@ -68,6 +68,8 @@ Item {
visible: (index >= 0 && index < editorListModel.count && currentDocumentId === editorListModel.get(index).documentId) visible: (index >= 0 && index < editorListModel.count && currentDocumentId === editorListModel.get(index).documentId)
onVisibleChanged: { onVisibleChanged: {
loadIfNotLoaded() loadIfNotLoaded()
if (visible && item)
loader.item.setFocus();
} }
Component.onCompleted: { Component.onCompleted: {
loadIfNotLoaded() loadIfNotLoaded()

23
mix/qml/MainContent.qml

@ -20,6 +20,7 @@ Rectangle {
property alias rightViewVisible : rightView.visible property alias rightViewVisible : rightView.visible
property alias webViewVisible : webPreview.visible property alias webViewVisible : webPreview.visible
property bool webViewHorizontal : codeWebSplitter.orientation === Qt.Vertical
onWidthChanged: onWidthChanged:
{ {
@ -50,6 +51,10 @@ Rectangle {
webPreview.visible = !webPreview.visible; webPreview.visible = !webPreview.visible;
} }
function toggleWebPreviewOrientation() {
codeWebSplitter.orientation = (codeWebSplitter.orientation === Qt.Vertical ? Qt.Horizontal : Qt.Vertical);
}
function rightViewVisible() { function rightViewVisible() {
return rightView.visible; return rightView.visible;
} }
@ -59,6 +64,13 @@ Rectangle {
rightView: rightPaneTabs; rightView: rightPaneTabs;
} }
Settings {
id: mainLayoutSettings
property alias codeWebOrientation: codeWebSplitter.orientation
property alias webWidth: webPreview.width
property alias webHeight: webPreview.height
}
GridLayout GridLayout
{ {
anchors.fill: parent anchors.fill: parent
@ -130,6 +142,12 @@ Rectangle {
width: parent.width - projectList.width width: parent.width - projectList.width
height: parent.height height: parent.height
SplitView { SplitView {
handleDelegate: Rectangle {
width: 4
height: 4
color: "#cccccc"
}
id: codeWebSplitter
anchors.fill: parent anchors.fill: parent
orientation: Qt.Vertical orientation: Qt.Vertical
CodeEditorView { CodeEditorView {
@ -141,7 +159,10 @@ Rectangle {
WebPreview { WebPreview {
id: webPreview id: webPreview
height: parent.height * 0.4 height: parent.height * 0.4
Layout.fillWidth: true Layout.fillWidth: codeWebSplitter.orientation === Qt.Vertical
Layout.fillHeight: codeWebSplitter.orientation === Qt.Horizontal
Layout.minimumHeight: 200
Layout.minimumWidth: 200
} }
} }
} }

5
mix/qml/ProjectList.qml

@ -130,6 +130,11 @@ Item {
onProjectClosed: { onProjectClosed: {
projectList.currentIndex = -1; projectList.currentIndex = -1;
} }
onDocumentOpened: {
if (projectList.currentItem.documentId !== document.documentId)
projectList.currentIndex = projectModel.getDocumentIndex(document.documentId);
}
} }
} }

4
mix/qml/ProjectModel.qml

@ -26,6 +26,7 @@ Item {
property bool haveUnsavedChanges: false property bool haveUnsavedChanges: false
property string projectPath: "" property string projectPath: ""
property string projectTitle: "" property string projectTitle: ""
property string currentDocumentId: ""
property var listModel: projectListModel property var listModel: projectListModel
//interface //interface
@ -40,9 +41,12 @@ Item {
function newJsFile() { ProjectModelCode.newJsFile(); } function newJsFile() { ProjectModelCode.newJsFile(); }
//function newContract() { ProjectModelCode.newContract(); } //function newContract() { ProjectModelCode.newContract(); }
function openDocument(documentId) { ProjectModelCode.openDocument(documentId); } function openDocument(documentId) { ProjectModelCode.openDocument(documentId); }
function openNextDocument() { ProjectModelCode.openNextDocument(); }
function openPrevDocument() { ProjectModelCode.openPrevDocument(); }
function renameDocument(documentId, newName) { ProjectModelCode.renameDocument(documentId, newName); } function renameDocument(documentId, newName) { ProjectModelCode.renameDocument(documentId, newName); }
function removeDocument(documentId) { ProjectModelCode.removeDocument(documentId); } function removeDocument(documentId) { ProjectModelCode.removeDocument(documentId); }
function getDocument(documentId) { return ProjectModelCode.getDocument(documentId); } function getDocument(documentId) { return ProjectModelCode.getDocument(documentId); }
function getDocumentIndex(documentId) { return ProjectModelCode.getDocumentIndex(documentId); }
Connections { Connections {
target: appContext target: appContext

4
mix/qml/WebCodeEditor.qml

@ -18,6 +18,10 @@ Item {
editorBrowser.runJavaScript("setTextBase64(\"" + Qt.btoa(text) + "\")"); editorBrowser.runJavaScript("setTextBase64(\"" + Qt.btoa(text) + "\")");
editorBrowser.runJavaScript("setMode(\"" + mode + "\")"); editorBrowser.runJavaScript("setMode(\"" + mode + "\")");
} }
setFocus();
}
function setFocus() {
editorBrowser.forceActiveFocus(); editorBrowser.forceActiveFocus();
} }

3
mix/qml/WebPreview.qml

@ -109,7 +109,7 @@ Item {
id: httpServer id: httpServer
listen: true listen: true
accept: true accept: true
port: 8892 port: 8893
onClientConnected: { onClientConnected: {
console.log(_request.content); console.log(_request.content);
var response = clientModel.apiCall(_request.content); var response = clientModel.apiCall(_request.content);
@ -149,7 +149,6 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
id: webView id: webView
experimental.settings.localContentCanAccessFileUrls: true
experimental.settings.localContentCanAccessRemoteUrls: true experimental.settings.localContentCanAccessRemoteUrls: true
onJavaScriptConsoleMessage: { onJavaScriptConsoleMessage: {
console.log(sourceID + ":" + lineNumber + ":" + message); console.log(sourceID + ":" + lineNumber + ":" + message);

2
mix/qml/html/cm/solidity.js

@ -12,7 +12,7 @@
CodeMirror.defineMode("solidity", function(config) { CodeMirror.defineMode("solidity", function(config) {
var indentUnit = config.indentUnit; var indentUnit = config.indentUnit;
var keywords = { "delete":true, "break":true, "case":true, "const":true, "continue":true, "contract":true, "default":true, var keywords = { "delete":true, "break":true, "case":true, "constant":true, "continue":true, "contract":true, "default":true,
"do":true, "else":true, "is":true, "for":true, "function":true, "if":true, "import":true, "mapping":true, "new":true, "do":true, "else":true, "is":true, "for":true, "function":true, "if":true, "import":true, "mapping":true, "new":true,
"public":true, "private":true, "return":true, "returns":true, "struct":true, "switch":true, "var":true, "while":true, "public":true, "private":true, "return":true, "returns":true, "struct":true, "switch":true, "var":true, "while":true,
"int":true, "uint":true, "hash":true, "bool":true, "string":true, "string0":true, "text":true, "real":true, "int":true, "uint":true, "hash":true, "bool":true, "string":true, "string0":true, "text":true, "real":true,

41
mix/qml/js/ProjectModel.js

@ -104,7 +104,7 @@ function addFile(fileName) {
return docData.documentId; return docData.documentId;
} }
function findDocument(documentId) function getDocumentIndex(documentId)
{ {
for (var i = 0; i < projectListModel.count; i++) for (var i = 0; i < projectListModel.count; i++)
if (projectListModel.get(i).documentId === documentId) if (projectListModel.get(i).documentId === documentId)
@ -114,7 +114,38 @@ function findDocument(documentId)
} }
function openDocument(documentId) { function openDocument(documentId) {
documentOpened(projectListModel.get(findDocument(documentId))); if (documentId !== currentDocumentId) {
documentOpened(projectListModel.get(getDocumentIndex(documentId)));
currentDocumentId = documentId;
}
}
function openNextDocument() {
var docIndex = getDocumentIndex(currentDocumentId);
var nextDocId = "";
while (nextDocId === "") {
docIndex++;
if (docIndex >= projectListModel.count)
docIndex = 0;
var document = projectListModel.get(docIndex);
if (document.isText)
nextDocId = document.documentId;
}
openDocument(nextDocId);
}
function openPrevDocument() {
var docIndex = getDocumentIndex(currentDocumentId);
var prevDocId = "";
while (prevDocId === "") {
docIndex--;
if (docIndex < 0)
docIndex = projectListModel.count - 1;
var document = projectListModel.get(docIndex);
if (document.isText)
prevDocId = document.documentId;
}
openDocument(prevDocId);
} }
function doCloseProject() { function doCloseProject() {
@ -160,7 +191,7 @@ function doAddExistingFiles(files) {
} }
function renameDocument(documentId, newName) { function renameDocument(documentId, newName) {
var i = findDocument(documentId); var i = getDocumentIndex(documentId);
var document = projectListModel.get(i); var document = projectListModel.get(i);
if (!document.isContract) { if (!document.isContract) {
var sourcePath = document.path; var sourcePath = document.path;
@ -174,12 +205,12 @@ function renameDocument(documentId, newName) {
} }
function getDocument(documentId) { function getDocument(documentId) {
var i = findDocument(documentId); var i = getDocumentIndex(documentId);
return projectListModel.get(i); return projectListModel.get(i);
} }
function removeDocument(documentId) { function removeDocument(documentId) {
var i = findDocument(documentId); var i = getDocumentIndex(documentId);
var document = projectListModel.get(i); var document = projectListModel.get(i);
if (!document.isContract) { if (!document.isContract) {
projectListModel.remove(i); projectListModel.remove(i);

38
mix/qml/main.qml

@ -39,8 +39,12 @@ ApplicationWindow {
} }
Menu { Menu {
title: qsTr("Windows") title: qsTr("Windows")
MenuItem { action: showHideRightPanel } MenuItem { action: openNextDocumentAction }
MenuItem { action: toggleWebPreview } MenuItem { action: openPrevDocumentAction }
MenuSeparator {}
MenuItem { action: showHideRightPanelAction }
MenuItem { action: toggleWebPreviewAction }
MenuItem { action: toggleWebPreviewOrientationAction }
} }
} }
@ -90,7 +94,7 @@ ApplicationWindow {
} }
Action { Action {
id: toggleWebPreview id: toggleWebPreviewAction
text: "Show Web View" text: "Show Web View"
shortcut: "F2" shortcut: "F2"
checkable: true checkable: true
@ -99,7 +103,16 @@ ApplicationWindow {
} }
Action { Action {
id: showHideRightPanel id: toggleWebPreviewOrientationAction
text: "Horizontal Web View"
shortcut: ""
checkable: true
checked: mainContent.webViewHorizontal
onTriggered: mainContent.toggleWebPreviewOrientation();
}
Action {
id: showHideRightPanelAction
text: "Show Right View" text: "Show Right View"
shortcut: "F7" shortcut: "F7"
checkable: true checkable: true
@ -170,4 +183,21 @@ ApplicationWindow {
enabled: !projectModel.isEmpty enabled: !projectModel.isEmpty
onTriggered: projectModel.closeProject(); onTriggered: projectModel.closeProject();
} }
Action {
id: openNextDocumentAction
text: qsTr("Next Document")
shortcut: "Ctrl+Tab"
enabled: !projectModel.isEmpty
onTriggered: projectModel.openNextDocument();
}
Action {
id: openPrevDocumentAction
text: qsTr("Previous Document")
shortcut: "Ctrl+Shift+Tab"
enabled: !projectModel.isEmpty
onTriggered: projectModel.openPrevDocument();
}
} }

Loading…
Cancel
Save