diff --git a/programs/light_client/ClientDataModel.cpp b/programs/light_client/ClientDataModel.cpp index 88caaa74..f878de66 100644 --- a/programs/light_client/ClientDataModel.cpp +++ b/programs/light_client/ClientDataModel.cpp @@ -31,7 +31,6 @@ QQmlListProperty Account::balances() return QQmlListProperty(this, m_balances); } - GrapheneApplication::GrapheneApplication( QObject* parent ) :QObject( parent ),m_thread("app") { diff --git a/programs/light_client/main.cpp b/programs/light_client/main.cpp index f8c7bc5f..3d7f16ef 100644 --- a/programs/light_client/main.cpp +++ b/programs/light_client/main.cpp @@ -19,8 +19,11 @@ int main(int argc, char *argv[]) qmlRegisterType("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(); } - diff --git a/programs/light_client/qml/FormBox.qml b/programs/light_client/qml/FormBox.qml new file mode 100644 index 00000000..7d50959c --- /dev/null +++ b/programs/light_client/qml/FormBox.qml @@ -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 + } +} diff --git a/programs/light_client/qml/TransferForm.qml b/programs/light_client/qml/TransferForm.qml new file mode 100644 index 00000000..fdbc1515 --- /dev/null +++ b/programs/light_client/qml/TransferForm.qml @@ -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") +} diff --git a/programs/light_client/qml/main.qml b/programs/light_client/qml/main.qml index 75b21f15..0db0575d 100644 --- a/programs/light_client/qml/main.qml +++ b/programs/light_client/qml/main.qml @@ -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 diff --git a/programs/light_client/qml/qml.qrc b/programs/light_client/qml/qml.qrc index 0ff3892d..5cf2b727 100644 --- a/programs/light_client/qml/qml.qrc +++ b/programs/light_client/qml/qml.qrc @@ -1,6 +1,8 @@ main.qml + TransferForm.qml + FormBox.qml diff --git a/programs/light_client/qml/qml.qrc.depends b/programs/light_client/qml/qml.qrc.depends new file mode 100644 index 00000000..5cf2b727 --- /dev/null +++ b/programs/light_client/qml/qml.qrc.depends @@ -0,0 +1,8 @@ + + + main.qml + TransferForm.qml + FormBox.qml + + +