[GUI] Initial work on showing dialogs
This commit is contained in:
parent
2fda814b76
commit
bca5eb1fc9
7 changed files with 154 additions and 6 deletions
|
|
@ -31,7 +31,6 @@ QQmlListProperty<Balance> Account::balances()
|
|||
return QQmlListProperty<Balance>(this, m_balances);
|
||||
}
|
||||
|
||||
|
||||
GrapheneApplication::GrapheneApplication( QObject* parent )
|
||||
:QObject( parent ),m_thread("app")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,8 +19,11 @@ int main(int argc, char *argv[])
|
|||
qmlRegisterType<GrapheneApplication>("Graphene.Client", 0, 1, "GrapheneApplication");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
#ifdef NDEBUG
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
#else
|
||||
engine.load(QUrl(QStringLiteral("qml/main.qml")));
|
||||
#endif
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
|
|
|||
121
programs/light_client/qml/FormBox.qml
Normal file
121
programs/light_client/qml/FormBox.qml
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
Rectangle {
|
||||
id: greySheet
|
||||
state: "HIDDEN"
|
||||
|
||||
property real showOpacity: .5
|
||||
property int animationTime: 300
|
||||
|
||||
/// Emitted immediately when opening, before fade-in animation
|
||||
signal opening
|
||||
/// Emitted when opened, following fade-in animation
|
||||
signal opened
|
||||
/// Emitted immediately when closing, before fade-out animation
|
||||
signal closing
|
||||
/// Emitted when closed, following fade-out animation
|
||||
signal closed
|
||||
|
||||
function showForm(formType, closedCallback) {
|
||||
formLoader.sourceComponent = formType
|
||||
if (closedCallback instanceof Function)
|
||||
internal.callback = closedCallback
|
||||
state = "SHOWN"
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseTrap
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
mouse.accepted = true
|
||||
greySheet.state = "HIDDEN"
|
||||
}
|
||||
acceptedButtons: Qt.AllButtons
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: formLoader
|
||||
acceptedButtons: Qt.AllButtons
|
||||
onClicked: mouse.accepted = true
|
||||
}
|
||||
Loader {
|
||||
id: formLoader
|
||||
anchors.centerIn: parent
|
||||
width: parent.width / 2
|
||||
height: parent.height / 2
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "HIDDEN"
|
||||
PropertyChanges {
|
||||
target: greySheet
|
||||
color: Qt.rgba(0, 0, 0, 0)
|
||||
enabled: false
|
||||
}
|
||||
StateChangeScript {
|
||||
name: "preHidden"
|
||||
script: {
|
||||
greySheet.closing()
|
||||
}
|
||||
}
|
||||
StateChangeScript {
|
||||
name: "postHidden"
|
||||
script: {
|
||||
greySheet.closed()
|
||||
formLoader.sourceComponent = undefined
|
||||
if (internal.callback instanceof Function)
|
||||
internal.callback()
|
||||
}
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "SHOWN"
|
||||
PropertyChanges {
|
||||
target: greySheet
|
||||
color: Qt.rgba(0, 0, 0, showOpacity)
|
||||
enabled: true
|
||||
}
|
||||
StateChangeScript {
|
||||
name: "preShown"
|
||||
script: {
|
||||
greySheet.opening()
|
||||
}
|
||||
}
|
||||
StateChangeScript {
|
||||
name: "postShown"
|
||||
script: {
|
||||
greySheet.opened()
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
from: "HIDDEN"
|
||||
to: "SHOWN"
|
||||
ScriptAction { scriptName: "preShown" }
|
||||
ColorAnimation {
|
||||
target: greySheet
|
||||
duration: animationTime
|
||||
}
|
||||
ScriptAction { scriptName: "postShown" }
|
||||
},
|
||||
Transition {
|
||||
from: "SHOWN"
|
||||
to: "HIDDEN"
|
||||
ScriptAction { scriptName: "preHidden" }
|
||||
ColorAnimation {
|
||||
target: greySheet
|
||||
duration: animationTime
|
||||
}
|
||||
ScriptAction { scriptName: "postHidden" }
|
||||
}
|
||||
]
|
||||
|
||||
QtObject {
|
||||
id: internal
|
||||
property var callback
|
||||
}
|
||||
}
|
||||
8
programs/light_client/qml/TransferForm.qml
Normal file
8
programs/light_client/qml/TransferForm.qml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
Rectangle {
|
||||
Component.onCompleted: console.log("Made a transfer form")
|
||||
Component.onDestruction: console.log("Destroyed a transfer form")
|
||||
}
|
||||
|
|
@ -35,11 +35,18 @@ ApplicationWindow {
|
|||
category: "appSettings"
|
||||
}
|
||||
|
||||
Label {
|
||||
Button {
|
||||
text: "Transfer"
|
||||
anchors.centerIn: parent
|
||||
font.pointSize: 75
|
||||
text: "Dashboard goes here"
|
||||
opacity: .5
|
||||
onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), function() {
|
||||
console.log("Closed form")
|
||||
})
|
||||
}
|
||||
|
||||
FormBox {
|
||||
id: formBox
|
||||
anchors.fill: parent
|
||||
z: 10
|
||||
}
|
||||
|
||||
// This Settings is only for geometry -- it doesn't get an id. See appSettings for normal settings
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>TransferForm.qml</file>
|
||||
<file>FormBox.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
|
|
|||
8
programs/light_client/qml/qml.qrc.depends
Normal file
8
programs/light_client/qml/qml.qrc.depends
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>TransferForm.qml</file>
|
||||
<file>FormBox.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Loading…
Reference in a new issue