1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-19 17:45:21 -04:00

fix(FileBrowser): Improve save-to-file handling w/safety override diags

Fixes #2641
This commit is contained in:
purian23
2026-06-15 01:11:32 -04:00
parent 1fc4890857
commit 1df7e478df
5 changed files with 46 additions and 40 deletions
@@ -201,6 +201,21 @@ FocusScope {
keyboardSelectionRequested = true; keyboardSelectionRequested = true;
} }
function activateFile(path, name, isDir) {
if (isDir) {
navigateTo(path);
return;
}
if (saveMode) {
saveRow.fileName = name;
pendingFilePath = path;
showOverwriteConfirmation = true;
} else {
fileSelected(path);
closeRequested();
}
}
function handleSaveFile(filePath) { function handleSaveFile(filePath) {
var normalizedPath = filePath; var normalizedPath = filePath;
if (!normalizedPath.startsWith("file://")) { if (!normalizedPath.startsWith("file://")) {
@@ -652,6 +667,7 @@ FocusScope {
Row { Row {
anchors.fill: parent anchors.fill: parent
anchors.bottomMargin: root.saveMode ? 40 + Theme.spacingL * 2 : 0
spacing: 0 spacing: 0
Row { Row {
@@ -756,12 +772,7 @@ FocusScope {
onItemClicked: (index, path, name, isDir) => { onItemClicked: (index, path, name, isDir) => {
selectedIndex = index; selectedIndex = index;
setSelectedFileData(path, name, isDir); setSelectedFileData(path, name, isDir);
if (isDir) { root.activateFile(path, name, isDir);
navigateTo(path);
} else {
fileSelected(path);
root.closeRequested();
}
} }
onItemSelected: (index, path, name, isDir) => { onItemSelected: (index, path, name, isDir) => {
setSelectedFileData(path, name, isDir); setSelectedFileData(path, name, isDir);
@@ -776,12 +787,7 @@ FocusScope {
root.keyboardSelectionRequested = false; root.keyboardSelectionRequested = false;
selectedIndex = index; selectedIndex = index;
setSelectedFileData(filePath, fileName, fileIsDir); setSelectedFileData(filePath, fileName, fileIsDir);
if (fileIsDir) { root.activateFile(filePath, fileName, fileIsDir);
navigateTo(filePath);
} else {
fileSelected(filePath);
root.closeRequested();
}
} }
} }
@@ -817,12 +823,7 @@ FocusScope {
onItemClicked: (index, path, name, isDir) => { onItemClicked: (index, path, name, isDir) => {
selectedIndex = index; selectedIndex = index;
setSelectedFileData(path, name, isDir); setSelectedFileData(path, name, isDir);
if (isDir) { root.activateFile(path, name, isDir);
navigateTo(path);
} else {
fileSelected(path);
root.closeRequested();
}
} }
onItemSelected: (index, path, name, isDir) => { onItemSelected: (index, path, name, isDir) => {
setSelectedFileData(path, name, isDir); setSelectedFileData(path, name, isDir);
@@ -837,12 +838,7 @@ FocusScope {
root.keyboardSelectionRequested = false; root.keyboardSelectionRequested = false;
selectedIndex = index; selectedIndex = index;
setSelectedFileData(filePath, fileName, fileIsDir); setSelectedFileData(filePath, fileName, fileIsDir);
if (fileIsDir) { root.activateFile(filePath, fileName, fileIsDir);
navigateTo(filePath);
} else {
fileSelected(filePath);
root.closeRequested();
}
} }
} }
@@ -855,6 +851,7 @@ FocusScope {
} }
FileBrowserSaveRow { FileBrowserSaveRow {
id: saveRow
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
@@ -913,21 +910,21 @@ FocusScope {
} }
} }
} }
}
FileBrowserOverwriteDialog { FileBrowserOverwriteDialog {
anchors.fill: parent anchors.fill: parent
showDialog: showOverwriteConfirmation showDialog: showOverwriteConfirmation
pendingFilePath: root.pendingFilePath pendingFilePath: root.pendingFilePath
onConfirmed: filePath => { onConfirmed: filePath => {
showOverwriteConfirmation = false; showOverwriteConfirmation = false;
fileSelected(filePath); fileSelected(filePath);
pendingFilePath = ""; pendingFilePath = "";
Qt.callLater(() => root.closeRequested()); Qt.callLater(() => root.closeRequested());
} }
onCancelled: { onCancelled: {
showOverwriteConfirmation = false; showOverwriteConfirmation = false;
pendingFilePath = ""; pendingFilePath = "";
}
} }
} }
@@ -74,7 +74,7 @@ Item {
width: 80 width: 80
height: 36 height: 36
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: cancelArea.containsMouse ? Theme.surfaceVariantHover : Theme.surfaceVariant color: cancelArea.containsMouse ? Qt.lighter(Theme.surfaceVariant, 1.2) : Theme.surfaceVariant
border.color: Theme.outline border.color: Theme.outline
border.width: 1 border.width: 1
@@ -8,6 +8,7 @@ Row {
property bool saveMode: false property bool saveMode: false
property string defaultFileName: "" property string defaultFileName: ""
property string currentPath: "" property string currentPath: ""
property alias fileName: fileNameInput.text
signal saveRequested(string filePath) signal saveRequested(string filePath)
+6
View File
@@ -44,6 +44,12 @@ Item {
service: NotepadStorageService service: NotepadStorageService
} }
// In connected frame mode the slideout sits on the Overlay layer
onFileDialogOpenChanged: {
if (slideout)
slideout.suppressOverlayLayer = fileDialogOpen;
}
Connections { Connections {
target: slideout target: slideout
enabled: slideout !== null enabled: slideout !== null
+3 -1
View File
@@ -16,6 +16,8 @@ PanelWindow {
property var targetScreen: null property var targetScreen: null
property var modelData: null property var modelData: null
property bool triggerUsesOverlayLayer: false property bool triggerUsesOverlayLayer: false
// Drop off the Overlay layer (back to Top) while an overlay modal
property bool suppressOverlayLayer: false
property real slideoutWidth: 480 property real slideoutWidth: 480
property bool expandable: false property bool expandable: false
property bool expandedWidth: false property bool expandedWidth: false
@@ -67,7 +69,7 @@ PanelWindow {
readonly property bool slideoutBlurActive: root.visible && BlurService.enabled && Theme.connectedSurfaceBlurEnabled readonly property bool slideoutBlurActive: root.visible && BlurService.enabled && Theme.connectedSurfaceBlurEnabled
WlrLayershell.layer: (triggerUsesOverlayLayer || CompositorService.framePeerSurfacesUseOverlayForScreen(modelData)) ? WlrLayershell.Overlay : WlrLayershell.Top WlrLayershell.layer: (!suppressOverlayLayer && (triggerUsesOverlayLayer || CompositorService.framePeerSurfacesUseOverlayForScreen(modelData))) ? WlrLayershell.Overlay : WlrLayershell.Top
WlrLayershell.exclusiveZone: 0 WlrLayershell.exclusiveZone: 0
WlrLayershell.keyboardFocus: isVisible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None WlrLayershell.keyboardFocus: isVisible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None