Browse Source

Merge pull request #933 from arkpar/mix_ux

mix: Minor ui improvements, msvc build fix
cl-refactor
Arkadiy Paronyan 10 years ago
parent
commit
59cc4b244a
  1. 1
      mix/AssemblyDebuggerControl.cpp
  2. 79
      mix/MachineStates.h
  3. 41
      mix/MixClient.h
  4. 1
      mix/main.cpp
  5. 101
      mix/qml/MainContent.qml
  6. 3
      mix/qml/ProjectModel.qml
  7. 47
      mix/qml/Splitter.qml
  8. 2
      mix/qml/StateListModel.qml
  9. 2
      mix/qml/WebPreview.qml
  10. 1
      mix/qml/html/codeeditor.js
  11. 3
      mix/qml/js/ProjectModel.js
  12. 39
      mix/qml/main.qml
  13. 1
      mix/res.qrc

1
mix/AssemblyDebuggerControl.cpp

@ -20,7 +20,6 @@
#include <QDebug>
#include <QQmlContext>
#include <QQmlApplicationEngine>
#include "AppContext.h"
#include "ClientModel.h"
#include "AssemblyDebuggerControl.h"

79
mix/MachineStates.h

@ -0,0 +1,79 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file MixClient.h
* @author Yann yann@ethdev.com
* @author Arkadiy Paronyan arkadiy@ethdev.com
* @date 2015
* Ethereum IDE client.
*/
#pragma once
#include <vector>
#include <map>
#include <stdint.h>
#include <libdevcore/Common.h>
#include <libdevcrypto/Common.h>
#include <libevmcore/Instruction.h>
#include <libethereum/TransactionReceipt.h>
namespace dev
{
namespace mix
{
/**
* @brief Store information about a machine state.
*/
struct MachineState
{
uint64_t steps;
dev::Address address;
dev::u256 curPC;
dev::eth::Instruction inst;
dev::bigint newMemSize;
dev::u256 gas;
dev::u256s stack;
dev::bytes memory;
dev::bigint gasCost;
std::map<dev::u256, dev::u256> storage;
std::vector<unsigned> levels;
unsigned codeIndex;
unsigned dataIndex;
};
/**
* @brief Store information about a machine states.
*/
struct ExecutionResult
{
ExecutionResult() : receipt(dev::h256(), dev::h256(), dev::eth::LogEntries()) {}
std::vector<MachineState> machineStates;
std::vector<bytes> transactionData;
std::vector<bytes> executionCode;
bytes returnValue;
dev::Address address;
dev::Address sender;
dev::Address contractAddress;
dev::u256 value;
dev::eth::TransactionReceipt receipt;
};
using ExecutionResults = std::vector<ExecutionResult>;
}
}

41
mix/MixClient.h

@ -26,52 +26,13 @@
#include <vector>
#include <libethereum/Interface.h>
#include <libethereum/Client.h>
#include "MachineStates.h"
namespace dev
{
namespace mix
{
/**
* @brief Store information about a machine state.
*/
struct MachineState
{
uint64_t steps;
dev::Address address;
dev::u256 curPC;
dev::eth::Instruction inst;
dev::bigint newMemSize;
dev::u256 gas;
dev::u256s stack;
dev::bytes memory;
dev::bigint gasCost;
std::map<dev::u256, dev::u256> storage;
std::vector<unsigned> levels;
unsigned codeIndex;
unsigned dataIndex;
};
/**
* @brief Store information about a machine states.
*/
struct ExecutionResult
{
ExecutionResult(): receipt(dev::h256(), dev::h256(), dev::eth::LogEntries()) {}
std::vector<MachineState> machineStates;
std::vector<bytes> transactionData;
std::vector<bytes> executionCode;
bytes returnValue;
dev::Address address;
dev::Address sender;
dev::Address contractAddress;
dev::u256 value;
dev::eth::TransactionReceipt receipt;
};
using ExecutionResults = std::vector<ExecutionResult>;
struct Block
{
ExecutionResults transactions;

1
mix/main.cpp

@ -35,6 +35,7 @@ int main(int _argc, char* _argv[])
//work around ubuntu appmenu-qt5 bug
//https://bugs.launchpad.net/ubuntu/+source/appmenu-qt5/+bug/1323853
putenv((char*)"QT_QPA_PLATFORMTHEME=");
putenv((char*)"QSG_RENDER_LOOP=threaded");
#endif
try
{

101
mix/qml/MainContent.qml

@ -23,14 +23,20 @@ Rectangle {
property alias rightViewVisible : rightView.visible
property alias webViewVisible : webPreview.visible
property alias projectViewVisible : projectList.visible
property alias runOnProjectLoad : mainSettings.runOnProjectLoad
property bool webViewHorizontal : codeWebSplitter.orientation === Qt.Vertical //vertical splitter positions elements vertically, splits screen horizontally
property bool firstCompile: true
onWidthChanged:
{
if (rightView.visible)
contentView.width = parent.width - projectList.width - rightView.width;
else
contentView.width = parent.width - projectList.width;
Connections {
target: codeModel
onCompilationComplete: {
if (firstCompile) {
firstCompile = false;
if (codeModel.code.successful && runOnProjectLoad)
startQuickDebugging();
}
}
}
function startQuickDebugging()
@ -40,15 +46,11 @@ Rectangle {
}
function toggleRightView() {
if (!rightView.visible)
rightView.show();
else
rightView.hide();
rightView.visible = !rightView.visible;
}
function ensureRightView() {
if (!rightView.visible)
rightView.show();
rightView.visible = true;
}
function rightViewIsVisible()
@ -65,6 +67,10 @@ Rectangle {
webPreview.visible = !webPreview.visible;
}
function toggleProjectView() {
projectList.visible = !projectList.visible;
}
function toggleWebPreviewOrientation() {
codeWebSplitter.orientation = (codeWebSplitter.orientation === Qt.Vertical ? Qt.Horizontal : Qt.Vertical);
}
@ -75,19 +81,18 @@ Rectangle {
}
Settings {
id: mainLayoutSettings
id: mainSettings
property alias codeWebOrientation: codeWebSplitter.orientation
property alias webWidth: webPreview.width
property alias webHeight: webPreview.height
property alias showProjectView: projectList.visible
property bool runOnProjectLoad: false
}
GridLayout
ColumnLayout
{
anchors.fill: parent
rows: 2
flow: GridLayout.TopToBottom
columnSpacing: 0
rowSpacing: 0
spacing: 0
Rectangle {
width: parent.width
height: 50
@ -128,29 +133,26 @@ Rectangle {
property alias rightViewWidth: rightView.width
}
SplitView
{
anchors.fill: parent
handleDelegate: Rectangle {
width: 4
height: 4
color: "#cccccc"
}
orientation: Qt.Horizontal
ProjectList {
anchors.left: parent.left
id: projectList
width: 200
height: parent.height
Layout.minimumWidth: 200
}
Splitter
{
id: resizeLeft
itemToStick: projectList
itemMinimumWidth: projectList.Layout.minimumWidth
direction: "right"
brother: contentView
color: "#a2a2a2"
Layout.minimumWidth: 180
Layout.fillHeight: true
}
Rectangle {
anchors.left: projectList.right
id: contentView
width: parent.width - projectList.width
height: parent.height
Layout.fillHeight: true
Layout.fillWidth: true
SplitView {
handleDelegate: Rectangle {
width: 4
@ -177,35 +179,11 @@ Rectangle {
}
}
Splitter
{
id: resizeRight
visible: false;
itemToStick: rightView
itemMinimumWidth: rightView.Layout.minimumWidth
direction: "left"
brother: contentView
color: "#a2a2a2"
}
Rectangle {
visible: false;
id: rightView;
Keys.onEscapePressed: hide()
function show() {
visible = true;
resizeRight.visible = true;
contentView.width = parent.width - projectList.width - rightView.width;
}
function hide() {
resizeRight.visible = false;
visible = false;
contentView.width = parent.width - projectList.width;
}
Layout.fillHeight: true
Keys.onEscapePressed: visible = false
height: parent.height;
width: 515
Layout.minimumWidth: 515
@ -245,6 +223,7 @@ Rectangle {
}
}
}
}

3
mix/qml/ProjectModel.qml

@ -10,7 +10,8 @@ Item {
id: projectModel
signal projectClosed
signal projectLoaded(var projectData)
signal projectLoading(var projectData)
signal projectLoaded()
signal documentOpened(var document)
signal documentRemoved(var documentId)
signal documentUpdated(var documentId) //renamed

47
mix/qml/Splitter.qml

@ -1,47 +0,0 @@
import QtQuick 2.2
Rectangle {
property variant itemToStick;
property int itemMinimumWidth;
property string direction;
property variant brother;
Component.onCompleted:
{
if (direction === "left")
anchors.right = itemToStick.left;
else if (direction === "right")
anchors.left = itemToStick.right;
}
width: 5
height: parent.height
anchors.top: parent.top;
MouseArea
{
property int startX: 0;
anchors.fill: parent
onPressed: startX = mouseX;
onPositionChanged:
{
parent.x += mouseX;
var diff = 0;
if (direction == "left")
diff = mouseX - startX;
else if (direction == "right")
diff = -(mouseX - startX);
if (itemMinimumWidth > itemToStick.width - diff)
{
brother.width = brother.width + diff;
itemToStick.width = itemMinimumWidth;
}
else
{
brother.width = brother.width + diff;
itemToStick.width = itemToStick.width - diff;
}
}
cursorShape: Qt.SizeHorCursor
}
}

2
mix/qml/StateListModel.qml

@ -105,7 +105,7 @@ Item {
stateListModel.clear();
stateList = [];
}
onProjectLoaded: {
onProjectLoading: {
if (!projectData.states)
projectData.states = [];
if (projectData.defaultStateIndex !== undefined)

2
mix/qml/WebPreview.qml

@ -86,7 +86,7 @@ Item {
updateDocument(documentId, function(i) { pageListModel.set(i, projectModel.getDocument(documentId)) } )
}
onProjectLoaded: {
onProjectLoading: {
for (var i = 0; i < target.listModel.count; i++) {
var document = target.listModel.get(i);
if (document.isHtml) {

1
mix/qml/html/codeeditor.js

@ -31,6 +31,7 @@ getText = function() {
setTextBase64 = function(text) {
editor.setValue(window.atob(text));
editor.getDoc().clearHistory();
editor.focus();
};

3
mix/qml/js/ProjectModel.js

@ -73,7 +73,8 @@ function loadProject(path) {
addFile(projectData.files[i]);
}
projectSettings.lastProjectPath = path;
projectLoaded(projectData);
projectLoading(projectData);
projectLoaded()
}
function addExistingFile() {

39
mix/qml/main.qml

@ -36,14 +36,16 @@ ApplicationWindow {
Menu {
title: qsTr("Debug")
MenuItem { action: debugRunAction }
MenuItem { action: debugResetStateAction }
MenuItem { action: mineAction }
MenuSeparator {}
MenuItem { action: toggleRunOnLoadAction }
}
Menu {
title: qsTr("Windows")
MenuItem { action: openNextDocumentAction }
MenuItem { action: openPrevDocumentAction }
MenuSeparator {}
MenuItem { action: toggleProjectNavigatorAction }
MenuItem { action: showHideRightPanelAction }
MenuItem { action: toggleWebPreviewAction }
MenuItem { action: toggleWebPreviewOrientationAction }
@ -82,47 +84,58 @@ ApplicationWindow {
Action {
id: mineAction
text: "Mine"
text: qsTr("Mine")
shortcut: "Ctrl+M"
onTriggered: clientModel.mine();
enabled: codeModel.hasContract && !clientModel.running
}
Action {
id: debugRunAction
text: "&Run"
text: qsTr("Run")
shortcut: "F5"
onTriggered: mainContent.startQuickDebugging()
enabled: codeModel.hasContract && !clientModel.running
}
Action {
id: debugResetStateAction
text: "Reset &State"
shortcut: "F6"
onTriggered: clientModel.resetState();
}
Action {
id: toggleWebPreviewAction
text: "Show Web View"
text: qsTr("Show Web View")
shortcut: "F2"
checkable: true
checked: mainContent.webViewVisible
onTriggered: mainContent.toggleWebPreview();
}
Action {
id: toggleProjectNavigatorAction
text: qsTr("Show Project Navigator")
shortcut: "Alt+0"
checkable: true
checked: mainContent.projectViewVisible
onTriggered: mainContent.toggleProjectView();
}
Action {
id: toggleWebPreviewOrientationAction
text: "Horizontal Web View"
text: qsTr("Horizontal Web View")
shortcut: ""
checkable: true
checked: mainContent.webViewHorizontal
onTriggered: mainContent.toggleWebPreviewOrientation();
}
Action {
id: toggleRunOnLoadAction
text: qsTr("Load State on Startup")
shortcut: ""
checkable: true
checked: mainContent.runOnProjectLoad
onTriggered: mainContent.runOnProjectLoad = !mainContent.runOnProjectLoad
}
Action {
id: showHideRightPanelAction
text: "Show Right View"
text: qsTr("Show Right View")
shortcut: "F7"
checkable: true
checked: mainContent.rightViewVisible

1
mix/res.qrc

@ -49,7 +49,6 @@
<file>qml/QRealType.qml</file>
<file>qml/js/QEtherHelper.js</file>
<file>qml/js/TransactionHelper.js</file>
<file>qml/Splitter.qml</file>
<file>qml/QStringType.qml</file>
<file>qml/QBoolTypeView.qml</file>
<file>qml/QIntTypeView.qml</file>

Loading…
Cancel
Save