From 2f31756be8971e9b5d4eaa39393f7bb74c908764 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Tue, 14 May 2019 13:54:41 +0200 Subject: [PATCH] Add FileDialog --- src/qt/About.qml | 12 +++++++++++- src/qt/MainForm.ui.qml | 11 ++--------- src/qt/main.qml | 17 ++++++++++++++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/qt/About.qml b/src/qt/About.qml index 93a49d8..4b90dc4 100644 --- a/src/qt/About.qml +++ b/src/qt/About.qml @@ -3,6 +3,7 @@ import QtQuick.Window 2.0 import com.oboy.oboy 1.0 Window { + id: window title: "About" width: 256 height: 128 @@ -18,12 +19,21 @@ Window { Text { id: name text: oboy.name + font.pointSize: 20 + font.weight: Font.Bold + font.bold: false + horizontalAlignment: Text.AlignHCenter + anchors.top: parent.top + anchors.topMargin: 30 anchors.horizontalCenter: parent.horizontalCenter } + Text { id: version text: oboy.version - anchors.horizontalCenter: parent.horizontalCenter anchors.top: name.bottom + anchors.topMargin: 0 + anchors.horizontalCenter: parent.horizontalCenter } + } diff --git a/src/qt/MainForm.ui.qml b/src/qt/MainForm.ui.qml index facbad8..7348e2c 100644 --- a/src/qt/MainForm.ui.qml +++ b/src/qt/MainForm.ui.qml @@ -3,21 +3,14 @@ import QtQuick.Controls 1.4 import QtQuick.Layouts 1.2 Item { - - property alias button1: button1 - property alias button2: button2 + property alias openButton: openButton RowLayout { anchors.centerIn: parent Button { - id: button1 + id: openButton text: qsTr("Open ROM...") } - - Button { - id: button2 - text: qsTr("Press Me 2") - } } } diff --git a/src/qt/main.qml b/src/qt/main.qml index 1d7f72e..1c60442 100644 --- a/src/qt/main.qml +++ b/src/qt/main.qml @@ -14,7 +14,7 @@ ApplicationWindow { title: qsTr("File") MenuItem { text: qsTr("&Open") - onTriggered: console.log("Open action triggered"); + onTriggered: fileDialog.open(); } MenuItem { text: qsTr("Exit") @@ -51,8 +51,7 @@ ApplicationWindow { MainForm { anchors.fill: parent - button1.onClicked: messageDialog.show(qsTr("Button 1 pressed")) - button2.onClicked: messageDialog.show(qsTr("Button 2 pressed")) + openButton.onClicked: fileDialog.open() } MessageDialog { @@ -65,4 +64,16 @@ ApplicationWindow { } } + FileDialog { + id: fileDialog + nameFilters: [ "Game Boy ROMs (*.gb)" ] + title: "Please choose a file" + folder: shortcuts.home + onAccepted: { + console.log("You chose: " + fileDialog.fileUrls) + } + onRejected: { + console.log("Canceled") + } + } }