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
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
}
}

View File

@ -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")
}
}
}

View File

@ -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")
}
}
}