You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
5.6 KiB

import QtQuick 2.2
import QtQuick.Controls 1.1
10 years ago
import QtQuick.Layouts 1.0
import QtQuick.Controls.Styles 1.1
import Qt.labs.settings 1.0
import org.ethereum.qml.QEther 1.0
import "js/QEtherHelper.js" as QEtherHelper
import "js/TransactionHelper.js" as TransactionHelper
10 years ago
import "."
10 years ago
Rectangle {
objectName: "mainContent"
signal keyPressed(variant event)
focus: true
Keys.enabled: true
Keys.onPressed:
{
root.keyPressed(event.key);
}
anchors.fill: parent
10 years ago
id: root
10 years ago
property alias rightViewVisible: scenarioExe.visible
property alias webViewVisible: webPreview.visible
property alias webView: webPreview
property alias projectViewVisible: projectList.visible
10 years ago
property alias projectNavigator: projectList
property alias runOnProjectLoad: mainSettings.runOnProjectLoad
10 years ago
property alias rightPane: scenarioExe
property alias debuggerPanel: debugPanel
10 years ago
property alias codeEditor: codeEditor
property bool webViewHorizontal: codeWebSplitter.orientation === Qt.Vertical //vertical splitter positions elements vertically, splits screen horizontally
10 years ago
property bool firstCompile: true
10 years ago
property int scenarioMinWidth: 590
10 years ago
Connections {
target: codeModel
onCompilationComplete: {
if (firstCompile) {
firstCompile = false;
10 years ago
if (runOnProjectLoad)
startQuickDebugging();
10 years ago
}
}
}
10 years ago
Connections {
target: debugPanel
onDebugExecuteLocation: {
codeEditor.highlightExecution(documentId, location);
}
10 years ago
}
10 years ago
Connections {
target: codeEditor
onBreakpointsChanged: {
10 years ago
debugPanel.setBreakpoints(codeEditor.getBreakpoints());
10 years ago
}
}
function startQuickDebugging()
{
10 years ago
ensureRightView();
projectModel.stateListModel.debugDefaultState();
}
function toggleRightView() {
10 years ago
scenarioExe.visible = !scenarioExe.visible;
}
function ensureRightView() {
10 years ago
scenarioExe.visible = true;
10 years ago
}
function rightViewIsVisible()
{
10 years ago
return scenarioExe.visible;
}
function hideRightView() {
10 years ago
scenarioExe.visible = lfalse;
10 years ago
}
function toggleWebPreview() {
webPreview.visible = !webPreview.visible;
}
10 years ago
function toggleProjectView() {
projectList.visible = !projectList.visible;
}
function toggleWebPreviewOrientation() {
codeWebSplitter.orientation = (codeWebSplitter.orientation === Qt.Vertical ? Qt.Horizontal : Qt.Vertical);
}
10 years ago
//TODO: move this to debugger.js after refactoring, introduce events
function toggleBreakpoint() {
codeEditor.toggleBreakpoint();
}
function displayCompilationErrorIfAny()
{
10 years ago
scenarioExe.visible = true;
scenarioExe.displayCompilationErrorIfAny();
}
Settings {
10 years ago
id: mainSettings
property alias codeWebOrientation: codeWebSplitter.orientation
property alias webWidth: webPreview.width
property alias webHeight: webPreview.height
10 years ago
property alias showProjectView: projectList.visible
property bool runOnProjectLoad: true
10 years ago
property int scenarioMinWidth: scenarioMinWidth
}
10 years ago
ColumnLayout
10 years ago
{
10 years ago
id: mainColumn
10 years ago
anchors.fill: parent
10 years ago
spacing: 0
Rectangle {
width: parent.width
height: 50
10 years ago
Layout.row: 0
Layout.fillWidth: true
Layout.preferredHeight: 50
id: headerView
Rectangle
{
gradient: Gradient {
GradientStop { position: 0.0; color: "#f1f1f1" }
GradientStop { position: 1.0; color: "#d9d7da" }
}
id: headerPaneContainer
10 years ago
anchors.fill: parent
StatusPane
{
anchors.fill: parent
webPreview: webPreview
}
}
}
10 years ago
10 years ago
Rectangle {
10 years ago
Layout.fillWidth: true
height: 1
color: "#8c8c8c"
}
Rectangle {
10 years ago
Layout.fillWidth: true
Layout.preferredHeight: root.height - headerView.height;
Settings {
id: splitSettings
property alias projectWidth: projectList.width
property alias contentViewWidth: contentView.width
10 years ago
property alias rightViewWidth: scenarioExe.width
}
Splitter
{
10 years ago
anchors.fill: parent
orientation: Qt.Horizontal
10 years ago
10 years ago
ProjectList {
id: projectList
width: 350
Layout.minimumWidth: 250
10 years ago
Layout.fillHeight: true
Connections {
target: projectModel.codeEditor
}
}
10 years ago
10 years ago
Rectangle {
id: contentView
Layout.fillHeight: true
Layout.fillWidth: true
10 years ago
Splitter {
10 years ago
id: codeWebSplitter
anchors.fill: parent
orientation: Qt.Vertical
CodeEditorView {
id: codeEditor
10 years ago
height: parent.height * 0.6
anchors.top: parent.top
Layout.fillWidth: true
Layout.fillHeight: true
}
WebPreview {
id: webPreview
height: parent.height * 0.4
Layout.fillWidth: codeWebSplitter.orientation === Qt.Vertical
Layout.fillHeight: codeWebSplitter.orientation === Qt.Horizontal
Layout.minimumHeight: 200
Layout.minimumWidth: 200
}
}
10 years ago
}
10 years ago
ScenarioExecution
{
id: scenarioExe;
visible: false;
Layout.fillHeight: true
Keys.onEscapePressed: visible = false
10 years ago
Layout.minimumWidth: scenarioMinWidth
10 years ago
anchors.right: parent.right
}
Debugger
{
id: debugPanel
visible: false
Layout.fillHeight: true
Keys.onEscapePressed: visible = false
10 years ago
Layout.minimumWidth: scenarioMinWidth
10 years ago
anchors.right: parent.right
}
Connections {
target: clientModel
onDebugDataReady: {
scenarioExe.visible = false
debugPanel.visible = true
10 years ago
debugPanel.width = scenarioExe.width
10 years ago
if (scenarioExe.bc.debugTrRequested)
debugPanel.setTr(scenarioExe.bc.model.blocks[scenarioExe.bc.debugTrRequested[0]].transactions[scenarioExe.bc.debugTrRequested[1]])
}
}
Connections {
target: debugPanel
onPanelClosed: {
debugPanel.visible = false
scenarioExe.visible = true
10 years ago
scenarioExe.width = debugPanel.width
10 years ago
}
}
}
}
}
10 years ago
}