File tree Expand file tree Collapse file tree 6 files changed +51
-29
lines changed
Expand file tree Collapse file tree 6 files changed +51
-29
lines changed Original file line number Diff line number Diff line change @@ -78,32 +78,23 @@ ColumnLayout {
7878 elide: Text .ElideMiddle
7979 }
8080
81- ColumnLayout {
81+ FileSelect {
82+ id: flashEdit
8283 Layout .fillWidth : true
83-
84- FileSelect {
85- id: flashEdit
86- Layout .fillWidth : true
87- filePath: kitList .currentItem .myData .flash
88- onFilePathChanged: {
89- if (filePath !== kitList .currentItem .myData .flash )
90- kitModel .setDataRow (kitList .currentIndex , filePath, KitModel .FlashRole );
91- filePath = Qt .binding (function () { return kitList .currentItem .myData .flash ; });
92- }
93- }
94-
95- FlashDialog {
96- id: flashDialog
97- onFlashCreated: {
84+ filePath: kitList .currentItem .myData .flash
85+ onFilePathChanged: {
86+ if (filePath !== kitList .currentItem .myData .flash )
9887 kitModel .setDataRow (kitList .currentIndex , filePath, KitModel .FlashRole );
99- }
88+ filePath = Qt . binding ( function () { return kitList . currentItem . myData . flash ; });
10089 }
90+ showCreateButton: true
91+ onCreate: flashDialog .visible = true
92+ }
10193
102- Button {
103- id: createButton
104- Layout .alignment : Qt .AlignRight
105- text: qsTr (" New" )
106- onClicked: flashDialog .visible = true
94+ FlashDialog {
95+ id: flashDialog
96+ onFlashCreated: {
97+ kitModel .setDataRow (kitList .currentIndex , filePath, KitModel .FlashRole );
10798 }
10899 }
109100
Original file line number Diff line number Diff line change @@ -5,9 +5,10 @@ import QtQuick.Layouts 1.0
55import Firebird.Emu 1.0
66
77RowLayout {
8- id: root
98 property string filePath: " "
109 property bool selectExisting: true
10+ property bool showCreateButton: false
11+ signal create ()
1112
1213 Loader {
1314 id: dialogLoader
@@ -38,13 +39,41 @@ RowLayout {
3839 color: (! selectExisting || filePath === " " || Emu .fileExists (filePath)) ? paletteActive .text : " red"
3940 }
4041
41- Button {
42- id: selectButton
43- text: qsTr (" Select" )
42+ // Button for either custom creation functionality (onCreate) or
43+ // if the open file dialog doesn't allow creation, to open a file creation dialog.
44+ ToolButton {
45+ text: qsTr (" New" )
46+ visible: showCreateButton || (! selectExisting && ! Emu .saveDialogSupported ())
47+ iconSource: " qrc:/icons/resources/icons/document-new.png"
48+ onClicked: {
49+ if (showCreateButton)
50+ parent .create ()
51+ else {
52+ createDialogLoader .active = true ;
53+ createDialogLoader .item .visible = true ;
54+ }
55+ }
4456
57+ Loader {
58+ id: createDialogLoader
59+ active: false
60+ sourceComponent: FileDialog {
61+ folder: filePath ? Emu .dir (filePath) : Global .lastFileDialogDir
62+ selectExisting: false
63+ onAccepted: {
64+ filePath = Emu .toLocalFile (fileUrl);
65+ Global .lastFileDialogDir = Emu .dir (filePath);
66+ }
67+ }
68+ }
69+ }
70+
71+ ToolButton {
72+ text: qsTr (" Select" )
73+ iconSource: " qrc:/icons/resources/icons/document-edit.png"
4574 onClicked: {
46- dialogLoader .active = true
47- dialogLoader .item .visible = true
75+ dialogLoader .active = true ;
76+ dialogLoader .item .visible = true ;
4877 }
4978 }
5079}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Dialog {
2323 GridLayout {
2424 id: layout
2525 width: parent .width
26- columns: width > modelCombo . implicitWidth * 2 ? 2 : 1
26+ columns: 2
2727
2828 FBLabel {
2929 Layout .minimumHeight : implicitHeight
Original file line number Diff line number Diff line change 2222 <file>resources/icons/drive-removable-media-usb.png</file>
2323 <file>resources/icons/smartphone.png</file>
2424 <file>resources/icons/video-display.png</file>
25+ <file>resources/icons/document-edit.png</file>
26+ <file>resources/icons/document-new.png</file>
2527 </qresource>
2628 <qresource prefix="/qml">
2729 <file>qml/Keypad.qml</file>
You can’t perform that action at this time.
0 commit comments