From 4393a754e20cdaf28606b35831d4d59ba76746e5 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Mon, 1 Feb 2016 14:18:27 -0800 Subject: [PATCH] File dialog polish --- .../resources/qml/dialogs/FileDialog.qml | 79 ++++++++++++------- .../resources/qml/dialogs/QueryDialog.qml | 2 +- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/interface/resources/qml/dialogs/FileDialog.qml b/interface/resources/qml/dialogs/FileDialog.qml index 353e2df494..96a0c95e88 100644 --- a/interface/resources/qml/dialogs/FileDialog.qml +++ b/interface/resources/qml/dialogs/FileDialog.qml @@ -55,35 +55,39 @@ ModalWindow { anchors { left: parent.left; top: parent.top; margins: 8 } spacing: 8 // FIXME implement back button -// VrControls.FontAwesome { -// id: backButton -// text: "\uf0a8" -// size: currentDirectory.height -// enabled: d.backStack.length != 0 -// MouseArea { anchors.fill: parent; onClicked: d.navigateBack() } -// } - VrControls.FontAwesome { + //VrControls.ButtonAwesome { + // id: backButton + // text: "\uf0a8" + // size: currentDirectory.height + // enabled: d.backStack.length != 0 + // MouseArea { anchors.fill: parent; onClicked: d.navigateBack() } + //} + VrControls.ButtonAwesome { id: upButton + enabled: model.parentFolder && model.parentFolder !== "" text: "\uf0aa" - size: currentDirectory.height - color: enabled ? "black" : "gray" - MouseArea { anchors.fill: parent; onClicked: d.navigateUp() } + size: 32 + onClicked: d.navigateUp(); } - VrControls.FontAwesome { + VrControls.ButtonAwesome { id: homeButton property var destination: helper.home(); - visible: destination ? true : false + enabled: d.homeDestination ? true : false text: "\uf015" - size: currentDirectory.height - MouseArea { anchors.fill: parent; onClicked: model.folder = parent.destination } + size: 32 + onClicked: d.navigateHome(); } } TextField { id: currentDirectory + height: homeButton.height anchors { left: navControls.right; right: parent.right; top: parent.top; margins: 8 } property var lastValidFolder: helper.urlToPath(model.folder) onLastValidFolderChanged: text = lastValidFolder; + verticalAlignment: Text.AlignVCenter + font.pointSize: 14 + font.bold: true // FIXME add support auto-completion onAccepted: { @@ -93,7 +97,6 @@ ModalWindow { } model.folder = helper.pathToUrl(text); } - } QtObject { @@ -104,6 +107,7 @@ ModalWindow { property var backStack: [] property var tableViewConnection: Connections { target: fileTableView; onCurrentRowChanged: d.update(); } property var modelConnection: Connections { target: model; onFolderChanged: d.update(); } + property var homeDestination: helper.home(); Component.onCompleted: update(); function update() { @@ -127,12 +131,20 @@ ModalWindow { return true; } } + + function navigateHome() { + model.folder = homeDestination; + return true; + } } FileTableView { id: fileTableView anchors { left: parent.left; right: parent.right; top: currentDirectory.bottom; bottom: currentSelection.top; margins: 8 } onDoubleClicked: navigateToRow(row); + focus: true + Keys.onReturnPressed: navigateToCurrentRow(); + Keys.onEnterPressed: navigateToCurrentRow(); model: FolderListModel { id: model nameFilters: selectionType.currentFilter @@ -146,6 +158,7 @@ ModalWindow { upButton.enabled = Qt.binding(function() { return (model.parentFolder && model.parentFolder != "") ? true : false; }); showFiles = !root.selectDirectory } + onFolderChanged: fileTableView.currentRow = 0; } function navigateToRow(row) { @@ -159,10 +172,9 @@ ModalWindow { var file = model.get(row, "fileURL"); if (isFolder) { fileTableView.model.folder = file - currentRow = -1; } else { root.selectedFile(file); - root.visible = false; + root.destroy(); } } } @@ -171,6 +183,7 @@ ModalWindow { id: currentSelection anchors { right: root.selectDirectory ? parent.right : selectionType.left; rightMargin: 8; left: parent.left; leftMargin: 8; top: selectionType.top } readOnly: true + activeFocusOnTab: false } FileTypeSelection { @@ -187,17 +200,7 @@ ModalWindow { anchors.rightMargin: 8 anchors.bottom: parent.bottom anchors.bottomMargin: 8 - layoutDirection: Qt.RightToLeft spacing: 8 - Button { - id: cancelButton - text: "Cancel" - KeyNavigation.up: selectionType - KeyNavigation.left: openButton - KeyNavigation.right: fileTableView.contentItem - Keys.onReturnPressed: { canceled(); root.enabled = false } - onClicked: { canceled(); root.visible = false; } - } Button { id: openButton text: root.selectDirectory ? "Choose" : "Open" @@ -209,12 +212,28 @@ ModalWindow { KeyNavigation.left: selectionType KeyNavigation.right: cancelButton } + Button { + id: cancelButton + text: "Cancel" + KeyNavigation.up: selectionType + KeyNavigation.left: openButton + KeyNavigation.right: fileTableView.contentItem + Keys.onReturnPressed: { canceled(); root.enabled = false } + onClicked: { canceled(); root.visible = false; } + } } } Keys.onPressed: { - if (event.key === Qt.Key_Backspace && d.navigateUp()) { - event.accepted = true + switch (event.key) { + case Qt.Key_Backspace: + event.accepted = d.navigateUp(); + break; + + case Qt.Key_Home: + event.accepted = d.navigateHome(); + break; + } } } diff --git a/interface/resources/qml/dialogs/QueryDialog.qml b/interface/resources/qml/dialogs/QueryDialog.qml index 159bb95b5d..fecd69a4c6 100644 --- a/interface/resources/qml/dialogs/QueryDialog.qml +++ b/interface/resources/qml/dialogs/QueryDialog.qml @@ -71,7 +71,7 @@ ModalWindow { VrControls.ComboBox { id: comboBox - focus: items ? true : false + focus: true visible: items ? true : false anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter } model: items ? items : []