Browse Source

- 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).
cl-refactor
yann300 10 years ago
parent
commit
0a496d7725
  1. 37
      mix/ApplicationCtx.cpp
  2. 30
      mix/ApplicationCtx.h
  3. 66
      mix/CodeEditorExtensionManager.cpp
  4. 24
      mix/CodeEditorExtensionManager.h
  5. 48
      mix/ConstantCompilationCtrl.cpp
  6. 35
      mix/ConstantCompilationCtrl.h
  7. 41
      mix/ConstantCompilationModel.cpp
  8. 44
      mix/ConstantCompilationModel.h
  9. 43
      mix/Extension.cpp
  10. 26
      mix/Extension.h
  11. 42
      mix/MixApplication.cpp
  12. 46
      mix/MixApplication.h
  13. 17
      mix/main.cpp
  14. 1
      mix/qml/BasicContent.qml
  15. 2
      mix/qml/MainContent.qml
  16. 1
      mix/qml/TabStyle.qml
  17. 1
      mix/qml/main.qml

37
mix/ApplicationCtx.cpp

@ -1,55 +1,30 @@
/* /*
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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file ApplicationCtx.cpp /** @file ApplicationCtx.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
* @date 2014 * @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 <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include "ApplicationCtx.h"
using namespace dev::mix;
ApplicationCtx* ApplicationCtx::m_instance = nullptr; ApplicationCtx* ApplicationCtx::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) QQmlApplicationEngine* ApplicationCtx::appEngine()
{ {
m_instance = new ApplicationCtx(engine);
}
QQmlApplicationEngine* ApplicationCtx::appEngine(){
return m_applicationEngine; return m_applicationEngine;
} }
void ApplicationCtx::QuitApplication()
{
delete m_instance;
}

30
mix/ApplicationCtx.h

@ -17,29 +17,39 @@
/** @file ApplicationCtx.h /** @file ApplicationCtx.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
* @date 2014 * @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 #pragma once
#define APPLICATIONCONTEXT_H
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
namespace dev
{
namespace mix
{
class ApplicationCtx : public QObject class ApplicationCtx : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
ApplicationCtx(QQmlApplicationEngine*); ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; }
~ApplicationCtx(); ~ApplicationCtx() { delete m_applicationEngine; }
static ApplicationCtx* getInstance() { return Instance; }
static void setApplicationContext(QQmlApplicationEngine* _engine) { Instance = new ApplicationCtx(_engine); }
QQmlApplicationEngine* appEngine(); QQmlApplicationEngine* appEngine();
static ApplicationCtx* GetInstance();
static void SetApplicationContext(QQmlApplicationEngine*);
private: private:
static ApplicationCtx* m_instance; static ApplicationCtx* Instance;
QQmlApplicationEngine* m_applicationEngine; QQmlApplicationEngine* m_applicationEngine;
public slots: public slots:
void QuitApplication(); void quitApplication() { delete Instance; }
}; };
#endif // APPLICATIONCTX_H }
}

66
mix/CodeEditorExtensionMan.cpp → mix/CodeEditorExtensionManager.cpp

@ -27,64 +27,66 @@
#include <QtDeclarative/QDeclarativeView> #include <QtDeclarative/QDeclarativeView>
#include <QQmlComponent> #include <QQmlComponent>
#include <QQuickTextDocument> #include <QQuickTextDocument>
#include "CodeEditorExtensionMan.h" #include <libevm/VM.h>
#include "ConstantCompilationCtrl.h" #include "ConstantCompilationCtrl.h"
#include "features.h" #include "features.h"
#include "ApplicationCtx.h" #include "ApplicationCtx.h"
#include <libevm/VM.h> #include "CodeEditorExtensionManager.h"
using namespace dev; using namespace dev::mix;
CodeEditorExtensionMan::CodeEditorExtensionMan() CodeEditorExtensionManager::~CodeEditorExtensionManager()
{
}
CodeEditorExtensionMan::~CodeEditorExtensionMan()
{ {
for (int k = 0; k < m_features.length(); k++){ m_features.clear();
delete m_features.at(k);
}
} }
void CodeEditorExtensionMan::loadEditor(QQuickItem* _editor) void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor)
{ {
if (!_editor) if (!_editor)
return; return;
try{ try
{
QVariant doc = _editor->property("textDocument"); QVariant doc = _editor->property("textDocument");
if (doc.canConvert<QQuickTextDocument*>()) { if (doc.canConvert<QQuickTextDocument*>())
{
QQuickTextDocument* qqdoc = doc.value<QQuickTextDocument*>(); QQuickTextDocument* qqdoc = doc.value<QQuickTextDocument*>();
if (qqdoc) { if (qqdoc)
m_doc = qqdoc->textDocument(); m_doc = qqdoc->textDocument();
}
} }
} }
catch (dev::Exception const& exception){ catch (...)
{
qDebug() << "unable to load editor: "; qDebug() << "unable to load editor: ";
qDebug() << exception.what();
} }
} }
void CodeEditorExtensionMan::initExtensions() void CodeEditorExtensionManager::initExtensions()
{ {
try{ //only one for now
//only one for now std::shared_ptr<ConstantCompilationCtrl> m_constantCompilation(new ConstantCompilationCtrl(m_doc));
ConstantCompilation* m_constantCompilation = new ConstantCompilation(m_doc); ConstantCompilationCtrl* ext = m_constantCompilation.get();
if (m_constantCompilation->tabUrl() != "") if (ext->contentUrl() != "")
m_constantCompilation->addContentOn(m_tabView); {
m_constantCompilation->start(); try
m_features.append(m_constantCompilation); {
} ext->addContentOn(m_tabView);
catch (dev::Exception const& exception){ }
qDebug() << "unable to load extensions: "; catch (...)
qDebug() << exception.what(); {
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->loadEditor(_editor);
this->initExtensions(); this->initExtensions();
} }
void CodeEditorExtensionMan::setTabView(QQuickItem* _tabView){ void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView)
{
m_tabView = _tabView; m_tabView = _tabView;
} }

24
mix/CodeEditorExtensionMan.h → mix/CodeEditorExtensionManager.h

@ -20,15 +20,21 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#ifndef CODEEDITOREXTENSIONMAN_H #pragma once
#define CODEEDITOREXTENSIONMAN_H
#include "memory"
#include <QQuickItem> #include <QQuickItem>
#include <QTextDocument> #include <QTextDocument>
#include <QVector> #include <QVector>
#include "Feature.h" #include "ConstantCompilationCtrl.h"
class CodeEditorExtensionMan : public QObject namespace dev
{
namespace mix
{
class CodeEditorExtensionManager : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -36,18 +42,20 @@ class CodeEditorExtensionMan : public QObject
Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView)
public: public:
CodeEditorExtensionMan(); CodeEditorExtensionManager() {}
~CodeEditorExtensionMan(); ~CodeEditorExtensionManager();
void initExtensions(); void initExtensions();
void setEditor(QQuickItem*); void setEditor(QQuickItem*);
void setTabView(QQuickItem*); void setTabView(QQuickItem*);
private: private:
QQuickItem* m_editor; QQuickItem* m_editor;
QVector<Feature*> m_features; QVector<std::shared_ptr<ConstantCompilationCtrl>> m_features;
QQuickItem* m_tabView; QQuickItem* m_tabView;
QTextDocument* m_doc; QTextDocument* m_doc;
void loadEditor(QQuickItem*); void loadEditor(QQuickItem*);
}; };
#endif // CODEEDITOREXTENSIONMAN_H }
}

48
mix/ConstantCompilationCtrl.cpp

@ -20,53 +20,55 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#include "ConstantCompilationCtrl.h"
#include "ConstantCompilationModel.h"
#include <QQuickItem> #include <QQuickItem>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QtCore/QtCore> #include <QtCore/QtCore>
#include <QDebug> #include <QDebug>
#include "ConstantCompilationCtrl.h"
#include "ConstantCompilationModel.h"
using namespace dev::mix;
ConstantCompilation::ConstantCompilation(QTextDocument* _doc) ConstantCompilationCtrl::ConstantCompilationCtrl(QTextDocument* _doc)
{ {
m_editor = _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"); return QStringLiteral("qrc:/qml/BasicContent.qml");
} }
QString ConstantCompilation::title() QString ConstantCompilationCtrl::title() const
{ {
return "compiler"; return "compiler";
} }
void ConstantCompilation::start() 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 ConstantCompilation::compile() void ConstantCompilationCtrl::compile()
{ {
QString codeContent = m_editor->toPlainText().replace("\n", ""); QString codeContent = m_editor->toPlainText().replace("\n", "");
if (codeContent == ""){ if (codeContent == "")
{
resetOutPut(); resetOutPut();
return; return;
} }
compilerResult res = compilationModel->compile(m_editor->toPlainText()); CompilerResult res = m_compilationModel->compile(m_editor->toPlainText());
writeOutPut(res); writeOutPut(res);
} }
void ConstantCompilation::resetOutPut() void ConstantCompilationCtrl::resetOutPut()
{ {
QObject* status = m_view->findChild<QObject*>("status", Qt::FindChildrenRecursively); QObject* status = m_view->findChild<QObject*>("status", Qt::FindChildrenRecursively);
QObject* content = m_view->findChild<QObject*>("content", Qt::FindChildrenRecursively); QObject* content = m_view->findChild<QObject*>("content", Qt::FindChildrenRecursively);
@ -74,24 +76,22 @@ void ConstantCompilation::resetOutPut()
content->setProperty("text", ""); content->setProperty("text", "");
} }
void ConstantCompilation::writeOutPut(compilerResult res) void ConstantCompilationCtrl::writeOutPut(CompilerResult _res)
{ {
QObject* status = m_view->findChild<QObject*>("status", Qt::FindChildrenRecursively); QObject* status = m_view->findChild<QObject*>("status", Qt::FindChildrenRecursively);
QObject* content = m_view->findChild<QObject*>("content", Qt::FindChildrenRecursively); QObject* content = m_view->findChild<QObject*>("content", Qt::FindChildrenRecursively);
if (res.success){ if (_res.success)
{
status->setProperty("text", "succeeded"); status->setProperty("text", "succeeded");
status->setProperty("color", "green"); status->setProperty("color", "green");
content->setProperty("text", res.hexCode); content->setProperty("text", _res.hexCode);
qDebug() << QString("compile succeeded " + res.hexCode); qDebug() << QString("compile succeeded " + _res.hexCode);
} }
else { else
{
status->setProperty("text", "failure"); status->setProperty("text", "failure");
status->setProperty("color", "red"); status->setProperty("color", "red");
content->setProperty("text", res.comment); content->setProperty("text", _res.comment);
qDebug() << QString("compile failed " + res.comment); qDebug() << QString("compile failed " + _res.comment);
} }
} }

35
mix/ConstantCompilationCtrl.h

@ -1,16 +1,13 @@
/* /*
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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -20,33 +17,39 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#ifndef CONSTANTCOMPILATION_H #pragma once
#define CONSTANTCOMPILATION_H
#include <QTextDocument> #include <QTextDocument>
#include "ConstantCompilationModel.h" #include "ConstantCompilationModel.h"
#include "Feature.h" #include "Extension.h"
namespace dev
{
class ConstantCompilation : public Feature namespace mix
{
class ConstantCompilationCtrl : public Extension
{ {
Q_OBJECT Q_OBJECT
public: public:
ConstantCompilation(QTextDocument* doc); ConstantCompilationCtrl(QTextDocument*);
~ConstantCompilation(); ~ConstantCompilationCtrl();
void start() override; void start() const override;
QString title() override; QString title() const override;
QString tabUrl() override; QString contentUrl() const override;
private: private:
QTextDocument* m_editor; QTextDocument* m_editor;
ConstantCompilationModel* compilationModel; ConstantCompilationModel* m_compilationModel;
void writeOutPut(compilerResult); void writeOutPut(CompilerResult);
void resetOutPut(); void resetOutPut();
public Q_SLOTS: public Q_SLOTS:
void compile(); void compile();
}; };
#endif // CONSTANTCOMPILATION_H }
}

41
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 <http://www.gnu.org/licenses/>.
*/
/** @file ApplicationCtx.h
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#include <QObject> #include <QObject>
#include <libevm/VM.h> #include <libevm/VM.h>
#include <libsolidity/Scanner.h> #include <libsolidity/Scanner.h>
#include <libsolidity/CompilerStack.h> #include <libsolidity/CompilerStack.h>
#include <libsolidity/SourceReferenceFormatter.h> #include <libsolidity/SourceReferenceFormatter.h>
#include "ConstantCompilationModel.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; 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::solidity::CompilerStack compiler;
dev::bytes m_data; dev::bytes m_data;
compilerResult res; CompilerResult res;
try try
{ {
m_data = compiler.compile(code.toStdString(), true); m_data = compiler.compile(_code.toStdString(), true);
res.success = true; res.success = true;
res.comment = "ok"; res.comment = "ok";
res.hexCode = QString::fromStdString(dev::eth::disassemble(m_data)); res.hexCode = QString::fromStdString(dev::eth::disassemble(m_data));
} }
catch (dev::Exception const& exception) catch (dev::Exception const& _exception)
{ {
ostringstream error; ostringstream error;
solidity::SourceReferenceFormatter::printExceptionInformation(error, exception, "Error", compiler.getScanner()); solidity::SourceReferenceFormatter::printExceptionInformation(error, _exception, "Error", compiler.getScanner());
res.success = false; res.success = false;
res.comment = QString::fromStdString(error.str()).toHtmlEscaped(); res.comment = QString::fromStdString(error.str()).toHtmlEscaped();
res.hexCode = ""; res.hexCode = "";
@ -41,4 +59,3 @@ compilerResult ConstantCompilationModel::compile(QString code)
} }
return res; return res;
} }

44
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 <http://www.gnu.org/licenses/>.
*/
/** @file ApplicationCtx.h
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#pragma once
#include <QObject> #include <QObject>
struct compilerResult{ namespace dev
{
namespace mix
{
struct CompilerResult
{
QString hexCode; QString hexCode;
QString comment; QString comment;
bool success; bool success;
@ -12,8 +41,11 @@ class ConstantCompilationModel
{ {
public: public:
ConstantCompilationModel(); ConstantCompilationModel() { }
compilerResult compile(QString code); ~ConstantCompilationModel() { }
CompilerResult compile(QString code);
}; };
#endif // CONSTANTCOMPILATIONMODEL_H }
}

43
mix/Feature.cpp → mix/Extension.cpp

@ -1,16 +1,13 @@
/* /*
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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -20,36 +17,28 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#include "Feature.h"
#include "ApplicationCtx.h"
#include <libevm/VM.h>
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
#include <libevm/VM.h>
#include "Extension.h"
#include "ApplicationCtx.h"
using namespace dev; using namespace dev;
using namespace dev::mix;
Feature::Feature() void Extension::addContentOn(QObject* _tabView)
{ {
} if (contentUrl() == "")
return;
void Feature::addContentOn(QObject* tabView) { QVariant returnValue;
try{ QQmlComponent* component = new QQmlComponent(
if (tabUrl() == "") ApplicationCtx::getInstance()->appEngine(),
return; QUrl(this->contentUrl()), _tabView);
QVariant returnValue; QMetaObject::invokeMethod(_tabView, "addTab",
QQmlComponent* component = new QQmlComponent( Q_RETURN_ARG(QVariant, returnValue),
ApplicationCtx::GetInstance()->appEngine(), Q_ARG(QVariant, this->title()),
QUrl(this->tabUrl()), tabView); Q_ARG(QVariant, QVariant::fromValue(component)));
QMetaObject::invokeMethod(tabView, "addTab", m_view = qvariant_cast<QObject*>(returnValue);
Q_RETURN_ARG(QVariant, returnValue),
Q_ARG(QVariant, this->title()),
Q_ARG(QVariant, QVariant::fromValue(component)));
m_view = qvariant_cast<QObject*>(returnValue);
}
catch (dev::Exception const& exception){
qDebug() << exception.what();
}
} }

26
mix/Feature.h → mix/Extension.h

@ -1,16 +1,13 @@
/* /*
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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -20,25 +17,32 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#ifndef FEATURE_H #pragma once
#define FEATURE_H
#include <QApplication> #include <QApplication>
#include <QQmlComponent> #include <QQmlComponent>
class Feature : public QObject namespace dev
{
namespace mix
{
class Extension : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Feature(); Extension() {}
virtual QString tabUrl() { return ""; } virtual QString contentUrl() const { return ""; }
virtual QString title() { return ""; } virtual QString title() const { return ""; }
virtual void start() {} virtual void start() const {}
void addContentOn(QObject* tabView); void addContentOn(QObject* tabView);
protected: protected:
QObject* m_view; QObject* m_view;
}; };
#endif // FEATURE_H }
}

42
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 <http://www.gnu.org/licenses/>.
*/
/** @file main.cpp
* @author Yann yann@ethdev.com
* @date 2014
*/
#include <QDebug>
#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;
}

46
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 <http://www.gnu.org/licenses/>.
*/
/** @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 <QApplication>
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);
};
}
}

17
mix/main.cpp

@ -23,19 +23,18 @@
#include <QApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQuickItem> #include <QQuickItem>
#include "CodeEditorExtensionMan.h" #include "CodeEditorExtensionManager.h"
#include "ApplicationCtx.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>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager");
QQmlApplicationEngine* engine = new QQmlApplicationEngine(); QQmlApplicationEngine* engine = new QQmlApplicationEngine();
qmlRegisterType<CodeEditorExtensionMan>("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"))); engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
return app.exec(); return app.exec();
} }

1
mix/qml/BasicContent.qml

@ -6,6 +6,7 @@ Rectangle {
width: parent.width width: parent.width
height: parent.height height: parent.height
color: "lightgray" color: "lightgray"
Text { Text {
font.pointSize: 7 font.pointSize: 7
anchors.left: parent.left anchors.left: parent.left

2
mix/qml/MainContent.qml

@ -13,7 +13,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
orientation: Qt.Vertical orientation: Qt.Vertical
Rectangle { Rectangle {
anchors.top : parent.top anchors.top: parent.top
id: contentView id: contentView
width: parent.width width: parent.width
height: parent.height * 0.7 height: parent.height * 0.7

1
mix/qml/TabStyle.qml

@ -8,7 +8,6 @@ TabViewStyle {
color: "lightgray" color: "lightgray"
} }
tab: Rectangle { tab: Rectangle {
color: "lightsteelblue" color: "lightsteelblue"
implicitWidth: Math.max(text.width + 4, 80) implicitWidth: Math.max(text.width + 4, 80)
implicitHeight: 20 implicitHeight: 20

1
mix/qml/main.qml

@ -4,7 +4,6 @@ import QtQuick.Controls.Styles 1.2
import CodeEditorExtensionManager 1.0 import CodeEditorExtensionManager 1.0
ApplicationWindow { ApplicationWindow {
visible: true visible: true
width: 1000 width: 1000
height: 480 height: 480

Loading…
Cancel
Save