diff --git a/mix/InverseMouseArea.cpp b/mix/InverseMouseArea.cpp new file mode 100644 index 000000000..172862038 --- /dev/null +++ b/mix/InverseMouseArea.cpp @@ -0,0 +1,59 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file InverseMouseArea.cpp + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + +#include +#include +#include +#include +#include "InverseMouseArea.h" + +using namespace dev::mix; + +void InverseMouseArea::itemChange(ItemChange _c, const ItemChangeData& _v) +{ + qDebug() << "itemCHange"; + Q_UNUSED(_v); + + if (_c == ItemSceneChange) + { + + window()->installEventFilter(this); + //this->parentItem()->installEventFilter(this); + } + +} + +bool InverseMouseArea::eventFilter(QObject* _obj, QEvent* _ev) +{ + qDebug() << _ev->type(); + Q_UNUSED(_obj); + if (_ev->type() == QEvent::MouseButtonPress) + { + qDebug() << "mouse event"; + if (!this->contains(static_cast(_ev)->pos())) + { + qDebug() << "click outside"; + emit clickedOutside(); + } + } + return false; +} diff --git a/mix/InverseMouseArea.h b/mix/InverseMouseArea.h new file mode 100644 index 000000000..8105e03de --- /dev/null +++ b/mix/InverseMouseArea.h @@ -0,0 +1,50 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file InverseMouseArea.h + * @author Yann yann@ethdev.com + * @date 2014 + * Ethereum IDE client. + */ + +#pragma once + +#include + +namespace dev +{ +namespace mix +{ + +class InverseMouseArea: public QQuickItem +{ + Q_OBJECT + +public: + InverseMouseArea(QQuickItem* _parent = 0): QQuickItem(_parent) {} + ~InverseMouseArea() { /*scene()->removeEventFilter(this);*/ } + +protected: + void itemChange(ItemChange _c, const ItemChangeData& _v); + bool eventFilter(QObject* _obj, QEvent *_ev); + +signals: + void clickedOutside(); +}; + +} +} + diff --git a/mix/MixApplication.cpp b/mix/MixApplication.cpp index 4822b8da5..d81a4f6b2 100644 --- a/mix/MixApplication.cpp +++ b/mix/MixApplication.cpp @@ -36,6 +36,7 @@ #include "SortFilterProxyModel.h" #include "Clipboard.h" #include "HttpServer.h" +#include "InverseMouseArea.h" extern int qInitResources_js(); using namespace dev::mix; @@ -89,9 +90,9 @@ void MixApplication::initialize() qmlRegisterType("org.ethereum.qml.QSolidityType", 1, 0, "QSolidityType"); qmlRegisterType("org.ethereum.qml.Clipboard", 1, 0, "Clipboard"); qmlRegisterType("HttpServer", 1, 0, "HttpServer"); + qmlRegisterType("org.ethereum.qml.InverseMouseArea", 1, 0, "InverseMouseArea"); qRegisterMetaType("CodeModel*"); qRegisterMetaType("ClientModel*"); - qRegisterMetaType("ClientModel*"); } MixApplication::~MixApplication() diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 6524ef6d8..36df419ed 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -2,6 +2,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.3 +import org.ethereum.qml.InverseMouseArea 1.0 import "js/ErrorLocationFormater.js" as ErrorLocationFormater import "." @@ -247,6 +248,20 @@ Rectangle { Rectangle { + InverseMouseArea + { + id: outsideClick + anchors.fill: parent + } + + Connections + { + target: outsideClick + onClickedOutside: { + toggle(); + } + } + function toggle() { if (logsContainer.state === "opened")