Browse Source

small changes

cl-refactor
yann300 10 years ago
parent
commit
4a870cda7b
  1. 2
      CMakeLists.txt
  2. 33
      mix/ApplicationContext.cpp
  3. 55
      mix/ApplicationCtx.cpp
  4. 12
      mix/ApplicationCtx.h
  5. 2
      mix/CodeEditorExtensionMan.cpp
  6. 10
      mix/ConstantCompilation.cpp
  7. 22
      mix/ConstantCompilation.h
  8. 7
      mix/Feature.cpp
  9. 22
      mix/Feature.h
  10. 7
      mix/MainContent.qml
  11. 28
      mix/main.cpp

2
CMakeLists.txt

@ -158,6 +158,7 @@ if (NOT LANGUAGES)
add_subdirectory(libqethereum) add_subdirectory(libqethereum)
add_subdirectory(alethzero) add_subdirectory(alethzero)
add_subdirectory(third) add_subdirectory(third)
add_subdirectory(mix)
if(QTQML) if(QTQML)
#add_subdirectory(iethxi) #add_subdirectory(iethxi)
#add_subdirectory(walleth) // resurect once we want to submit ourselves to QML. #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) #unset(TARGET_PLATFORM CACHE)

33
mix/ApplicationContext.cpp

@ -1,33 +0,0 @@
#include "ApplicationContext.h"
#include <QQmlApplicationEngine>
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;
}

55
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 <http://www.gnu.org/licenses/>.
*/
/** @file main.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
* Ethereum client.
*/
#include "ApplicationCtx.h"
#include <QQmlApplicationEngine>
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;
}

12
mix/ApplicationContext.h → mix/ApplicationCtx.h

@ -3,21 +3,21 @@
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
class ApplicationContext : public QObject class ApplicationCtx : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
ApplicationContext(QQmlApplicationEngine*); ApplicationCtx(QQmlApplicationEngine*);
~ApplicationContext(); ~ApplicationCtx();
QQmlApplicationEngine* appEngine(); QQmlApplicationEngine* appEngine();
static ApplicationContext* GetInstance(); static ApplicationCtx* GetInstance();
static void SetApplicationContext(QQmlApplicationEngine*); static void SetApplicationContext(QQmlApplicationEngine*);
private: private:
static ApplicationContext* m_instance; static ApplicationCtx* m_instance;
QQmlApplicationEngine* m_applicationEngine; QQmlApplicationEngine* m_applicationEngine;
public slots: public slots:
void QuitApplication(); void QuitApplication();
}; };
#endif // APPLICATIONCONTEXT_H #endif // APPLICATIONCTX_H

2
mix/CodeEditorExtensionMan.cpp

@ -8,7 +8,7 @@
#include "CodeEditorExtensionMan.h" #include "CodeEditorExtensionMan.h"
#include "ConstantCompilation.h" #include "ConstantCompilation.h"
#include "features.h" #include "features.h"
#include "ApplicationContext.h" #include "ApplicationCtx.h"
#include <libevm/VM.h> #include <libevm/VM.h>
using namespace dev; using namespace dev;

10
mix/ConstantCompilation.cpp

@ -29,7 +29,7 @@ void ConstantCompilation::start()
QString ConstantCompilation::title() QString ConstantCompilation::title()
{ {
return "compilation"; return "compiler";
} }
void ConstantCompilation::compile() void ConstantCompilation::compile()
@ -60,8 +60,8 @@ void ConstantCompilation::compile()
content = "Uncaught exception."; content = "Uncaught exception.";
this->writeOutPut(false, content); this->writeOutPut(false, content);
} }
} }
void ConstantCompilation::writeOutPut(bool _success, QString _content){ void ConstantCompilation::writeOutPut(bool _success, QString _content){
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);
@ -70,13 +70,13 @@ void ConstantCompilation::writeOutPut(bool _success, QString _content){
content->setProperty("text", ""); content->setProperty("text", "");
} }
else if (_success){ else if (_success){
status->setProperty("text", "compile successfull"); status->setProperty("text", "succeeded");
status->setProperty("color", "green"); status->setProperty("color", "green");
content->setProperty("text", _content); content->setProperty("text", _content);
qDebug() << QString("compile suceeded " + _content); qDebug() << QString("compile succeeded " + _content);
} }
else { else {
status->setProperty("text", "compile failed"); status->setProperty("text", "failure");
status->setProperty("color", "red"); status->setProperty("color", "red");
content->setProperty("text", _content); content->setProperty("text", _content);
qDebug() << QString("compile failed " + _content); qDebug() << QString("compile failed " + _content);

22
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 <http://www.gnu.org/licenses/>.
*/
/** @file ConstantCompilation.h
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#ifndef CONSTANTCOMPILATION_H #ifndef CONSTANTCOMPILATION_H
#define CONSTANTCOMPILATION_H #define CONSTANTCOMPILATION_H

7
mix/Feature.cpp

@ -1,5 +1,5 @@
#include "Feature.h" #include "Feature.h"
#include "ApplicationContext.h" #include "ApplicationCtx.h"
#include <libevm/VM.h> #include <libevm/VM.h>
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
@ -16,8 +16,8 @@ void Feature::addContentOn(QObject* tabView) {
QVariant returnValue; QVariant returnValue;
QQmlComponent* component = new QQmlComponent( QQmlComponent* component = new QQmlComponent(
ApplicationContext::GetInstance()->appEngine(), ApplicationCtx::GetInstance()->appEngine(),
QUrl(this->tabUrl())); QUrl(this->tabUrl()), tabView);
QMetaObject::invokeMethod(tabView, "addTab", QMetaObject::invokeMethod(tabView, "addTab",
Q_RETURN_ARG(QVariant, returnValue), Q_RETURN_ARG(QVariant, returnValue),
@ -25,6 +25,7 @@ void Feature::addContentOn(QObject* tabView) {
Q_ARG(QVariant, QVariant::fromValue(component))); Q_ARG(QVariant, QVariant::fromValue(component)));
m_view = qvariant_cast<QObject*>(returnValue); m_view = qvariant_cast<QObject*>(returnValue);
} }
catch (dev::Exception const& exception){ catch (dev::Exception const& exception){
qDebug() << exception.what(); qDebug() << exception.what();

22
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 <http://www.gnu.org/licenses/>.
*/
/** @file Feature.h
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#ifndef FEATURE_H #ifndef FEATURE_H
#define FEATURE_H #define FEATURE_H

7
mix/MainContent.qml

@ -24,6 +24,13 @@ Rectangle {
font.pointSize: 9 font.pointSize: 9
width: parent.width width: parent.width
anchors.centerIn: parent anchors.centerIn: parent
tabChangesFocus: false
Keys.onPressed: {
if (event.key === Qt.Key_Tab) {
codeEditor.insert(codeEditor.cursorPosition, "\t");
event.accepted = true;
}
}
} }
} }
Rectangle { Rectangle {

28
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 <http://www.gnu.org/licenses/>.
*/
/** @file main.cpp
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#include <QApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQuickItem> #include <QQuickItem>
#include "CodeEditorExtensionMan.h" #include "CodeEditorExtensionMan.h"
#include "ApplicationContext.h" #include "ApplicationCtx.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -10,8 +32,8 @@ int main(int argc, char *argv[])
QQmlApplicationEngine* engine = new QQmlApplicationEngine(); QQmlApplicationEngine* engine = new QQmlApplicationEngine();
qmlRegisterType<CodeEditorExtensionManager>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); qmlRegisterType<CodeEditorExtensionManager>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager");
ApplicationContext::SetApplicationContext(engine); ApplicationCtx::SetApplicationContext(engine);
QObject::connect(&app, SIGNAL(lastWindowClosed()), ApplicationContext::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:/main.qml"))); engine->load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec(); return app.exec();

Loading…
Cancel
Save