mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-02 16:28:51 +02:00
[ui] MessageDialog: add "Copy Message to Clipboard" button
Add a button to copy the textual content of a MessageDialog to the clipboard. * use hidden TextEdit to perform the copy operation * add function to modify this text in inherited components * move icon to title
This commit is contained in:
parent
a4a40de8b8
commit
02dc58f144
1 changed files with 65 additions and 25 deletions
|
@ -1,3 +1,4 @@
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import MaterialIcons 2.2
|
||||
|
@ -12,6 +13,16 @@ Dialog {
|
|||
|
||||
default property alias children: layout.children
|
||||
|
||||
// the content of this MessageDialog as a string
|
||||
readonly property string asString: title + "\n\n" + text + "\n" + detailedText + "\n" + helperText + "\n"
|
||||
|
||||
/// Return the text content of this dialog as a simple string.
|
||||
/// Used when copying the message in the system clipboard.
|
||||
/// Can be overriden in components extending MessageDialog
|
||||
function getAsString() {
|
||||
return asString
|
||||
}
|
||||
|
||||
x: parent.width/2 - width/2
|
||||
y: parent.height/2 - height/2
|
||||
modal: true
|
||||
|
@ -19,38 +30,67 @@ Dialog {
|
|||
padding: 15
|
||||
standardButtons: Dialog.Ok
|
||||
|
||||
RowLayout {
|
||||
spacing: 12
|
||||
header: Pane {
|
||||
padding: 6
|
||||
leftPadding: 8
|
||||
rightPadding: leftPadding
|
||||
|
||||
// Icon
|
||||
Label {
|
||||
id: iconLabel
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
font.family: MaterialIcons.fontFamily
|
||||
font.pointSize: 14
|
||||
visible: text != ""
|
||||
background: Item {
|
||||
// hidden text edit to perform copy in clipboard
|
||||
TextEdit {
|
||||
id: textContent
|
||||
visible: false
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: layout
|
||||
// Text
|
||||
spacing: 12
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
// Icon
|
||||
Label {
|
||||
id: textLabel
|
||||
id: iconLabel
|
||||
font.family: MaterialIcons.fontFamily
|
||||
font.pointSize: 14
|
||||
visible: text != ""
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: title
|
||||
font.bold: true
|
||||
visible: text != ""
|
||||
}
|
||||
// Detailed text
|
||||
Label {
|
||||
id: detailedLabel
|
||||
text: text
|
||||
visible: text != ""
|
||||
}
|
||||
// Additional helper text
|
||||
Label {
|
||||
id: helperLabel
|
||||
visible: text != ""
|
||||
ToolButton {
|
||||
font.family: MaterialIcons.fontFamily
|
||||
text: MaterialIcons.content_copy
|
||||
ToolTip.text: "Copy Message to Clipboard"
|
||||
ToolTip.visible: hovered
|
||||
font.pointSize: 12
|
||||
onClicked: {
|
||||
textContent.text = getAsString()
|
||||
textContent.selectAll(); textContent.copy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: layout
|
||||
// Text
|
||||
spacing: 12
|
||||
Label {
|
||||
id: textLabel
|
||||
font.bold: true
|
||||
visible: text != ""
|
||||
}
|
||||
// Detailed text
|
||||
Label {
|
||||
id: detailedLabel
|
||||
text: text
|
||||
visible: text != ""
|
||||
}
|
||||
// Additional helper text
|
||||
Label {
|
||||
id: helperLabel
|
||||
visible: text != ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue