From d84ec425e790b0a1265484ffed5869b3b8356b26 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 19 Nov 2014 20:25:37 +0100 Subject: [PATCH 01/17] m1 --- mix/ApplicationContext.cpp | 33 ++++++++++++ mix/ApplicationContext.h | 23 +++++++++ mix/BasicContent.qml | 36 +++++++++++++ mix/CMakeLists.txt | 94 ++++++++++++++++++++++++++++++++++ mix/CodeEditorExtensionMan.cpp | 60 ++++++++++++++++++++++ mix/CodeEditorExtensionMan.h | 28 ++++++++++ mix/ConstantCompilation.cpp | 88 +++++++++++++++++++++++++++++++ mix/ConstantCompilation.h | 26 ++++++++++ mix/ContextualTabs.qml | 5 ++ mix/Feature.cpp | 33 ++++++++++++ mix/Feature.h | 21 ++++++++ mix/MainContent.qml | 47 +++++++++++++++++ mix/Qt47supp.txt | 29 +++++++++++ mix/TabStyle.qml | 24 +++++++++ mix/main.cpp | 19 +++++++ mix/main.qml | 27 ++++++++++ mix/mix.pro | 19 +++++++ mix/qml.qrc | 8 +++ 18 files changed, 620 insertions(+) create mode 100644 mix/ApplicationContext.cpp create mode 100644 mix/ApplicationContext.h create mode 100644 mix/BasicContent.qml create mode 100644 mix/CMakeLists.txt create mode 100644 mix/CodeEditorExtensionMan.cpp create mode 100644 mix/CodeEditorExtensionMan.h create mode 100644 mix/ConstantCompilation.cpp create mode 100644 mix/ConstantCompilation.h create mode 100644 mix/ContextualTabs.qml create mode 100644 mix/Feature.cpp create mode 100644 mix/Feature.h create mode 100644 mix/MainContent.qml create mode 100644 mix/Qt47supp.txt create mode 100644 mix/TabStyle.qml create mode 100644 mix/main.cpp create mode 100644 mix/main.qml create mode 100644 mix/mix.pro create mode 100644 mix/qml.qrc diff --git a/mix/ApplicationContext.cpp b/mix/ApplicationContext.cpp new file mode 100644 index 000000000..dcbb6d958 --- /dev/null +++ b/mix/ApplicationContext.cpp @@ -0,0 +1,33 @@ +#include "ApplicationContext.h" +#include + +ApplicationContext* ApplicationContext::m_instance = nullptr; + +ApplicationContext::ApplicationContext(QQmlApplicationEngine* _engine) +{ + m_applicationEngine = _engine; +} + +ApplicationContext::~ApplicationContext() +{ + delete m_applicationEngine; +} + +ApplicationContext* ApplicationContext::GetInstance() +{ + return m_instance; +} + +void ApplicationContext::SetApplicationContext(QQmlApplicationEngine* engine) +{ + m_instance = new ApplicationContext(engine); +} + +QQmlApplicationEngine* ApplicationContext::appEngine(){ + return m_applicationEngine; +} + +void ApplicationContext::QuitApplication() +{ + delete m_instance; +} diff --git a/mix/ApplicationContext.h b/mix/ApplicationContext.h new file mode 100644 index 000000000..154a4120e --- /dev/null +++ b/mix/ApplicationContext.h @@ -0,0 +1,23 @@ +#ifndef APPLICATIONCONTEXT_H +#define APPLICATIONCONTEXT_H + +#include + +class ApplicationContext : public QObject +{ + Q_OBJECT + +public: + ApplicationContext(QQmlApplicationEngine*); + ~ApplicationContext(); + QQmlApplicationEngine* appEngine(); + static ApplicationContext* GetInstance(); + static void SetApplicationContext(QQmlApplicationEngine*); +private: + static ApplicationContext* m_instance; + QQmlApplicationEngine* m_applicationEngine; +public slots: + void QuitApplication(); +}; + +#endif // APPLICATIONCONTEXT_H diff --git a/mix/BasicContent.qml b/mix/BasicContent.qml new file mode 100644 index 000000000..a61ee8b8f --- /dev/null +++ b/mix/BasicContent.qml @@ -0,0 +1,36 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 + +Rectangle { + anchors.fill: parent + width: parent.width + height: parent.height + color: "lightgray" + Text { + font.pointSize: 7 + anchors.left: parent.left + anchors.top: parent.top + anchors.topMargin: 3 + anchors.leftMargin: 3 + height: 9 + font.family: "Sego UI light" + objectName: "status" + id: status + } + + TextArea{ + readOnly: true + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.top: status.bottom + anchors.topMargin: 3 + font.pointSize: 7 + font.family: "Sego UI light" + height: parent.height * 0.8 + width: parent.width - 20 + wrapMode: Text.Wrap + backgroundVisible: false + objectName: "content" + id: content + } +} diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt new file mode 100644 index 000000000..7272c4d99 --- /dev/null +++ b/mix/CMakeLists.txt @@ -0,0 +1,94 @@ +set(CMAKE_INCLUDE_CURRENT_DIR ON) +aux_source_directory(. SRC_LIST) +include_directories(..) + +if (APPLE) + # Add homebrew path for qt5 + set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) + include_directories(/usr/local/opt/qt5/include /usr/local/include) +elseif ("${TARGET_PLATFORM}" STREQUAL "w64") + set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) + include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) +elseif (UNIX) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake" /opt/Qt5.3.2/5.3/gcc_64/lib/cmake/Qt5Declarative) +endif () + +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Quick REQUIRED) +find_package(Qt5Qml REQUIRED) +find_package(Qt5Network REQUIRED) +find_package(Qt5Widgets REQUIRED) +find_package(Qt5WebKit REQUIRED) +find_package(Qt5WebKitWidgets REQUIRED) +find_package(Qt5Declarative REQUIRED) + +#qt5_wrap_ui(ui_Main.h Main.ui) + +qt5_add_resources(UI_RESOURCES qml.qrc) + +# Set name of binary and add_executable() +file(GLOB HEADERS "*.h") +if (APPLE) + set(EXECUTEABLE mix) + set(BIN_INSTALL_DIR ".") + set(DOC_INSTALL_DIR ".") + + set(PROJECT_VERSION "${ETH_VERSION}") + set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") + set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") + set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") + set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") + set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTEABLE}) + set(MACOSX_BUNDLE_ICON_FILE mix) + include(BundleUtilities) + + add_executable(${EXECUTEABLE} MACOSX_BUNDLE ${SRC_LIST} ${HEADERS} ${UI_RESOURCES}) + set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") + SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) + SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + +else () + set(EXECUTEABLE mix) + add_executable(${EXECUTEABLE} ${SRC_LIST} ${HEADERS} ${UI_RESOURCES}) +endif () + +qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets) +target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll solidity evmcore devcore web3jsonrpc jsqrc) + +if (APPLE) + # First have qt5 install plugins and frameworks + add_custom_command(TARGET ${EXECUTEABLE} POST_BUILD + COMMAND /usr/local/opt/qt5/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTEABLE}.app + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + + # This tool and next will inspect linked libraries in order to determine which dependencies are required + if (${CMAKE_CFG_INTDIR} STREQUAL ".") + set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTEABLE}.app") + else () + set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}/${EXECUTEABLE}.app") + endif () + install(CODE " + include(BundleUtilities) + set(BU_CHMOD_BUNDLE_ITEMS 1) + fixup_bundle(\"${APP_BUNDLE_PATH}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") + " COMPONENT RUNTIME ) + # Cleanup duplicate libs from macdeployqt + install(CODE " + file(GLOB LINGER_RM \"${APP_BUNDLE_PATH}/Contents/Frameworks/*.dylib\") + if (LINGER_RM) + file(REMOVE \${LINGER_RM}) + endif () + ") +elseif (UNIX) +else () + target_link_libraries(${EXECUTEABLE} boost_system) + target_link_libraries(${EXECUTEABLE} boost_filesystem) + find_package(Threads REQUIRED) + target_link_libraries(${EXECUTEABLE} ${CMAKE_THREAD_LIBS_INIT}) + install( TARGETS ${EXECUTEABLE} RUNTIME DESTINATION bin ) +endif () + +qt5_use_modules(${EXECUTEABLE} Core Gui Declarative) diff --git a/mix/CodeEditorExtensionMan.cpp b/mix/CodeEditorExtensionMan.cpp new file mode 100644 index 000000000..1c845dbbf --- /dev/null +++ b/mix/CodeEditorExtensionMan.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +#include "CodeEditorExtensionMan.h" +#include "ConstantCompilation.h" +#include "features.h" +#include "ApplicationContext.h" +#include +using namespace dev; + +CodeEditorExtensionManager::CodeEditorExtensionManager() +{ +} + +void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) +{ + if (!_editor) + return; + try{ + QVariant doc = _editor->property("textDocument"); + if (doc.canConvert()) { + QQuickTextDocument* qqdoc = doc.value(); + if (qqdoc) { + m_doc = qqdoc->textDocument(); + } + } + } + catch (dev::Exception const& exception){ + qDebug() << "unable to load editor: "; + qDebug() << exception.what(); + } +} + +void CodeEditorExtensionManager::initExtensions() +{ + try{ + //only one for now + ConstantCompilation* compil = new ConstantCompilation(m_doc); + if (compil->tabUrl() != "") + compil->addContentOn(m_tabView); + compil->start(); + } + catch (dev::Exception const& exception){ + qDebug() << "unable to load extensions: "; + qDebug() << exception.what(); + } +} + +void CodeEditorExtensionManager::setEditor(QQuickItem* _editor){ + this->loadEditor(_editor); + this->initExtensions(); +} + +void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView){ + m_tabView = _tabView; +} diff --git a/mix/CodeEditorExtensionMan.h b/mix/CodeEditorExtensionMan.h new file mode 100644 index 000000000..cfe505c09 --- /dev/null +++ b/mix/CodeEditorExtensionMan.h @@ -0,0 +1,28 @@ +#ifndef CODEEDITOREXTENSIONMANAGER_H +#define CODEEDITOREXTENSIONMANAGER_H + +#include +#include +#include "Feature.h" + +class CodeEditorExtensionManager : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QQuickItem* editor MEMBER m_editor WRITE setEditor) + Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) + +public: + CodeEditorExtensionManager(); + void initExtensions(); + void setEditor(QQuickItem*); + void setTabView(QQuickItem*); + +private: + QQuickItem* m_editor; + QQuickItem* m_tabView; + QTextDocument* m_doc; + void loadEditor(QQuickItem*); +}; + +#endif // CODEEDITOREXTENSIONMANAGER_H diff --git a/mix/ConstantCompilation.cpp b/mix/ConstantCompilation.cpp new file mode 100644 index 000000000..76fbd1546 --- /dev/null +++ b/mix/ConstantCompilation.cpp @@ -0,0 +1,88 @@ +#include "ConstantCompilation.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +using namespace dev; +using namespace dev::eth; + +ConstantCompilation::ConstantCompilation(QTextDocument* _doc) +{ + m_editor = _doc; +} + +QString ConstantCompilation::tabUrl(){ + return QStringLiteral("qrc:/BasicContent.qml"); +} + +void ConstantCompilation::start() +{ + connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); +} + +QString ConstantCompilation::title() +{ + return "compilation"; +} + +void ConstantCompilation::compile() +{ + QString codeContent = m_editor->toPlainText(); + if (codeContent == ""){ + this->writeOutPut(true, codeContent); + return; + } + dev::solidity::CompilerStack compiler; + dev::bytes m_data; + QString content; + try + { + m_data = compiler.compile(codeContent.toStdString(), true); + content = QString::fromStdString(dev::eth::disassemble(m_data)); + this->writeOutPut(true, content); + } + catch (dev::Exception const& exception) + { + ostringstream error; + solidity::SourceReferenceFormatter::printExceptionInformation(error, exception, "Error", compiler.getScanner()); + content = QString::fromStdString(error.str()).toHtmlEscaped(); + this->writeOutPut(false, content); + } + catch (...) + { + content = "Uncaught exception."; + this->writeOutPut(false, content); + } + +} +void ConstantCompilation::writeOutPut(bool _success, QString _content){ + QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); + QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); + if (_content == ""){ + status->setProperty("text", ""); + content->setProperty("text", ""); + } + else if (_success){ + status->setProperty("text", "compile successfull"); + status->setProperty("color", "green"); + content->setProperty("text", _content); + qDebug() << QString("compile suceeded " + _content); + } + else { + status->setProperty("text", "compile failed"); + status->setProperty("color", "red"); + content->setProperty("text", _content); + qDebug() << QString("compile failed " + _content); + } +} + + + + diff --git a/mix/ConstantCompilation.h b/mix/ConstantCompilation.h new file mode 100644 index 000000000..c3c93b8aa --- /dev/null +++ b/mix/ConstantCompilation.h @@ -0,0 +1,26 @@ +#ifndef CONSTANTCOMPILATION_H +#define CONSTANTCOMPILATION_H + +#include +#include "Feature.h" + +class ConstantCompilation : public Feature +{ + Q_OBJECT + +public: + ConstantCompilation(QTextDocument* doc); + void start(); + QString title(); + QString tabUrl(); + +private: + QTextDocument* m_editor; + void writeOutPut(bool success, QString content); + +public Q_SLOTS: + void compile(); + +}; + +#endif // CONSTANTCOMPILATION_H diff --git a/mix/ContextualTabs.qml b/mix/ContextualTabs.qml new file mode 100644 index 000000000..d32e6c3af --- /dev/null +++ b/mix/ContextualTabs.qml @@ -0,0 +1,5 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 + + + diff --git a/mix/Feature.cpp b/mix/Feature.cpp new file mode 100644 index 000000000..028dca8bd --- /dev/null +++ b/mix/Feature.cpp @@ -0,0 +1,33 @@ +#include "Feature.h" +#include "ApplicationContext.h" +#include +#include +#include +using namespace dev; + +Feature::Feature() +{ +} + +void Feature::addContentOn(QObject* tabView) { + try{ + if (tabUrl() == "") + return; + + QVariant returnValue; + QQmlComponent* component = new QQmlComponent( + ApplicationContext::GetInstance()->appEngine(), + QUrl(this->tabUrl())); + + QMetaObject::invokeMethod(tabView, "addTab", + Q_RETURN_ARG(QVariant, returnValue), + Q_ARG(QVariant, this->title()), + Q_ARG(QVariant, QVariant::fromValue(component))); + + m_view = qvariant_cast(returnValue); + } + catch (dev::Exception const& exception){ + qDebug() << exception.what(); + } +} + diff --git a/mix/Feature.h b/mix/Feature.h new file mode 100644 index 000000000..5a51f928d --- /dev/null +++ b/mix/Feature.h @@ -0,0 +1,21 @@ +#ifndef FEATURE_H +#define FEATURE_H + +#include +#include + +class Feature : public QObject +{ + Q_OBJECT + +public: + Feature(); + virtual QString tabUrl() { return ""; } + virtual QString title() { return ""; } + void addContentOn(QObject* tabView); + +protected: + QObject* m_view; +}; + +#endif // FEATURE_H diff --git a/mix/MainContent.qml b/mix/MainContent.qml new file mode 100644 index 000000000..d1170b185 --- /dev/null +++ b/mix/MainContent.qml @@ -0,0 +1,47 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.0 +import QtQuick.Controls.Styles 1.2 +import CodeEditorExtensionManager 1.0 + +Rectangle { + anchors.fill: parent + height: parent.height + width: parent.width; + id:root + SplitView { + anchors.fill: parent + orientation: Qt.Vertical + Rectangle { + anchors.top : parent.top + id: contentView + width: parent.width + height: parent.height * 0.7 + TextArea { + id: codeEditor + height: parent.height + font.family: "Verdana" + font.pointSize: 9 + width: parent.width + anchors.centerIn: parent + } + } + Rectangle { + anchors.bottom: parent.bottom + id: contextualView + width: parent.width + Layout.minimumHeight: 20 + height: parent.height * 0.3 + TabView { + id: contextualTabs + antialiasing: true + anchors.fill: parent + style: TabStyle{} + } + } + CodeEditorExtensionManager{ + tabView: contextualTabs + editor: codeEditor + } + } +} diff --git a/mix/Qt47supp.txt b/mix/Qt47supp.txt new file mode 100644 index 000000000..1da4f51bf --- /dev/null +++ b/mix/Qt47supp.txt @@ -0,0 +1,29 @@ +{ + + Memcheck:Cond + fun:_ZN20QSharedMemoryPrivate6detachEv + fun:_ZN13QSharedMemory6detachEv + fun:_ZN13QSharedMemory6setKeyERK7QString + fun:_ZN13QSharedMemoryD1Ev + fun:_ZN20QRasterWindowSurface5flushEP7QWidgetRK7QRegionRK6QPoint + fun:_Z8qt_flushP7QWidgetRK7QRegionP14QWindowSurfaceS0_RK6QPoint + fun:_ZN19QWidgetBackingStore5flushEP7QWidgetP14QWindowSurface + fun:_ZN19QWidgetBackingStore8endPaintERK7QRegionP14QWindowSurfaceP14BeginPaintInfo + fun:_ZN19QWidgetBackingStore4syncEv + fun:_ZN14QWidgetPrivate16syncBackingStoreEv + fun:_ZN7QWidget5eventEP6QEvent + fun:_ZN11QMainWindow5eventEP6QEvent +} +{ + + Memcheck:Leak + fun:_Znwm + fun:_ZN18QtSimulatorPrivate15connectToServerEv + fun:_ZN18QtSimulatorPrivate19SimulatorConnection18connectToSimulatorEv + fun:_ZN18QtSimulatorPrivate19SimulatorConnection8instanceEv + fun:_ZN9QColormap10initializeEv + fun:_Z7qt_initP19QApplicationPrivatei + fun:_ZN19QApplicationPrivate9constructEv + fun:_ZN12QApplicationC1ERiPPci + fun:main +} diff --git a/mix/TabStyle.qml b/mix/TabStyle.qml new file mode 100644 index 000000000..df31f9910 --- /dev/null +++ b/mix/TabStyle.qml @@ -0,0 +1,24 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +TabViewStyle { + frameOverlap: 1 + tabBar: Rectangle { + color: "lightgray" + } + tab: Rectangle { + + color: "lightsteelblue" + implicitWidth: Math.max(text.width + 4, 80) + implicitHeight: 20 + radius: 2 + Text { + id: text + anchors.centerIn: parent + text: styleData.title + color: styleData.selected ? "white" : "black" + } + } + frame: Rectangle { color: "steelblue" } +} diff --git a/mix/main.cpp b/mix/main.cpp new file mode 100644 index 000000000..3aa0cb85a --- /dev/null +++ b/mix/main.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +#include "CodeEditorExtensionMan.h" +#include "ApplicationContext.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QQmlApplicationEngine* engine = new QQmlApplicationEngine(); + qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); + + ApplicationContext::SetApplicationContext(engine); + QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationContext::GetInstance(), SLOT(QuitApplication())); //use to kill ApplicationContext and other stuff + + engine->load(QUrl(QStringLiteral("qrc:/main.qml"))); + return app.exec(); +} + diff --git a/mix/main.qml b/mix/main.qml new file mode 100644 index 000000000..6486c1dfd --- /dev/null +++ b/mix/main.qml @@ -0,0 +1,27 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import CodeEditorExtensionManager 1.0 + +ApplicationWindow { + + visible: true + width: 1000 + height: 480 + minimumWidth: 400 + minimumHeight: 300 + title: qsTr("mix") + + menuBar: MenuBar { + Menu { + title: qsTr("File") + MenuItem { + text: qsTr("Exit") + onTriggered: Qt.quit(); + } + } + } + + MainContent{ + } +} diff --git a/mix/mix.pro b/mix/mix.pro new file mode 100644 index 000000000..6595db37f --- /dev/null +++ b/mix/mix.pro @@ -0,0 +1,19 @@ +TEMPLATE = app + +QT += qml quick widgets + +SOURCES += main.cpp \ + CodeEditorExtensionManager.cpp \ + ConstantCompilation.cpp + +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Default rules for deployment. +include(deployment.pri) + +HEADERS += \ + CodeEditorExtensionManager.h \ + ConstantCompilation.h diff --git a/mix/qml.qrc b/mix/qml.qrc new file mode 100644 index 000000000..65dc7f826 --- /dev/null +++ b/mix/qml.qrc @@ -0,0 +1,8 @@ + + + main.qml + BasicContent.qml + TabStyle.qml + MainContent.qml + + From 4a870cda7b511cd4489532c01e5ec8fe37e5e00e Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 10:04:02 +0100 Subject: [PATCH 02/17] small changes --- CMakeLists.txt | 2 + mix/ApplicationContext.cpp | 33 ----------- mix/ApplicationCtx.cpp | 55 +++++++++++++++++++ ...{ApplicationContext.h => ApplicationCtx.h} | 12 ++-- mix/CodeEditorExtensionMan.cpp | 2 +- mix/ConstantCompilation.cpp | 10 ++-- mix/ConstantCompilation.h | 22 ++++++++ mix/Feature.cpp | 7 ++- mix/Feature.h | 22 ++++++++ mix/MainContent.qml | 7 +++ mix/main.cpp | 28 +++++++++- 11 files changed, 149 insertions(+), 51 deletions(-) delete mode 100644 mix/ApplicationContext.cpp create mode 100644 mix/ApplicationCtx.cpp rename mix/{ApplicationContext.h => ApplicationCtx.h} (57%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8c517fef..e3a7d9b83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,7 @@ if (NOT LANGUAGES) add_subdirectory(libqethereum) add_subdirectory(alethzero) add_subdirectory(third) + add_subdirectory(mix) if(QTQML) #add_subdirectory(iethxi) #add_subdirectory(walleth) // resurect once we want to submit ourselves to QML. @@ -171,3 +172,4 @@ add_test(NAME alltests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testet #unset(TARGET_PLATFORM CACHE) + diff --git a/mix/ApplicationContext.cpp b/mix/ApplicationContext.cpp deleted file mode 100644 index dcbb6d958..000000000 --- a/mix/ApplicationContext.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "ApplicationContext.h" -#include - -ApplicationContext* ApplicationContext::m_instance = nullptr; - -ApplicationContext::ApplicationContext(QQmlApplicationEngine* _engine) -{ - m_applicationEngine = _engine; -} - -ApplicationContext::~ApplicationContext() -{ - delete m_applicationEngine; -} - -ApplicationContext* ApplicationContext::GetInstance() -{ - return m_instance; -} - -void ApplicationContext::SetApplicationContext(QQmlApplicationEngine* engine) -{ - m_instance = new ApplicationContext(engine); -} - -QQmlApplicationEngine* ApplicationContext::appEngine(){ - return m_applicationEngine; -} - -void ApplicationContext::QuitApplication() -{ - delete m_instance; -} diff --git a/mix/ApplicationCtx.cpp b/mix/ApplicationCtx.cpp new file mode 100644 index 000000000..1c8ed9820 --- /dev/null +++ b/mix/ApplicationCtx.cpp @@ -0,0 +1,55 @@ +/* + 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 . +*/ +/** @file main.cpp + * @author Gav Wood + * @date 2014 + * Ethereum client. + */ + +#include "ApplicationCtx.h" +#include + +ApplicationCtx* ApplicationCtx::m_instance = nullptr; + +ApplicationCtx::ApplicationCtx(QQmlApplicationEngine* _engine) +{ + m_applicationEngine = _engine; +} + +ApplicationCtx::~ApplicationCtx() +{ + delete m_applicationEngine; +} + +ApplicationCtx* ApplicationCtx::GetInstance() +{ + return m_instance; +} + +void ApplicationCtx::SetApplicationContext(QQmlApplicationEngine* engine) +{ + m_instance = new ApplicationCtx(engine); +} + +QQmlApplicationEngine* ApplicationCtx::appEngine(){ + return m_applicationEngine; +} + +void ApplicationCtx::QuitApplication() +{ + delete m_instance; +} diff --git a/mix/ApplicationContext.h b/mix/ApplicationCtx.h similarity index 57% rename from mix/ApplicationContext.h rename to mix/ApplicationCtx.h index 154a4120e..f54eb7f09 100644 --- a/mix/ApplicationContext.h +++ b/mix/ApplicationCtx.h @@ -3,21 +3,21 @@ #include -class ApplicationContext : public QObject +class ApplicationCtx : public QObject { Q_OBJECT public: - ApplicationContext(QQmlApplicationEngine*); - ~ApplicationContext(); + ApplicationCtx(QQmlApplicationEngine*); + ~ApplicationCtx(); QQmlApplicationEngine* appEngine(); - static ApplicationContext* GetInstance(); + static ApplicationCtx* GetInstance(); static void SetApplicationContext(QQmlApplicationEngine*); private: - static ApplicationContext* m_instance; + static ApplicationCtx* m_instance; QQmlApplicationEngine* m_applicationEngine; public slots: void QuitApplication(); }; -#endif // APPLICATIONCONTEXT_H +#endif // APPLICATIONCTX_H diff --git a/mix/CodeEditorExtensionMan.cpp b/mix/CodeEditorExtensionMan.cpp index 1c845dbbf..d9691fb42 100644 --- a/mix/CodeEditorExtensionMan.cpp +++ b/mix/CodeEditorExtensionMan.cpp @@ -8,7 +8,7 @@ #include "CodeEditorExtensionMan.h" #include "ConstantCompilation.h" #include "features.h" -#include "ApplicationContext.h" +#include "ApplicationCtx.h" #include using namespace dev; diff --git a/mix/ConstantCompilation.cpp b/mix/ConstantCompilation.cpp index 76fbd1546..8a2d14af9 100644 --- a/mix/ConstantCompilation.cpp +++ b/mix/ConstantCompilation.cpp @@ -29,7 +29,7 @@ void ConstantCompilation::start() QString ConstantCompilation::title() { - return "compilation"; + return "compiler"; } void ConstantCompilation::compile() @@ -60,8 +60,8 @@ void ConstantCompilation::compile() content = "Uncaught exception."; this->writeOutPut(false, content); } - } + void ConstantCompilation::writeOutPut(bool _success, QString _content){ QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); @@ -70,13 +70,13 @@ void ConstantCompilation::writeOutPut(bool _success, QString _content){ content->setProperty("text", ""); } else if (_success){ - status->setProperty("text", "compile successfull"); + status->setProperty("text", "succeeded"); status->setProperty("color", "green"); content->setProperty("text", _content); - qDebug() << QString("compile suceeded " + _content); + qDebug() << QString("compile succeeded " + _content); } else { - status->setProperty("text", "compile failed"); + status->setProperty("text", "failure"); status->setProperty("color", "red"); content->setProperty("text", _content); qDebug() << QString("compile failed " + _content); diff --git a/mix/ConstantCompilation.h b/mix/ConstantCompilation.h index c3c93b8aa..ed99c6a5f 100644 --- a/mix/ConstantCompilation.h +++ b/mix/ConstantCompilation.h @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file ConstantCompilation.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #ifndef CONSTANTCOMPILATION_H #define CONSTANTCOMPILATION_H diff --git a/mix/Feature.cpp b/mix/Feature.cpp index 028dca8bd..f3239252f 100644 --- a/mix/Feature.cpp +++ b/mix/Feature.cpp @@ -1,5 +1,5 @@ #include "Feature.h" -#include "ApplicationContext.h" +#include "ApplicationCtx.h" #include #include #include @@ -16,8 +16,8 @@ void Feature::addContentOn(QObject* tabView) { QVariant returnValue; QQmlComponent* component = new QQmlComponent( - ApplicationContext::GetInstance()->appEngine(), - QUrl(this->tabUrl())); + ApplicationCtx::GetInstance()->appEngine(), + QUrl(this->tabUrl()), tabView); QMetaObject::invokeMethod(tabView, "addTab", Q_RETURN_ARG(QVariant, returnValue), @@ -25,6 +25,7 @@ void Feature::addContentOn(QObject* tabView) { Q_ARG(QVariant, QVariant::fromValue(component))); m_view = qvariant_cast(returnValue); + } catch (dev::Exception const& exception){ qDebug() << exception.what(); diff --git a/mix/Feature.h b/mix/Feature.h index 5a51f928d..7a53f3a44 100644 --- a/mix/Feature.h +++ b/mix/Feature.h @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file Feature.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #ifndef FEATURE_H #define FEATURE_H diff --git a/mix/MainContent.qml b/mix/MainContent.qml index d1170b185..abae4a37f 100644 --- a/mix/MainContent.qml +++ b/mix/MainContent.qml @@ -24,6 +24,13 @@ Rectangle { font.pointSize: 9 width: parent.width anchors.centerIn: parent + tabChangesFocus: false + Keys.onPressed: { + if (event.key === Qt.Key_Tab) { + codeEditor.insert(codeEditor.cursorPosition, "\t"); + event.accepted = true; + } + } } } Rectangle { diff --git a/mix/main.cpp b/mix/main.cpp index 3aa0cb85a..088830c3c 100644 --- a/mix/main.cpp +++ b/mix/main.cpp @@ -1,8 +1,30 @@ +/* + 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 . +*/ +/** @file main.cpp + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #include #include #include #include "CodeEditorExtensionMan.h" -#include "ApplicationContext.h" +#include "ApplicationCtx.h" int main(int argc, char *argv[]) { @@ -10,8 +32,8 @@ int main(int argc, char *argv[]) QQmlApplicationEngine* engine = new QQmlApplicationEngine(); qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); - ApplicationContext::SetApplicationContext(engine); - QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationContext::GetInstance(), SLOT(QuitApplication())); //use to kill ApplicationContext and other stuff + ApplicationCtx::SetApplicationContext(engine); + QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::GetInstance(), SLOT(QuitApplication())); //use to kill ApplicationContext and other stuff engine->load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); From 860259c2a58e43ee96dfdc8a7ba9e08700166e1a Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 10:05:46 +0100 Subject: [PATCH 03/17] delete unused file --- mix/Qt47supp.txt | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 mix/Qt47supp.txt diff --git a/mix/Qt47supp.txt b/mix/Qt47supp.txt deleted file mode 100644 index 1da4f51bf..000000000 --- a/mix/Qt47supp.txt +++ /dev/null @@ -1,29 +0,0 @@ -{ - - Memcheck:Cond - fun:_ZN20QSharedMemoryPrivate6detachEv - fun:_ZN13QSharedMemory6detachEv - fun:_ZN13QSharedMemory6setKeyERK7QString - fun:_ZN13QSharedMemoryD1Ev - fun:_ZN20QRasterWindowSurface5flushEP7QWidgetRK7QRegionRK6QPoint - fun:_Z8qt_flushP7QWidgetRK7QRegionP14QWindowSurfaceS0_RK6QPoint - fun:_ZN19QWidgetBackingStore5flushEP7QWidgetP14QWindowSurface - fun:_ZN19QWidgetBackingStore8endPaintERK7QRegionP14QWindowSurfaceP14BeginPaintInfo - fun:_ZN19QWidgetBackingStore4syncEv - fun:_ZN14QWidgetPrivate16syncBackingStoreEv - fun:_ZN7QWidget5eventEP6QEvent - fun:_ZN11QMainWindow5eventEP6QEvent -} -{ - - Memcheck:Leak - fun:_Znwm - fun:_ZN18QtSimulatorPrivate15connectToServerEv - fun:_ZN18QtSimulatorPrivate19SimulatorConnection18connectToSimulatorEv - fun:_ZN18QtSimulatorPrivate19SimulatorConnection8instanceEv - fun:_ZN9QColormap10initializeEv - fun:_Z7qt_initP19QApplicationPrivatei - fun:_ZN19QApplicationPrivate9constructEv - fun:_ZN12QApplicationC1ERiPPci - fun:main -} From 2b2b1f1701e99b333f551df22200f2fa1811b809 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 10:10:05 +0100 Subject: [PATCH 04/17] misc --- mix/ApplicationCtx.cpp | 6 +++--- mix/ApplicationCtx.h | 22 ++++++++++++++++++++++ mix/CodeEditorExtensionMan.cpp | 22 ++++++++++++++++++++++ mix/CodeEditorExtensionMan.h | 22 ++++++++++++++++++++++ mix/ConstantCompilation.cpp | 22 ++++++++++++++++++++++ mix/Feature.cpp | 22 ++++++++++++++++++++++ 6 files changed, 113 insertions(+), 3 deletions(-) diff --git a/mix/ApplicationCtx.cpp b/mix/ApplicationCtx.cpp index 1c8ed9820..7475c1b57 100644 --- a/mix/ApplicationCtx.cpp +++ b/mix/ApplicationCtx.cpp @@ -14,10 +14,10 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file main.cpp - * @author Gav Wood +/** @file ApplicationCtx.cpp + * @author Yann yann@ethdev.com * @date 2014 - * Ethereum client. + * Ethereum IDE client. */ #include "ApplicationCtx.h" diff --git a/mix/ApplicationCtx.h b/mix/ApplicationCtx.h index f54eb7f09..68806cc33 100644 --- a/mix/ApplicationCtx.h +++ b/mix/ApplicationCtx.h @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file ApplicationCtx.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #ifndef APPLICATIONCONTEXT_H #define APPLICATIONCONTEXT_H diff --git a/mix/CodeEditorExtensionMan.cpp b/mix/CodeEditorExtensionMan.cpp index d9691fb42..d1ad6c075 100644 --- a/mix/CodeEditorExtensionMan.cpp +++ b/mix/CodeEditorExtensionMan.cpp @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file CodeEditorExtensionMan.cpp + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #include #include #include diff --git a/mix/CodeEditorExtensionMan.h b/mix/CodeEditorExtensionMan.h index cfe505c09..32f435338 100644 --- a/mix/CodeEditorExtensionMan.h +++ b/mix/CodeEditorExtensionMan.h @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file CodeEditorExtensionMan.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #ifndef CODEEDITOREXTENSIONMANAGER_H #define CODEEDITOREXTENSIONMANAGER_H diff --git a/mix/ConstantCompilation.cpp b/mix/ConstantCompilation.cpp index 8a2d14af9..34f5b3967 100644 --- a/mix/ConstantCompilation.cpp +++ b/mix/ConstantCompilation.cpp @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file ConstantCompilation.cpp + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #include "ConstantCompilation.h" #include #include diff --git a/mix/Feature.cpp b/mix/Feature.cpp index f3239252f..309cf7eff 100644 --- a/mix/Feature.cpp +++ b/mix/Feature.cpp @@ -1,3 +1,25 @@ +/* + 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 . +*/ +/** @file Feature.cpp + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #include "Feature.h" #include "ApplicationCtx.h" #include From 37b9f56d305f867ccc3bc5d460b451be67022430 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 10:12:11 +0100 Subject: [PATCH 05/17] gitignore --- mix/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 mix/.gitignore diff --git a/mix/.gitignore b/mix/.gitignore new file mode 100644 index 000000000..f96209dc3 --- /dev/null +++ b/mix/.gitignore @@ -0,0 +1 @@ +*.pro From c97e7199a7d133fb7b31b9e148a813881548e0f7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 10:18:48 +0100 Subject: [PATCH 06/17] delete pro file --- mix/mix.pro | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 mix/mix.pro diff --git a/mix/mix.pro b/mix/mix.pro deleted file mode 100644 index 6595db37f..000000000 --- a/mix/mix.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app - -QT += qml quick widgets - -SOURCES += main.cpp \ - CodeEditorExtensionManager.cpp \ - ConstantCompilation.cpp - -RESOURCES += qml.qrc - -# Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH = - -# Default rules for deployment. -include(deployment.pri) - -HEADERS += \ - CodeEditorExtensionManager.h \ - ConstantCompilation.h From e79d5709d0fae8011349b927fbf22d4ffdcec44c Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 10:25:25 +0100 Subject: [PATCH 07/17] put qml file in folder --- mix/ConstantCompilation.cpp | 2 +- mix/ContextualTabs.qml | 5 ----- mix/main.cpp | 2 +- mix/qml.qrc | 8 ++++---- mix/{ => qml}/BasicContent.qml | 0 mix/{ => qml}/MainContent.qml | 0 mix/{ => qml}/TabStyle.qml | 0 mix/{ => qml}/main.qml | 0 8 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 mix/ContextualTabs.qml rename mix/{ => qml}/BasicContent.qml (100%) rename mix/{ => qml}/MainContent.qml (100%) rename mix/{ => qml}/TabStyle.qml (100%) rename mix/{ => qml}/main.qml (100%) diff --git a/mix/ConstantCompilation.cpp b/mix/ConstantCompilation.cpp index 34f5b3967..72e7b2bfe 100644 --- a/mix/ConstantCompilation.cpp +++ b/mix/ConstantCompilation.cpp @@ -41,7 +41,7 @@ ConstantCompilation::ConstantCompilation(QTextDocument* _doc) } QString ConstantCompilation::tabUrl(){ - return QStringLiteral("qrc:/BasicContent.qml"); + return QStringLiteral("qrc:/qml/BasicContent.qml"); } void ConstantCompilation::start() diff --git a/mix/ContextualTabs.qml b/mix/ContextualTabs.qml deleted file mode 100644 index d32e6c3af..000000000 --- a/mix/ContextualTabs.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 - - - diff --git a/mix/main.cpp b/mix/main.cpp index 088830c3c..49b6e5195 100644 --- a/mix/main.cpp +++ b/mix/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) ApplicationCtx::SetApplicationContext(engine); QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::GetInstance(), SLOT(QuitApplication())); //use to kill ApplicationContext and other stuff - engine->load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); return app.exec(); } diff --git a/mix/qml.qrc b/mix/qml.qrc index 65dc7f826..267427ce5 100644 --- a/mix/qml.qrc +++ b/mix/qml.qrc @@ -1,8 +1,8 @@ - main.qml - BasicContent.qml - TabStyle.qml - MainContent.qml + qml/BasicContent.qml + qml/main.qml + qml/MainContent.qml + qml/TabStyle.qml diff --git a/mix/BasicContent.qml b/mix/qml/BasicContent.qml similarity index 100% rename from mix/BasicContent.qml rename to mix/qml/BasicContent.qml diff --git a/mix/MainContent.qml b/mix/qml/MainContent.qml similarity index 100% rename from mix/MainContent.qml rename to mix/qml/MainContent.qml diff --git a/mix/TabStyle.qml b/mix/qml/TabStyle.qml similarity index 100% rename from mix/TabStyle.qml rename to mix/qml/TabStyle.qml diff --git a/mix/main.qml b/mix/qml/main.qml similarity index 100% rename from mix/main.qml rename to mix/qml/main.qml From d97c0b51413ae2dd4e0cc528835d45d7fdb4c4a6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 11:04:44 +0100 Subject: [PATCH 08/17] misc --- mix/CMakeLists.txt | 2 +- mix/CodeEditorExtensionMan.cpp | 16 ++++++++++++---- mix/CodeEditorExtensionMan.h | 9 ++++++--- mix/ConstantCompilation.cpp | 11 ++++++----- mix/ConstantCompilation.h | 6 +++--- mix/Feature.cpp | 1 - mix/Feature.h | 1 + 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 7272c4d99..6bcb76704 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -10,7 +10,7 @@ elseif ("${TARGET_PLATFORM}" STREQUAL "w64") set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) elseif (UNIX) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake" /opt/Qt5.3.2/5.3/gcc_64/lib/cmake/Qt5Declarative) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") endif () find_package(Qt5Core REQUIRED) diff --git a/mix/CodeEditorExtensionMan.cpp b/mix/CodeEditorExtensionMan.cpp index d1ad6c075..6e2c72c7f 100644 --- a/mix/CodeEditorExtensionMan.cpp +++ b/mix/CodeEditorExtensionMan.cpp @@ -38,6 +38,13 @@ CodeEditorExtensionManager::CodeEditorExtensionManager() { } +CodeEditorExtensionManager::~CodeEditorExtensionManager() +{ + for (int k = 0; k < m_features.length(); k++){ + delete m_features.at(k); + } +} + void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) { if (!_editor) @@ -61,10 +68,11 @@ void CodeEditorExtensionManager::initExtensions() { try{ //only one for now - ConstantCompilation* compil = new ConstantCompilation(m_doc); - if (compil->tabUrl() != "") - compil->addContentOn(m_tabView); - compil->start(); + ConstantCompilation* m_constantCompilation = new ConstantCompilation(m_doc); + if (m_constantCompilation->tabUrl() != "") + m_constantCompilation->addContentOn(m_tabView); + m_constantCompilation->start(); + m_features.append(m_constantCompilation); } catch (dev::Exception const& exception){ qDebug() << "unable to load extensions: "; diff --git a/mix/CodeEditorExtensionMan.h b/mix/CodeEditorExtensionMan.h index 32f435338..306392254 100644 --- a/mix/CodeEditorExtensionMan.h +++ b/mix/CodeEditorExtensionMan.h @@ -20,11 +20,12 @@ * Ethereum IDE client. */ -#ifndef CODEEDITOREXTENSIONMANAGER_H -#define CODEEDITOREXTENSIONMANAGER_H +#ifndef CODEEDITOREXTENSIONMAN_H +#define CODEEDITOREXTENSIONMAN_H #include #include +#include #include "Feature.h" class CodeEditorExtensionManager : public QObject @@ -36,15 +37,17 @@ class CodeEditorExtensionManager : public QObject public: CodeEditorExtensionManager(); + ~CodeEditorExtensionManager(); void initExtensions(); void setEditor(QQuickItem*); void setTabView(QQuickItem*); private: QQuickItem* m_editor; + QVector m_features; QQuickItem* m_tabView; QTextDocument* m_doc; void loadEditor(QQuickItem*); }; -#endif // CODEEDITOREXTENSIONMANAGER_H +#endif // CODEEDITOREXTENSIONMAN_H diff --git a/mix/ConstantCompilation.cpp b/mix/ConstantCompilation.cpp index 72e7b2bfe..3ed687177 100644 --- a/mix/ConstantCompilation.cpp +++ b/mix/ConstantCompilation.cpp @@ -40,18 +40,19 @@ ConstantCompilation::ConstantCompilation(QTextDocument* _doc) m_editor = _doc; } -QString ConstantCompilation::tabUrl(){ +QString ConstantCompilation::tabUrl() +{ return QStringLiteral("qrc:/qml/BasicContent.qml"); } -void ConstantCompilation::start() +QString ConstantCompilation::title() { - connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); + return "compiler"; } -QString ConstantCompilation::title() +void ConstantCompilation::start() { - return "compiler"; + connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); } void ConstantCompilation::compile() diff --git a/mix/ConstantCompilation.h b/mix/ConstantCompilation.h index ed99c6a5f..974277d2a 100644 --- a/mix/ConstantCompilation.h +++ b/mix/ConstantCompilation.h @@ -32,9 +32,9 @@ class ConstantCompilation : public Feature public: ConstantCompilation(QTextDocument* doc); - void start(); - QString title(); - QString tabUrl(); + void start() override; + QString title() override; + QString tabUrl() override; private: QTextDocument* m_editor; diff --git a/mix/Feature.cpp b/mix/Feature.cpp index 309cf7eff..747b538d8 100644 --- a/mix/Feature.cpp +++ b/mix/Feature.cpp @@ -47,7 +47,6 @@ void Feature::addContentOn(QObject* tabView) { Q_ARG(QVariant, QVariant::fromValue(component))); m_view = qvariant_cast(returnValue); - } catch (dev::Exception const& exception){ qDebug() << exception.what(); diff --git a/mix/Feature.h b/mix/Feature.h index 7a53f3a44..d5cee7e74 100644 --- a/mix/Feature.h +++ b/mix/Feature.h @@ -34,6 +34,7 @@ public: Feature(); virtual QString tabUrl() { return ""; } virtual QString title() { return ""; } + virtual void start() {} void addContentOn(QObject* tabView); protected: From f6dfd4ac963687c1297355518f3d18a6f5607e89 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Nov 2014 12:16:45 +0100 Subject: [PATCH 09/17] add ConstantCompilationModel --- mix/CMakeLists.txt | 1 + mix/CodeEditorExtensionMan.cpp | 14 ++-- mix/CodeEditorExtensionMan.h | 6 +- ...lation.cpp => ConstantCompilationCtrl.cpp} | 68 ++++++++----------- ...ompilation.h => ConstantCompilationCtrl.h} | 6 +- mix/ConstantCompilationModel.cpp | 44 ++++++++++++ mix/ConstantCompilationModel.h | 19 ++++++ mix/main.cpp | 2 +- 8 files changed, 107 insertions(+), 53 deletions(-) rename mix/{ConstantCompilation.cpp => ConstantCompilationCtrl.cpp} (55%) rename mix/{ConstantCompilation.h => ConstantCompilationCtrl.h} (87%) create mode 100644 mix/ConstantCompilationModel.cpp create mode 100644 mix/ConstantCompilationModel.h diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 6bcb76704..28fbc7342 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -2,6 +2,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) aux_source_directory(. SRC_LIST) include_directories(..) + if (APPLE) # Add homebrew path for qt5 set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) diff --git a/mix/CodeEditorExtensionMan.cpp b/mix/CodeEditorExtensionMan.cpp index 6e2c72c7f..39473af84 100644 --- a/mix/CodeEditorExtensionMan.cpp +++ b/mix/CodeEditorExtensionMan.cpp @@ -28,24 +28,24 @@ #include #include #include "CodeEditorExtensionMan.h" -#include "ConstantCompilation.h" +#include "ConstantCompilationCtrl.h" #include "features.h" #include "ApplicationCtx.h" #include using namespace dev; -CodeEditorExtensionManager::CodeEditorExtensionManager() +CodeEditorExtensionMan::CodeEditorExtensionMan() { } -CodeEditorExtensionManager::~CodeEditorExtensionManager() +CodeEditorExtensionMan::~CodeEditorExtensionMan() { for (int k = 0; k < m_features.length(); k++){ delete m_features.at(k); } } -void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) +void CodeEditorExtensionMan::loadEditor(QQuickItem* _editor) { if (!_editor) return; @@ -64,7 +64,7 @@ void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) } } -void CodeEditorExtensionManager::initExtensions() +void CodeEditorExtensionMan::initExtensions() { try{ //only one for now @@ -80,11 +80,11 @@ void CodeEditorExtensionManager::initExtensions() } } -void CodeEditorExtensionManager::setEditor(QQuickItem* _editor){ +void CodeEditorExtensionMan::setEditor(QQuickItem* _editor){ this->loadEditor(_editor); this->initExtensions(); } -void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView){ +void CodeEditorExtensionMan::setTabView(QQuickItem* _tabView){ m_tabView = _tabView; } diff --git a/mix/CodeEditorExtensionMan.h b/mix/CodeEditorExtensionMan.h index 306392254..b3c99c3df 100644 --- a/mix/CodeEditorExtensionMan.h +++ b/mix/CodeEditorExtensionMan.h @@ -28,7 +28,7 @@ #include #include "Feature.h" -class CodeEditorExtensionManager : public QObject +class CodeEditorExtensionMan : public QObject { Q_OBJECT @@ -36,8 +36,8 @@ class CodeEditorExtensionManager : public QObject Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) public: - CodeEditorExtensionManager(); - ~CodeEditorExtensionManager(); + CodeEditorExtensionMan(); + ~CodeEditorExtensionMan(); void initExtensions(); void setEditor(QQuickItem*); void setTabView(QQuickItem*); diff --git a/mix/ConstantCompilation.cpp b/mix/ConstantCompilationCtrl.cpp similarity index 55% rename from mix/ConstantCompilation.cpp rename to mix/ConstantCompilationCtrl.cpp index 3ed687177..69f493a98 100644 --- a/mix/ConstantCompilation.cpp +++ b/mix/ConstantCompilationCtrl.cpp @@ -20,24 +20,24 @@ * Ethereum IDE client. */ -#include "ConstantCompilation.h" +#include "ConstantCompilationCtrl.h" +#include "ConstantCompilationModel.h" #include #include #include #include #include #include -#include -#include -#include -#include -using namespace std; -using namespace dev; -using namespace dev::eth; ConstantCompilation::ConstantCompilation(QTextDocument* _doc) { m_editor = _doc; + compilationModel = new ConstantCompilationModel(); +} + +ConstantCompilation::~ConstantCompilation() +{ + delete compilationModel; } QString ConstantCompilation::tabUrl() @@ -57,52 +57,38 @@ void ConstantCompilation::start() void ConstantCompilation::compile() { - QString codeContent = m_editor->toPlainText(); + QString codeContent = m_editor->toPlainText().replace("\n", ""); if (codeContent == ""){ - this->writeOutPut(true, codeContent); + resetOutPut(); return; } - dev::solidity::CompilerStack compiler; - dev::bytes m_data; - QString content; - try - { - m_data = compiler.compile(codeContent.toStdString(), true); - content = QString::fromStdString(dev::eth::disassemble(m_data)); - this->writeOutPut(true, content); - } - catch (dev::Exception const& exception) - { - ostringstream error; - solidity::SourceReferenceFormatter::printExceptionInformation(error, exception, "Error", compiler.getScanner()); - content = QString::fromStdString(error.str()).toHtmlEscaped(); - this->writeOutPut(false, content); - } - catch (...) - { - content = "Uncaught exception."; - this->writeOutPut(false, content); - } + compilerResult res = compilationModel->compile(m_editor->toPlainText()); + writeOutPut(res); } -void ConstantCompilation::writeOutPut(bool _success, QString _content){ +void ConstantCompilation::resetOutPut() +{ QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); - if (_content == ""){ - status->setProperty("text", ""); - content->setProperty("text", ""); - } - else if (_success){ + status->setProperty("text", ""); + content->setProperty("text", ""); +} + +void ConstantCompilation::writeOutPut(compilerResult res) +{ + QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); + QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); + if (res.success){ status->setProperty("text", "succeeded"); status->setProperty("color", "green"); - content->setProperty("text", _content); - qDebug() << QString("compile succeeded " + _content); + content->setProperty("text", res.hexCode); + qDebug() << QString("compile succeeded " + res.hexCode); } else { status->setProperty("text", "failure"); status->setProperty("color", "red"); - content->setProperty("text", _content); - qDebug() << QString("compile failed " + _content); + content->setProperty("text", res.comment); + qDebug() << QString("compile failed " + res.comment); } } diff --git a/mix/ConstantCompilation.h b/mix/ConstantCompilationCtrl.h similarity index 87% rename from mix/ConstantCompilation.h rename to mix/ConstantCompilationCtrl.h index 974277d2a..193c8db77 100644 --- a/mix/ConstantCompilation.h +++ b/mix/ConstantCompilationCtrl.h @@ -24,6 +24,7 @@ #define CONSTANTCOMPILATION_H #include +#include "ConstantCompilationModel.h" #include "Feature.h" class ConstantCompilation : public Feature @@ -32,13 +33,16 @@ class ConstantCompilation : public Feature public: ConstantCompilation(QTextDocument* doc); + ~ConstantCompilation(); void start() override; QString title() override; QString tabUrl() override; private: QTextDocument* m_editor; - void writeOutPut(bool success, QString content); + ConstantCompilationModel* compilationModel; + void writeOutPut(compilerResult); + void resetOutPut(); public Q_SLOTS: void compile(); diff --git a/mix/ConstantCompilationModel.cpp b/mix/ConstantCompilationModel.cpp new file mode 100644 index 000000000..1801bc854 --- /dev/null +++ b/mix/ConstantCompilationModel.cpp @@ -0,0 +1,44 @@ +#include "ConstantCompilationModel.h" +#include +#include +#include +#include +#include +using namespace std; +using namespace dev; +using namespace dev::eth; + +ConstantCompilationModel::ConstantCompilationModel() +{ +} + +compilerResult ConstantCompilationModel::compile(QString code) +{ + dev::solidity::CompilerStack compiler; + dev::bytes m_data; + compilerResult res; + try + { + m_data = compiler.compile(code.toStdString(), true); + res.success = true; + res.comment = "ok"; + res.hexCode = QString::fromStdString(dev::eth::disassemble(m_data)); + + } + catch (dev::Exception const& exception) + { + ostringstream error; + solidity::SourceReferenceFormatter::printExceptionInformation(error, exception, "Error", compiler.getScanner()); + res.success = false; + res.comment = QString::fromStdString(error.str()).toHtmlEscaped(); + res.hexCode = ""; + } + catch (...) + { + res.success = false; + res.comment = "Uncaught exception."; + res.hexCode = ""; + } + return res; +} + diff --git a/mix/ConstantCompilationModel.h b/mix/ConstantCompilationModel.h new file mode 100644 index 000000000..fb1f18e1c --- /dev/null +++ b/mix/ConstantCompilationModel.h @@ -0,0 +1,19 @@ +#ifndef CONSTANTCOMPILATIONMODEL_H +#define CONSTANTCOMPILATIONMODEL_H +#include + +struct compilerResult{ + QString hexCode; + QString comment; + bool success; +}; + +class ConstantCompilationModel +{ + +public: + ConstantCompilationModel(); + compilerResult compile(QString code); +}; + +#endif // CONSTANTCOMPILATIONMODEL_H diff --git a/mix/main.cpp b/mix/main.cpp index 49b6e5195..e1aa5d9a5 100644 --- a/mix/main.cpp +++ b/mix/main.cpp @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine* engine = new QQmlApplicationEngine(); - qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); + qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); ApplicationCtx::SetApplicationContext(engine); QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::GetInstance(), SLOT(QuitApplication())); //use to kill ApplicationContext and other stuff From 0a496d772546bc46d8ad24a51cc11a1079ea55ae Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 21 Nov 2014 16:18:09 +0100 Subject: [PATCH 10/17] - ApplicationCtx.h: refactor of singleton (put inline code in *.h). - Coding standards (#pragma once, ...). - CodeEditorExtensionManager.cpp: replace normal pointer by shared_ptr. - Add namespace dev::mix. - MixApplication: will be used to catch exception (not used now). --- mix/ApplicationCtx.cpp | 37 ++--------- mix/ApplicationCtx.h | 30 ++++++--- ...Man.cpp => CodeEditorExtensionManager.cpp} | 66 ++++++++++--------- ...sionMan.h => CodeEditorExtensionManager.h} | 24 ++++--- mix/ConstantCompilationCtrl.cpp | 48 +++++++------- mix/ConstantCompilationCtrl.h | 35 +++++----- mix/ConstantCompilationModel.cpp | 41 ++++++++---- mix/ConstantCompilationModel.h | 44 +++++++++++-- mix/{Feature.cpp => Extension.cpp} | 43 +++++------- mix/{Feature.h => Extension.h} | 26 ++++---- mix/MixApplication.cpp | 42 ++++++++++++ mix/MixApplication.h | 46 +++++++++++++ mix/main.cpp | 17 +++-- mix/qml/BasicContent.qml | 1 + mix/qml/MainContent.qml | 2 +- mix/qml/TabStyle.qml | 1 - mix/qml/main.qml | 1 - 17 files changed, 315 insertions(+), 189 deletions(-) rename mix/{CodeEditorExtensionMan.cpp => CodeEditorExtensionManager.cpp} (57%) rename mix/{CodeEditorExtensionMan.h => CodeEditorExtensionManager.h} (81%) rename mix/{Feature.cpp => Extension.cpp} (54%) rename mix/{Feature.h => Extension.h} (79%) create mode 100644 mix/MixApplication.cpp create mode 100644 mix/MixApplication.h diff --git a/mix/ApplicationCtx.cpp b/mix/ApplicationCtx.cpp index 7475c1b57..8ea8bd8d8 100644 --- a/mix/ApplicationCtx.cpp +++ b/mix/ApplicationCtx.cpp @@ -1,55 +1,30 @@ /* 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 . */ /** @file ApplicationCtx.cpp * @author Yann yann@ethdev.com * @date 2014 - * Ethereum IDE client. + * Provide an access to the current QQmlApplicationEngine which is used to add QML file on the fly. + * In the future this class can be extended to add more variable related to the context of the application. */ -#include "ApplicationCtx.h" #include +#include "ApplicationCtx.h" +using namespace dev::mix; -ApplicationCtx* ApplicationCtx::m_instance = nullptr; - -ApplicationCtx::ApplicationCtx(QQmlApplicationEngine* _engine) -{ - m_applicationEngine = _engine; -} - -ApplicationCtx::~ApplicationCtx() -{ - delete m_applicationEngine; -} - -ApplicationCtx* ApplicationCtx::GetInstance() -{ - return m_instance; -} +ApplicationCtx* ApplicationCtx::Instance = nullptr; -void ApplicationCtx::SetApplicationContext(QQmlApplicationEngine* engine) +QQmlApplicationEngine* ApplicationCtx::appEngine() { - m_instance = new ApplicationCtx(engine); -} - -QQmlApplicationEngine* ApplicationCtx::appEngine(){ return m_applicationEngine; } - -void ApplicationCtx::QuitApplication() -{ - delete m_instance; -} diff --git a/mix/ApplicationCtx.h b/mix/ApplicationCtx.h index 68806cc33..32e2bd3f1 100644 --- a/mix/ApplicationCtx.h +++ b/mix/ApplicationCtx.h @@ -17,29 +17,39 @@ /** @file ApplicationCtx.h * @author Yann yann@ethdev.com * @date 2014 - * Ethereum IDE client. + * Provide an access to the current QQmlApplicationEngine which is used to add QML file on the fly. + * In the future this class can be extended to add more variable related to the context of the application. */ -#ifndef APPLICATIONCONTEXT_H -#define APPLICATIONCONTEXT_H +#pragma once #include +namespace dev +{ + +namespace mix +{ + class ApplicationCtx : public QObject { Q_OBJECT public: - ApplicationCtx(QQmlApplicationEngine*); - ~ApplicationCtx(); + ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; } + ~ApplicationCtx() { delete m_applicationEngine; } + static ApplicationCtx* getInstance() { return Instance; } + static void setApplicationContext(QQmlApplicationEngine* _engine) { Instance = new ApplicationCtx(_engine); } QQmlApplicationEngine* appEngine(); - static ApplicationCtx* GetInstance(); - static void SetApplicationContext(QQmlApplicationEngine*); + private: - static ApplicationCtx* m_instance; + static ApplicationCtx* Instance; QQmlApplicationEngine* m_applicationEngine; + public slots: - void QuitApplication(); + void quitApplication() { delete Instance; } }; -#endif // APPLICATIONCTX_H +} + +} diff --git a/mix/CodeEditorExtensionMan.cpp b/mix/CodeEditorExtensionManager.cpp similarity index 57% rename from mix/CodeEditorExtensionMan.cpp rename to mix/CodeEditorExtensionManager.cpp index 39473af84..316c37ee0 100644 --- a/mix/CodeEditorExtensionMan.cpp +++ b/mix/CodeEditorExtensionManager.cpp @@ -27,64 +27,66 @@ #include #include #include -#include "CodeEditorExtensionMan.h" +#include #include "ConstantCompilationCtrl.h" #include "features.h" #include "ApplicationCtx.h" -#include -using namespace dev; +#include "CodeEditorExtensionManager.h" +using namespace dev::mix; -CodeEditorExtensionMan::CodeEditorExtensionMan() -{ -} - -CodeEditorExtensionMan::~CodeEditorExtensionMan() +CodeEditorExtensionManager::~CodeEditorExtensionManager() { - for (int k = 0; k < m_features.length(); k++){ - delete m_features.at(k); - } + m_features.clear(); } -void CodeEditorExtensionMan::loadEditor(QQuickItem* _editor) +void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) { if (!_editor) return; - try{ + try + { QVariant doc = _editor->property("textDocument"); - if (doc.canConvert()) { + if (doc.canConvert()) + { QQuickTextDocument* qqdoc = doc.value(); - if (qqdoc) { + if (qqdoc) m_doc = qqdoc->textDocument(); - } } } - catch (dev::Exception const& exception){ + catch (...) + { qDebug() << "unable to load editor: "; - qDebug() << exception.what(); } } -void CodeEditorExtensionMan::initExtensions() +void CodeEditorExtensionManager::initExtensions() { - try{ - //only one for now - ConstantCompilation* m_constantCompilation = new ConstantCompilation(m_doc); - if (m_constantCompilation->tabUrl() != "") - m_constantCompilation->addContentOn(m_tabView); - m_constantCompilation->start(); - m_features.append(m_constantCompilation); - } - catch (dev::Exception const& exception){ - qDebug() << "unable to load extensions: "; - qDebug() << exception.what(); + //only one for now + std::shared_ptr m_constantCompilation(new ConstantCompilationCtrl(m_doc)); + ConstantCompilationCtrl* ext = m_constantCompilation.get(); + if (ext->contentUrl() != "") + { + try + { + ext->addContentOn(m_tabView); + } + catch (...) + { + qDebug() << "Exception when adding content into view."; + return; + } } + ext->start(); + m_features.append(m_constantCompilation); } -void CodeEditorExtensionMan::setEditor(QQuickItem* _editor){ +void CodeEditorExtensionManager::setEditor(QQuickItem* _editor) +{ this->loadEditor(_editor); this->initExtensions(); } -void CodeEditorExtensionMan::setTabView(QQuickItem* _tabView){ +void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView) +{ m_tabView = _tabView; } diff --git a/mix/CodeEditorExtensionMan.h b/mix/CodeEditorExtensionManager.h similarity index 81% rename from mix/CodeEditorExtensionMan.h rename to mix/CodeEditorExtensionManager.h index b3c99c3df..c368a9714 100644 --- a/mix/CodeEditorExtensionMan.h +++ b/mix/CodeEditorExtensionManager.h @@ -20,15 +20,21 @@ * Ethereum IDE client. */ -#ifndef CODEEDITOREXTENSIONMAN_H -#define CODEEDITOREXTENSIONMAN_H +#pragma once +#include "memory" #include #include #include -#include "Feature.h" +#include "ConstantCompilationCtrl.h" -class CodeEditorExtensionMan : public QObject +namespace dev +{ + +namespace mix +{ + +class CodeEditorExtensionManager : public QObject { Q_OBJECT @@ -36,18 +42,20 @@ class CodeEditorExtensionMan : public QObject Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) public: - CodeEditorExtensionMan(); - ~CodeEditorExtensionMan(); + CodeEditorExtensionManager() {} + ~CodeEditorExtensionManager(); void initExtensions(); void setEditor(QQuickItem*); void setTabView(QQuickItem*); private: QQuickItem* m_editor; - QVector m_features; + QVector> m_features; QQuickItem* m_tabView; QTextDocument* m_doc; void loadEditor(QQuickItem*); }; -#endif // CODEEDITOREXTENSIONMAN_H +} + +} diff --git a/mix/ConstantCompilationCtrl.cpp b/mix/ConstantCompilationCtrl.cpp index 69f493a98..0f73da781 100644 --- a/mix/ConstantCompilationCtrl.cpp +++ b/mix/ConstantCompilationCtrl.cpp @@ -20,53 +20,55 @@ * Ethereum IDE client. */ -#include "ConstantCompilationCtrl.h" -#include "ConstantCompilationModel.h" #include #include #include #include #include #include +#include "ConstantCompilationCtrl.h" +#include "ConstantCompilationModel.h" +using namespace dev::mix; -ConstantCompilation::ConstantCompilation(QTextDocument* _doc) +ConstantCompilationCtrl::ConstantCompilationCtrl(QTextDocument* _doc) { m_editor = _doc; - compilationModel = new ConstantCompilationModel(); + m_compilationModel = new ConstantCompilationModel(); } -ConstantCompilation::~ConstantCompilation() +ConstantCompilationCtrl::~ConstantCompilationCtrl() { - delete compilationModel; + delete m_compilationModel; } -QString ConstantCompilation::tabUrl() +QString ConstantCompilationCtrl::contentUrl() const { return QStringLiteral("qrc:/qml/BasicContent.qml"); } -QString ConstantCompilation::title() +QString ConstantCompilationCtrl::title() const { return "compiler"; } -void ConstantCompilation::start() +void ConstantCompilationCtrl::start() const { connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); } -void ConstantCompilation::compile() +void ConstantCompilationCtrl::compile() { QString codeContent = m_editor->toPlainText().replace("\n", ""); - if (codeContent == ""){ + if (codeContent == "") + { resetOutPut(); return; } - compilerResult res = compilationModel->compile(m_editor->toPlainText()); + CompilerResult res = m_compilationModel->compile(m_editor->toPlainText()); writeOutPut(res); } -void ConstantCompilation::resetOutPut() +void ConstantCompilationCtrl::resetOutPut() { QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); @@ -74,24 +76,22 @@ void ConstantCompilation::resetOutPut() content->setProperty("text", ""); } -void ConstantCompilation::writeOutPut(compilerResult res) +void ConstantCompilationCtrl::writeOutPut(CompilerResult _res) { QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); - if (res.success){ + if (_res.success) + { status->setProperty("text", "succeeded"); status->setProperty("color", "green"); - content->setProperty("text", res.hexCode); - qDebug() << QString("compile succeeded " + res.hexCode); + content->setProperty("text", _res.hexCode); + qDebug() << QString("compile succeeded " + _res.hexCode); } - else { + else + { status->setProperty("text", "failure"); status->setProperty("color", "red"); - content->setProperty("text", res.comment); - qDebug() << QString("compile failed " + res.comment); + content->setProperty("text", _res.comment); + qDebug() << QString("compile failed " + _res.comment); } } - - - - diff --git a/mix/ConstantCompilationCtrl.h b/mix/ConstantCompilationCtrl.h index 193c8db77..3bb221b3d 100644 --- a/mix/ConstantCompilationCtrl.h +++ b/mix/ConstantCompilationCtrl.h @@ -1,16 +1,13 @@ /* 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 . */ @@ -20,33 +17,39 @@ * Ethereum IDE client. */ -#ifndef CONSTANTCOMPILATION_H -#define CONSTANTCOMPILATION_H +#pragma once #include #include "ConstantCompilationModel.h" -#include "Feature.h" +#include "Extension.h" + +namespace dev +{ -class ConstantCompilation : public Feature +namespace mix +{ + +class ConstantCompilationCtrl : public Extension { Q_OBJECT public: - ConstantCompilation(QTextDocument* doc); - ~ConstantCompilation(); - void start() override; - QString title() override; - QString tabUrl() override; + ConstantCompilationCtrl(QTextDocument*); + ~ConstantCompilationCtrl(); + void start() const override; + QString title() const override; + QString contentUrl() const override; private: QTextDocument* m_editor; - ConstantCompilationModel* compilationModel; - void writeOutPut(compilerResult); + ConstantCompilationModel* m_compilationModel; + void writeOutPut(CompilerResult); void resetOutPut(); public Q_SLOTS: void compile(); - }; -#endif // CONSTANTCOMPILATION_H +} + +} diff --git a/mix/ConstantCompilationModel.cpp b/mix/ConstantCompilationModel.cpp index 1801bc854..533523a4e 100644 --- a/mix/ConstantCompilationModel.cpp +++ b/mix/ConstantCompilationModel.cpp @@ -1,34 +1,52 @@ -#include "ConstantCompilationModel.h" +/* + 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 . +*/ +/** @file ApplicationCtx.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + #include #include #include #include #include +#include "ConstantCompilationModel.h" using namespace std; using namespace dev; using namespace dev::eth; +using namespace dev::mix; -ConstantCompilationModel::ConstantCompilationModel() -{ -} - -compilerResult ConstantCompilationModel::compile(QString code) +CompilerResult ConstantCompilationModel::compile(QString _code) { dev::solidity::CompilerStack compiler; dev::bytes m_data; - compilerResult res; + CompilerResult res; try { - m_data = compiler.compile(code.toStdString(), true); + m_data = compiler.compile(_code.toStdString(), true); res.success = true; res.comment = "ok"; res.hexCode = QString::fromStdString(dev::eth::disassemble(m_data)); - } - catch (dev::Exception const& exception) + catch (dev::Exception const& _exception) { ostringstream error; - solidity::SourceReferenceFormatter::printExceptionInformation(error, exception, "Error", compiler.getScanner()); + solidity::SourceReferenceFormatter::printExceptionInformation(error, _exception, "Error", compiler.getScanner()); res.success = false; res.comment = QString::fromStdString(error.str()).toHtmlEscaped(); res.hexCode = ""; @@ -41,4 +59,3 @@ compilerResult ConstantCompilationModel::compile(QString code) } return res; } - diff --git a/mix/ConstantCompilationModel.h b/mix/ConstantCompilationModel.h index fb1f18e1c..4c84bc0eb 100644 --- a/mix/ConstantCompilationModel.h +++ b/mix/ConstantCompilationModel.h @@ -1,8 +1,37 @@ -#ifndef CONSTANTCOMPILATIONMODEL_H -#define CONSTANTCOMPILATIONMODEL_H +/* + 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 . +*/ +/** @file ApplicationCtx.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + +#pragma once + #include -struct compilerResult{ +namespace dev +{ + +namespace mix +{ + +struct CompilerResult +{ QString hexCode; QString comment; bool success; @@ -12,8 +41,11 @@ class ConstantCompilationModel { public: - ConstantCompilationModel(); - compilerResult compile(QString code); + ConstantCompilationModel() { } + ~ConstantCompilationModel() { } + CompilerResult compile(QString code); }; -#endif // CONSTANTCOMPILATIONMODEL_H +} + +} diff --git a/mix/Feature.cpp b/mix/Extension.cpp similarity index 54% rename from mix/Feature.cpp rename to mix/Extension.cpp index 747b538d8..b1ae31ecc 100644 --- a/mix/Feature.cpp +++ b/mix/Extension.cpp @@ -1,16 +1,13 @@ /* 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 . */ @@ -20,36 +17,28 @@ * Ethereum IDE client. */ -#include "Feature.h" -#include "ApplicationCtx.h" -#include #include #include +#include +#include "Extension.h" +#include "ApplicationCtx.h" using namespace dev; +using namespace dev::mix; -Feature::Feature() +void Extension::addContentOn(QObject* _tabView) { -} + if (contentUrl() == "") + return; -void Feature::addContentOn(QObject* tabView) { - try{ - if (tabUrl() == "") - return; + QVariant returnValue; + QQmlComponent* component = new QQmlComponent( + ApplicationCtx::getInstance()->appEngine(), + QUrl(this->contentUrl()), _tabView); - QVariant returnValue; - QQmlComponent* component = new QQmlComponent( - ApplicationCtx::GetInstance()->appEngine(), - QUrl(this->tabUrl()), tabView); + QMetaObject::invokeMethod(_tabView, "addTab", + Q_RETURN_ARG(QVariant, returnValue), + Q_ARG(QVariant, this->title()), + Q_ARG(QVariant, QVariant::fromValue(component))); - QMetaObject::invokeMethod(tabView, "addTab", - Q_RETURN_ARG(QVariant, returnValue), - Q_ARG(QVariant, this->title()), - Q_ARG(QVariant, QVariant::fromValue(component))); - - m_view = qvariant_cast(returnValue); - } - catch (dev::Exception const& exception){ - qDebug() << exception.what(); - } + m_view = qvariant_cast(returnValue); } - diff --git a/mix/Feature.h b/mix/Extension.h similarity index 79% rename from mix/Feature.h rename to mix/Extension.h index d5cee7e74..3a401eeeb 100644 --- a/mix/Feature.h +++ b/mix/Extension.h @@ -1,16 +1,13 @@ /* 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 . */ @@ -20,25 +17,32 @@ * Ethereum IDE client. */ -#ifndef FEATURE_H -#define FEATURE_H +#pragma once #include #include -class Feature : public QObject +namespace dev +{ + +namespace mix +{ + +class Extension : public QObject { Q_OBJECT public: - Feature(); - virtual QString tabUrl() { return ""; } - virtual QString title() { return ""; } - virtual void start() {} + Extension() {} + virtual QString contentUrl() const { return ""; } + virtual QString title() const { return ""; } + virtual void start() const {} void addContentOn(QObject* tabView); protected: QObject* m_view; }; -#endif // FEATURE_H +} + +} diff --git a/mix/MixApplication.cpp b/mix/MixApplication.cpp new file mode 100644 index 000000000..fa9feadb5 --- /dev/null +++ b/mix/MixApplication.cpp @@ -0,0 +1,42 @@ +/* + 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 . +*/ +/** @file main.cpp + * @author Yann yann@ethdev.com + * @date 2014 + */ + +#include +#include "MixApplication.h" +using namespace dev::mix; + +MixApplication::MixApplication(int _argc, char *_argv[]) + : QApplication(_argc, _argv) +{ +} + +bool MixApplication::notify(QObject* _receiver, QEvent* _event) +{ + try + { + return MixApplication::notify(_receiver, _event); + } + catch (std::exception& _ex) + { + qDebug() << "std::exception was caught " << _ex.what(); + } + return false; +} diff --git a/mix/MixApplication.h b/mix/MixApplication.h new file mode 100644 index 000000000..3f4ace5a6 --- /dev/null +++ b/mix/MixApplication.h @@ -0,0 +1,46 @@ +/* + 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 . +*/ +/** @file main.cpp + * @author Yann yann@ethdev.com + * @date 2014 + * This class will be use instead of QApplication to launch the application. the method 'notify' allows to catch all exceptions. + * Not use for now: TODO. + */ + +#pragma once + +#include + +namespace dev +{ + +namespace mix +{ + +class MixApplication : public QApplication +{ + Q_OBJECT + +public: + MixApplication(int _argc, char* _argv[]); + virtual ~MixApplication() { } + virtual bool notify(QObject* _receiver, QEvent* _event); +}; + +} + +} diff --git a/mix/main.cpp b/mix/main.cpp index e1aa5d9a5..c0fc76bdd 100644 --- a/mix/main.cpp +++ b/mix/main.cpp @@ -23,19 +23,18 @@ #include #include #include -#include "CodeEditorExtensionMan.h" +#include "CodeEditorExtensionManager.h" #include "ApplicationCtx.h" +#include "MixApplication.h" +using namespace dev::mix; -int main(int argc, char *argv[]) +int main(int _argc, char *_argv[]) { - QApplication app(argc, argv); + QApplication app(_argc, _argv); + qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); QQmlApplicationEngine* engine = new QQmlApplicationEngine(); - qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); - - ApplicationCtx::SetApplicationContext(engine); - QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::GetInstance(), SLOT(QuitApplication())); //use to kill ApplicationContext and other stuff - + ApplicationCtx::setApplicationContext(engine); + QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::getInstance(), SLOT(quitApplication())); //use to kill ApplicationContext and other stuff engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); return app.exec(); } - diff --git a/mix/qml/BasicContent.qml b/mix/qml/BasicContent.qml index a61ee8b8f..8e450dabf 100644 --- a/mix/qml/BasicContent.qml +++ b/mix/qml/BasicContent.qml @@ -6,6 +6,7 @@ Rectangle { width: parent.width height: parent.height color: "lightgray" + Text { font.pointSize: 7 anchors.left: parent.left diff --git a/mix/qml/MainContent.qml b/mix/qml/MainContent.qml index abae4a37f..80bbec3aa 100644 --- a/mix/qml/MainContent.qml +++ b/mix/qml/MainContent.qml @@ -13,7 +13,7 @@ Rectangle { anchors.fill: parent orientation: Qt.Vertical Rectangle { - anchors.top : parent.top + anchors.top: parent.top id: contentView width: parent.width height: parent.height * 0.7 diff --git a/mix/qml/TabStyle.qml b/mix/qml/TabStyle.qml index df31f9910..8f72fa12c 100644 --- a/mix/qml/TabStyle.qml +++ b/mix/qml/TabStyle.qml @@ -8,7 +8,6 @@ TabViewStyle { color: "lightgray" } tab: Rectangle { - color: "lightsteelblue" implicitWidth: Math.max(text.width + 4, 80) implicitHeight: 20 diff --git a/mix/qml/main.qml b/mix/qml/main.qml index 6486c1dfd..331720f41 100644 --- a/mix/qml/main.qml +++ b/mix/qml/main.qml @@ -4,7 +4,6 @@ import QtQuick.Controls.Styles 1.2 import CodeEditorExtensionManager 1.0 ApplicationWindow { - visible: true width: 1000 height: 480 From 0e391e50a214537431deeab6dd21868ab8d641d6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 28 Nov 2014 14:52:08 +0100 Subject: [PATCH 11/17] misc corrections --- mix/ApplicationCtx.cpp | 6 ++++++ mix/ApplicationCtx.h | 4 ++-- mix/CodeEditorExtensionManager.cpp | 11 +++++------ mix/CodeEditorExtensionManager.h | 2 +- mix/ConstantCompilationCtrl.cpp | 2 +- mix/ConstantCompilationCtrl.h | 4 ++-- mix/Extension.h | 2 +- mix/MixApplication.cpp | 4 ++++ mix/MixApplication.h | 2 +- 9 files changed, 23 insertions(+), 14 deletions(-) diff --git a/mix/ApplicationCtx.cpp b/mix/ApplicationCtx.cpp index 8ea8bd8d8..5b8c34aaf 100644 --- a/mix/ApplicationCtx.cpp +++ b/mix/ApplicationCtx.cpp @@ -28,3 +28,9 @@ QQmlApplicationEngine* ApplicationCtx::appEngine() { return m_applicationEngine; } + +void ApplicationCtx::setApplicationContext(QQmlApplicationEngine* _engine) +{ + if (Instance == nullptr) + Instance = new ApplicationCtx(_engine); +} diff --git a/mix/ApplicationCtx.h b/mix/ApplicationCtx.h index 32e2bd3f1..3938c7bf5 100644 --- a/mix/ApplicationCtx.h +++ b/mix/ApplicationCtx.h @@ -31,7 +31,7 @@ namespace dev namespace mix { -class ApplicationCtx : public QObject +class ApplicationCtx: public QObject { Q_OBJECT @@ -39,7 +39,7 @@ public: ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; } ~ApplicationCtx() { delete m_applicationEngine; } static ApplicationCtx* getInstance() { return Instance; } - static void setApplicationContext(QQmlApplicationEngine* _engine) { Instance = new ApplicationCtx(_engine); } + static void setApplicationContext(QQmlApplicationEngine* _engine); QQmlApplicationEngine* appEngine(); private: diff --git a/mix/CodeEditorExtensionManager.cpp b/mix/CodeEditorExtensionManager.cpp index 316c37ee0..92400cd63 100644 --- a/mix/CodeEditorExtensionManager.cpp +++ b/mix/CodeEditorExtensionManager.cpp @@ -62,13 +62,12 @@ void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) void CodeEditorExtensionManager::initExtensions() { //only one for now - std::shared_ptr m_constantCompilation(new ConstantCompilationCtrl(m_doc)); - ConstantCompilationCtrl* ext = m_constantCompilation.get(); - if (ext->contentUrl() != "") + std::shared_ptr constantCompilation = std::make_shared(m_doc); + if (constantCompilation.get()->contentUrl() != "") { try { - ext->addContentOn(m_tabView); + constantCompilation.get()->addContentOn(m_tabView); } catch (...) { @@ -76,8 +75,8 @@ void CodeEditorExtensionManager::initExtensions() return; } } - ext->start(); - m_features.append(m_constantCompilation); + constantCompilation.get()->start(); + m_features.append(constantCompilation); } void CodeEditorExtensionManager::setEditor(QQuickItem* _editor) diff --git a/mix/CodeEditorExtensionManager.h b/mix/CodeEditorExtensionManager.h index c368a9714..1d8fb1ec5 100644 --- a/mix/CodeEditorExtensionManager.h +++ b/mix/CodeEditorExtensionManager.h @@ -34,7 +34,7 @@ namespace dev namespace mix { -class CodeEditorExtensionManager : public QObject +class CodeEditorExtensionManager: public QObject { Q_OBJECT diff --git a/mix/ConstantCompilationCtrl.cpp b/mix/ConstantCompilationCtrl.cpp index 0f73da781..2c42a28dd 100644 --- a/mix/ConstantCompilationCtrl.cpp +++ b/mix/ConstantCompilationCtrl.cpp @@ -76,7 +76,7 @@ void ConstantCompilationCtrl::resetOutPut() content->setProperty("text", ""); } -void ConstantCompilationCtrl::writeOutPut(CompilerResult _res) +void ConstantCompilationCtrl::writeOutPut(const CompilerResult& _res) { QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); diff --git a/mix/ConstantCompilationCtrl.h b/mix/ConstantCompilationCtrl.h index 3bb221b3d..af7c97951 100644 --- a/mix/ConstantCompilationCtrl.h +++ b/mix/ConstantCompilationCtrl.h @@ -29,7 +29,7 @@ namespace dev namespace mix { -class ConstantCompilationCtrl : public Extension +class ConstantCompilationCtrl: public Extension { Q_OBJECT @@ -43,7 +43,7 @@ public: private: QTextDocument* m_editor; ConstantCompilationModel* m_compilationModel; - void writeOutPut(CompilerResult); + void writeOutPut(const CompilerResult&); void resetOutPut(); public Q_SLOTS: diff --git a/mix/Extension.h b/mix/Extension.h index 3a401eeeb..0678fdd5b 100644 --- a/mix/Extension.h +++ b/mix/Extension.h @@ -28,7 +28,7 @@ namespace dev namespace mix { -class Extension : public QObject +class Extension: public QObject { Q_OBJECT diff --git a/mix/MixApplication.cpp b/mix/MixApplication.cpp index fa9feadb5..634b3142a 100644 --- a/mix/MixApplication.cpp +++ b/mix/MixApplication.cpp @@ -38,5 +38,9 @@ bool MixApplication::notify(QObject* _receiver, QEvent* _event) { qDebug() << "std::exception was caught " << _ex.what(); } + catch (...) + { + qDebug() << "uncaught exception "; + } return false; } diff --git a/mix/MixApplication.h b/mix/MixApplication.h index 3f4ace5a6..ba344fcdc 100644 --- a/mix/MixApplication.h +++ b/mix/MixApplication.h @@ -31,7 +31,7 @@ namespace dev namespace mix { -class MixApplication : public QApplication +class MixApplication: public QApplication { Q_OBJECT From 369268c0cedf0e0e4a7dfb8175ed35cd2989b235 Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 29 Nov 2014 01:02:12 +0100 Subject: [PATCH 12/17] tab indentation --- mix/ApplicationCtx.cpp | 28 ++++----- mix/ApplicationCtx.h | 40 ++++++------- mix/CodeEditorExtensionManager.cpp | 94 +++++++++++++++--------------- mix/CodeEditorExtensionManager.h | 48 +++++++-------- mix/ConstantCompilationCtrl.cpp | 92 ++++++++++++++--------------- mix/ConstantCompilationCtrl.h | 44 +++++++------- mix/ConstantCompilationModel.cpp | 72 +++++++++++------------ mix/ConstantCompilationModel.h | 34 +++++------ mix/Extension.cpp | 44 +++++++------- mix/Extension.h | 36 ++++++------ mix/MixApplication.cpp | 50 ++++++++-------- mix/MixApplication.h | 30 +++++----- mix/main.cpp | 36 ++++++------ mix/qml/BasicContent.qml | 3 +- 14 files changed, 326 insertions(+), 325 deletions(-) diff --git a/mix/ApplicationCtx.cpp b/mix/ApplicationCtx.cpp index 5b8c34aaf..f97478f3c 100644 --- a/mix/ApplicationCtx.cpp +++ b/mix/ApplicationCtx.cpp @@ -1,15 +1,15 @@ /* - 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 . + 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 . */ /** @file ApplicationCtx.cpp * @author Yann yann@ethdev.com @@ -26,11 +26,11 @@ ApplicationCtx* ApplicationCtx::Instance = nullptr; QQmlApplicationEngine* ApplicationCtx::appEngine() { - return m_applicationEngine; + return m_applicationEngine; } void ApplicationCtx::setApplicationContext(QQmlApplicationEngine* _engine) { - if (Instance == nullptr) - Instance = new ApplicationCtx(_engine); + if (Instance == nullptr) + Instance = new ApplicationCtx(_engine); } diff --git a/mix/ApplicationCtx.h b/mix/ApplicationCtx.h index 3938c7bf5..37166ea05 100644 --- a/mix/ApplicationCtx.h +++ b/mix/ApplicationCtx.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file ApplicationCtx.h * @author Yann yann@ethdev.com @@ -33,21 +33,21 @@ namespace mix class ApplicationCtx: public QObject { - Q_OBJECT + Q_OBJECT public: - ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; } - ~ApplicationCtx() { delete m_applicationEngine; } - static ApplicationCtx* getInstance() { return Instance; } - static void setApplicationContext(QQmlApplicationEngine* _engine); - QQmlApplicationEngine* appEngine(); + ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; } + ~ApplicationCtx() { delete m_applicationEngine; } + static ApplicationCtx* getInstance() { return Instance; } + static void setApplicationContext(QQmlApplicationEngine* _engine); + QQmlApplicationEngine* appEngine(); private: - static ApplicationCtx* Instance; - QQmlApplicationEngine* m_applicationEngine; + static ApplicationCtx* Instance; + QQmlApplicationEngine* m_applicationEngine; public slots: - void quitApplication() { delete Instance; } + void quitApplication() { delete Instance; } }; } diff --git a/mix/CodeEditorExtensionManager.cpp b/mix/CodeEditorExtensionManager.cpp index 92400cd63..4a46c60d4 100644 --- a/mix/CodeEditorExtensionManager.cpp +++ b/mix/CodeEditorExtensionManager.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file CodeEditorExtensionMan.cpp * @author Yann yann@ethdev.com @@ -36,56 +36,56 @@ using namespace dev::mix; CodeEditorExtensionManager::~CodeEditorExtensionManager() { - m_features.clear(); + m_features.clear(); } void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) { - if (!_editor) - return; - try - { - QVariant doc = _editor->property("textDocument"); - if (doc.canConvert()) - { - QQuickTextDocument* qqdoc = doc.value(); - if (qqdoc) - m_doc = qqdoc->textDocument(); - } - } - catch (...) - { - qDebug() << "unable to load editor: "; - } + if (!_editor) + return; + try + { + QVariant doc = _editor->property("textDocument"); + if (doc.canConvert()) + { + QQuickTextDocument* qqdoc = doc.value(); + if (qqdoc) + m_doc = qqdoc->textDocument(); + } + } + catch (...) + { + qDebug() << "unable to load editor: "; + } } void CodeEditorExtensionManager::initExtensions() { - //only one for now - std::shared_ptr constantCompilation = std::make_shared(m_doc); - if (constantCompilation.get()->contentUrl() != "") - { - try - { - constantCompilation.get()->addContentOn(m_tabView); - } - catch (...) - { - qDebug() << "Exception when adding content into view."; - return; - } - } - constantCompilation.get()->start(); - m_features.append(constantCompilation); + //only one for now + std::shared_ptr constantCompilation = std::make_shared(m_doc); + if (constantCompilation.get()->contentUrl() != "") + { + try + { + constantCompilation.get()->addContentOn(m_tabView); + } + catch (...) + { + qDebug() << "Exception when adding content into view."; + return; + } + } + constantCompilation.get()->start(); + m_features.append(constantCompilation); } void CodeEditorExtensionManager::setEditor(QQuickItem* _editor) { - this->loadEditor(_editor); - this->initExtensions(); + this->loadEditor(_editor); + this->initExtensions(); } void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView) { - m_tabView = _tabView; + m_tabView = _tabView; } diff --git a/mix/CodeEditorExtensionManager.h b/mix/CodeEditorExtensionManager.h index 1d8fb1ec5..2b8402bf2 100644 --- a/mix/CodeEditorExtensionManager.h +++ b/mix/CodeEditorExtensionManager.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file CodeEditorExtensionMan.h * @author Yann yann@ethdev.com @@ -36,24 +36,24 @@ namespace mix class CodeEditorExtensionManager: public QObject { - Q_OBJECT + Q_OBJECT - Q_PROPERTY(QQuickItem* editor MEMBER m_editor WRITE setEditor) - Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) + Q_PROPERTY(QQuickItem* editor MEMBER m_editor WRITE setEditor) + Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) public: - CodeEditorExtensionManager() {} - ~CodeEditorExtensionManager(); - void initExtensions(); - void setEditor(QQuickItem*); - void setTabView(QQuickItem*); + CodeEditorExtensionManager() {} + ~CodeEditorExtensionManager(); + void initExtensions(); + void setEditor(QQuickItem*); + void setTabView(QQuickItem*); private: - QQuickItem* m_editor; - QVector> m_features; - QQuickItem* m_tabView; - QTextDocument* m_doc; - void loadEditor(QQuickItem*); + QQuickItem* m_editor; + QVector> m_features; + QQuickItem* m_tabView; + QTextDocument* m_doc; + void loadEditor(QQuickItem*); }; } diff --git a/mix/ConstantCompilationCtrl.cpp b/mix/ConstantCompilationCtrl.cpp index 2c42a28dd..06b9c0284 100644 --- a/mix/ConstantCompilationCtrl.cpp +++ b/mix/ConstantCompilationCtrl.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file ConstantCompilation.cpp * @author Yann yann@ethdev.com @@ -32,66 +32,66 @@ using namespace dev::mix; ConstantCompilationCtrl::ConstantCompilationCtrl(QTextDocument* _doc) { - m_editor = _doc; - m_compilationModel = new ConstantCompilationModel(); + m_editor = _doc; + m_compilationModel = new ConstantCompilationModel(); } ConstantCompilationCtrl::~ConstantCompilationCtrl() { - delete m_compilationModel; + delete m_compilationModel; } QString ConstantCompilationCtrl::contentUrl() const { - return QStringLiteral("qrc:/qml/BasicContent.qml"); + return QStringLiteral("qrc:/qml/BasicContent.qml"); } QString ConstantCompilationCtrl::title() const { - return "compiler"; + return "compiler"; } void ConstantCompilationCtrl::start() const { - connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); + connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); } void ConstantCompilationCtrl::compile() { - QString codeContent = m_editor->toPlainText().replace("\n", ""); - if (codeContent == "") - { - resetOutPut(); - return; - } - CompilerResult res = m_compilationModel->compile(m_editor->toPlainText()); - writeOutPut(res); + QString codeContent = m_editor->toPlainText().replace("\n", ""); + if (codeContent.isEmpty()) + { + resetOutPut(); + return; + } + CompilerResult res = m_compilationModel->compile(m_editor->toPlainText()); + writeOutPut(res); } void ConstantCompilationCtrl::resetOutPut() { - QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); - QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); - status->setProperty("text", ""); - content->setProperty("text", ""); + QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); + QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); + status->setProperty("text", ""); + content->setProperty("text", ""); } -void ConstantCompilationCtrl::writeOutPut(const CompilerResult& _res) +void ConstantCompilationCtrl::writeOutPut(CompilerResult const& _res) { - QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); - QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); - if (_res.success) - { - status->setProperty("text", "succeeded"); - status->setProperty("color", "green"); - content->setProperty("text", _res.hexCode); - qDebug() << QString("compile succeeded " + _res.hexCode); - } - else - { - status->setProperty("text", "failure"); - status->setProperty("color", "red"); - content->setProperty("text", _res.comment); - qDebug() << QString("compile failed " + _res.comment); - } + QObject* status = m_view->findChild("status", Qt::FindChildrenRecursively); + QObject* content = m_view->findChild("content", Qt::FindChildrenRecursively); + if (_res.success) + { + status->setProperty("text", "succeeded"); + status->setProperty("color", "green"); + content->setProperty("text", _res.hexCode); + qDebug() << QString("compile succeeded " + _res.hexCode); + } + else + { + status->setProperty("text", "failure"); + status->setProperty("color", "red"); + content->setProperty("text", _res.comment); + qDebug() << QString("compile failed " + _res.comment); + } } diff --git a/mix/ConstantCompilationCtrl.h b/mix/ConstantCompilationCtrl.h index af7c97951..e4661c800 100644 --- a/mix/ConstantCompilationCtrl.h +++ b/mix/ConstantCompilationCtrl.h @@ -1,15 +1,15 @@ /* - 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 . + 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 . */ /** @file ConstantCompilation.h * @author Yann yann@ethdev.com @@ -31,23 +31,23 @@ namespace mix class ConstantCompilationCtrl: public Extension { - Q_OBJECT + Q_OBJECT public: - ConstantCompilationCtrl(QTextDocument*); - ~ConstantCompilationCtrl(); - void start() const override; - QString title() const override; - QString contentUrl() const override; + ConstantCompilationCtrl(QTextDocument*); + ~ConstantCompilationCtrl(); + void start() const override; + QString title() const override; + QString contentUrl() const override; private: - QTextDocument* m_editor; - ConstantCompilationModel* m_compilationModel; - void writeOutPut(const CompilerResult&); - void resetOutPut(); + QTextDocument* m_editor; + ConstantCompilationModel* m_compilationModel; + void writeOutPut(CompilerResult const&); + void resetOutPut(); public Q_SLOTS: - void compile(); + void compile(); }; } diff --git a/mix/ConstantCompilationModel.cpp b/mix/ConstantCompilationModel.cpp index 533523a4e..e06734f59 100644 --- a/mix/ConstantCompilationModel.cpp +++ b/mix/ConstantCompilationModel.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file ApplicationCtx.h * @author Yann yann@ethdev.com @@ -33,29 +33,29 @@ using namespace dev::mix; CompilerResult ConstantCompilationModel::compile(QString _code) { - dev::solidity::CompilerStack compiler; - dev::bytes m_data; - CompilerResult res; - try - { - m_data = compiler.compile(_code.toStdString(), true); - res.success = true; - res.comment = "ok"; - res.hexCode = QString::fromStdString(dev::eth::disassemble(m_data)); - } - catch (dev::Exception const& _exception) - { - ostringstream error; - solidity::SourceReferenceFormatter::printExceptionInformation(error, _exception, "Error", compiler.getScanner()); - res.success = false; - res.comment = QString::fromStdString(error.str()).toHtmlEscaped(); - res.hexCode = ""; - } - catch (...) - { - res.success = false; - res.comment = "Uncaught exception."; - res.hexCode = ""; - } - return res; + dev::solidity::CompilerStack compiler; + dev::bytes m_data; + CompilerResult res; + try + { + m_data = compiler.compile(_code.toStdString(), true); + res.success = true; + res.comment = "ok"; + res.hexCode = QString::fromStdString(dev::eth::disassemble(m_data)); + } + catch (dev::Exception const& _exception) + { + ostringstream error; + solidity::SourceReferenceFormatter::printExceptionInformation(error, _exception, "Error", compiler.getScanner()); + res.success = false; + res.comment = QString::fromStdString(error.str()).toHtmlEscaped(); + res.hexCode = ""; + } + catch (...) + { + res.success = false; + res.comment = "Uncaught exception."; + res.hexCode = ""; + } + return res; } diff --git a/mix/ConstantCompilationModel.h b/mix/ConstantCompilationModel.h index 4c84bc0eb..faeb853e0 100644 --- a/mix/ConstantCompilationModel.h +++ b/mix/ConstantCompilationModel.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file ApplicationCtx.h * @author Yann yann@ethdev.com @@ -32,18 +32,18 @@ namespace mix struct CompilerResult { - QString hexCode; - QString comment; - bool success; + QString hexCode; + QString comment; + bool success; }; class ConstantCompilationModel { public: - ConstantCompilationModel() { } - ~ConstantCompilationModel() { } - CompilerResult compile(QString code); + ConstantCompilationModel() { } + ~ConstantCompilationModel() { } + CompilerResult compile(QString code); }; } diff --git a/mix/Extension.cpp b/mix/Extension.cpp index b1ae31ecc..5aeb0cc17 100644 --- a/mix/Extension.cpp +++ b/mix/Extension.cpp @@ -1,15 +1,15 @@ /* - 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 . + 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 . */ /** @file Feature.cpp * @author Yann yann@ethdev.com @@ -27,18 +27,18 @@ using namespace dev::mix; void Extension::addContentOn(QObject* _tabView) { - if (contentUrl() == "") - return; + if (contentUrl() == "") + return; - QVariant returnValue; - QQmlComponent* component = new QQmlComponent( - ApplicationCtx::getInstance()->appEngine(), - QUrl(this->contentUrl()), _tabView); + QVariant returnValue; + QQmlComponent* component = new QQmlComponent( + ApplicationCtx::getInstance()->appEngine(), + QUrl(this->contentUrl()), _tabView); - QMetaObject::invokeMethod(_tabView, "addTab", - Q_RETURN_ARG(QVariant, returnValue), - Q_ARG(QVariant, this->title()), - Q_ARG(QVariant, QVariant::fromValue(component))); + QMetaObject::invokeMethod(_tabView, "addTab", + Q_RETURN_ARG(QVariant, returnValue), + Q_ARG(QVariant, this->title()), + Q_ARG(QVariant, QVariant::fromValue(component))); - m_view = qvariant_cast(returnValue); + m_view = qvariant_cast(returnValue); } diff --git a/mix/Extension.h b/mix/Extension.h index 0678fdd5b..f8fef0aa6 100644 --- a/mix/Extension.h +++ b/mix/Extension.h @@ -1,15 +1,15 @@ /* - 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 . + 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 . */ /** @file Feature.h * @author Yann yann@ethdev.com @@ -30,17 +30,17 @@ namespace mix class Extension: public QObject { - Q_OBJECT + Q_OBJECT public: - Extension() {} - virtual QString contentUrl() const { return ""; } - virtual QString title() const { return ""; } - virtual void start() const {} - void addContentOn(QObject* tabView); + Extension() {} + virtual QString contentUrl() const { return ""; } + virtual QString title() const { return ""; } + virtual void start() const {} + void addContentOn(QObject* tabView); protected: - QObject* m_view; + QObject* m_view; }; } diff --git a/mix/MixApplication.cpp b/mix/MixApplication.cpp index 634b3142a..c63349409 100644 --- a/mix/MixApplication.cpp +++ b/mix/MixApplication.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file main.cpp * @author Yann yann@ethdev.com @@ -24,23 +24,23 @@ using namespace dev::mix; MixApplication::MixApplication(int _argc, char *_argv[]) - : QApplication(_argc, _argv) + : QApplication(_argc, _argv) { } bool MixApplication::notify(QObject* _receiver, QEvent* _event) { - try - { - return MixApplication::notify(_receiver, _event); - } - catch (std::exception& _ex) - { - qDebug() << "std::exception was caught " << _ex.what(); - } - catch (...) - { - qDebug() << "uncaught exception "; - } - return false; + try + { + return MixApplication::notify(_receiver, _event); + } + catch (std::exception& _ex) + { + qDebug() << "std::exception was caught " << _ex.what(); + } + catch (...) + { + qDebug() << "uncaught exception "; + } + return false; } diff --git a/mix/MixApplication.h b/mix/MixApplication.h index ba344fcdc..fdc506268 100644 --- a/mix/MixApplication.h +++ b/mix/MixApplication.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file main.cpp * @author Yann yann@ethdev.com @@ -33,12 +33,12 @@ namespace mix class MixApplication: public QApplication { - Q_OBJECT + Q_OBJECT public: - MixApplication(int _argc, char* _argv[]); - virtual ~MixApplication() { } - virtual bool notify(QObject* _receiver, QEvent* _event); + MixApplication(int _argc, char* _argv[]); + virtual ~MixApplication() {} + virtual bool notify(QObject* _receiver, QEvent* _event); }; } diff --git a/mix/main.cpp b/mix/main.cpp index c0fc76bdd..537941290 100644 --- a/mix/main.cpp +++ b/mix/main.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + 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 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. + 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 . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file main.cpp * @author Yann yann@ethdev.com @@ -30,11 +30,11 @@ using namespace dev::mix; int main(int _argc, char *_argv[]) { - QApplication app(_argc, _argv); - qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); - QQmlApplicationEngine* engine = new QQmlApplicationEngine(); - ApplicationCtx::setApplicationContext(engine); - QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::getInstance(), SLOT(quitApplication())); //use to kill ApplicationContext and other stuff - engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); - return app.exec(); + QApplication app(_argc, _argv); + qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); + QQmlApplicationEngine* engine = new QQmlApplicationEngine(); + ApplicationCtx::setApplicationContext(engine); + QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::getInstance(), SLOT(quitApplication())); //use to kill ApplicationContext and other stuff + engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + return app.exec(); } diff --git a/mix/qml/BasicContent.qml b/mix/qml/BasicContent.qml index 8e450dabf..6d5020d3d 100644 --- a/mix/qml/BasicContent.qml +++ b/mix/qml/BasicContent.qml @@ -2,6 +2,7 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 Rectangle { + anchors.fill: parent width: parent.width height: parent.height @@ -19,7 +20,7 @@ Rectangle { id: status } - TextArea{ + TextArea { readOnly: true anchors.left: parent.left anchors.leftMargin: 10 From 252910d387ad72e28bc675cc661c3ffe39337b3c Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 29 Nov 2014 01:11:07 +0100 Subject: [PATCH 13/17] tab indentation in QML --- mix/qml/BasicContent.qml | 63 +++++++++++++-------------- mix/qml/MainContent.qml | 92 ++++++++++++++++++++-------------------- mix/qml/TabStyle.qml | 34 +++++++-------- mix/qml/main.qml | 36 ++++++++-------- 4 files changed, 110 insertions(+), 115 deletions(-) diff --git a/mix/qml/BasicContent.qml b/mix/qml/BasicContent.qml index 6d5020d3d..0049e6127 100644 --- a/mix/qml/BasicContent.qml +++ b/mix/qml/BasicContent.qml @@ -2,37 +2,34 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 Rectangle { - - anchors.fill: parent - width: parent.width - height: parent.height - color: "lightgray" - - Text { - font.pointSize: 7 - anchors.left: parent.left - anchors.top: parent.top - anchors.topMargin: 3 - anchors.leftMargin: 3 - height: 9 - font.family: "Sego UI light" - objectName: "status" - id: status - } - - TextArea { - readOnly: true - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.top: status.bottom - anchors.topMargin: 3 - font.pointSize: 7 - font.family: "Sego UI light" - height: parent.height * 0.8 - width: parent.width - 20 - wrapMode: Text.Wrap - backgroundVisible: false - objectName: "content" - id: content - } + anchors.fill: parent + width: parent.width + height: parent.height + color: "lightgray" + Text { + font.pointSize: 7 + anchors.left: parent.left + anchors.top: parent.top + anchors.topMargin: 3 + anchors.leftMargin: 3 + height: 9 + font.family: "Sego UI light" + objectName: "status" + id: status + } + TextArea { + readOnly: true + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.top: status.bottom + anchors.topMargin: 3 + font.pointSize: 7 + font.family: "Sego UI light" + height: parent.height * 0.8 + width: parent.width - 20 + wrapMode: Text.Wrap + backgroundVisible: false + objectName: "content" + id: content + } } diff --git a/mix/qml/MainContent.qml b/mix/qml/MainContent.qml index 80bbec3aa..f243b16ac 100644 --- a/mix/qml/MainContent.qml +++ b/mix/qml/MainContent.qml @@ -5,50 +5,50 @@ import QtQuick.Controls.Styles 1.2 import CodeEditorExtensionManager 1.0 Rectangle { - anchors.fill: parent - height: parent.height - width: parent.width; - id:root - SplitView { - anchors.fill: parent - orientation: Qt.Vertical - Rectangle { - anchors.top: parent.top - id: contentView - width: parent.width - height: parent.height * 0.7 - TextArea { - id: codeEditor - height: parent.height - font.family: "Verdana" - font.pointSize: 9 - width: parent.width - anchors.centerIn: parent - tabChangesFocus: false - Keys.onPressed: { - if (event.key === Qt.Key_Tab) { - codeEditor.insert(codeEditor.cursorPosition, "\t"); - event.accepted = true; - } - } - } - } - Rectangle { - anchors.bottom: parent.bottom - id: contextualView - width: parent.width - Layout.minimumHeight: 20 - height: parent.height * 0.3 - TabView { - id: contextualTabs - antialiasing: true - anchors.fill: parent - style: TabStyle{} - } - } - CodeEditorExtensionManager{ - tabView: contextualTabs - editor: codeEditor - } - } + anchors.fill: parent + height: parent.height + width: parent.width; + id:root + SplitView { + anchors.fill: parent + orientation: Qt.Vertical + Rectangle { + anchors.top: parent.top + id: contentView + width: parent.width + height: parent.height * 0.7 + TextArea { + id: codeEditor + height: parent.height + font.family: "Verdana" + font.pointSize: 9 + width: parent.width + anchors.centerIn: parent + tabChangesFocus: false + Keys.onPressed: { + if (event.key === Qt.Key_Tab) { + codeEditor.insert(codeEditor.cursorPosition, "\t"); + event.accepted = true; + } + } + } + } + Rectangle { + anchors.bottom: parent.bottom + id: contextualView + width: parent.width + Layout.minimumHeight: 20 + height: parent.height * 0.3 + TabView { + id: contextualTabs + antialiasing: true + anchors.fill: parent + style: TabStyle {} + } + } + CodeEditorExtensionManager{ + tabView: contextualTabs + editor: codeEditor + } + } } diff --git a/mix/qml/TabStyle.qml b/mix/qml/TabStyle.qml index 8f72fa12c..5f78f8947 100644 --- a/mix/qml/TabStyle.qml +++ b/mix/qml/TabStyle.qml @@ -3,21 +3,21 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 TabViewStyle { - frameOverlap: 1 - tabBar: Rectangle { - color: "lightgray" - } - tab: Rectangle { - color: "lightsteelblue" - implicitWidth: Math.max(text.width + 4, 80) - implicitHeight: 20 - radius: 2 - Text { - id: text - anchors.centerIn: parent - text: styleData.title - color: styleData.selected ? "white" : "black" - } - } - frame: Rectangle { color: "steelblue" } + frameOverlap: 1 + tabBar: Rectangle { + color: "lightgray" + } + tab: Rectangle { + color: "lightsteelblue" + implicitWidth: Math.max(text.width + 4, 80) + implicitHeight: 20 + radius: 2 + Text { + id: text + anchors.centerIn: parent + text: styleData.title + color: styleData.selected ? "white" : "black" + } + } + frame: Rectangle { color: "steelblue" } } diff --git a/mix/qml/main.qml b/mix/qml/main.qml index 331720f41..8a1b86cee 100644 --- a/mix/qml/main.qml +++ b/mix/qml/main.qml @@ -4,23 +4,21 @@ import QtQuick.Controls.Styles 1.2 import CodeEditorExtensionManager 1.0 ApplicationWindow { - visible: true - width: 1000 - height: 480 - minimumWidth: 400 - minimumHeight: 300 - title: qsTr("mix") - - menuBar: MenuBar { - Menu { - title: qsTr("File") - MenuItem { - text: qsTr("Exit") - onTriggered: Qt.quit(); - } - } - } - - MainContent{ - } + visible: true + width: 1000 + height: 480 + minimumWidth: 400 + minimumHeight: 300 + title: qsTr("mix") + menuBar: MenuBar { + Menu { + title: qsTr("File") + MenuItem { + text: qsTr("Exit") + onTriggered: Qt.quit(); + } + } + } + MainContent{ + } } From db1ba8b5b4c609cc0ddada528dccf2f5cdc62f6e Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 29 Nov 2014 19:28:03 +0100 Subject: [PATCH 14/17] style correction. --- mix/ConstantCompilationModel.h | 4 ++-- mix/MixApplication.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mix/ConstantCompilationModel.h b/mix/ConstantCompilationModel.h index faeb853e0..4a17853f6 100644 --- a/mix/ConstantCompilationModel.h +++ b/mix/ConstantCompilationModel.h @@ -41,8 +41,8 @@ class ConstantCompilationModel { public: - ConstantCompilationModel() { } - ~ConstantCompilationModel() { } + ConstantCompilationModel() {} + ~ConstantCompilationModel() {} CompilerResult compile(QString code); }; diff --git a/mix/MixApplication.cpp b/mix/MixApplication.cpp index c63349409..e67ca1b12 100644 --- a/mix/MixApplication.cpp +++ b/mix/MixApplication.cpp @@ -23,8 +23,7 @@ #include "MixApplication.h" using namespace dev::mix; -MixApplication::MixApplication(int _argc, char *_argv[]) - : QApplication(_argc, _argv) +MixApplication::MixApplication(int _argc, char *_argv[]): QApplication(_argc, _argv) { } From 51f746f523c28becc25f9dcd82a3c886aacf5f1b Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Dec 2014 15:22:48 +0100 Subject: [PATCH 15/17] Add cmake file path (used to find QtDeclarativeConfig.cmake module) --- mix/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 28fbc7342..152485cec 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -11,7 +11,8 @@ elseif ("${TARGET_PLATFORM}" STREQUAL "w64") set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) elseif (UNIX) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";/opt/Qt5.3.2/5.3/gcc_64/lib/cmake") endif () find_package(Qt5Core REQUIRED) @@ -46,14 +47,14 @@ if (APPLE) set(MACOSX_BUNDLE_ICON_FILE mix) include(BundleUtilities) - add_executable(${EXECUTEABLE} MACOSX_BUNDLE ${SRC_LIST} ${HEADERS} ${UI_RESOURCES}) + add_executable(${EXECUTEABLE} MACOSX_BUNDLE ${SRC_LIST} ${HEADERS} ${UI_RESOURCES}) set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") else () set(EXECUTEABLE mix) - add_executable(${EXECUTEABLE} ${SRC_LIST} ${HEADERS} ${UI_RESOURCES}) + add_executable(${EXECUTEABLE} ${SRC_LIST} ${HEADERS} ${UI_RESOURCES}) endif () qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets) @@ -64,7 +65,7 @@ if (APPLE) add_custom_command(TARGET ${EXECUTEABLE} POST_BUILD COMMAND /usr/local/opt/qt5/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTEABLE}.app WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - + # This tool and next will inspect linked libraries in order to determine which dependencies are required if (${CMAKE_CFG_INTDIR} STREQUAL ".") set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTEABLE}.app") From 1edbaae205354f4f1c08545d01e3d3359f07295f Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 2 Dec 2014 11:54:33 +0100 Subject: [PATCH 16/17] delete reference to Qt5Declarative --- mix/CMakeLists.txt | 4 +--- mix/CodeEditorExtensionManager.cpp | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 152485cec..14a33ab11 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -11,8 +11,7 @@ elseif ("${TARGET_PLATFORM}" STREQUAL "w64") set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) elseif (UNIX) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";/opt/Qt5.3.2/5.3/gcc_64/lib/cmake") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake;../cmake/") endif () find_package(Qt5Core REQUIRED) @@ -23,7 +22,6 @@ find_package(Qt5Network REQUIRED) find_package(Qt5Widgets REQUIRED) find_package(Qt5WebKit REQUIRED) find_package(Qt5WebKitWidgets REQUIRED) -find_package(Qt5Declarative REQUIRED) #qt5_wrap_ui(ui_Main.h Main.ui) diff --git a/mix/CodeEditorExtensionManager.cpp b/mix/CodeEditorExtensionManager.cpp index 4a46c60d4..596aea165 100644 --- a/mix/CodeEditorExtensionManager.cpp +++ b/mix/CodeEditorExtensionManager.cpp @@ -22,9 +22,7 @@ #include #include -#include #include -#include #include #include #include From 2f355039b609b50dc2099a50aa1c9abecbc584ce Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 2 Dec 2014 12:13:28 +0100 Subject: [PATCH 17/17] delete qt5declarative from qt5_use_modules (cmake) --- mix/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 14a33ab11..da214fd29 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -11,7 +11,7 @@ elseif ("${TARGET_PLATFORM}" STREQUAL "w64") set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) elseif (UNIX) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake;../cmake/") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") endif () find_package(Qt5Core REQUIRED) @@ -91,4 +91,4 @@ else () install( TARGETS ${EXECUTEABLE} RUNTIME DESTINATION bin ) endif () -qt5_use_modules(${EXECUTEABLE} Core Gui Declarative) +qt5_use_modules(${EXECUTEABLE} Core Gui)