mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 09:33:29 +02:00
Merge pull request #7986 from ctrlaltdavid/20937
make navigating directories in file browser dialog possible without double-clicking
This commit is contained in:
commit
da983ffe68
3 changed files with 37 additions and 5 deletions
interface/resources/qml
|
@ -26,10 +26,10 @@ import "fileDialog"
|
|||
ModalWindow {
|
||||
id: root
|
||||
resizable: true
|
||||
implicitWidth: 640
|
||||
implicitHeight: 480
|
||||
implicitWidth: 480
|
||||
implicitHeight: 360
|
||||
|
||||
minSize: Qt.vector2d(300, 240)
|
||||
minSize: Qt.vector2d(360, 240)
|
||||
draggable: true
|
||||
|
||||
HifiConstants { id: hifi }
|
||||
|
@ -79,6 +79,9 @@ ModalWindow {
|
|||
fileTableModel.folder = initialFolder;
|
||||
|
||||
iconText = root.title !== "" ? hifi.glyphs.scriptUpload : "";
|
||||
|
||||
// Clear selection when click on external frame.
|
||||
frameClicked.connect(function() { d.clearSelection(); });
|
||||
}
|
||||
|
||||
Item {
|
||||
|
@ -87,6 +90,13 @@ ModalWindow {
|
|||
height: pane.height
|
||||
anchors.margins: 0
|
||||
|
||||
MouseArea {
|
||||
// Clear selection when click on internal unused area.
|
||||
anchors.fill: parent
|
||||
drag.target: root
|
||||
onClicked: d.clearSelection()
|
||||
}
|
||||
|
||||
Row {
|
||||
id: navControls
|
||||
anchors {
|
||||
|
@ -202,6 +212,8 @@ ModalWindow {
|
|||
function update() {
|
||||
var row = fileTableView.currentRow;
|
||||
|
||||
openButton.text = root.selectDirectory && row === -1 ? "Choose" : "Open"
|
||||
|
||||
if (row === -1) {
|
||||
return;
|
||||
}
|
||||
|
@ -226,6 +238,12 @@ ModalWindow {
|
|||
fileTableModel.folder = homeDestination;
|
||||
return true;
|
||||
}
|
||||
|
||||
function clearSelection() {
|
||||
fileTableView.selection.clear();
|
||||
fileTableView.currentRow = -1;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
FolderListModel {
|
||||
|
@ -389,6 +407,8 @@ ModalWindow {
|
|||
|
||||
rows++;
|
||||
}
|
||||
|
||||
d.clearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -633,8 +653,15 @@ ModalWindow {
|
|||
Action {
|
||||
id: okAction
|
||||
text: root.saveDialog ? "Save" : (root.selectDirectory ? "Choose" : "Open")
|
||||
enabled: currentSelection.text ? true : false
|
||||
onTriggered: okActionTimer.start();
|
||||
enabled: currentSelection.text || !root.selectDirectory && d.currentSelectionIsFolder ? true : false
|
||||
onTriggered: {
|
||||
if (!root.selectDirectory && !d.currentSelectionIsFolder
|
||||
|| root.selectDirectory && fileTableView.currentRow === -1) {
|
||||
okActionTimer.start();
|
||||
} else {
|
||||
fileTableView.navigateToCurrentRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
@ -27,6 +27,8 @@ Frame {
|
|||
readonly property int frameMarginTop: hifi.dimensions.modalDialogMargin.y + (frameContent.hasTitle ? hifi.dimensions.modalDialogTitleHeight + 10 : 0)
|
||||
readonly property int frameMarginBottom: hifi.dimensions.modalDialogMargin.y
|
||||
|
||||
signal frameClicked();
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
topMargin: -frameMarginTop
|
||||
|
@ -47,6 +49,7 @@ Frame {
|
|||
anchors.fill: parent
|
||||
drag.target: window
|
||||
enabled: window.draggable
|
||||
onClicked: window.frameClicked();
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
@ -22,5 +22,7 @@ Window {
|
|||
property int colorScheme: hifi.colorSchemes.light
|
||||
property bool draggable: false
|
||||
|
||||
signal frameClicked();
|
||||
|
||||
anchors.centerIn: draggable ? undefined : parent
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue