Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
bc90008f0e
  1. 4
      mix/InverseMouseArea.cpp
  2. 8
      mix/InverseMouseArea.h
  3. 1
      mix/qml/Application.qml
  4. 52
      mix/qml/CodeEditorView.qml
  5. 2
      mix/qml/ProjectModel.qml
  6. 169
      mix/qml/StateDialog.qml
  7. 4
      mix/qml/StateListModel.qml
  8. 11
      mix/qml/StatesComboBox.qml
  9. 31
      mix/qml/StatusPane.qml
  10. 1
      mix/qml/TransactionDialog.qml
  11. 10
      mix/qml/TransactionLog.qml
  12. 2
      mix/qml/WebCodeEditor.qml
  13. 3
      mix/qml/js/ProjectModel.js
  14. 8
      mix/test/qml/TestMain.qml
  15. 1
      mix/test/qml/js/TestDebugger.js

4
mix/InverseMouseArea.cpp

@ -39,11 +39,11 @@ bool InverseMouseArea::eventFilter(QObject* _obj, QEvent* _ev)
{
Q_UNUSED(_obj);
if (this->m_active && _ev->type() == QEvent::MouseButtonPress && !this->contains(static_cast<QMouseEvent*>(_ev)->pos()))
emit clickedOutside();
emit clickedOutside(QPointF(static_cast<QMouseEvent*>(_ev)->pos()));
return false;
}
bool InverseMouseArea::contains(const QPoint& _point) const
bool InverseMouseArea::contains(const QPointF& _point) const
{
if (!this->m_active)
return false;

8
mix/InverseMouseArea.h

@ -41,15 +41,15 @@ public:
void setActive(bool _v);
protected:
void itemChange(ItemChange _c, const ItemChangeData& _v);
bool eventFilter(QObject* _obj, QEvent *_ev);
bool contains(const QPoint& _point) const;
void itemChange(ItemChange _c, const ItemChangeData& _v) override;
bool eventFilter(QObject* _obj, QEvent *_ev) override;
bool contains(const QPointF& _point) const override;
private:
bool m_active;
signals:
void clickedOutside();
void clickedOutside(QPointF _point);
};
}

1
mix/qml/Application.qml

@ -29,6 +29,7 @@ ApplicationWindow {
property alias clientModel: clientModel;
property alias projectModel: projectModel;
property alias appService: appService;
property bool trackLastProject: true;
ApplicationService {
id: appService

52
mix/qml/CodeEditorView.qml

@ -46,31 +46,36 @@ Item {
else
{
editorListModel.set(openDocCount, document);
editors.itemAt(openDocCount).visible = true;
doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount))
doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount), false)
loadComplete();
}
openDocCount++;
}
function doLoadDocument(editor, document) {
function doLoadDocument(editor, document, create) {
var data = fileIo.readFile(document.path);
editor.onLoadComplete.connect(function() {
loadComplete();
});
editor.onEditorTextChanged.connect(function() {
documentEdit(document.documentId);
if (document.isContract)
codeModel.registerCodeChange(document.documentId, editor.getText());
});
editor.onBreakpointsChanged.connect(function() {
if (document.isContract)
breakpointsChanged(document.documentId);
});
editor.setText(data, document.syntaxMode);
editor.onIsCleanChanged.connect(function() {
isCleanChanged(editor.isClean, document.documentId);
});
if (create)
{
editor.onLoadComplete.connect(function() {
codeEditorView.loadComplete();
});
editor.onEditorTextChanged.connect(function() {
documentEdit(editor.document.documentId);
if (editor.document.isContract)
codeModel.registerCodeChange(editor.document.documentId, editor.getText());
});
editor.onBreakpointsChanged.connect(function() {
if (editor.document.isContract)
breakpointsChanged(editor.document.documentId);
});
editor.onIsCleanChanged.connect(function() {
isCleanChanged(editor.isClean, editor.document.documentId);
});
}
editor.document = document;
editor.sourceName = document.documentId;
editor.setText(data, document.syntaxMode);
editor.changeGeneration();
}
function getEditor(documentId) {
@ -192,9 +197,6 @@ Item {
}
onProjectClosed: {
for (var i = 0; i < editorListModel.count; i++)
editors.itemAt(i).visible = false;
//editorListModel.clear();
currentDocumentId = "";
openDocCount = 0;
}
@ -234,7 +236,7 @@ Item {
property variant item
property variant doc
onYes: {
doLoadDocument(item, doc);
doLoadDocument(item, doc, false);
resetEditStatus(doc.documentId);
}
}
@ -251,7 +253,7 @@ Item {
asynchronous: true
anchors.fill: parent
source: appService.haveWebEngine ? "WebCodeEditor.qml" : "CodeEditor.qml"
visible: (index >= 0 && index < editorListModel.count && currentDocumentId === editorListModel.get(index).documentId)
visible: (index >= 0 && index < openDocCount && currentDocumentId === editorListModel.get(index).documentId)
property bool changed: false
onVisibleChanged: {
loadIfNotLoaded()
@ -271,7 +273,7 @@ Item {
loadIfNotLoaded()
}
onLoaded: {
doLoadDocument(loader.item, editorListModel.get(index))
doLoadDocument(loader.item, editorListModel.get(index), true)
}
Connections

2
mix/qml/ProjectModel.qml

@ -76,7 +76,7 @@ Item {
Connections {
target: mainApplication
onLoaded: {
if (projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "")
if (mainApplication.trackLastProject && projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "")
projectModel.loadProject(projectSettings.lastProjectPath)
}
}

169
mix/qml/StateDialog.qml

@ -13,7 +13,7 @@ Dialog {
id: modalStateDialog
modality: Qt.ApplicationModal
width: 590
width: 630
height: 480
title: qsTr("Edit State")
visible: false
@ -79,7 +79,10 @@ Dialog {
}
contentItem: Rectangle {
color: stateDialogStyle.generic.backgroundColor
ColumnLayout {
Rectangle {
color: stateDialogStyle.generic.backgroundColor
anchors.top: parent.top
anchors.margins: 10
anchors.fill: parent
ColumnLayout {
anchors.fill: parent
@ -91,7 +94,7 @@ Dialog {
{
Layout.fillWidth: true
DefaultLabel {
Layout.preferredWidth: 75
Layout.preferredWidth: 85
text: qsTr("Title")
}
DefaultTextField
@ -112,10 +115,10 @@ Dialog {
Rectangle
{
Layout.preferredWidth: 75
Layout.preferredWidth: 85
DefaultLabel {
id: accountsLabel
Layout.preferredWidth: 75
Layout.preferredWidth: 85
text: qsTr("Accounts")
}
@ -227,7 +230,7 @@ Dialog {
{
Layout.fillWidth: true
DefaultLabel {
Layout.preferredWidth: 75
Layout.preferredWidth: 85
text: qsTr("Default")
}
CheckBox {
@ -240,52 +243,91 @@ Dialog {
{
Layout.fillWidth: true
}
}
ColumnLayout {
anchors.top: dialogContent.bottom
anchors.topMargin: 5
spacing: 0
RowLayout
{
Layout.preferredWidth: 150
DefaultLabel {
text: qsTr("Transactions: ")
}
Layout.fillWidth: true
Button
Rectangle
{
iconSource: "qrc:/qml/img/plus.png"
action: newTrAction
width: 10
height: 10
anchors.right: parent.right
}
Layout.preferredWidth: 85
DefaultLabel {
id: transactionsLabel
Layout.preferredWidth: 85
text: qsTr("Transactions")
}
Action {
id: newTrAction
tooltip: qsTr("Create a new transaction")
onTriggered: transactionsModel.addTransaction()
Button
{
anchors.top: transactionsLabel.bottom
anchors.topMargin: 10
iconSource: "qrc:/qml/img/plus.png"
action: newTrAction
}
Action {
id: newTrAction
tooltip: qsTr("Create a new transaction")
onTriggered: transactionsModel.addTransaction()
}
}
}
ScrollView
{
Layout.fillHeight: true
Layout.preferredWidth: 300
Column
TableView
{
Layout.fillHeight: true
Repeater
{
id: trRepeater
model: transactionsModel
delegate: transactionRenderDelegate
visible: transactionsModel.count > 0
height: 20 * transactionsModel.count
id: transactionsView
Layout.fillWidth: true
model: transactionsModel
headerVisible: false
TableViewColumn {
role: "name"
title: qsTr("Name")
width: 150
delegate: Item {
RowLayout
{
height: 30
width: parent.width
Button
{
iconSource: "qrc:/qml/img/delete_sign.png"
action: deleteTransactionAction
}
Action {
id: deleteTransactionAction
tooltip: qsTr("Delete")
onTriggered: transactionsModel.deleteTransaction(styleData.row)
}
Button
{
iconSource: "qrc:/qml/img/edit.png"
action: editAction
visible: styleData.row >= 0 ? !transactionsModel.get(styleData.row).stdContract : false
width: 10
height: 10
Action {
id: editAction
tooltip: qsTr("Edit")
onTriggered: transactionsModel.editTransaction(styleData.row)
}
}
DefaultLabel {
Layout.preferredWidth: 150
text: styleData.row >= 0 ? transactionsModel.get(styleData.row).functionId : ""
}
}
}
}
rowDelegate:
Rectangle {
color: styleData.alternate ? "transparent" : "#f0f0f0"
height: 30;
}
}
}
}
RowLayout
@ -293,6 +335,14 @@ Dialog {
anchors.bottom: parent.bottom
anchors.right: parent.right;
Button {
text: qsTr("Delete");
enabled: !modalStateDialog.isDefault
onClicked: {
projectModel.stateListModel.deleteState(stateIndex);
close();
}
}
Button {
text: qsTr("OK");
onClicked: {
@ -325,7 +375,6 @@ Dialog {
}
function addTransaction() {
// Set next id here to work around Qt bug
// https://bugreports.qt-project.org/browse/QTBUG-41327
// Second call to signal handler would just edit the item that was just created, no harm done
@ -350,44 +399,6 @@ Dialog {
}
}
Component {
id: transactionRenderDelegate
RowLayout {
DefaultLabel {
Layout.preferredWidth: 150
text: functionId
}
Button
{
id: deleteBtn
iconSource: "qrc:/qml/img/delete_sign.png"
action: deleteAction
width: 10
height: 10
Action {
id: deleteAction
tooltip: qsTr("Delete")
onTriggered: transactionsModel.deleteTransaction(index)
}
}
Button
{
iconSource: "qrc:/qml/img/edit.png"
action: editAction
visible: stdContract === false
width: 10
height: 10
Action {
id: editAction
tooltip: qsTr("Edit")
onTriggered: transactionsModel.editTransaction(index)
}
}
}
}
TransactionDialog
{
id: transactionDialog

4
mix/qml/StateListModel.qml

@ -167,6 +167,7 @@ Item {
signal defaultStateChanged;
signal stateListModelReady;
signal stateRun(int index)
signal stateDeleted(int index)
function defaultTransactionItem() {
return TransactionHelper.defaultTransaction();
@ -293,9 +294,8 @@ Item {
}
else if (defaultStateIndex > index)
defaultStateIndex--;
save();
stateDeleted(index);
}
function save() {

11
mix/qml/StatesComboBox.qml

@ -99,11 +99,10 @@ Rectangle {
}
MouseArea {
id: selectorArea
anchors.fill: parent
onClicked: {
if (outsideClick.trigerred)
outsideClick.trigerred = false;
else if (statesCombo.state === "")
if (statesCombo.state === "")
statesCombo.state = "dropDown";
}
}
@ -133,13 +132,13 @@ Rectangle {
InverseMouseArea
{
property bool trigerred: false
id: outsideClick
anchors.fill: parent
active: false
onClickedOutside: {
trigerred = true;
statesCombo.hideDropDown()
var p = selectorArea.mapFromItem(null, _point.x, _point.y);
if (!selectorArea.contains(Qt.point(p.x, p.y)))
statesCombo.hideDropDown()
}
}

31
mix/qml/StatusPane.qml

@ -3,6 +3,7 @@ import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.InverseMouseArea 1.0
import QtGraphicalEffects 1.0
import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "."
@ -246,6 +247,27 @@ Rectangle {
tooltip: ""
}
Rectangle
{
id: logsShadow
width: logsContainer.width + 5
height: 0
opacity: 0.3
clip: true
anchors.top: logsContainer.top
anchors.margins: 4
Rectangle {
color: "gray"
anchors.top: parent.top
radius: 10
id: roundRect
height: 400
width: parent.width
}
}
Rectangle
{
InverseMouseArea
@ -287,9 +309,16 @@ Rectangle {
top = top.parent
var coordinates = logsContainer.mapToItem(top, 0, 0);
logsContainer.parent = top;
logsShadow.parent = top;
logsContainer.x = status.x + statusContainer.x - logStyle.generic.layout.dateWidth - logStyle.generic.layout.typeWidth + 70
logsShadow.x = status.x + statusContainer.x - logStyle.generic.layout.dateWidth - logStyle.generic.layout.typeWidth + 70;
logsShadow.z = 1
logsContainer.z = 2
if (Qt.platform.os === "osx")
{
logsContainer.y = statusContainer.y;
logsShadow.y = statusContainer.y;
}
}
LogsPaneStyle {
@ -305,6 +334,7 @@ Rectangle {
State {
name: "opened";
PropertyChanges { target: logsContainer; height: 500; visible: true }
PropertyChanges { target: logsShadow; height: 500; visible: true }
PropertyChanges { target: outsideClick; active: true }
},
@ -313,6 +343,7 @@ Rectangle {
PropertyChanges { target: logsContainer; height: 0; visible: false }
PropertyChanges { target: statusContainer; width: 600; height: 30 }
PropertyChanges { target: outsideClick; active: false }
PropertyChanges { target: logsShadow; height: 0; visible: false }
}
]
transitions: Transition {

1
mix/qml/TransactionDialog.qml

@ -400,7 +400,6 @@ Dialog {
Button {
text: qsTr("Cancel");
onClicked: close();
Layout.fillWidth: true
}
}
}

10
mix/qml/TransactionLog.qml

@ -52,7 +52,7 @@ Item {
{
id: statesCombo
items: projectModel.stateListModel
onSelectCreate: projectModel.stateListModel.addState();
onSelectCreate: projectModel.stateListModel.addState()
onEditItem: projectModel.stateListModel.editState(item)
colorItem: "#808080"
colorSelect: "#4a90e2"
@ -63,8 +63,16 @@ Item {
if (statesCombo.selectedIndex !== index)
statesCombo.setSelectedIndex(index)
}
onStateListModelReady: {
statesCombo.setSelectedIndex(projectModel.stateListModel.defaultStateIndex)
}
onStateDeleted: {
if (index === statesCombo.selectedIndex)
statesCombo.setSelectedIndex(0);
}
}
}
Button
{
anchors.rightMargin: 9

2
mix/qml/WebCodeEditor.qml

@ -18,6 +18,7 @@ Item {
property bool unloaded: false
property var currentBreakpoints: []
property string sourceName
property var document
function setText(text, mode) {
currentText = text;
@ -117,6 +118,7 @@ Item {
codeModel.onCompilationError.connect(compilationError);
}
parent.changeGeneration();
loadComplete();
}
}

3
mix/qml/js/ProjectModel.js

@ -124,7 +124,8 @@ function loadProject(path) {
for(var i = 0; i < projectData.files.length; i++) {
addFile(projectData.files[i]);
}
projectSettings.lastProjectPath = path;
if (mainApplication.trackLastProject)
projectSettings.lastProjectPath = path;
projectLoading(projectData);
projectLoaded()

8
mix/test/qml/TestMain.qml

@ -30,18 +30,20 @@ TestCase
Application
{
id: mainApplication
trackLastProject: false
}
function newProject()
{
waitForRendering(mainApplication.mainContent, 10000);
mainApplication.projectModel.createProject();
var projectDlg = mainApplication.projectModel.newProjectDialog;
wait(30);
projectDlg.projectTitle = "TestProject";
projectDlg.pathFieldText = "/tmp/MixTest"; //TODO: get platform temp path
projectDlg.acceptAndClose();
wait(30);
wait(1);
if (!ts.waitForSignal(mainApplication.codeModel, "compilationComplete()", 5000))
fail("new contract not compiled");
}
function editContract(c)
@ -55,7 +57,7 @@ TestCase
function editHtml(c)
{
mainApplication.projectModel.openDocument("index.html");
wait(1);
ts.waitForSignal(mainApplication.mainContent.codeEditor, "loadComplete()", 5000);
mainApplication.mainContent.codeEditor.getEditor("index.html").setText(c);
ts.keyPressChar(mainApplication, "S", Qt.ControlModifier, 200); //Ctrl+S
}

1
mix/test/qml/js/TestDebugger.js

@ -75,7 +75,6 @@ function test_constructorParameters()
ts.typeString("442", transactionDialog);
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.model.addTransaction();
ts.waitForRendering(transactionDialog, 3000);
transactionDialog.selectFunction("getZ");
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose();

Loading…
Cancel
Save