Browse Source

tab indentation

cl-refactor
yann300 10 years ago
parent
commit
369268c0ce
  1. 28
      mix/ApplicationCtx.cpp
  2. 40
      mix/ApplicationCtx.h
  3. 94
      mix/CodeEditorExtensionManager.cpp
  4. 48
      mix/CodeEditorExtensionManager.h
  5. 92
      mix/ConstantCompilationCtrl.cpp
  6. 44
      mix/ConstantCompilationCtrl.h
  7. 72
      mix/ConstantCompilationModel.cpp
  8. 34
      mix/ConstantCompilationModel.h
  9. 44
      mix/Extension.cpp
  10. 36
      mix/Extension.h
  11. 50
      mix/MixApplication.cpp
  12. 30
      mix/MixApplication.h
  13. 36
      mix/main.cpp
  14. 3
      mix/qml/BasicContent.qml

28
mix/ApplicationCtx.cpp

@ -1,15 +1,15 @@
/* /*
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
@ -26,11 +26,11 @@ ApplicationCtx* ApplicationCtx::Instance = nullptr;
QQmlApplicationEngine* ApplicationCtx::appEngine() QQmlApplicationEngine* ApplicationCtx::appEngine()
{ {
return m_applicationEngine; return m_applicationEngine;
} }
void ApplicationCtx::setApplicationContext(QQmlApplicationEngine* _engine) void ApplicationCtx::setApplicationContext(QQmlApplicationEngine* _engine)
{ {
if (Instance == nullptr) if (Instance == nullptr)
Instance = new ApplicationCtx(_engine); Instance = new ApplicationCtx(_engine);
} }

40
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 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.h /** @file ApplicationCtx.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -33,21 +33,21 @@ namespace mix
class ApplicationCtx: public QObject class ApplicationCtx: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; } ApplicationCtx(QQmlApplicationEngine* _engine) { m_applicationEngine = _engine; }
~ApplicationCtx() { delete m_applicationEngine; } ~ApplicationCtx() { delete m_applicationEngine; }
static ApplicationCtx* getInstance() { return Instance; } static ApplicationCtx* getInstance() { return Instance; }
static void setApplicationContext(QQmlApplicationEngine* _engine); static void setApplicationContext(QQmlApplicationEngine* _engine);
QQmlApplicationEngine* appEngine(); QQmlApplicationEngine* appEngine();
private: private:
static ApplicationCtx* Instance; static ApplicationCtx* Instance;
QQmlApplicationEngine* m_applicationEngine; QQmlApplicationEngine* m_applicationEngine;
public slots: public slots:
void quitApplication() { delete Instance; } void quitApplication() { delete Instance; }
}; };
} }

94
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 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 CodeEditorExtensionMan.cpp /** @file CodeEditorExtensionMan.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -36,56 +36,56 @@ using namespace dev::mix;
CodeEditorExtensionManager::~CodeEditorExtensionManager() CodeEditorExtensionManager::~CodeEditorExtensionManager()
{ {
m_features.clear(); m_features.clear();
} }
void CodeEditorExtensionManager::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 (...) catch (...)
{ {
qDebug() << "unable to load editor: "; qDebug() << "unable to load editor: ";
} }
} }
void CodeEditorExtensionManager::initExtensions() void CodeEditorExtensionManager::initExtensions()
{ {
//only one for now //only one for now
std::shared_ptr<ConstantCompilationCtrl> constantCompilation = std::make_shared<ConstantCompilationCtrl>(m_doc); std::shared_ptr<ConstantCompilationCtrl> constantCompilation = std::make_shared<ConstantCompilationCtrl>(m_doc);
if (constantCompilation.get()->contentUrl() != "") if (constantCompilation.get()->contentUrl() != "")
{ {
try try
{ {
constantCompilation.get()->addContentOn(m_tabView); constantCompilation.get()->addContentOn(m_tabView);
} }
catch (...) catch (...)
{ {
qDebug() << "Exception when adding content into view."; qDebug() << "Exception when adding content into view.";
return; return;
} }
} }
constantCompilation.get()->start(); constantCompilation.get()->start();
m_features.append(constantCompilation); m_features.append(constantCompilation);
} }
void CodeEditorExtensionManager::setEditor(QQuickItem* _editor) void CodeEditorExtensionManager::setEditor(QQuickItem* _editor)
{ {
this->loadEditor(_editor); this->loadEditor(_editor);
this->initExtensions(); this->initExtensions();
} }
void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView) void CodeEditorExtensionManager::setTabView(QQuickItem* _tabView)
{ {
m_tabView = _tabView; m_tabView = _tabView;
} }

48
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 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 CodeEditorExtensionMan.h /** @file CodeEditorExtensionMan.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -36,24 +36,24 @@ namespace mix
class CodeEditorExtensionManager: public QObject class CodeEditorExtensionManager: public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QQuickItem* editor MEMBER m_editor WRITE setEditor) Q_PROPERTY(QQuickItem* editor MEMBER m_editor WRITE setEditor)
Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView) Q_PROPERTY(QQuickItem* tabView MEMBER m_tabView WRITE setTabView)
public: public:
CodeEditorExtensionManager() {} CodeEditorExtensionManager() {}
~CodeEditorExtensionManager(); ~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<std::shared_ptr<ConstantCompilationCtrl>> 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*);
}; };
} }

92
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 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 ConstantCompilation.cpp /** @file ConstantCompilation.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -32,66 +32,66 @@ using namespace dev::mix;
ConstantCompilationCtrl::ConstantCompilationCtrl(QTextDocument* _doc) ConstantCompilationCtrl::ConstantCompilationCtrl(QTextDocument* _doc)
{ {
m_editor = _doc; m_editor = _doc;
m_compilationModel = new ConstantCompilationModel(); m_compilationModel = new ConstantCompilationModel();
} }
ConstantCompilationCtrl::~ConstantCompilationCtrl() ConstantCompilationCtrl::~ConstantCompilationCtrl()
{ {
delete m_compilationModel; delete m_compilationModel;
} }
QString ConstantCompilationCtrl::contentUrl() const QString ConstantCompilationCtrl::contentUrl() const
{ {
return QStringLiteral("qrc:/qml/BasicContent.qml"); return QStringLiteral("qrc:/qml/BasicContent.qml");
} }
QString ConstantCompilationCtrl::title() const QString ConstantCompilationCtrl::title() const
{ {
return "compiler"; return "compiler";
} }
void ConstantCompilationCtrl::start() const 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() void ConstantCompilationCtrl::compile()
{ {
QString codeContent = m_editor->toPlainText().replace("\n", ""); QString codeContent = m_editor->toPlainText().replace("\n", "");
if (codeContent == "") if (codeContent.isEmpty())
{ {
resetOutPut(); resetOutPut();
return; return;
} }
CompilerResult res = m_compilationModel->compile(m_editor->toPlainText()); CompilerResult res = m_compilationModel->compile(m_editor->toPlainText());
writeOutPut(res); writeOutPut(res);
} }
void ConstantCompilationCtrl::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);
status->setProperty("text", ""); status->setProperty("text", "");
content->setProperty("text", ""); content->setProperty("text", "");
} }
void ConstantCompilationCtrl::writeOutPut(const CompilerResult& _res) void ConstantCompilationCtrl::writeOutPut(CompilerResult const& _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);
} }
} }

44
mix/ConstantCompilationCtrl.h

@ -1,15 +1,15 @@
/* /*
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 ConstantCompilation.h /** @file ConstantCompilation.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -31,23 +31,23 @@ namespace mix
class ConstantCompilationCtrl: public Extension class ConstantCompilationCtrl: public Extension
{ {
Q_OBJECT Q_OBJECT
public: public:
ConstantCompilationCtrl(QTextDocument*); ConstantCompilationCtrl(QTextDocument*);
~ConstantCompilationCtrl(); ~ConstantCompilationCtrl();
void start() const override; void start() const override;
QString title() const override; QString title() const override;
QString contentUrl() const override; QString contentUrl() const override;
private: private:
QTextDocument* m_editor; QTextDocument* m_editor;
ConstantCompilationModel* m_compilationModel; ConstantCompilationModel* m_compilationModel;
void writeOutPut(const CompilerResult&); void writeOutPut(CompilerResult const&);
void resetOutPut(); void resetOutPut();
public Q_SLOTS: public Q_SLOTS:
void compile(); void compile();
}; };
} }

72
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 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.h /** @file ApplicationCtx.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -33,29 +33,29 @@ using namespace dev::mix;
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 = "";
} }
catch (...) catch (...)
{ {
res.success = false; res.success = false;
res.comment = "Uncaught exception."; res.comment = "Uncaught exception.";
res.hexCode = ""; res.hexCode = "";
} }
return res; return res;
} }

34
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 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.h /** @file ApplicationCtx.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -32,18 +32,18 @@ namespace mix
struct CompilerResult struct CompilerResult
{ {
QString hexCode; QString hexCode;
QString comment; QString comment;
bool success; bool success;
}; };
class ConstantCompilationModel class ConstantCompilationModel
{ {
public: public:
ConstantCompilationModel() { } ConstantCompilationModel() { }
~ConstantCompilationModel() { } ~ConstantCompilationModel() { }
CompilerResult compile(QString code); CompilerResult compile(QString code);
}; };
} }

44
mix/Extension.cpp

@ -1,15 +1,15 @@
/* /*
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 Feature.cpp /** @file Feature.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -27,18 +27,18 @@ using namespace dev::mix;
void Extension::addContentOn(QObject* _tabView) void Extension::addContentOn(QObject* _tabView)
{ {
if (contentUrl() == "") if (contentUrl() == "")
return; return;
QVariant returnValue; QVariant returnValue;
QQmlComponent* component = new QQmlComponent( QQmlComponent* component = new QQmlComponent(
ApplicationCtx::getInstance()->appEngine(), ApplicationCtx::getInstance()->appEngine(),
QUrl(this->contentUrl()), _tabView); QUrl(this->contentUrl()), _tabView);
QMetaObject::invokeMethod(_tabView, "addTab", QMetaObject::invokeMethod(_tabView, "addTab",
Q_RETURN_ARG(QVariant, returnValue), Q_RETURN_ARG(QVariant, returnValue),
Q_ARG(QVariant, this->title()), Q_ARG(QVariant, this->title()),
Q_ARG(QVariant, QVariant::fromValue(component))); Q_ARG(QVariant, QVariant::fromValue(component)));
m_view = qvariant_cast<QObject*>(returnValue); m_view = qvariant_cast<QObject*>(returnValue);
} }

36
mix/Extension.h

@ -1,15 +1,15 @@
/* /*
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 Feature.h /** @file Feature.h
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -30,17 +30,17 @@ namespace mix
class Extension: public QObject class Extension: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Extension() {} Extension() {}
virtual QString contentUrl() const { return ""; } virtual QString contentUrl() const { return ""; }
virtual QString title() const { return ""; } virtual QString title() const { return ""; }
virtual void start() const {} virtual void start() const {}
void addContentOn(QObject* tabView); void addContentOn(QObject* tabView);
protected: protected:
QObject* m_view; QObject* m_view;
}; };
} }

50
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 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 main.cpp /** @file main.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -24,23 +24,23 @@
using namespace dev::mix; using namespace dev::mix;
MixApplication::MixApplication(int _argc, char *_argv[]) MixApplication::MixApplication(int _argc, char *_argv[])
: QApplication(_argc, _argv) : QApplication(_argc, _argv)
{ {
} }
bool MixApplication::notify(QObject* _receiver, QEvent* _event) bool MixApplication::notify(QObject* _receiver, QEvent* _event)
{ {
try try
{ {
return MixApplication::notify(_receiver, _event); return MixApplication::notify(_receiver, _event);
} }
catch (std::exception& _ex) catch (std::exception& _ex)
{ {
qDebug() << "std::exception was caught " << _ex.what(); qDebug() << "std::exception was caught " << _ex.what();
} }
catch (...) catch (...)
{ {
qDebug() << "uncaught exception "; qDebug() << "uncaught exception ";
} }
return false; return false;
} }

30
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 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 main.cpp /** @file main.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -33,12 +33,12 @@ namespace mix
class MixApplication: public QApplication class MixApplication: public QApplication
{ {
Q_OBJECT Q_OBJECT
public: public:
MixApplication(int _argc, char* _argv[]); MixApplication(int _argc, char* _argv[]);
virtual ~MixApplication() { } virtual ~MixApplication() {}
virtual bool notify(QObject* _receiver, QEvent* _event); virtual bool notify(QObject* _receiver, QEvent* _event);
}; };
} }

36
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 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 main.cpp /** @file main.cpp
* @author Yann yann@ethdev.com * @author Yann yann@ethdev.com
@ -30,11 +30,11 @@ 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"); qmlRegisterType<CodeEditorExtensionManager>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager");
QQmlApplicationEngine* engine = new QQmlApplicationEngine(); QQmlApplicationEngine* engine = new QQmlApplicationEngine();
ApplicationCtx::setApplicationContext(engine); ApplicationCtx::setApplicationContext(engine);
QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationCtx::getInstance(), SLOT(quitApplication())); //use to kill ApplicationContext and other stuff 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();
} }

3
mix/qml/BasicContent.qml

@ -2,6 +2,7 @@ import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
width: parent.width width: parent.width
height: parent.height height: parent.height
@ -19,7 +20,7 @@ Rectangle {
id: status id: status
} }
TextArea{ TextArea {
readOnly: true readOnly: true
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 10 anchors.leftMargin: 10

Loading…
Cancel
Save