mirror of
https://github.com/lubosz/overte.git
synced 2025-08-18 07:21:41 +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
|
@ -26,10 +26,10 @@ import "fileDialog"
|
||||||
ModalWindow {
|
ModalWindow {
|
||||||
id: root
|
id: root
|
||||||
resizable: true
|
resizable: true
|
||||||
implicitWidth: 640
|
implicitWidth: 480
|
||||||
implicitHeight: 480
|
implicitHeight: 360
|
||||||
|
|
||||||
minSize: Qt.vector2d(300, 240)
|
minSize: Qt.vector2d(360, 240)
|
||||||
draggable: true
|
draggable: true
|
||||||
|
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
@ -79,6 +79,9 @@ ModalWindow {
|
||||||
fileTableModel.folder = initialFolder;
|
fileTableModel.folder = initialFolder;
|
||||||
|
|
||||||
iconText = root.title !== "" ? hifi.glyphs.scriptUpload : "";
|
iconText = root.title !== "" ? hifi.glyphs.scriptUpload : "";
|
||||||
|
|
||||||
|
// Clear selection when click on external frame.
|
||||||
|
frameClicked.connect(function() { d.clearSelection(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -87,6 +90,13 @@ ModalWindow {
|
||||||
height: pane.height
|
height: pane.height
|
||||||
anchors.margins: 0
|
anchors.margins: 0
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
// Clear selection when click on internal unused area.
|
||||||
|
anchors.fill: parent
|
||||||
|
drag.target: root
|
||||||
|
onClicked: d.clearSelection()
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: navControls
|
id: navControls
|
||||||
anchors {
|
anchors {
|
||||||
|
@ -202,6 +212,8 @@ ModalWindow {
|
||||||
function update() {
|
function update() {
|
||||||
var row = fileTableView.currentRow;
|
var row = fileTableView.currentRow;
|
||||||
|
|
||||||
|
openButton.text = root.selectDirectory && row === -1 ? "Choose" : "Open"
|
||||||
|
|
||||||
if (row === -1) {
|
if (row === -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -226,6 +238,12 @@ ModalWindow {
|
||||||
fileTableModel.folder = homeDestination;
|
fileTableModel.folder = homeDestination;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearSelection() {
|
||||||
|
fileTableView.selection.clear();
|
||||||
|
fileTableView.currentRow = -1;
|
||||||
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderListModel {
|
FolderListModel {
|
||||||
|
@ -389,6 +407,8 @@ ModalWindow {
|
||||||
|
|
||||||
rows++;
|
rows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.clearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,8 +653,15 @@ ModalWindow {
|
||||||
Action {
|
Action {
|
||||||
id: okAction
|
id: okAction
|
||||||
text: root.saveDialog ? "Save" : (root.selectDirectory ? "Choose" : "Open")
|
text: root.saveDialog ? "Save" : (root.selectDirectory ? "Choose" : "Open")
|
||||||
enabled: currentSelection.text ? true : false
|
enabled: currentSelection.text || !root.selectDirectory && d.currentSelectionIsFolder ? true : false
|
||||||
onTriggered: okActionTimer.start();
|
onTriggered: {
|
||||||
|
if (!root.selectDirectory && !d.currentSelectionIsFolder
|
||||||
|
|| root.selectDirectory && fileTableView.currentRow === -1) {
|
||||||
|
okActionTimer.start();
|
||||||
|
} else {
|
||||||
|
fileTableView.navigateToCurrentRow();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
|
|
@ -27,6 +27,8 @@ Frame {
|
||||||
readonly property int frameMarginTop: hifi.dimensions.modalDialogMargin.y + (frameContent.hasTitle ? hifi.dimensions.modalDialogTitleHeight + 10 : 0)
|
readonly property int frameMarginTop: hifi.dimensions.modalDialogMargin.y + (frameContent.hasTitle ? hifi.dimensions.modalDialogTitleHeight + 10 : 0)
|
||||||
readonly property int frameMarginBottom: hifi.dimensions.modalDialogMargin.y
|
readonly property int frameMarginBottom: hifi.dimensions.modalDialogMargin.y
|
||||||
|
|
||||||
|
signal frameClicked();
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
topMargin: -frameMarginTop
|
topMargin: -frameMarginTop
|
||||||
|
@ -47,6 +49,7 @@ Frame {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: window
|
drag.target: window
|
||||||
enabled: window.draggable
|
enabled: window.draggable
|
||||||
|
onClicked: window.frameClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
|
@ -22,5 +22,7 @@ Window {
|
||||||
property int colorScheme: hifi.colorSchemes.light
|
property int colorScheme: hifi.colorSchemes.light
|
||||||
property bool draggable: false
|
property bool draggable: false
|
||||||
|
|
||||||
|
signal frameClicked();
|
||||||
|
|
||||||
anchors.centerIn: draggable ? undefined : parent
|
anchors.centerIn: draggable ? undefined : parent
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue