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)
{
CompiledContract* contract = contractByDocumentId(_documentId);
if (contract != nullptr && contract->m_sourceHash == qHash(_code))
{
emit compilationComplete();
return;
}
{
Guard pl(x_pendingContracts);
m_pendingContracts[_documentId] = _code;
@ -256,7 +249,6 @@ void CodeModel::runCompilationJob(int _jobId)
{
if (_jobId != m_backgroundJobId)
return; //obsolete job
ContractMap result;
solidity::CompilerStack cs(true);
try
@ -309,7 +301,7 @@ void CodeModel::runCompilationJob(int _jobId)
CompiledContract* contract = nullptr;
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
compilationError(message);
compilationError(message, QString::fromStdString(*location->sourceName));
}
m_compiling = false;
emit stateChanged();

2
mix/CodeModel.h

@ -160,7 +160,7 @@ signals:
/// Emitted on compilation complete
void compilationComplete();
/// Emitted on compilation error
void compilationError(QString _error);
void compilationError(QString _error, QString _sourceName);
/// Internal signal used to transfer compilation job to background thread
void scheduleCompilationJob(int _jobId);
/// 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
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 {
id: codeEditorView
property string currentDocumentId: ""
property string sourceInError
property int openDocCount: 0
signal documentEdit(string documentId)
signal breakpointsChanged(string documentId)
signal isCleanChanged(var isClean, string documentId)
signal loadComplete
function getDocumentText(documentId) {
for (var i = 0; i < openDocCount; i++) {
if (editorListModel.get(i).documentId === documentId) {
@ -50,7 +50,6 @@ Item {
doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount))
}
openDocCount++;
}
function doLoadDocument(editor, document) {
@ -71,6 +70,7 @@ Item {
editor.onIsCleanChanged.connect(function() {
isCleanChanged(editor.isClean, document.documentId);
});
editor.sourceName = document.documentId;
}
function getEditor(documentId) {
@ -135,8 +135,36 @@ Item {
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;
Connections {
target: codeModel
onCompilationError: {
sourceInError = _sourceName;
}
onCompilationComplete: {
sourceInError = "";
}
}
Connections {
target: projectModel
onDocumentOpened: {

125
mix/qml/NewProjectDialog.qml

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

76
mix/qml/StatusPane.qml

@ -112,8 +112,17 @@ Rectangle {
}
Connections {
target: codeModel
onCompilationComplete: updateStatus();
onCompilationError: updateStatus(_error);
onCompilationComplete:
{
goToLine.visible = false;
updateStatus();
}
onCompilationError:
{
goToLine.visible = true
updateStatus(_error);
}
}
color: "transparent"
@ -176,24 +185,57 @@ Rectangle {
else
width = undefined
}
}
Button
{
anchors.fill: parent
id: toolTip
action: toolTipInfo
text: ""
style:
ButtonStyle {
background:Rectangle {
color: "transparent"
Button
{
anchors.fill: parent
id: toolTip
action: toolTipInfo
text: ""
z: 3;
style:
ButtonStyle {
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
onClicked: {
logsContainer.toggle();
Rectangle
{
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);
logsContainer.parent = top;
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 {

12
mix/qml/WebCodeEditor.qml

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

5
mix/qml/html/codeeditor.js

@ -189,4 +189,9 @@ compilationComplete = function()
compilationCompleteBool = true;
}
goToCompilationError = function()
{
editor.setCursor(annotation.line, annotation.column)
}
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/searchicon.png</file>
<file>qml/img/stop_button2x.png</file>
<file>qml/img/signerroricon32.png</file>
</qresource>
</RCC>

Loading…
Cancel
Save