arkpar
10 years ago
25 changed files with 125 additions and 634 deletions
@ -1,122 +0,0 @@ |
|||||
/*
|
|
||||
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 AppContext.cpp
|
|
||||
* @author Yann yann@ethdev.com |
|
||||
* @date 2014 |
|
||||
* Provides 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. |
|
||||
* For now AppContext provides reference to: |
|
||||
* - QQmlApplicationEngine |
|
||||
* - dev::WebThreeDirect (and dev::eth::Client) |
|
||||
* - KeyEventManager |
|
||||
*/ |
|
||||
|
|
||||
#include <QMessageBox> |
|
||||
#include <QClipboard> |
|
||||
#include <QQmlComponent> |
|
||||
#include <QQmlContext> |
|
||||
#include <QQmlApplicationEngine> |
|
||||
#include <QWindow> |
|
||||
#include "CodeModel.h" |
|
||||
#include "FileIo.h" |
|
||||
#include "ClientModel.h" |
|
||||
#include "CodeEditorExtensionManager.h" |
|
||||
#include "Exceptions.h" |
|
||||
#include "QEther.h" |
|
||||
#include "QVariableDefinition.h" |
|
||||
#include "HttpServer.h" |
|
||||
#include "AppContext.h" |
|
||||
#include "SortFilterProxyModel.h" |
|
||||
|
|
||||
using namespace dev; |
|
||||
using namespace dev::eth; |
|
||||
using namespace dev::mix; |
|
||||
|
|
||||
const QString c_projectFileName = "project.mix"; |
|
||||
|
|
||||
AppContext::AppContext(QQmlApplicationEngine* _engine) |
|
||||
{ |
|
||||
m_applicationEngine = _engine; |
|
||||
m_codeModel.reset(new CodeModel(this)); |
|
||||
m_clientModel.reset(new ClientModel(this)); |
|
||||
m_fileIo.reset(new FileIo()); |
|
||||
connect(QApplication::clipboard(), &QClipboard::dataChanged, [this] { emit clipboardChanged();}); |
|
||||
} |
|
||||
|
|
||||
AppContext::~AppContext() |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
void AppContext::load() |
|
||||
{ |
|
||||
m_applicationEngine->rootContext()->setContextProperty("appContext", this); |
|
||||
QFont f; |
|
||||
m_applicationEngine->rootContext()->setContextProperty("systemPointSize", f.pointSize()); |
|
||||
qmlRegisterType<FileIo>("org.ethereum.qml", 1, 0, "FileIo"); |
|
||||
m_applicationEngine->rootContext()->setContextProperty("codeModel", m_codeModel.get()); |
|
||||
m_applicationEngine->rootContext()->setContextProperty("fileIo", m_fileIo.get()); |
|
||||
qmlRegisterType<QEther>("org.ethereum.qml.QEther", 1, 0, "QEther"); |
|
||||
qmlRegisterType<QBigInt>("org.ethereum.qml.QBigInt", 1, 0, "QBigInt"); |
|
||||
qmlRegisterType<QVariableDeclaration>("org.ethereum.qml.QVariableDeclaration", 1, 0, "QVariableDeclaration"); |
|
||||
qmlRegisterType<RecordLogEntry>("org.ethereum.qml.RecordLogEntry", 1, 0, "RecordLogEntry"); |
|
||||
qmlRegisterType<SortFilterProxyModel>("org.ethereum.qml.SortFilterProxyModel", 1, 0, "SortFilterProxyModel"); |
|
||||
qmlRegisterType<QSolidityType>("org.ethereum.qml.QSolidityType", 1, 0, "QSolidityType"); |
|
||||
QQmlComponent projectModelComponent(m_applicationEngine, QUrl("qrc:/qml/ProjectModel.qml")); |
|
||||
QObject* projectModel = projectModelComponent.create(); |
|
||||
if (projectModelComponent.isError()) |
|
||||
{ |
|
||||
QmlLoadException exception; |
|
||||
for (auto const& e : projectModelComponent.errors()) |
|
||||
exception << QmlErrorInfo(e); |
|
||||
BOOST_THROW_EXCEPTION(exception); |
|
||||
} |
|
||||
m_applicationEngine->rootContext()->setContextProperty("projectModel", projectModel); |
|
||||
qmlRegisterType<CodeEditorExtensionManager>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); |
|
||||
qmlRegisterType<HttpServer>("HttpServer", 1, 0, "HttpServer"); |
|
||||
|
|
||||
m_applicationEngine->load(QUrl("qrc:/qml/main.qml")); |
|
||||
QWindow *window = qobject_cast<QWindow*>(m_applicationEngine->rootObjects().at(0)); |
|
||||
window->setIcon(QIcon(":/res/mix_256x256x32.png")); |
|
||||
appLoaded(); |
|
||||
} |
|
||||
|
|
||||
QQmlApplicationEngine* AppContext::appEngine() |
|
||||
{ |
|
||||
return m_applicationEngine; |
|
||||
} |
|
||||
|
|
||||
void AppContext::displayMessageDialog(QString _title, QString _message) |
|
||||
{ |
|
||||
// TODO : move to a UI dedicated layer.
|
|
||||
QObject* dialogWin = m_applicationEngine->rootObjects().at(0)->findChild<QObject*>("alertMessageDialog", Qt::FindChildrenRecursively); |
|
||||
QObject* dialogWinComponent = m_applicationEngine->rootObjects().at(0)->findChild<QObject*>("alertMessageDialogContent", Qt::FindChildrenRecursively); |
|
||||
dialogWinComponent->setProperty("source", QString("qrc:/qml/BasicMessage.qml")); |
|
||||
dialogWin->setProperty("title", _title); |
|
||||
dialogWin->setProperty("width", "250"); |
|
||||
dialogWin->setProperty("height", "100"); |
|
||||
dialogWin->findChild<QObject*>("messageContent", Qt::FindChildrenRecursively)->setProperty("text", _message); |
|
||||
QMetaObject::invokeMethod(dialogWin, "open"); |
|
||||
} |
|
||||
|
|
||||
QString AppContext::clipboard() const |
|
||||
{ |
|
||||
QClipboard *clipboard = QApplication::clipboard(); |
|
||||
return clipboard->text(); |
|
||||
} |
|
||||
|
|
||||
void AppContext::toClipboard(QString _text) |
|
||||
{ |
|
||||
QClipboard *clipboard = QApplication::clipboard(); |
|
||||
clipboard->setText(_text); |
|
||||
} |
|
@ -1,88 +0,0 @@ |
|||||
/*
|
|
||||
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 AppContext.h
|
|
||||
* @author Yann yann@ethdev.com |
|
||||
* @date 2014 |
|
||||
* Provides 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. |
|
||||
* For now AppContext provides reference to: |
|
||||
* - QQmlApplicationEngine |
|
||||
* - dev::WebThreeDirect (and dev::eth::Client) |
|
||||
* - KeyEventManager |
|
||||
*/ |
|
||||
|
|
||||
#pragma once |
|
||||
|
|
||||
#include <memory> |
|
||||
#include <QUrl> |
|
||||
#include <QObject> |
|
||||
|
|
||||
class QQmlApplicationEngine; |
|
||||
|
|
||||
namespace dev |
|
||||
{ |
|
||||
namespace mix |
|
||||
{ |
|
||||
|
|
||||
class CodeModel; |
|
||||
class ClientModel; |
|
||||
class FileIo; |
|
||||
/**
|
|
||||
* @brief Provides access to application scope variable. |
|
||||
*/ |
|
||||
|
|
||||
class AppContext: public QObject |
|
||||
{ |
|
||||
Q_OBJECT |
|
||||
Q_PROPERTY(QString clipboard READ clipboard WRITE toClipboard NOTIFY clipboardChanged) |
|
||||
|
|
||||
public: |
|
||||
AppContext(QQmlApplicationEngine* _engine); |
|
||||
virtual ~AppContext(); |
|
||||
/// Load the UI from qml files
|
|
||||
void load(); |
|
||||
/// Get the current QQMLApplicationEngine instance.
|
|
||||
QQmlApplicationEngine* appEngine(); |
|
||||
/// Get code model
|
|
||||
CodeModel* codeModel() { return m_codeModel.get(); } |
|
||||
/// Get client model
|
|
||||
ClientModel* clientModel() { return m_clientModel.get(); } |
|
||||
/// Display an alert message.
|
|
||||
void displayMessageDialog(QString _title, QString _message); |
|
||||
/// Copy text to clipboard
|
|
||||
Q_INVOKABLE void toClipboard(QString _text); |
|
||||
/// Get text from clipboard
|
|
||||
QString clipboard() const; |
|
||||
|
|
||||
signals: |
|
||||
/// Triggered once components have been loaded
|
|
||||
void appLoaded(); |
|
||||
void clipboardChanged(); |
|
||||
|
|
||||
private: |
|
||||
QQmlApplicationEngine* m_applicationEngine; //owned by app
|
|
||||
std::unique_ptr<CodeModel> m_codeModel; |
|
||||
std::unique_ptr<ClientModel> m_clientModel; |
|
||||
std::unique_ptr<FileIo> m_fileIo; |
|
||||
|
|
||||
public slots: |
|
||||
/// Delete the current instance when application quit.
|
|
||||
void quitApplication() {} |
|
||||
}; |
|
||||
|
|
||||
} |
|
||||
} |
|
@ -1,55 +1,40 @@ |
|||||
/*
|
/*
|
||||
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 ConstantCompilationControl.cpp
|
/** @file Clipboard.cpp
|
||||
* @author Yann yann@ethdev.com |
* @author Yann yann@ethdev.com |
||||
* @date 2014 |
* @date 2015 |
||||
* Ethereum IDE client. |
|
||||
*/ |
*/ |
||||
|
|
||||
#include <QQmlContext> |
#include "Clipboard.h" |
||||
#include <QQuickItem> |
|
||||
#include <QtCore/QFileInfo> |
|
||||
#include <QApplication> |
#include <QApplication> |
||||
#include <QQmlApplicationEngine> |
#include <QClipboard> |
||||
#include <QtCore/QtCore> |
|
||||
#include <QDebug> |
|
||||
#include "StatusPane.h" |
|
||||
#include "QContractDefinition.h" |
|
||||
#include "AppContext.h" |
|
||||
#include "CodeModel.h" |
|
||||
|
|
||||
using namespace dev::mix; |
using namespace dev::mix; |
||||
|
|
||||
StatusPane::StatusPane(AppContext* _context): Extension(_context, ExtensionDisplayBehavior::HeaderView) |
Clipboard::Clipboard() |
||||
{ |
{ |
||||
_context->appEngine()->rootContext()->setContextProperty("statusPane", this); |
connect(QApplication::clipboard(), &QClipboard::dataChanged, [this] { emit clipboardChanged();}); |
||||
} |
} |
||||
|
|
||||
QString StatusPane::contentUrl() const |
QString Clipboard::text() const |
||||
{ |
{ |
||||
return QStringLiteral("qrc:/qml/StatusPane.qml"); |
QClipboard *clipboard = QApplication::clipboard(); |
||||
|
return clipboard->text(); |
||||
} |
} |
||||
|
|
||||
QString StatusPane::title() const |
void Clipboard::setText(QString _text) |
||||
{ |
{ |
||||
return QApplication::tr("compiler"); |
QClipboard *clipboard = QApplication::clipboard(); |
||||
|
clipboard->setText(_text); |
||||
} |
} |
||||
|
|
||||
void StatusPane::start() const |
|
||||
{ |
|
||||
} |
|
||||
|
|
@ -1,88 +0,0 @@ |
|||||
/*
|
|
||||
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 CodeEditorExtensionManager.cpp
|
|
||||
* @author Yann yann@ethdev.com |
|
||||
* @date 2014 |
|
||||
* Ethereum IDE client. |
|
||||
*/ |
|
||||
|
|
||||
#include <QQuickItem> |
|
||||
#include <QGraphicsObject> |
|
||||
#include <QQmlEngine> |
|
||||
#include <QQmlComponent> |
|
||||
#include <QQuickTextDocument> |
|
||||
#include "StatusPane.h" |
|
||||
#include "AppContext.h" |
|
||||
#include "MixApplication.h" |
|
||||
#include "CodeModel.h" |
|
||||
#include "ClientModel.h" |
|
||||
#include "CodeHighlighter.h" |
|
||||
#include "CodeEditorExtensionManager.h" |
|
||||
|
|
||||
using namespace dev::mix; |
|
||||
|
|
||||
CodeEditorExtensionManager::CodeEditorExtensionManager(): |
|
||||
m_appContext(static_cast<MixApplication*>(QApplication::instance())->context()) |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
CodeEditorExtensionManager::~CodeEditorExtensionManager() |
|
||||
{ |
|
||||
m_features.clear(); |
|
||||
} |
|
||||
|
|
||||
void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) |
|
||||
{ |
|
||||
if (!_editor) |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> _ext) |
|
||||
{ |
|
||||
if (!_ext->contentUrl().isEmpty()) |
|
||||
{ |
|
||||
try |
|
||||
{ |
|
||||
if (_ext->getDisplayBehavior() == ExtensionDisplayBehavior::RightView) |
|
||||
_ext->addTabOn(m_rightView); |
|
||||
if (_ext->getDisplayBehavior() == ExtensionDisplayBehavior::HeaderView) |
|
||||
_ext->addTabOn(m_headerView); |
|
||||
} |
|
||||
catch (...) |
|
||||
{ |
|
||||
qDebug() << "Exception when adding tab into view."; |
|
||||
return; |
|
||||
} |
|
||||
} |
|
||||
_ext->start(); |
|
||||
m_features.append(_ext); |
|
||||
} |
|
||||
|
|
||||
void CodeEditorExtensionManager::applyCodeHighlight() |
|
||||
{ |
|
||||
//TODO: reimplement
|
|
||||
} |
|
||||
|
|
||||
void CodeEditorExtensionManager::setRightView(QQuickItem* _rightView) |
|
||||
{ |
|
||||
m_rightView = _rightView; |
|
||||
} |
|
||||
|
|
||||
void CodeEditorExtensionManager::setHeaderView(QQuickItem* _headerView) |
|
||||
{ |
|
||||
m_headerView = _headerView; |
|
||||
} |
|
@ -1,71 +0,0 @@ |
|||||
/*
|
|
||||
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 CodeEditorExtensionManager.h
|
|
||||
* @author Yann yann@ethdev.com |
|
||||
* @date 2014 |
|
||||
* Ethereum IDE client. |
|
||||
*/ |
|
||||
|
|
||||
#pragma once |
|
||||
|
|
||||
#include <memory> |
|
||||
#include <QQuickItem> |
|
||||
#include <QTextDocument> |
|
||||
#include <QVector> |
|
||||
#include "StatusPane.h" |
|
||||
|
|
||||
namespace dev |
|
||||
{ |
|
||||
namespace mix |
|
||||
{ |
|
||||
|
|
||||
|
|
||||
class AppContext; |
|
||||
|
|
||||
/**
|
|
||||
* @brief Init and provides connection between extensions. |
|
||||
*/ |
|
||||
class CodeEditorExtensionManager: public QObject |
|
||||
{ |
|
||||
Q_OBJECT |
|
||||
|
|
||||
Q_PROPERTY(QQuickItem* headerView MEMBER m_headerView WRITE setHeaderView) |
|
||||
Q_PROPERTY(QQuickItem* rightView MEMBER m_rightView WRITE setRightView) |
|
||||
|
|
||||
public: |
|
||||
CodeEditorExtensionManager(); |
|
||||
~CodeEditorExtensionManager(); |
|
||||
/// Initialize extension.
|
|
||||
void initExtension(std::shared_ptr<Extension>); |
|
||||
/// Set current tab view
|
|
||||
void setHeaderView(QQuickItem*); |
|
||||
/// Set current right tab view.
|
|
||||
void setRightView(QQuickItem*); |
|
||||
|
|
||||
private slots: |
|
||||
void applyCodeHighlight(); |
|
||||
|
|
||||
private: |
|
||||
QVector<std::shared_ptr<Extension>> m_features; |
|
||||
QQuickItem* m_headerView; |
|
||||
QQuickItem* m_rightView; |
|
||||
AppContext* m_appContext; |
|
||||
void loadEditor(QQuickItem* _editor); |
|
||||
}; |
|
||||
|
|
||||
} |
|
||||
} |
|
@ -1,82 +0,0 @@ |
|||||
/*
|
|
||||
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 Extension.cpp
|
|
||||
* @author Yann yann@ethdev.com |
|
||||
* @date 2014 |
|
||||
* Ethereum IDE client. |
|
||||
*/ |
|
||||
|
|
||||
|
|
||||
#include <QMessageBox> |
|
||||
#include <QDebug> |
|
||||
#include <QQmlApplicationEngine> |
|
||||
|
|
||||
#include <libevm/VM.h> |
|
||||
#include <libwebthree/WebThree.h> |
|
||||
#include "Extension.h" |
|
||||
#include "AppContext.h" |
|
||||
|
|
||||
using namespace dev; |
|
||||
using namespace dev::mix; |
|
||||
|
|
||||
Extension::Extension(AppContext* _context) |
|
||||
{ |
|
||||
init(_context); |
|
||||
} |
|
||||
|
|
||||
Extension::Extension(AppContext* _context, ExtensionDisplayBehavior _displayBehavior) |
|
||||
{ |
|
||||
init(_context); |
|
||||
m_displayBehavior = _displayBehavior; |
|
||||
} |
|
||||
|
|
||||
void Extension::init(AppContext* _context) |
|
||||
{ |
|
||||
m_ctx = _context; |
|
||||
m_appEngine = m_ctx->appEngine(); |
|
||||
} |
|
||||
|
|
||||
void Extension::addTabOn(QObject* _view) |
|
||||
{ |
|
||||
if (contentUrl() == "") |
|
||||
return; |
|
||||
|
|
||||
QVariant returnValue; |
|
||||
QQmlComponent* component = new QQmlComponent( |
|
||||
m_appEngine, |
|
||||
QUrl(contentUrl()), _view); |
|
||||
|
|
||||
QMetaObject::invokeMethod(_view, "addTab", |
|
||||
Q_RETURN_ARG(QVariant, returnValue), |
|
||||
Q_ARG(QVariant, this->title()), |
|
||||
Q_ARG(QVariant, QVariant::fromValue(component))); |
|
||||
|
|
||||
m_view = qvariant_cast<QObject*>(returnValue); |
|
||||
} |
|
||||
|
|
||||
void Extension::addContentOn(QObject* _view) |
|
||||
{ |
|
||||
Q_UNUSED(_view); |
|
||||
if (m_displayBehavior == ExtensionDisplayBehavior::ModalDialog) |
|
||||
{ |
|
||||
QQmlComponent* component = new QQmlComponent(m_appEngine, QUrl(contentUrl()), _view); |
|
||||
QObject* dialogWin = m_appEngine->rootObjects().at(0)->findChild<QObject*>("dialog", Qt::FindChildrenRecursively); |
|
||||
QObject* dialogWinComponent = m_appEngine->rootObjects().at(0)->findChild<QObject*>("modalDialogContent", Qt::FindChildrenRecursively); |
|
||||
dialogWinComponent->setProperty("sourceComponent", QVariant::fromValue(component)); |
|
||||
dialogWin->setProperty("title", title()); |
|
||||
QMetaObject::invokeMethod(dialogWin, "open"); |
|
||||
} |
|
||||
//TODO add more view type.
|
|
||||
} |
|
||||
|
|
@ -1,75 +0,0 @@ |
|||||
/*
|
|
||||
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 Extension.h
|
|
||||
* @author Yann yann@ethdev.com |
|
||||
* @date 2014 |
|
||||
* Ethereum IDE client. |
|
||||
*/ |
|
||||
|
|
||||
#pragma once |
|
||||
|
|
||||
#include <QApplication> |
|
||||
#include <QQmlComponent> |
|
||||
|
|
||||
class QQmlApplicationEngine; |
|
||||
|
|
||||
namespace dev |
|
||||
{ |
|
||||
namespace mix |
|
||||
{ |
|
||||
|
|
||||
class AppContext; |
|
||||
|
|
||||
enum ExtensionDisplayBehavior |
|
||||
{ |
|
||||
HeaderView, |
|
||||
RightView, |
|
||||
ModalDialog |
|
||||
}; |
|
||||
|
|
||||
|
|
||||
class Extension: public QObject |
|
||||
{ |
|
||||
Q_OBJECT |
|
||||
|
|
||||
public: |
|
||||
Extension(AppContext* _context); |
|
||||
Extension(AppContext* _context, ExtensionDisplayBehavior _displayBehavior); |
|
||||
/// Return the QML url of the view to display.
|
|
||||
virtual QString contentUrl() const { return ""; } |
|
||||
/// Return the title of this extension.
|
|
||||
virtual QString title() const { return ""; } |
|
||||
/// Initialize extension.
|
|
||||
virtual void start() const {} |
|
||||
/// Add the view define in contentUrl() in the _view QObject.
|
|
||||
void addContentOn(QObject* _view); |
|
||||
/// Add the view define in contentUrl() in the _view QObject (_view has to be a tab).
|
|
||||
void addTabOn(QObject* _view); |
|
||||
/// Modify the display behavior of this extension.
|
|
||||
void setDisplayBehavior(ExtensionDisplayBehavior _displayBehavior) { m_displayBehavior = _displayBehavior; } |
|
||||
/// Get the display behavior of thi extension.
|
|
||||
ExtensionDisplayBehavior getDisplayBehavior() { return m_displayBehavior; } |
|
||||
|
|
||||
protected: |
|
||||
QObject* m_view; |
|
||||
ExtensionDisplayBehavior m_displayBehavior; |
|
||||
AppContext* m_ctx; |
|
||||
QQmlApplicationEngine* m_appEngine; |
|
||||
|
|
||||
private: |
|
||||
void init(AppContext* _context); |
|
||||
}; |
|
||||
|
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue