From cb3796b4e4b135ffafb87bdd1ec4091350a9cfaa Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Mon, 28 Mar 2022 18:15:17 +0200 Subject: [PATCH] WIP: Icon buttons for file selection and creation Saves (horizontal) space, important on phones. Also allows to create snapshot files that way. TODO: - Document and test createDialogLoader logic - Proper button on desktop - Rename saveDialogSupported to saveDialogCanOverwrite? --- qml/ConfigPageKits.qml | 35 +++++++------------ qml/Firebird/UIComponents/FileSelect.qml | 41 +++++++++++++++++++---- qml/FlashDialog.qml | 2 +- resources.qrc | 2 ++ resources/icons/document-edit.png | Bin 0 -> 2955 bytes resources/icons/document-new.png | Bin 0 -> 2461 bytes 6 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 resources/icons/document-edit.png create mode 100644 resources/icons/document-new.png diff --git a/qml/ConfigPageKits.qml b/qml/ConfigPageKits.qml index 0f79abfd..2a49feb7 100644 --- a/qml/ConfigPageKits.qml +++ b/qml/ConfigPageKits.qml @@ -78,32 +78,23 @@ ColumnLayout { elide: Text.ElideMiddle } - ColumnLayout { + FileSelect { + id: flashEdit Layout.fillWidth: true - - FileSelect { - id: flashEdit - Layout.fillWidth: true - filePath: kitList.currentItem.myData.flash - onFilePathChanged: { - if(filePath !== kitList.currentItem.myData.flash) - kitModel.setDataRow(kitList.currentIndex, filePath, KitModel.FlashRole); - filePath = Qt.binding(function() { return kitList.currentItem.myData.flash; }); - } - } - - FlashDialog { - id: flashDialog - onFlashCreated: { + filePath: kitList.currentItem.myData.flash + onFilePathChanged: { + if(filePath !== kitList.currentItem.myData.flash) kitModel.setDataRow(kitList.currentIndex, filePath, KitModel.FlashRole); - } + filePath = Qt.binding(function() { return kitList.currentItem.myData.flash; }); } + showCreateButton: true + onCreate: flashDialog.visible = true + } - Button { - id: createButton - Layout.alignment: Qt.AlignRight - text: qsTr("New") - onClicked: flashDialog.visible = true + FlashDialog { + id: flashDialog + onFlashCreated: { + kitModel.setDataRow(kitList.currentIndex, filePath, KitModel.FlashRole); } } diff --git a/qml/Firebird/UIComponents/FileSelect.qml b/qml/Firebird/UIComponents/FileSelect.qml index 6dedaaa2..4cd9ebc6 100644 --- a/qml/Firebird/UIComponents/FileSelect.qml +++ b/qml/Firebird/UIComponents/FileSelect.qml @@ -5,9 +5,10 @@ import QtQuick.Layouts 1.0 import Firebird.Emu 1.0 RowLayout { - id: root property string filePath: "" property bool selectExisting: true + property bool showCreateButton: false + signal create() Loader { id: dialogLoader @@ -38,13 +39,41 @@ RowLayout { color: (!selectExisting || filePath === "" || Emu.fileExists(filePath)) ? paletteActive.text : "red" } - Button { - id: selectButton - text: qsTr("Select") + // Button for either custom creation functionality (onCreate) or + // if the open file dialog doesn't allow creation, to open a file creation dialog. + ToolButton { + text: qsTr("New") + visible: showCreateButton || (!selectExisting && !Emu.saveDialogSupported()) + iconSource: "qrc:/icons/resources/icons/document-new.png" + onClicked: { + if(showCreateButton) + parent.create() + else { + createDialogLoader.active = true; + createDialogLoader.item.visible = true; + } + } + Loader { + id: createDialogLoader + active: false + sourceComponent: FileDialog { + folder: filePath ? Emu.dir(filePath) : Global.lastFileDialogDir + selectExisting: false + onAccepted: { + filePath = Emu.toLocalFile(fileUrl); + Global.lastFileDialogDir = Emu.dir(filePath); + } + } + } + } + + ToolButton { + text: qsTr("Select") + iconSource: "qrc:/icons/resources/icons/document-edit.png" onClicked: { - dialogLoader.active = true - dialogLoader.item.visible = true + dialogLoader.active = true; + dialogLoader.item.visible = true; } } } diff --git a/qml/FlashDialog.qml b/qml/FlashDialog.qml index 427f77dd..31ded55b 100644 --- a/qml/FlashDialog.qml +++ b/qml/FlashDialog.qml @@ -23,7 +23,7 @@ Dialog { GridLayout { id: layout width: parent.width - columns: width > modelCombo.implicitWidth * 2 ? 2 : 1 + columns: 2 FBLabel { Layout.minimumHeight: implicitHeight diff --git a/resources.qrc b/resources.qrc index 0b951751..f63df94b 100644 --- a/resources.qrc +++ b/resources.qrc @@ -22,6 +22,8 @@ resources/icons/drive-removable-media-usb.png resources/icons/smartphone.png resources/icons/video-display.png + resources/icons/document-edit.png + resources/icons/document-new.png qml/Keypad.qml diff --git a/resources/icons/document-edit.png b/resources/icons/document-edit.png new file mode 100644 index 0000000000000000000000000000000000000000..e8fe0972a0ef38d3ecfe75795ed86422148eea1b GIT binary patch literal 2955 zcmV;63v~2}P)K~#9!)tU=%RMi>BfBW9--6Wd_kQYgWVn7U5Dl%5I#m;C& zI?#gF7gRE=n}2Tw8cDfWXxPqQEM4BYH`ub znE~Q7paG3Wqf?jsNP7Br71GtZasSll4dd-YhG5vTg@Q?wzBLvXFE79U{+9tEeG2$X zfPx>(fDSbI=eGV)8>p%Z9hb;Cd>Eb0#)-9S%M}Cb-Fx?*Gy3({mkp2sVZaF7tn9zU zkEDGcE~Qd_5nFxF zlTYp`12IFYb^mfxRq z;|8N4=rtJRPM`&F!_V}bQb`6JuU~0I5+#HEWB*Yg-;L#0cRCRTA z5ex!>O-3CSvtDk|YVUcdJ+=cNjR6L%chb!%vyf=$ z+u8->8=5dngXrsZGW#hD-Oji}-O<6M3AxPujT5s`r?F(|HOD)3tA4#O@Bt78Vy9O^ zWS9j|O(hPXe)p4<89qU>mEm;sF!vb)$2+wNbw9E~!{fJwF&ShOcT-MWH4cPs&3iGBniZ3!hCNnP8dm^DDqXGhz3C%JhQM58i?>Kv@v zY#|bf07Bx%d3s?U=auz|vN2`l(rj9e&NLVx78m&-K>7^CM==RLee~5i8u1f8GMntY zQqW1Xw)L=b^B{VAov3m+9L%3?WMZ{|SB9Ae?GmDfN_09MKokUgK#6`dy#Wg3WaZP{hluZjt4f?aa8sZkzE!@CUd`nK z+-Nka1|onP5|#cCLwfiW?ZxqZYbi80kd;$`*VVzQ*Wja_$B4yZsLC179N z7s=#VqXOPVHAnn^P$PeG2qT4sh3X+D^9&>br_O@C<#P)BFCi8Dlz`8{n_D}0>!Uu= z+w?2yW6j-BO7epOKBO&YuWJrEy-|(&$-^t)Efxz2$~*(<;XQp#NZqTj4j!uj2dMq3 zk+r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ovPDHLkV1n>e BfMWmv literal 0 HcmV?d00001 diff --git a/resources/icons/document-new.png b/resources/icons/document-new.png new file mode 100644 index 0000000000000000000000000000000000000000..61db97ae49ca9bd542c685c973df94e0e0daa460 GIT binary patch literal 2461 zcmV;O31aq%P)*d~vum5(jg1rAac~j=DXJ7GQuz|W zw}1fk0}mkqg%t59Av~&9rO-;13Z-h*2c|7;+6vJSNL#9+q=JU>`T(V^Rq;v*Rbmnw zV!-zLvCo;^oyYC<)vTP=WIf$gBGjWjx@YcO-TD3RIrq-4v@szBpO(db5Hs1x4$54D zO+O|HG`gfGaCwsod-*53#UA0%!cHh47K<564X4U(B+F*LL!4{T$Qq`>$f^;}>^~D~ z@P6riKCnN)Ew~^kkmLobd{x{jrXmFd@LvGVI3*&s@p;bW3R0x{R`qf7XKv=AH5XxM z#`4pAaB+Ec{#71(<1yyT^H8Nki5tYX#l9#3ao`TwKU%BR8oiBA!y@`aDMil5A19t> z+soVVk{*|iT*{SaU5Tli2n3GnfLLC#xDj7sq2|?i=IAr*KfE6-swB8c+%A4kU`DG) z)@pU;=I56}HIe+N7Fxy2?TO<3ll!^l^;_@^j|)dGWb2t*DTxwAw@5jk=e(ZJ(Pg9n zuw9#X3U86lX7Pxzb!01Lugq(QUrXZhWbCO}k}tALNHb_@B7kTqAOzXe0tE4lJ})=6LyyKNHV5xW3GSfGxvYD&m-K(b3jg`l_|g`_>cqP{)UL)+V_3#ee+%l6u^YdLz~HYISSq^6@M06da*o> z5IzkPzE8=TrnYon$Z>LP!OyXIcr(NSlQf^@dvbowXvq&iNIt`Qm98@Dz3>sPsDLh8Nl+9*QhxbK3M>pYuL)yS_u%q2{Qmh zwt*P6l207kMa8MW03@^oId_%}Ai0Uhr2B%Zwa}CS8LK|u*Kvgu;DhafB_LrWAPyL$ zxstCNw6>P;DvEA#rGRHYdKS_soA#$E{%ejtuZy%6C#6G5gVJoB<4!{re>jn&WEH6T zV0lpV913xZg>^2NKn9rS;uQph;M>XqLf|+K>?j1q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