Browse Source

debugging fixes

cl-refactor
arkpar 10 years ago
parent
commit
c37763c6fd
  1. 7
      mix/AppContext.cpp
  2. 2
      mix/AppContext.h
  3. 8
      mix/ClientModel.h
  4. 22
      mix/qml/StateListModel.qml
  5. 6
      mix/qml/TransactionLog.qml
  6. 2
      mix/qml/WebPreview.qml
  7. 17
      mix/qml/main.qml
  8. 2
      mix/stdc/config.sol
  9. 7
      mix/stdc/namereg.sol

7
mix/AppContext.cpp

@ -23,6 +23,7 @@
*/
#include <QMessageBox>
#include <QClipboard>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlApplicationEngine>
@ -94,3 +95,9 @@ void AppContext::displayMessageDialog(QString _title, QString _message)
dialogWin->findChild<QObject*>("messageContent", Qt::FindChildrenRecursively)->setProperty("text", _message);
QMetaObject::invokeMethod(dialogWin, "open");
}
void AppContext::toClipboard(QString _text)
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(_text);
}

2
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

8
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:

22
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;

6
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 {

2
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);

17
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")

2
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:

7
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));
}

Loading…
Cancel
Save