From b8c0ec86af7d663636c1bde1d2b969b9bb763f55 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 10 May 2016 15:09:13 +1200 Subject: [PATCH] Hide file filter if only 1 file type --- interface/resources/qml/dialogs/FileDialog.qml | 6 +++--- .../resources/qml/dialogs/fileDialog/FileTypeSelection.qml | 1 + tests/ui/qml/main.qml | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/dialogs/FileDialog.qml b/interface/resources/qml/dialogs/FileDialog.qml index 42fe7120ea..3be7fbc667 100644 --- a/interface/resources/qml/dialogs/FileDialog.qml +++ b/interface/resources/qml/dialogs/FileDialog.qml @@ -296,8 +296,8 @@ ModalWindow { label: "Path:" anchors { left: parent.left - right: root.selectDirectory ? parent.right : selectionType.left - rightMargin: root.selectDirectory ? 0 : hifi.dimensions.contentSpacing.x + right: selectionType.visible ? selectionType.left: parent.right + rightMargin: selectionType.visible ? hifi.dimensions.contentSpacing.x : 0 bottom: buttonRow.top bottomMargin: hifi.dimensions.contentSpacing.y } @@ -314,7 +314,7 @@ ModalWindow { left: buttonRow.left right: parent.right } - visible: !selectDirectory + visible: !selectDirectory && filtersCount > 1 KeyNavigation.left: fileTableView KeyNavigation.right: openButton } diff --git a/interface/resources/qml/dialogs/fileDialog/FileTypeSelection.qml b/interface/resources/qml/dialogs/fileDialog/FileTypeSelection.qml index 3d66b37b67..50a10974b5 100644 --- a/interface/resources/qml/dialogs/fileDialog/FileTypeSelection.qml +++ b/interface/resources/qml/dialogs/fileDialog/FileTypeSelection.qml @@ -16,6 +16,7 @@ ComboBox { id: root property string filtersString: "All Files (*.*)"; property var currentFilter: [ "*.*" ]; + property int filtersCount: filtersString.split(';;').length // Per http://doc.qt.io/qt-5/qfiledialog.html#getOpenFileName the string can contain // multiple filters separated by semicolons diff --git a/tests/ui/qml/main.qml b/tests/ui/qml/main.qml index 54ce16fbc2..1745658193 100644 --- a/tests/ui/qml/main.qml +++ b/tests/ui/qml/main.qml @@ -216,7 +216,8 @@ ApplicationWindow { property var builder: Component { FileDialog { title: "Open File" - filter: "*.js" + filter: "All Files (*.*)" + //filter: "HTML files (*.html);;Other(*.png)" } }