diff --git a/src/FileMenu.qml b/src/FileMenu.qml index 5e1ecb7c..0620f64e 100644 --- a/src/FileMenu.qml +++ b/src/FileMenu.qml @@ -303,8 +303,8 @@ FolioMenu { } // On empty space, only where the folder shown is one to work in. FolioMenuItem { - shown: fileMenu.forItem ? fileMenu.forFolder && fileMenu.forFiles - : fileMenu.folder.startsWith("/") && !fileMenu.trashView + shown: !fileMenu.trashView && (fileMenu.forItem ? fileMenu.forFolder && fileMenu.forFiles + : fileMenu.folder.startsWith("/")) text: qsTr("Open Terminal Here") onTriggered: fileOps.openTerminal(fileMenu.forItem ? fileMenu.target.path : fileMenu.folder) } diff --git a/src/FolioMenu.qml b/src/FolioMenu.qml index 1b4a4b70..dce6944a 100644 --- a/src/FolioMenu.qml +++ b/src/FolioMenu.qml @@ -23,6 +23,35 @@ Menu { return widest } + // Rules go only between entries that show: none at the top or the + // bottom, and one where several would meet. Which entries show is only + // known once the menu's owner has set it up, so it's done as it opens. + function tidyLines() { + let entries = 0 // entries shown since the last rule kept + let last = null // the last rule kept, to drop if nothing follows it + for (let i = 0; i < count; ++i) { + const entry = itemAt(i) + if (!entry) + continue + if (entry.isLine) { + entry.tucked = false + if (!entry.shown) + continue + if (entries === 0) { + entry.tucked = true + } else { + last = entry + entries = 0 + } + } else if (entry.shown !== false) { + ++entries + } + } + if (entries === 0 && last) + last.tucked = true + } + onAboutToShow: tidyLines() + background: Rectangle { implicitWidth: 240 color: theme.background diff --git a/src/MenuLine.qml b/src/MenuLine.qml index 59b2ab8c..bb8cf97d 100644 --- a/src/MenuLine.qml +++ b/src/MenuLine.qml @@ -2,10 +2,16 @@ import QtQuick import QtQuick.Controls // A thin rule between groups of menu entries, with little room around it. +// `shown` is what the menu's owner asks for; FolioMenu also sets `tucked` +// for a rule that would have no entry on one side of it, or sit beside +// another rule (a group emptied by the entries that don't apply, as in the +// trash), so a menu never starts, ends or doubles up with a line. MenuSeparator { property bool shown: true - visible: shown - height: shown ? implicitHeight : 0 + property bool tucked: false + readonly property bool isLine: true + visible: shown && !tucked + height: shown && !tucked ? implicitHeight : 0 topPadding: 4 bottomPadding: 4 contentItem: Rectangle {