Browse Source

Merge pull request #1549 from yann300/ui_macos

MACOS bug fixes
cl-refactor
Arkadiy Paronyan 10 years ago
parent
commit
31e43503cc
  1. 10
      mix/CodeModel.cpp
  2. 2
      mix/CodeModel.h
  3. 10
      mix/qml/Application.qml
  4. 32
      mix/qml/CodeEditorView.qml
  5. 125
      mix/qml/NewProjectDialog.qml
  6. 76
      mix/qml/StatusPane.qml
  7. 12
      mix/qml/WebCodeEditor.qml
  8. 5
      mix/qml/html/codeeditor.js
  9. BIN
      mix/qml/img/signerroricon32.png
  10. 1
      mix/res.qrc

10
mix/CodeModel.cpp

@ -193,13 +193,6 @@ void CodeModel::reset(QVariantMap const& _documents)
void CodeModel::registerCodeChange(QString const& _documentId, QString const& _code) void CodeModel::registerCodeChange(QString const& _documentId, QString const& _code)
{ {
CompiledContract* contract = contractByDocumentId(_documentId);
if (contract != nullptr && contract->m_sourceHash == qHash(_code))
{
emit compilationComplete();
return;
}
{ {
Guard pl(x_pendingContracts); Guard pl(x_pendingContracts);
m_pendingContracts[_documentId] = _code; m_pendingContracts[_documentId] = _code;
@ -256,7 +249,6 @@ void CodeModel::runCompilationJob(int _jobId)
{ {
if (_jobId != m_backgroundJobId) if (_jobId != m_backgroundJobId)
return; //obsolete job return; //obsolete job
ContractMap result; ContractMap result;
solidity::CompilerStack cs(true); solidity::CompilerStack cs(true);
try try
@ -309,7 +301,7 @@ void CodeModel::runCompilationJob(int _jobId)
CompiledContract* contract = nullptr; CompiledContract* contract = nullptr;
if (location && location->sourceName.get() && (contract = contractByDocumentId(QString::fromStdString(*location->sourceName)))) if (location && location->sourceName.get() && (contract = contractByDocumentId(QString::fromStdString(*location->sourceName))))
message = message.replace(QString::fromStdString(*location->sourceName), contract->contract()->name()); //substitute the location to match our contract names message = message.replace(QString::fromStdString(*location->sourceName), contract->contract()->name()); //substitute the location to match our contract names
compilationError(message); compilationError(message, QString::fromStdString(*location->sourceName));
} }
m_compiling = false; m_compiling = false;
emit stateChanged(); emit stateChanged();

2
mix/CodeModel.h

@ -160,7 +160,7 @@ signals:
/// Emitted on compilation complete /// Emitted on compilation complete
void compilationComplete(); void compilationComplete();
/// Emitted on compilation error /// Emitted on compilation error
void compilationError(QString _error); void compilationError(QString _error, QString _sourceName);
/// Internal signal used to transfer compilation job to background thread /// Internal signal used to transfer compilation job to background thread
void scheduleCompilationJob(int _jobId); void scheduleCompilationJob(int _jobId);
/// Emitted if there are any changes in the code model /// Emitted if there are any changes in the code model

10
mix/qml/Application.qml

@ -398,4 +398,14 @@ ApplicationWindow {
enabled: !projectModel.isEmpty && codeModel.hasContract enabled: !projectModel.isEmpty && codeModel.hasContract
onTriggered: projectModel.deployProject(); onTriggered: projectModel.deployProject();
} }
Action {
id: goToCompilationError
text: qsTr("Go to compilation error")
shortcut: "F4"
onTriggered:
{
mainContent.codeEditor.goToCompilationError();
}
}
} }

32
mix/qml/CodeEditorView.qml

@ -7,13 +7,13 @@ import QtQuick.Dialogs 1.1
Item { Item {
id: codeEditorView id: codeEditorView
property string currentDocumentId: "" property string currentDocumentId: ""
property string sourceInError
property int openDocCount: 0 property int openDocCount: 0
signal documentEdit(string documentId) signal documentEdit(string documentId)
signal breakpointsChanged(string documentId) signal breakpointsChanged(string documentId)
signal isCleanChanged(var isClean, string documentId) signal isCleanChanged(var isClean, string documentId)
signal loadComplete signal loadComplete
function getDocumentText(documentId) { function getDocumentText(documentId) {
for (var i = 0; i < openDocCount; i++) { for (var i = 0; i < openDocCount; i++) {
if (editorListModel.get(i).documentId === documentId) { if (editorListModel.get(i).documentId === documentId) {
@ -50,7 +50,6 @@ Item {
doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount)) doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount))
} }
openDocCount++; openDocCount++;
} }
function doLoadDocument(editor, document) { function doLoadDocument(editor, document) {
@ -71,6 +70,7 @@ Item {
editor.onIsCleanChanged.connect(function() { editor.onIsCleanChanged.connect(function() {
isCleanChanged(editor.isClean, document.documentId); isCleanChanged(editor.isClean, document.documentId);
}); });
editor.sourceName = document.documentId;
} }
function getEditor(documentId) { function getEditor(documentId) {
@ -135,8 +135,36 @@ Item {
editor.changeGeneration(); editor.changeGeneration();
} }
function goToCompilationError() {
if (sourceInError === "")
return;
if (currentDocumentId !== sourceInError)
projectModel.openDocument(sourceInError);
for (var i = 0; i < openDocCount; i++)
{
var doc = editorListModel.get(i);
if (doc.isContract && doc.documentId === sourceInError)
{
var editor = editors.itemAt(i).item;
if (editor)
editor.goToCompilationError();
break;
}
}
}
Component.onCompleted: projectModel.codeEditor = codeEditorView; Component.onCompleted: projectModel.codeEditor = codeEditorView;
Connections {
target: codeModel
onCompilationError: {
sourceInError = _sourceName;
}
onCompilationComplete: {
sourceInError = "";
}
}
Connections { Connections {
target: projectModel target: projectModel
onDocumentOpened: { onDocumentOpened: {

125
mix/qml/NewProjectDialog.qml

@ -5,96 +5,103 @@ import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Dialog { Item
id: newProjectWin {
modality: Qt.ApplicationModal
width: 640
height: 120
visible: false
property alias projectTitle: titleField.text property alias projectTitle: titleField.text
readonly property string projectPath: "file://" + pathField.text readonly property string projectPath: "file://" + pathField.text
property alias pathFieldText: pathField.text property alias pathFieldText: pathField.text
signal accepted signal accepted
function open() { function open() {
newProjectWin.setX((Screen.width - width) / 2); newProjectWin.visible = true;
newProjectWin.setY((Screen.height - height) / 2);
visible = true;
titleField.focus = true; titleField.focus = true;
} }
function close() { function close() {
visible = false; newProjectWin.visible = false;
} }
function acceptAndClose() { function acceptAndClose() {
close(); close();
accepted(); accepted();
} }
contentItem: Rectangle {
anchors.fill: parent Dialog {
GridLayout id: newProjectWin
{ modality: Qt.ApplicationModal
id: dialogContent
columns: 2 width: 640
height: 120
visible: false
contentItem: Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 GridLayout
rowSpacing: 10 {
columnSpacing: 10 id: dialogContent
columns: 2
anchors.fill: parent
anchors.margins: 10
rowSpacing: 10
columnSpacing: 10
Label { Label {
text: qsTr("Title") text: qsTr("Title")
}
TextField {
id: titleField
focus: true
Layout.fillWidth: true
Keys.onReturnPressed: {
if (okButton.enabled)
acceptAndClose();
} }
}
Label {
text: qsTr("Path")
}
RowLayout {
TextField { TextField {
id: pathField id: titleField
focus: true
Layout.fillWidth: true Layout.fillWidth: true
Keys.onReturnPressed: { Keys.onReturnPressed: {
if (okButton.enabled) if (okButton.enabled)
acceptAndClose(); acceptAndClose();
} }
} }
Button {
text: qsTr("Browse") Label {
onClicked: createProjectFileDialog.open() text: qsTr("Path")
}
RowLayout {
TextField {
id: pathField
Layout.fillWidth: true
Keys.onReturnPressed: {
if (okButton.enabled)
acceptAndClose();
}
}
Button {
text: qsTr("Browse")
onClicked:
{
newProjectWin.close()
createProjectFileDialog.open()
}
}
} }
}
RowLayout RowLayout
{ {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right; anchors.right: parent.right;
Button { Button {
id: okButton; id: okButton;
enabled: titleField.text != "" && pathField.text != "" enabled: titleField.text != "" && pathField.text != ""
text: qsTr("OK"); text: qsTr("OK");
onClicked: { onClicked: {
acceptAndClose(); acceptAndClose();
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
} }
}
Button {
text: qsTr("Cancel");
onClicked: close();
} }
} }
} }
Component.onCompleted: pathField.text = fileIo.homePath
} }
FileDialog { FileDialog {
@ -109,7 +116,7 @@ Dialog {
if (Qt.platform.os == "windows" && u.indexOf("/") == 0) if (Qt.platform.os == "windows" && u.indexOf("/") == 0)
u = u.substring(1, u.length); u = u.substring(1, u.length);
pathField.text = u; pathField.text = u;
newProjectWin.open()
} }
} }
Component.onCompleted: pathField.text = fileIo.homePath
} }

76
mix/qml/StatusPane.qml

@ -112,8 +112,17 @@ Rectangle {
} }
Connections { Connections {
target: codeModel target: codeModel
onCompilationComplete: updateStatus(); onCompilationComplete:
onCompilationError: updateStatus(_error); {
goToLine.visible = false;
updateStatus();
}
onCompilationError:
{
goToLine.visible = true
updateStatus(_error);
}
} }
color: "transparent" color: "transparent"
@ -176,24 +185,57 @@ Rectangle {
else else
width = undefined width = undefined
} }
}
Button Button
{ {
anchors.fill: parent anchors.fill: parent
id: toolTip id: toolTip
action: toolTipInfo action: toolTipInfo
text: "" text: ""
style: z: 3;
ButtonStyle { style:
background:Rectangle { ButtonStyle {
color: "transparent" background:Rectangle {
color: "transparent"
}
}
MouseArea {
anchors.fill: parent
onClicked: {
logsContainer.toggle();
}
} }
} }
MouseArea { }
Rectangle
{
visible: false
color: "transparent"
width: 40
height: parent.height
anchors.top: parent.top
anchors.left: status.right
anchors.leftMargin: 15
id: goToLine
RowLayout
{
anchors.fill: parent anchors.fill: parent
onClicked: { Rectangle
logsContainer.toggle(); {
color: "transparent"
anchors.fill: parent
Button
{
z: 4
anchors.right: parent.right
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
id: goToLineBtn
text: ""
iconSource: "qrc:/qml/img/signerroricon32.png"
action: goToCompilationError
}
} }
} }
} }
@ -235,6 +277,8 @@ Rectangle {
var coordinates = logsContainer.mapToItem(top, 0, 0); var coordinates = logsContainer.mapToItem(top, 0, 0);
logsContainer.parent = top; logsContainer.parent = top;
logsContainer.x = status.x + statusContainer.x - logStyle.generic.layout.dateWidth - logStyle.generic.layout.typeWidth + 70 logsContainer.x = status.x + statusContainer.x - logStyle.generic.layout.dateWidth - logStyle.generic.layout.typeWidth + 70
if (Qt.platform.os === "osx")
logsContainer.y = statusContainer.y;
} }
LogsPaneStyle { LogsPaneStyle {

12
mix/qml/WebCodeEditor.qml

@ -16,7 +16,8 @@ Item {
property string currentMode: "" property string currentMode: ""
property bool initialized: false property bool initialized: false
property bool unloaded: false property bool unloaded: false
property var currentBreakpoints: []; property var currentBreakpoints: []
property string sourceName
function setText(text, mode) { function setText(text, mode) {
currentText = text; currentText = text;
@ -69,6 +70,11 @@ Item {
editorBrowser.runJavaScript("changeGeneration()", function(result) {}); editorBrowser.runJavaScript("changeGeneration()", function(result) {});
} }
function goToCompilationError() {
if (initialized && editorBrowser)
editorBrowser.runJavaScript("goToCompilationError()", function(result) {});
}
Clipboard Clipboard
{ {
id: clipboard id: clipboard
@ -121,8 +127,10 @@ Item {
editorBrowser.runJavaScript("compilationComplete()", function(result) { }); editorBrowser.runJavaScript("compilationComplete()", function(result) { });
} }
function compilationError(error) function compilationError(error, sourceName)
{ {
if (sourceName !== parent.sourceName)
return;
if (!editorBrowser || !error) if (!editorBrowser || !error)
return; return;
var errorInfo = ErrorLocationFormater.extractErrorInfo(error, false); var errorInfo = ErrorLocationFormater.extractErrorInfo(error, false);

5
mix/qml/html/codeeditor.js

@ -189,4 +189,9 @@ compilationComplete = function()
compilationCompleteBool = true; compilationCompleteBool = true;
} }
goToCompilationError = function()
{
editor.setCursor(annotation.line, annotation.column)
}
editor.setOption("extraKeys", extraKeys); editor.setOption("extraKeys", extraKeys);

BIN
mix/qml/img/signerroricon32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

1
mix/res.qrc

@ -63,5 +63,6 @@
<file>qml/img/copyiconactive.png</file> <file>qml/img/copyiconactive.png</file>
<file>qml/img/searchicon.png</file> <file>qml/img/searchicon.png</file>
<file>qml/img/stop_button2x.png</file> <file>qml/img/stop_button2x.png</file>
<file>qml/img/signerroricon32.png</file>
</qresource> </qresource>
</RCC> </RCC>

Loading…
Cancel
Save