Browse Source

Implement InverseMouseArea

cl-refactor
yann300 10 years ago
parent
commit
5a4f7ea7ba
  1. 59
      mix/InverseMouseArea.cpp
  2. 50
      mix/InverseMouseArea.h
  3. 3
      mix/MixApplication.cpp
  4. 15
      mix/qml/StatusPane.qml

59
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 <http://www.gnu.org/licenses/>.
*/
/** @file InverseMouseArea.cpp
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#include <QQuickWindow>
#include <QDebug>
#include <QQuickItem>
#include <QGraphicsSceneMouseEvent>
#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<QMouseEvent*>(_ev)->pos()))
{
qDebug() << "click outside";
emit clickedOutside();
}
}
return false;
}

50
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 <http://www.gnu.org/licenses/>.
*/
/** @file InverseMouseArea.h
* @author Yann yann@ethdev.com
* @date 2014
* Ethereum IDE client.
*/
#pragma once
#include <QQuickItem>
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();
};
}
}

3
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<QSolidityType>("org.ethereum.qml.QSolidityType", 1, 0, "QSolidityType");
qmlRegisterType<Clipboard>("org.ethereum.qml.Clipboard", 1, 0, "Clipboard");
qmlRegisterType<HttpServer>("HttpServer", 1, 0, "HttpServer");
qmlRegisterType<InverseMouseArea>("org.ethereum.qml.InverseMouseArea", 1, 0, "InverseMouseArea");
qRegisterMetaType<CodeModel*>("CodeModel*");
qRegisterMetaType<ClientModel*>("ClientModel*");
qRegisterMetaType<ClientModel*>("ClientModel*");
}
MixApplication::~MixApplication()

15
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")

Loading…
Cancel
Save