From 6e59abc8f6ec64d8810ae4c80a600d200ba5316e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 10 May 2016 12:13:46 +1200 Subject: [PATCH] Switch file selection dialog over to using UI Toolkit files --- .../resources/qml/dialogs/FileDialog.qml | 54 ++++++++++++------- tests/ui/qml/main.qml | 37 +++++++------ 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/interface/resources/qml/dialogs/FileDialog.qml b/interface/resources/qml/dialogs/FileDialog.qml index 916ef434b6..8bb92b60d6 100644 --- a/interface/resources/qml/dialogs/FileDialog.qml +++ b/interface/resources/qml/dialogs/FileDialog.qml @@ -1,4 +1,14 @@ -import QtQuick 2.0 +// +// Desktop.qml +// +// Created by Bradley Austin Davis on 14 Jan 2016 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 import QtQuick.Controls 1.4 import Qt.labs.folderlistmodel 2.1 import Qt.labs.settings 1.0 @@ -6,17 +16,19 @@ import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.2 as OriginalDialogs import ".." -import "../windows" -import "../styles" -import "../controls" as VrControls +import "../controls-uit" +import "../styles-uit" +import "../windows-uit" + import "fileDialog" //FIXME implement shortcuts for favorite location ModalWindow { id: root - resizable: true - width: 640 - height: 480 + //resizable: true + implicitWidth: 640 + implicitHeight: 480 + HifiConstants { id: hifi } Settings { category: "FileDialog" @@ -46,6 +58,8 @@ ModalWindow { property alias model: fileTableView.model property var drives: helper.drives() + property int titleWidth: 0 + signal selectedFile(var file); signal canceled(); @@ -56,14 +70,17 @@ ModalWindow { }) } - Rectangle { - anchors.fill: parent - color: "white" + Item { + clip: true + width: pane.width + height: pane.height + anchors.margins: 0 Row { id: navControls anchors { left: parent.left; top: parent.top; margins: 8 } spacing: 8 + // FIXME implement back button //VrControls.ButtonAwesome { // id: backButton @@ -72,30 +89,29 @@ ModalWindow { // enabled: d.backStack.length != 0 // MouseArea { anchors.fill: parent; onClicked: d.navigateBack() } //} - VrControls.ButtonAwesome { + + Button { id: upButton enabled: model.parentFolder && model.parentFolder !== "" - text: "\uf0aa" - size: 32 + text: "up" onClicked: d.navigateUp(); } - VrControls.ButtonAwesome { + + Button { id: homeButton property var destination: helper.home(); enabled: d.homeDestination ? true : false - text: "\uf015" - size: 32 + text: "home" onClicked: d.navigateHome(); } - VrControls.ComboBox { + ComboBox { id: drivesSelector width: 48 height: homeButton.height model: drives visible: drives.length > 1 currentIndex: 0 - } } @@ -385,5 +401,3 @@ ModalWindow { } } } - - diff --git a/tests/ui/qml/main.qml b/tests/ui/qml/main.qml index e45749e1de..54ce16fbc2 100644 --- a/tests/ui/qml/main.qml +++ b/tests/ui/qml/main.qml @@ -211,6 +211,26 @@ ApplicationWindow { } } + Button { + text: "Open File" + property var builder: Component { + FileDialog { + title: "Open File" + filter: "*.js" + } + } + + onClicked: { + var fileDialog = builder.createObject(desktop); + fileDialog.canceled.connect(function(){ + console.log("Cancelled") + }) + fileDialog.selectedFile.connect(function(file){ + console.log("Selected " + file) + }) + } + } + Button { text: "Add Tab" onClicked: { @@ -246,24 +266,7 @@ ApplicationWindow { } } - Button { - text: "Open File" - property var builder: Component { - FileDialog { } - } - - onClicked: { - var fileDialog = builder.createObject(desktop); - fileDialog.canceled.connect(function(){ - console.log("Cancelled") - }) - fileDialog.selectedFile.connect(function(file){ - console.log("Selected " + file) - }) - } - } } - /* Window { id: blue