Add FileDialog

master
Fabien Freling 2019-05-14 13:54:41 +02:00
parent c4960d87f8
commit 2f31756be8
3 changed files with 27 additions and 13 deletions

View File

@ -3,6 +3,7 @@ import QtQuick.Window 2.0
import com.oboy.oboy 1.0 import com.oboy.oboy 1.0
Window { Window {
id: window
title: "About" title: "About"
width: 256 width: 256
height: 128 height: 128
@ -18,12 +19,21 @@ Window {
Text { Text {
id: name id: name
text: oboy.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 anchors.horizontalCenter: parent.horizontalCenter
} }
Text { Text {
id: version id: version
text: oboy.version text: oboy.version
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: name.bottom anchors.top: name.bottom
anchors.topMargin: 0
anchors.horizontalCenter: parent.horizontalCenter
} }
} }

View File

@ -3,21 +3,14 @@ import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
Item { Item {
property alias openButton: openButton
property alias button1: button1
property alias button2: button2
RowLayout { RowLayout {
anchors.centerIn: parent anchors.centerIn: parent
Button { Button {
id: button1 id: openButton
text: qsTr("Open ROM...") text: qsTr("Open ROM...")
} }
Button {
id: button2
text: qsTr("Press Me 2")
}
} }
} }

View File

@ -14,7 +14,7 @@ ApplicationWindow {
title: qsTr("File") title: qsTr("File")
MenuItem { MenuItem {
text: qsTr("&Open") text: qsTr("&Open")
onTriggered: console.log("Open action triggered"); onTriggered: fileDialog.open();
} }
MenuItem { MenuItem {
text: qsTr("Exit") text: qsTr("Exit")
@ -51,8 +51,7 @@ ApplicationWindow {
MainForm { MainForm {
anchors.fill: parent anchors.fill: parent
button1.onClicked: messageDialog.show(qsTr("Button 1 pressed")) openButton.onClicked: fileDialog.open()
button2.onClicked: messageDialog.show(qsTr("Button 2 pressed"))
} }
MessageDialog { 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")
}
}
} }