Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
d319ef4b14
  1. 59
      mix/InverseMouseArea.cpp
  2. 57
      mix/InverseMouseArea.h
  3. 3
      mix/MixApplication.cpp
  4. 42
      mix/qml/LogsPane.qml
  5. 31
      mix/qml/StatesComboBox.qml
  6. 14
      mix/qml/StatusPane.qml
  7. 3
      mix/qml/TransactionLog.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 2015
* 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)
{
Q_UNUSED(_v);
if (this->m_active && _c == ItemSceneChange && window())
window()->installEventFilter(this);
}
bool InverseMouseArea::eventFilter(QObject* _obj, QEvent* _ev)
{
Q_UNUSED(_obj);
if (this->m_active && _ev->type() == QEvent::MouseButtonPress && !this->contains(static_cast<QMouseEvent*>(_ev)->pos()))
emit clickedOutside();
return false;
}
bool InverseMouseArea::contains(const QPoint& _point) const
{
if (!this->m_active)
return false;
QPointF global = this->parentItem()->mapToItem(0, QPointF(0, 0));
return QRectF(global.x(), global.y(), this->parentItem()->width(), this->parentItem()->height()).contains(_point);
}
void InverseMouseArea::setActive(bool _v)
{
m_active = _v;
if (m_active && window())
window()->installEventFilter(this);
}

57
mix/InverseMouseArea.h

@ -0,0 +1,57 @@
/*
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 2015
* Ethereum IDE client.
*/
#pragma once
#include <QQuickWindow>
#include <QQuickItem>
namespace dev
{
namespace mix
{
class InverseMouseArea: public QQuickItem
{
Q_OBJECT
Q_PROPERTY(bool active MEMBER m_active WRITE setActive)
public:
InverseMouseArea(QQuickItem* _parent = 0): QQuickItem(_parent) {}
~InverseMouseArea() { if (window()) { window()->removeEventFilter(this); } }
void setActive(bool _v);
protected:
void itemChange(ItemChange _c, const ItemChangeData& _v);
bool eventFilter(QObject* _obj, QEvent *_ev);
bool contains(const QPoint& _point) const;
private:
bool m_active;
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()

42
mix/qml/LogsPane.qml

@ -585,48 +585,6 @@ Rectangle
}
}
}
Rectangle
{
height: logStyle.generic.layout.headerButtonHeight
anchors.verticalCenter: parent.verticalCenter
color: "transparent"
width: 20
Button
{
id: hideButton
action: hideAction
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
height: 25
style:
ButtonStyle {
background:
Rectangle {
height: logStyle.generic.layout.headerButtonHeight
implicitHeight: logStyle.generic.layout.headerButtonHeight
color: "transparent"
}
}
}
Image {
id: hideImage
source: "qrc:/qml/img/exit.png"
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
width: 20
height: 25
}
Action {
id: hideAction
tooltip: qsTr("Exit")
onTriggered: {
logsPane.parent.toggle();
}
}
}
}
}

31
mix/qml/StatesComboBox.qml

@ -24,13 +24,13 @@ import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import org.ethereum.qml.InverseMouseArea 1.0
Rectangle {
id: statesComboBox
width: 200
height: 23
Component.onCompleted: {
var top = dropDownList
while (top.parent) {
@ -62,6 +62,12 @@ Rectangle {
chosenItemText.text = statesComboBox.items.get(index).title
}
function hideDropDown()
{
if (statesComboBox.state === "dropDown")
statesComboBox.state = "";
}
signal comboClicked
property variant colorItem
@ -76,14 +82,12 @@ Rectangle {
{
id: boldFont
}
smooth: true
Rectangle {
id: chosenItem
width: parent.width
height: statesComboBox.height
color: statesComboBox.color
Text {
id: chosenItemText
anchors.left: parent.left
@ -97,7 +101,10 @@ Rectangle {
MouseArea {
anchors.fill: parent
onClicked: {
statesComboBox.state = statesComboBox.state === "dropDown" ? "" : "dropDown"
if (outsideClick.trigerred)
outsideClick.trigerred = false;
else if (statesCombo.state === "")
statesCombo.state = "dropDown";
}
}
}
@ -124,6 +131,18 @@ Rectangle {
anchors.topMargin: 23
color: statesComboBox.color
InverseMouseArea
{
property bool trigerred: false
id: outsideClick
anchors.fill: parent
active: false
onClickedOutside: {
trigerred = true;
statesCombo.hideDropDown()
}
}
ColumnLayout {
spacing: 2
TableView {
@ -256,5 +275,9 @@ Rectangle {
height: 20
implicitHeight: (statesComboBox.rowHeight * (statesComboBox.items.count))
}
PropertyChanges {
target: outsideClick
active: true
}
}
}

14
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,16 @@ Rectangle {
Rectangle
{
InverseMouseArea
{
id: outsideClick
anchors.fill: parent
active: false
onClickedOutside: {
logsContainer.toggle();
}
}
function toggle()
{
if (logsContainer.state === "opened")
@ -294,11 +305,14 @@ Rectangle {
State {
name: "opened";
PropertyChanges { target: logsContainer; height: 500; visible: true }
PropertyChanges { target: outsideClick; active: true }
},
State {
name: "closed";
PropertyChanges { target: logsContainer; height: 0; visible: false }
PropertyChanges { target: statusContainer; width: 600; height: 30 }
PropertyChanges { target: outsideClick; active: false }
}
]
transitions: Transition {

3
mix/qml/TransactionLog.qml

@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1
import org.ethereum.qml.RecordLogEntry 1.0
import org.ethereum.qml.InverseMouseArea 1.0
Item {
property ListModel fullModel: ListModel{}
@ -60,7 +61,7 @@ Item {
target: projectModel.stateListModel
onStateRun: {
if (statesCombo.selectedIndex !== index)
statesCombo.setSelectedIndex( index );
statesCombo.setSelectedIndex(index)
}
}
}

Loading…
Cancel
Save