From c37763c6fd55f2f5a1bfef6c2f5625802284a55e Mon Sep 17 00:00:00 2001 From: arkpar Date: Wed, 28 Jan 2015 18:48:21 +0100 Subject: [PATCH] debugging fixes --- mix/AppContext.cpp | 7 +++++++ mix/AppContext.h | 2 ++ mix/ClientModel.h | 8 ++++++++ mix/qml/StateListModel.qml | 22 +++++++++++++++++----- mix/qml/TransactionLog.qml | 6 ++++++ mix/qml/WebPreview.qml | 2 +- mix/qml/main.qml | 17 ++++++++++------- mix/stdc/config.sol | 2 +- mix/stdc/namereg.sol | 7 ++++--- 9 files changed, 56 insertions(+), 17 deletions(-) diff --git a/mix/AppContext.cpp b/mix/AppContext.cpp index 551ce1c72..cae6dde57 100644 --- a/mix/AppContext.cpp +++ b/mix/AppContext.cpp @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -94,3 +95,9 @@ void AppContext::displayMessageDialog(QString _title, QString _message) dialogWin->findChild("messageContent", Qt::FindChildrenRecursively)->setProperty("text", _message); QMetaObject::invokeMethod(dialogWin, "open"); } + +void AppContext::toClipboard(QString _text) +{ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(_text); +} diff --git a/mix/AppContext.h b/mix/AppContext.h index f304e1f73..31ecd3198 100644 --- a/mix/AppContext.h +++ b/mix/AppContext.h @@ -62,6 +62,8 @@ public: ClientModel* clientModel() { return m_clientModel.get(); } /// Display an alert message. void displayMessageDialog(QString _title, QString _message); + /// Copy text to clipboard + Q_INVOKABLE void toClipboard(QString _text); signals: /// Triggered once components have been loaded diff --git a/mix/ClientModel.h b/mix/ClientModel.h index 7900f7ff8..016673ba6 100644 --- a/mix/ClientModel.h +++ b/mix/ClientModel.h @@ -69,15 +69,23 @@ struct TransactionSettings }; +/// UI Transaction log record class TransactionLogEntry: public QObject { Q_OBJECT + /// Transaction block number Q_PROPERTY(unsigned block MEMBER m_block CONSTANT) + /// Transaction index within the block Q_PROPERTY(unsigned index MEMBER m_index CONSTANT) + /// Contract name if any Q_PROPERTY(QString contract MEMBER m_contract CONSTANT) + /// Function name if any Q_PROPERTY(QString function MEMBER m_function CONSTANT) + /// Transaction value Q_PROPERTY(QString value MEMBER m_value CONSTANT) + /// Receiving address Q_PROPERTY(QString address MEMBER m_address CONSTANT) + /// Returned value or transaction address in case of creation Q_PROPERTY(QString returned MEMBER m_returned CONSTANT) public: diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 325fbebdb..c158112e1 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -21,15 +21,23 @@ Item { } function fromPlainTransactionItem(t) { - return { + var r = { functionId: t.functionId, url: t.url, value: QEtherHelper.createEther(t.value.value, t.value.unit), gas: QEtherHelper.createEther(t.gas.value, t.gas.unit), gasPrice: QEtherHelper.createEther(t.gasPrice.value, t.gasPrice.unit), executeConstructor: t.executeConstructor, - stdContract: t.stdContract + stdContract: t.stdContract, + parameters: {} }; + for (var key in t.parameters) { + var intComponent = Qt.createComponent("qrc:/qml/BigIntValue.qml"); + var param = intComponent.createObject(); + param.setValue(t.parameters[key]); + r.parameters[key] = param; + } + return r; } function toPlainStateItem(s) { @@ -41,15 +49,19 @@ Item { } function toPlainTransactionItem(t) { - return { + var r = { functionId: t.functionId, url: t.url, value: { value: t.value.value, unit: t.value.unit }, gas: { value: t.gas.value, unit: t.gas.unit }, gasPrice: { value: t.gasPrice.value, unit: t.gasPrice.unit }, executeConstructor: t.executeConstructor, - stdContract: t.stdContract + stdContract: t.stdContract, + parameters: {} }; + for (var key in t.parameters) + r.parameters[key] = t.parameters[key].value(); + return r; } Connections { @@ -80,7 +92,7 @@ Item { projectData.defaultStateIndex = defaultStateIndex; } onNewProject: { - var state = toPlainTransactionItem(stateListModel.createDefaultState()); + var state = toPlainStateItem(stateListModel.createDefaultState()); state.title = qsTr("Default"); projectData.states = [ state ]; projectData.defaultStateIndex = 0; diff --git a/mix/qml/TransactionLog.qml b/mix/qml/TransactionLog.qml index d2d3883c3..6079366bb 100644 --- a/mix/qml/TransactionLog.qml +++ b/mix/qml/TransactionLog.qml @@ -48,6 +48,12 @@ Item { var item = logModel.get(row); clientModel.debugTransaction(item.block, item.index); } + Keys.onPressed: { + if ((event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_C && currentRow >=0 && currentRow < logModel.count) { + var item = logModel.get(currentRow); + appContext.toClipboard(item.returned); + } + } } ListModel { diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index b3808e87c..bd48210ef 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -114,7 +114,7 @@ Item { onClientConnected: { //filter polling spam //TODO: do it properly - var log = true;//_request.content.indexOf("eth_changed") < 0; + var log = _request.content.indexOf("eth_changed") < 0; if (log) console.log(_request.content); var response = clientModel.apiCall(_request.content); diff --git a/mix/qml/main.qml b/mix/qml/main.qml index 5074b6cd5..a0a4ba423 100644 --- a/mix/qml/main.qml +++ b/mix/qml/main.qml @@ -4,14 +4,14 @@ import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.1 -import CodeEditorExtensionManager 1.0 +import Qt.labs.settings 1.0 import org.ethereum.qml.QEther 1.0 ApplicationWindow { id: mainApplication visible: true width: 1200 - height: 600 + height: 800 minimumWidth: 400 minimumHeight: 300 title: qsTr("mix") @@ -50,11 +50,6 @@ ApplicationWindow { } } - Component.onCompleted: { - setX(Screen.width / 2 - width / 2); - setY(Screen.height / 2 - height / 2); - } - MainContent { id: mainContent; anchors.fill: parent @@ -70,6 +65,14 @@ ApplicationWindow { id: messageDialog } + Settings { + id: mainWindowSettings + property alias mainWidth: mainApplication.width + property alias mainHeight: mainApplication.height + property alias mainX: mainApplication.x + property alias mainY: mainApplication.y + } + Action { id: exitAppAction text: qsTr("Exit") diff --git a/mix/stdc/config.sol b/mix/stdc/config.sol index f79671778..f05412f25 100644 --- a/mix/stdc/config.sol +++ b/mix/stdc/config.sol @@ -31,7 +31,7 @@ contract Config is mortal { contract Config{function lookup(uint256 service)constant returns(address a){}function kill(){}function unregister(uint256 id){}function register(uint256 id,address service){}} // Example Solidity use: -address addrConfig = 0x661005d2720d855f1d9976f88bb10c1a3398c77f; +address addrConfig = 0xf025d81196b72fba60a1d4dddad12eeb8360d828; address addrNameReg = Config(addrConfig).lookup(1); // JS Interface: diff --git a/mix/stdc/namereg.sol b/mix/stdc/namereg.sol index b50a8e1ff..0886f5f71 100644 --- a/mix/stdc/namereg.sol +++ b/mix/stdc/namereg.sol @@ -12,11 +12,12 @@ contract NameRegister { #require Config, owned contract NameReg is owned, NameRegister { function NameReg() { - toName[Config()] = "Config"; - toAddress["Config"] = Config(); + address addrConfig = 0xf025d81196b72fba60a1d4dddad12eeb8360d828; + toName[addrConfig] = "Config"; + toAddress["Config"] = addrConfig; toName[this] = "NameReg"; toAddress["NameReg"] = this; - Config().register(1, this); + Config(addrConfig).register(1, this); log1(0, hash256(Config())); log1(0, hash256(this)); }