GODT-1411: refactor SettingView content to fill height

This commit is contained in:
Alexander Bilyak
2021-11-09 13:18:11 +00:00
committed by Jakub
parent 2e52b8db87
commit 31920a4468
10 changed files with 251 additions and 167 deletions

View File

@ -40,14 +40,27 @@ Item {
property int _lineWidth: 1
ScrollView {
id: scrollView
clip: true
anchors.fill: parent
Item {
// can't use parent here because parent is not ScrollView (Flickable inside contentItem inside ScrollView)
width: scrollView.availableWidth
height: scrollView.availableHeight
implicitHeight: children[0].implicitHeight + children[0].anchors.topMargin + children[0].anchors.bottomMargin
// do not set implicitWidth because implicit width of ColumnLayout will be equal to maximum implicit width of
// internal items. And if one of internal items would be a Text or Label - implicit width of those is always
// equal to non-wrapped text (i.e. one line only). That will lead to enabling horizontal scroll when not needed
implicitWidth: width
ColumnLayout {
width: root.width
spacing: 0
anchors.fill: parent
Rectangle {
id: topRectangle
color: root.colorScheme.background_norm
@ -66,7 +79,6 @@ Item {
anchors.topMargin: root._topMargin
anchors.bottomMargin: root._bottomMargin
RowLayout { // account delegate with action buttons
Layout.fillWidth: true
@ -235,3 +247,4 @@ Item {
}
}
}
}

View File

@ -24,6 +24,8 @@ import Proton 4.0
SettingsView {
id: root
fillHeight: true
property var selectedAddress
Label {
@ -41,7 +43,8 @@ SettingsView {
label: qsTr("Description")
colorScheme: root.colorScheme
Layout.fillWidth: true
Layout.minimumHeight: 100
Layout.fillHeight: true
Layout.minimumHeight: heightForLinesVisible(4)
hint: description.text.length + "/" + _maxLength
placeholderText: qsTr("Tell us what went wrong or isn't working (min. %1 characters).").arg(_minLength)
@ -66,6 +69,11 @@ SettingsView {
KeyNavigation.priority: KeyNavigation.BeforeItem
KeyNavigation.tab: address
// set implicitHeight to explicit height because se don't
// want TextArea implicitHeight (which is height of all text)
// to be considered in SettingsView internal scroll view
implicitHeight: height
}

View File

@ -41,4 +41,15 @@ Rectangle {
color: "black"
colorScheme: ProtonStyle.currentStyle
}
Rectangle {
width: target.implicitWidth
height: target.implicitHeight
color: "transparent"
border.color: "green"
border.width: 1
//z: parent.z - 1
z: 10000000
}
}

View File

@ -28,6 +28,8 @@ SettingsView {
property bool _isAdvancedShown: false
property var notifications
fillHeight: false
Label {
colorScheme: root.colorScheme
text: qsTr("Settings")

View File

@ -24,6 +24,8 @@ import Proton 4.0
SettingsView {
id: root
fillHeight: true
Label {
colorScheme: root.colorScheme
text: qsTr("Help")
@ -88,6 +90,12 @@ SettingsView {
Layout.fillWidth: true
}
// fill height so the footer label will be allways attached to the bottom
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
Label {
Layout.alignment: Qt.AlignHCenter
colorScheme: root.colorScheme

View File

@ -26,6 +26,8 @@ import Proton 4.0
SettingsView {
id: root
fillHeight: false
property var notifications
property bool _diskCacheEnabled: true
property string _diskCachePath: "/home"

View File

@ -25,6 +25,8 @@ import Proton 4.0
SettingsView {
id: root
fillHeight: false
property bool _valuesChanged: (
imapField.text*1 !== root.backend.portIMAP ||
smtpField.text*1 !== root.backend.portSMTP

View File

@ -124,11 +124,27 @@ FocusScope {
function selectWord() { return control.selectWord() }
function undo() { return control.undo() }
// Calculates the height of the component to make exactly lineNum visible in edit area
function heightForLinesVisible(lineNum) {
var totalHeight = 0
totalHeight += headerLayout.height
totalHeight += footerLayout.height
totalHeight += control.topPadding + control.bottomPadding
totalHeight += lineNum * fontMetrics.height
return totalHeight
}
FontMetrics {
id: fontMetrics
font: control.font
}
ColumnLayout {
anchors.fill: parent
spacing: 0
RowLayout {
id: headerLayout
Layout.fillWidth: true
spacing: 0
@ -282,6 +298,7 @@ FocusScope {
}
RowLayout {
id: footerLayout
Layout.fillWidth: true
spacing: 0

View File

@ -25,6 +25,8 @@ import Proton 4.0
SettingsView {
id: root
fillHeight: false
Label {
colorScheme: root.colorScheme
text: qsTr("SMTP connection mode")

View File

@ -37,28 +37,47 @@ Item {
property int _bottomMargin: 32
property int _spacing: 20
// fillHeight indicates whether the SettingsView should fill all available explicit height set
property bool fillHeight: false
ScrollView {
id: scrollView
clip: true
width:root.width
height:root.height
anchors.fill: parent
contentWidth: content.width + content.anchors.leftMargin + content.anchors.rightMargin
contentHeight: content.height + content.anchors.topMargin + content.anchors.bottomMargin
Item {
// can't use parent here because parent is not ScrollView (Flickable inside contentItem inside ScrollView)
width: scrollView.availableWidth
height: scrollView.availableHeight
implicitHeight: children[0].implicitHeight + children[0].anchors.topMargin + children[0].anchors.bottomMargin
// do not set implicitWidth because implicit width of ColumnLayout will be equal to maximum implicit width of
// internal items. And if one of internal items would be a Text or Label - implicit width of those is always
// equal to non-wrapped text (i.e. one line only). That will lead to enabling horizontal scroll when not needed
implicitWidth: width
ColumnLayout {
anchors.fill: parent
spacing: 0
ColumnLayout {
id: content
spacing: root._spacing
width: root.width - (root._leftMargin + root._rightMargin)
anchors{
top: parent.top
left: parent.left
topMargin: root._topMargin
bottomMargin: root._bottomMargin
leftMargin: root._leftMargin
rightMargin: root._rightMargin
Layout.fillWidth: true
Layout.topMargin: root._topMargin
Layout.bottomMargin: root._bottomMargin
Layout.leftMargin: root._leftMargin
Layout.rightMargin: root._rightMargin
}
Item {
id: filler
Layout.fillHeight: true
visible: !root.fillHeight
}
}
}
}