Skip to content

Commit

Permalink
Merge pull request #895 from Ultimaker/CURA-9374_make_long_messages_s…
Browse files Browse the repository at this point in the history
…crollable

Cura 9374 make long messages scrollable
  • Loading branch information
casperlamboo authored Aug 22, 2023
2 parents 0aade03 + c2675ed commit fd4ca91
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
19 changes: 12 additions & 7 deletions UM/Qt/qml/UM/MessageStack.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import QtQuick 2.3
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1

import UM 1.5 as UM
import UM 1.7 as UM

ListView
{
Expand Down Expand Up @@ -192,9 +192,10 @@ ListView
}
}

UM.Label
UM.ScrollableTextArea
{
id: messageLabel
id: scrollableMessageLabel

anchors
{
left: parent.left
Expand All @@ -207,23 +208,27 @@ ListView
topMargin: UM.Theme.getSize("default_margin").height
}

height: text == "" ? 0 : contentHeight
height: textArea.text === "" ? 0 : Math.min(UM.Theme.getSize("message").height * 3, contentHeight)

function getProgressText()
{
return "%1 %2%".arg(model.text).arg(Math.floor(model.progress))
}

text: model.progress > 0 ? messageLabel.getProgressText() : model.text == undefined ? "" : model.text
onLinkActivated: Qt.openUrlExternally(link)
textArea.text: model.progress > 0 ? getProgressText() : (model.text == undefined ? "" : model.text)
textArea.textFormat: Text.RichText
textArea.readOnly: true
textArea.onLinkActivated: Qt.openUrlExternally(link)
textArea.background: null
textArea.padding: 0
}

UM.CheckBox
{
id: optionToggle
anchors
{
top: messageLabel.bottom
top: scrollableMessageLabel.bottom
topMargin: visible ? UM.Theme.getSize("narrow_margin").height: 0
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
Expand Down
39 changes: 39 additions & 0 deletions UM/Qt/qml/UM/ScrollableTextArea.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2022 Ultimaker B.V.
// Uranium is released under the terms of the LGPLv3 or higher.

import QtQuick 2.10
import QtQuick.Controls 2.3
import UM 1.7 as UM

//TextArea with scrolls that uses our own theme.
Flickable
{
id: scrollableTextAreaBase
property bool do_borders: true
property var back_color: UM.Theme.getColor("main_background")
property alias textArea: flickableTextArea

ScrollBar.vertical: UM.ScrollBar {}

TextArea.flickable: TextArea
{
id: flickableTextArea

background: Rectangle //Providing the background color and border.
{
anchors.fill: parent
anchors.margins: -border.width

color: scrollableTextAreaBase.back_color
border.color: UM.Theme.getColor("thick_lining")
border.width: scrollableTextAreaBase.do_borders ? UM.Theme.getSize("default_lining").width : 0
}

font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
textFormat: TextEdit.PlainText
renderType: Text.NativeRendering
wrapMode: Text.Wrap
selectByMouse: true
}
}
1 change: 1 addition & 0 deletions UM/Qt/qml/UM/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ TooltipArea 1.1 TooltipArea.qml

ProgressBar 1.3 ProgressBar.qml
ScrollBar 1.5 ScrollBar.qml
ScrollableTextArea 1.7 ScrollableTextArea.qml
SimpleButton 1.1 SimpleButton.qml
TabRow 1.3 TabRow.qml
TabRowButton 1.3 TabRowButton.qml
Expand Down

0 comments on commit fd4ca91

Please sign in to comment.