forked from Silverfish/proton-bridge
GODT-1411: refactor SettingView content to fill height
This commit is contained in:
@ -40,14 +40,27 @@ Item {
|
|||||||
property int _lineWidth: 1
|
property int _lineWidth: 1
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
|
id: scrollView
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
anchors.fill: parent
|
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 {
|
ColumnLayout {
|
||||||
width: root.width
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: topRectangle
|
id: topRectangle
|
||||||
color: root.colorScheme.background_norm
|
color: root.colorScheme.background_norm
|
||||||
@ -66,7 +79,6 @@ Item {
|
|||||||
anchors.topMargin: root._topMargin
|
anchors.topMargin: root._topMargin
|
||||||
anchors.bottomMargin: root._bottomMargin
|
anchors.bottomMargin: root._bottomMargin
|
||||||
|
|
||||||
|
|
||||||
RowLayout { // account delegate with action buttons
|
RowLayout { // account delegate with action buttons
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
@ -235,3 +247,4 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import Proton 4.0
|
|||||||
SettingsView {
|
SettingsView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
fillHeight: true
|
||||||
|
|
||||||
property var selectedAddress
|
property var selectedAddress
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@ -41,7 +43,8 @@ SettingsView {
|
|||||||
label: qsTr("Description")
|
label: qsTr("Description")
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.minimumHeight: 100
|
Layout.fillHeight: true
|
||||||
|
Layout.minimumHeight: heightForLinesVisible(4)
|
||||||
hint: description.text.length + "/" + _maxLength
|
hint: description.text.length + "/" + _maxLength
|
||||||
placeholderText: qsTr("Tell us what went wrong or isn't working (min. %1 characters).").arg(_minLength)
|
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.priority: KeyNavigation.BeforeItem
|
||||||
KeyNavigation.tab: address
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,4 +41,15 @@ Rectangle {
|
|||||||
color: "black"
|
color: "black"
|
||||||
colorScheme: ProtonStyle.currentStyle
|
colorScheme: ProtonStyle.currentStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: target.implicitWidth
|
||||||
|
height: target.implicitHeight
|
||||||
|
|
||||||
|
color: "transparent"
|
||||||
|
border.color: "green"
|
||||||
|
border.width: 1
|
||||||
|
//z: parent.z - 1
|
||||||
|
z: 10000000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,8 @@ SettingsView {
|
|||||||
property bool _isAdvancedShown: false
|
property bool _isAdvancedShown: false
|
||||||
property var notifications
|
property var notifications
|
||||||
|
|
||||||
|
fillHeight: false
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
text: qsTr("Settings")
|
text: qsTr("Settings")
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import Proton 4.0
|
|||||||
SettingsView {
|
SettingsView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
fillHeight: true
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
text: qsTr("Help")
|
text: qsTr("Help")
|
||||||
@ -88,6 +90,12 @@ SettingsView {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill height so the footer label will be allways attached to the bottom
|
||||||
|
Item {
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
|
|||||||
@ -26,6 +26,8 @@ import Proton 4.0
|
|||||||
SettingsView {
|
SettingsView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
fillHeight: false
|
||||||
|
|
||||||
property var notifications
|
property var notifications
|
||||||
property bool _diskCacheEnabled: true
|
property bool _diskCacheEnabled: true
|
||||||
property string _diskCachePath: "/home"
|
property string _diskCachePath: "/home"
|
||||||
|
|||||||
@ -25,6 +25,8 @@ import Proton 4.0
|
|||||||
SettingsView {
|
SettingsView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
fillHeight: false
|
||||||
|
|
||||||
property bool _valuesChanged: (
|
property bool _valuesChanged: (
|
||||||
imapField.text*1 !== root.backend.portIMAP ||
|
imapField.text*1 !== root.backend.portIMAP ||
|
||||||
smtpField.text*1 !== root.backend.portSMTP
|
smtpField.text*1 !== root.backend.portSMTP
|
||||||
|
|||||||
@ -124,11 +124,27 @@ FocusScope {
|
|||||||
function selectWord() { return control.selectWord() }
|
function selectWord() { return control.selectWord() }
|
||||||
function undo() { return control.undo() }
|
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 {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
id: headerLayout
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
@ -282,6 +298,7 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
id: footerLayout
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,8 @@ import Proton 4.0
|
|||||||
SettingsView {
|
SettingsView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
fillHeight: false
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
text: qsTr("SMTP connection mode")
|
text: qsTr("SMTP connection mode")
|
||||||
|
|||||||
@ -37,28 +37,47 @@ Item {
|
|||||||
property int _bottomMargin: 32
|
property int _bottomMargin: 32
|
||||||
property int _spacing: 20
|
property int _spacing: 20
|
||||||
|
|
||||||
|
// fillHeight indicates whether the SettingsView should fill all available explicit height set
|
||||||
|
property bool fillHeight: false
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
|
id: scrollView
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
width:root.width
|
anchors.fill: parent
|
||||||
height:root.height
|
|
||||||
|
|
||||||
contentWidth: content.width + content.anchors.leftMargin + content.anchors.rightMargin
|
Item {
|
||||||
contentHeight: content.height + content.anchors.topMargin + content.anchors.bottomMargin
|
// 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 {
|
ColumnLayout {
|
||||||
id: content
|
id: content
|
||||||
spacing: root._spacing
|
spacing: root._spacing
|
||||||
width: root.width - (root._leftMargin + root._rightMargin)
|
|
||||||
|
|
||||||
anchors{
|
Layout.fillWidth: true
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
Layout.topMargin: root._topMargin
|
||||||
topMargin: root._topMargin
|
Layout.bottomMargin: root._bottomMargin
|
||||||
bottomMargin: root._bottomMargin
|
Layout.leftMargin: root._leftMargin
|
||||||
leftMargin: root._leftMargin
|
Layout.rightMargin: root._rightMargin
|
||||||
rightMargin: root._rightMargin
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: filler
|
||||||
|
Layout.fillHeight: true
|
||||||
|
visible: !root.fillHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user