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;
}
function setFocus() {
codeEditor.forceActiveFocus();
}
anchors.fill: parent
id: contentView
width: parent.width

2
mix/qml/CodeEditorView.qml

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

23
mix/qml/MainContent.qml

@ -20,6 +20,7 @@ Rectangle {
property alias rightViewVisible : rightView.visible
property alias webViewVisible : webPreview.visible
property bool webViewHorizontal : codeWebSplitter.orientation === Qt.Vertical
onWidthChanged:
{
@ -50,6 +51,10 @@ Rectangle {
webPreview.visible = !webPreview.visible;
}
function toggleWebPreviewOrientation() {
codeWebSplitter.orientation = (codeWebSplitter.orientation === Qt.Vertical ? Qt.Horizontal : Qt.Vertical);
}
function rightViewVisible() {
return rightView.visible;
}
@ -59,6 +64,13 @@ Rectangle {
rightView: rightPaneTabs;
}
Settings {
id: mainLayoutSettings
property alias codeWebOrientation: codeWebSplitter.orientation
property alias webWidth: webPreview.width
property alias webHeight: webPreview.height
}
GridLayout
{
anchors.fill: parent
@ -130,6 +142,12 @@ Rectangle {
width: parent.width - projectList.width
height: parent.height
SplitView {
handleDelegate: Rectangle {
width: 4
height: 4
color: "#cccccc"
}
id: codeWebSplitter
anchors.fill: parent
orientation: Qt.Vertical
CodeEditorView {
@ -141,7 +159,10 @@ Rectangle {
WebPreview {
id: webPreview
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: {
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 string projectPath: ""
property string projectTitle: ""
property string currentDocumentId: ""
property var listModel: projectListModel
//interface
@ -40,9 +41,12 @@ Item {
function newJsFile() { ProjectModelCode.newJsFile(); }
//function newContract() { ProjectModelCode.newContract(); }
function openDocument(documentId) { ProjectModelCode.openDocument(documentId); }
function openNextDocument() { ProjectModelCode.openNextDocument(); }
function openPrevDocument() { ProjectModelCode.openPrevDocument(); }
function renameDocument(documentId, newName) { ProjectModelCode.renameDocument(documentId, newName); }
function removeDocument(documentId) { ProjectModelCode.removeDocument(documentId); }
function getDocument(documentId) { return ProjectModelCode.getDocument(documentId); }
function getDocumentIndex(documentId) { return ProjectModelCode.getDocumentIndex(documentId); }
Connections {
target: appContext

4
mix/qml/WebCodeEditor.qml

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

3
mix/qml/WebPreview.qml

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

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

@ -12,7 +12,7 @@
CodeMirror.defineMode("solidity", function(config) {
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,
"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,

41
mix/qml/js/ProjectModel.js

@ -104,7 +104,7 @@ function addFile(fileName) {
return docData.documentId;
}
function findDocument(documentId)
function getDocumentIndex(documentId)
{
for (var i = 0; i < projectListModel.count; i++)
if (projectListModel.get(i).documentId === documentId)
@ -114,7 +114,38 @@ function findDocument(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() {
@ -160,7 +191,7 @@ function doAddExistingFiles(files) {
}
function renameDocument(documentId, newName) {
var i = findDocument(documentId);
var i = getDocumentIndex(documentId);
var document = projectListModel.get(i);
if (!document.isContract) {
var sourcePath = document.path;
@ -174,12 +205,12 @@ function renameDocument(documentId, newName) {
}
function getDocument(documentId) {
var i = findDocument(documentId);
var i = getDocumentIndex(documentId);
return projectListModel.get(i);
}
function removeDocument(documentId) {
var i = findDocument(documentId);
var i = getDocumentIndex(documentId);
var document = projectListModel.get(i);
if (!document.isContract) {
projectListModel.remove(i);

38
mix/qml/main.qml

@ -39,8 +39,12 @@ ApplicationWindow {
}
Menu {
title: qsTr("Windows")
MenuItem { action: showHideRightPanel }
MenuItem { action: toggleWebPreview }
MenuItem { action: openNextDocumentAction }
MenuItem { action: openPrevDocumentAction }
MenuSeparator {}
MenuItem { action: showHideRightPanelAction }
MenuItem { action: toggleWebPreviewAction }
MenuItem { action: toggleWebPreviewOrientationAction }
}
}
@ -90,7 +94,7 @@ ApplicationWindow {
}
Action {
id: toggleWebPreview
id: toggleWebPreviewAction
text: "Show Web View"
shortcut: "F2"
checkable: true
@ -99,7 +103,16 @@ ApplicationWindow {
}
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"
shortcut: "F7"
checkable: true
@ -170,4 +183,21 @@ ApplicationWindow {
enabled: !projectModel.isEmpty
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