From 5f776742a58b0ab93a3716ad52c3032f95127c82 Mon Sep 17 00:00:00 2001 From: waaake Date: Tue, 28 Jan 2025 17:12:01 +0530 Subject: [PATCH] [ui] Application MenuBar: Updated Menubar to occupy full height of the parent layout Reducing the default padding on the Home and Execution buttons reduced the overall height of the header and aligning the Menubar inside a Parent Rect occupying additional space ensures the lineup of the menu against the tool buttons --- meshroom/ui/qml/Application.qml | 546 ++++++++++++++++---------------- 1 file changed, 277 insertions(+), 269 deletions(-) diff --git a/meshroom/ui/qml/Application.qml b/meshroom/ui/qml/Application.qml index a27c1a5c6e..818191e1c6 100644 --- a/meshroom/ui/qml/Application.qml +++ b/meshroom/ui/qml/Application.qml @@ -606,6 +606,7 @@ Page { text: MaterialIcons.home font.pointSize: 18 + padding: 2 /// Reducing the default padding ensures the button size decreases while maintaining the size of icon background: Rectangle { color: homeButton.hovered ? activePalette.highlight : Qt.darker(activePalette.window, 1.15) @@ -624,320 +625,326 @@ Page { }) } } - MenuBar { - palette.window: Qt.darker(activePalette.window, 1.15) - Menu { - title: "File" - Action { - id: newAction - text: "New" - shortcut: "Ctrl+N" - onTriggered: ensureSaved(function() { - _reconstruction.new() - }) - } + Rectangle { + /** + * This Rectangle serves as the parent of the menubar + * occupying all of the additional space which the MenuBar is not going to get + */ + Layout.fillWidth: true + Layout.fillHeight: true + color: Qt.darker(activePalette.window, 1.15) + + MenuBar { + palette.window: Qt.darker(activePalette.window, 1.15) + anchors.verticalCenter: parent.verticalCenter Menu { - id: newPipelineMenu - title: "New Pipeline" - enabled: newPipelineMenuItems.model !== undefined && newPipelineMenuItems.model.length > 0 - property int maxWidth: 1000 - property int fullWidth: { - var result = 0; - for (var i = 0; i < count; ++i) { - var item = itemAt(i) - result = Math.max(item.implicitWidth + item.padding * 2, result) - } - return result; + title: "File" + Action { + id: newAction + text: "New" + shortcut: "Ctrl+N" + onTriggered: ensureSaved(function() { + _reconstruction.new() + }) } - implicitWidth: fullWidth - Repeater { - id: newPipelineMenuItems - model: MeshroomApp.pipelineTemplateFiles - MenuItem { - onTriggered: ensureSaved(function() { - _reconstruction.new(modelData["key"]) - }) - - text: fileTextMetrics.elidedText - TextMetrics { - id: fileTextMetrics - text: modelData["name"] - elide: Text.ElideLeft - elideWidth: newPipelineMenu.maxWidth + Menu { + id: newPipelineMenu + title: "New Pipeline" + enabled: newPipelineMenuItems.model !== undefined && newPipelineMenuItems.model.length > 0 + property int maxWidth: 1000 + property int fullWidth: { + var result = 0; + for (var i = 0; i < count; ++i) { + var item = itemAt(i) + result = Math.max(item.implicitWidth + item.padding * 2, result) } + return result; + } + implicitWidth: fullWidth + Repeater { + id: newPipelineMenuItems + model: MeshroomApp.pipelineTemplateFiles + MenuItem { + onTriggered: ensureSaved(function() { + _reconstruction.new(modelData["key"]) + }) + + text: fileTextMetrics.elidedText + TextMetrics { + id: fileTextMetrics + text: modelData["name"] + elide: Text.ElideLeft + elideWidth: newPipelineMenu.maxWidth + } - ToolTip { - id: toolTip + ToolTip { + id: toolTip - delay: 200 - text: modelData["path"] - visible: hovered + delay: 200 + text: modelData["path"] + visible: hovered + } } } } - } - Action { - id: openActionItem - text: "Open" - shortcut: "Ctrl+O" - onTriggered: ensureSaved(function() { - initFileDialogFolder(openFileDialog) - openFileDialog.open() - }) - } - Menu { - id: openRecentMenu - title: "Open Recent" - enabled: recentFilesMenuItems.model !== undefined && recentFilesMenuItems.model.length > 0 - property int maxWidth: 1000 - property int fullWidth: { - var result = 0; - for (var i = 0; i < count; ++i) { - var item = itemAt(i) - result = Math.max(item.implicitWidth + item.padding * 2, result) - } - return result + Action { + id: openActionItem + text: "Open" + shortcut: "Ctrl+O" + onTriggered: ensureSaved(function() { + initFileDialogFolder(openFileDialog) + openFileDialog.open() + }) } - implicitWidth: fullWidth - Repeater { - id: recentFilesMenuItems - model: MeshroomApp.recentProjectFiles - MenuItem { - onTriggered: ensureSaved(function() { - openRecentMenu.dismiss() - if (_reconstruction.loadUrl(modelData["path"])) { - MeshroomApp.addRecentProjectFile(modelData["path"]) - } else { - MeshroomApp.removeRecentProjectFile(modelData["path"]) + Menu { + id: openRecentMenu + title: "Open Recent" + enabled: recentFilesMenuItems.model !== undefined && recentFilesMenuItems.model.length > 0 + property int maxWidth: 1000 + property int fullWidth: { + var result = 0; + for (var i = 0; i < count; ++i) { + var item = itemAt(i) + result = Math.max(item.implicitWidth + item.padding * 2, result) + } + return result + } + implicitWidth: fullWidth + Repeater { + id: recentFilesMenuItems + model: MeshroomApp.recentProjectFiles + MenuItem { + onTriggered: ensureSaved(function() { + openRecentMenu.dismiss() + if (_reconstruction.loadUrl(modelData["path"])) { + MeshroomApp.addRecentProjectFile(modelData["path"]) + } else { + MeshroomApp.removeRecentProjectFile(modelData["path"]) + } + }) + + text: fileTextMetrics.elidedText + TextMetrics { + id: fileTextMetrics + text: modelData["path"] + elide: Text.ElideLeft + elideWidth: openRecentMenu.maxWidth } - }) - - text: fileTextMetrics.elidedText - TextMetrics { - id: fileTextMetrics - text: modelData["path"] - elide: Text.ElideLeft - elideWidth: openRecentMenu.maxWidth } } } - } - MenuSeparator { } - Action { - id: saveAction - text: "Save" - shortcut: "Ctrl+S" - enabled: _reconstruction ? (_reconstruction.graph && !_reconstruction.graph.filepath) || !_reconstruction.undoStack.clean : false - onTriggered: { - if (_reconstruction.graph.filepath) { - // Get current time date - var date = _reconstruction.graph.getFileDateVersionFromPath(_reconstruction.graph.filepath) - - // Check if the file has been modified by another instance - if (_reconstruction.graph.fileDateVersion !== date) { - fileModifiedDialog.open() - } else - _reconstruction.save() - } else { + MenuSeparator { } + Action { + id: saveAction + text: "Save" + shortcut: "Ctrl+S" + enabled: _reconstruction ? (_reconstruction.graph && !_reconstruction.graph.filepath) || !_reconstruction.undoStack.clean : false + onTriggered: { + if (_reconstruction.graph.filepath) { + // Get current time date + var date = _reconstruction.graph.getFileDateVersionFromPath(_reconstruction.graph.filepath) + + // Check if the file has been modified by another instance + if (_reconstruction.graph.fileDateVersion !== date) { + fileModifiedDialog.open() + } else + _reconstruction.save() + } else { + initFileDialogFolder(saveFileDialog) + saveFileDialog.open() + } + } + } + Action { + id: saveAsAction + text: "Save As..." + shortcut: "Ctrl+Shift+S" + onTriggered: { initFileDialogFolder(saveFileDialog) saveFileDialog.open() } } - } - Action { - id: saveAsAction - text: "Save As..." - shortcut: "Ctrl+Shift+S" - onTriggered: { - initFileDialogFolder(saveFileDialog) - saveFileDialog.open() - } - } - MenuSeparator { } - Action { - id: importImagesAction - text: "Import Images" - shortcut: "Ctrl+I" - onTriggered: { - initFileDialogFolder(importImagesDialog, true) - importImagesDialog.open() - } - } - - MenuItem { - action: removeAllImagesAction - ToolTip.visible: hovered - ToolTip.text: removeAllImagesAction.tooltip - } - - MenuSeparator { } - Menu { - id: advancedMenu - title: "Advanced" - implicitWidth: 300 - + MenuSeparator { } Action { - id: saveAsTemplateAction - text: "Save As Template..." - shortcut: Shortcut { - sequence: "Ctrl+Shift+T" - context: Qt.ApplicationShortcut - onActivated: saveAsTemplateAction.triggered() - } + id: importImagesAction + text: "Import Images" + shortcut: "Ctrl+I" onTriggered: { - initFileDialogFolder(saveTemplateDialog) - saveTemplateDialog.open() + initFileDialogFolder(importImagesDialog, true) + importImagesDialog.open() } } MenuItem { - action: loadTemplateAction + action: removeAllImagesAction ToolTip.visible: hovered - ToolTip.text: loadTemplateAction.tooltip + ToolTip.text: removeAllImagesAction.tooltip } - Action { - id: importProjectAction - text: "Import Project" - shortcut: Shortcut { - sequence: "Ctrl+Shift+I" - context: Qt.ApplicationShortcut - onActivated: importProjectAction.triggered() + MenuSeparator { } + Menu { + id: advancedMenu + title: "Advanced" + implicitWidth: 300 + + Action { + id: saveAsTemplateAction + text: "Save As Template..." + shortcut: Shortcut { + sequence: "Ctrl+Shift+T" + context: Qt.ApplicationShortcut + onActivated: saveAsTemplateAction.triggered() + } + onTriggered: { + initFileDialogFolder(saveTemplateDialog) + saveTemplateDialog.open() + } } - onTriggered: { - initFileDialogFolder(importProjectDialog) - importProjectDialog.open() + + MenuItem { + action: loadTemplateAction + ToolTip.visible: hovered + ToolTip.text: loadTemplateAction.tooltip } - } + Action { + id: importProjectAction + text: "Import Project" + shortcut: Shortcut { + sequence: "Ctrl+Shift+I" + context: Qt.ApplicationShortcut + onActivated: importProjectAction.triggered() + } + onTriggered: { + initFileDialogFolder(importProjectDialog) + importProjectDialog.open() + } + } + + MenuItem { + action: removeImagesFromAllGroupsAction + ToolTip.visible: hovered + ToolTip.text: removeImagesFromAllGroupsAction.tooltip + } + } + MenuSeparator { } + Action { + text: "Quit" + onTriggered: _window.close() + } + } + Menu { + title: "Edit" MenuItem { - action: removeImagesFromAllGroupsAction + action: undoAction ToolTip.visible: hovered - ToolTip.text: removeImagesFromAllGroupsAction.tooltip + ToolTip.text: undoAction.tooltip + } + MenuItem { + action: redoAction + ToolTip.visible: hovered + ToolTip.text: redoAction.tooltip + } + MenuItem { + action: cutAction + ToolTip.visible: hovered + ToolTip.text: cutAction.tooltip + } + MenuItem { + action: copyAction + ToolTip.visible: hovered + ToolTip.text: copyAction.tooltip + } + MenuItem { + action: pasteAction + ToolTip.visible: hovered + ToolTip.text: pasteAction.tooltip } } - MenuSeparator { } - Action { - text: "Quit" - onTriggered: _window.close() - } - } - Menu { - title: "Edit" - MenuItem { - action: undoAction - ToolTip.visible: hovered - ToolTip.text: undoAction.tooltip - } - MenuItem { - action: redoAction - ToolTip.visible: hovered - ToolTip.text: redoAction.tooltip - } - MenuItem { - action: cutAction - ToolTip.visible: hovered - ToolTip.text: cutAction.tooltip - } - MenuItem { - action: copyAction - ToolTip.visible: hovered - ToolTip.text: copyAction.tooltip - } - MenuItem { - action: pasteAction - ToolTip.visible: hovered - ToolTip.text: pasteAction.tooltip - } - } - Menu { - title: "View" - MenuItem { - id: graphEditorVisibilityCB - text: "Graph Editor" - checkable: true - checked: true - } - MenuItem { - id: liveSfMVisibilityCB - text: "Live Reconstruction" - checkable: true - checked: false - } - MenuItem { - id: imageViewerVisibilityCB - text: "Image Viewer" - checkable: true - checked: true - } - MenuItem { - id: viewer3DVisibilityCB - text: "3D Viewer" - checkable: true - checked: true - } - MenuItem { - id: imageGalleryVisibilityCB - text: "Image Gallery" - checkable: true - checked: true - } - MenuSeparator {} - Action { - text: "Fullscreen" - checkable: true - checked: _window.visibility == ApplicationWindow.FullScreen - shortcut: "Ctrl+F" - onTriggered: _window.visibility == ApplicationWindow.FullScreen ? _window.showNormal() : showFullScreen() - } - } - Menu { - title: "Process" - Action { - text: "Compute all nodes" - onTriggered: computeManager.compute(null) - enabled: _reconstruction ? !_reconstruction.computingLocally : false - } - Action { - text: "Submit all nodes" - onTriggered: computeManager.submit(null) - enabled: _reconstruction ? _reconstruction.canSubmit : false - } - MenuSeparator {} - Action { - text: "Stop computation" - onTriggered: _reconstruction.stopExecution() - enabled: _reconstruction ? _reconstruction.computingLocally : false + Menu { + title: "View" + MenuItem { + id: graphEditorVisibilityCB + text: "Graph Editor" + checkable: true + checked: true + } + MenuItem { + id: liveSfMVisibilityCB + text: "Live Reconstruction" + checkable: true + checked: false + } + MenuItem { + id: imageViewerVisibilityCB + text: "Image Viewer" + checkable: true + checked: true + } + MenuItem { + id: viewer3DVisibilityCB + text: "3D Viewer" + checkable: true + checked: true + } + MenuItem { + id: imageGalleryVisibilityCB + text: "Image Gallery" + checkable: true + checked: true + } + MenuSeparator {} + Action { + text: "Fullscreen" + checkable: true + checked: _window.visibility == ApplicationWindow.FullScreen + shortcut: "Ctrl+F" + onTriggered: _window.visibility == ApplicationWindow.FullScreen ? _window.showNormal() : showFullScreen() + } } - } - Menu { - title: "Help" - Action { - text: "Online Documentation" - onTriggered: Qt.openUrlExternally("https://meshroom-manual.readthedocs.io") + Menu { + title: "Process" + Action { + text: "Compute all nodes" + onTriggered: computeManager.compute(null) + enabled: _reconstruction ? !_reconstruction.computingLocally : false + } + Action { + text: "Submit all nodes" + onTriggered: computeManager.submit(null) + enabled: _reconstruction ? _reconstruction.canSubmit : false + } + MenuSeparator {} + Action { + text: "Stop computation" + onTriggered: _reconstruction.stopExecution() + enabled: _reconstruction ? _reconstruction.computingLocally : false + } } - Action { - text: "About Meshroom" - onTriggered: aboutDialog.open() - // Should be StandardKey.HelpContents, but for some reason it's not stable - // (may cause crash, requires pressing F1 twice after closing the popup) - shortcut: "F1" + Menu { + title: "Help" + Action { + text: "Online Documentation" + onTriggered: Qt.openUrlExternally("https://meshroom-manual.readthedocs.io") + } + Action { + text: "About Meshroom" + onTriggered: aboutDialog.open() + // Should be StandardKey.HelpContents, but for some reason it's not stable + // (may cause crash, requires pressing F1 twice after closing the popup) + shortcut: "F1" + } } } } - Rectangle { - Layout.fillWidth: true - Layout.fillHeight: true - color: Qt.darker(activePalette.window, 1.15) - } - Row { // Process buttons MaterialToolButton { id: processButton font.pointSize: 18 + padding: 2 text: !(_reconstruction.computingLocally) ? MaterialIcons.send : MaterialIcons.cancel_schedule_send @@ -956,6 +963,7 @@ Page { id: submitButton font.pointSize: 18 + padding: 2 visible: _reconstruction ? _reconstruction.canSubmit : false text: MaterialIcons.rocket_launch