diff --git a/meshroom/ui/qml/GraphEditor/AttributeEditor.qml b/meshroom/ui/qml/GraphEditor/AttributeEditor.qml index 5dfc4be2..e7e3268a 100644 --- a/meshroom/ui/qml/GraphEditor/AttributeEditor.qml +++ b/meshroom/ui/qml/GraphEditor/AttributeEditor.qml @@ -64,7 +64,7 @@ ColumnLayout { id: attributesListView anchors.fill: parent - anchors.margins: 6 + anchors.margins: 4 clip: true spacing: 1 diff --git a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml index 1559fd51..3e4f40c1 100644 --- a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml +++ b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml @@ -1,6 +1,7 @@ import QtQuick 2.9 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 +import "../filepath.js" as Filepath /** Instantiate a control to visualize and edit an Attribute based on its type. @@ -52,11 +53,34 @@ RowLayout { property Component menuComp: Menu { id: paramMenu + property bool isFileAttribute: attribute.type == "File" + property bool isFilepath: isFileAttribute && Filepath.isFile(attribute.value) + MenuItem { text: "Reset To Default Value" enabled: !attribute.isOutput && !attribute.isLink && !attribute.isDefault onTriggered: _reconstruction.resetAttribute(attribute) } + + MenuSeparator { + visible: paramMenu.isFileAttribute + height: visible ? implicitHeight : 0 + } + + MenuItem { + visible: paramMenu.isFileAttribute + height: visible ? implicitHeight : 0 + text: paramMenu.isFilepath ? "Open Containing Folder" : "Open Folder" + onClicked: paramMenu.isFilepath ? Qt.openUrlExternally(Filepath.dirname(attribute.value)) : + Qt.openUrlExternally(attribute.value) + } + + MenuItem { + visible: paramMenu.isFilepath + height: visible ? implicitHeight : 0 + text: "Open File" + onClicked: Qt.openUrlExternally(attribute.value) + } } onClicked: { @@ -240,7 +264,7 @@ RowLayout { Layout.fillWidth: true Layout.margins: 4 clip: true - spacing: 10 + spacing: 4 ScrollBar.vertical: ScrollBar { id: sb } diff --git a/meshroom/ui/qml/filepath.js b/meshroom/ui/qml/filepath.js index e993265d..b52b62ab 100644 --- a/meshroom/ui/qml/filepath.js +++ b/meshroom/ui/qml/filepath.js @@ -15,3 +15,10 @@ function extension(path) { var dot_pos = path.lastIndexOf('.'); return dot_pos > -1 ? path.substring(dot_pos, path.length) : "" } + +/// Return whether the given path is a path to a file. +/// (only based on the fact that the last portion of the path +/// matches the 'basename.extension' pattern) +function isFile(path) { + return extension(path) !== "" +}