Split HPage into more specialized components
This commit is contained in:
parent
abf7251f75
commit
5f6a23f051
16
src/gui/Base/HColumnPage.qml
Normal file
16
src/gui/Base/HColumnPage.qml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
|
||||||
|
HPage {
|
||||||
|
focusTarget: column
|
||||||
|
|
||||||
|
|
||||||
|
default property alias columnData: column.data
|
||||||
|
|
||||||
|
|
||||||
|
HColumnLayout {
|
||||||
|
id: column
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
}
|
26
src/gui/Base/HFlickableColumnPage.qml
Normal file
26
src/gui/Base/HFlickableColumnPage.qml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
|
||||||
|
HPage {
|
||||||
|
focusTarget: column
|
||||||
|
|
||||||
|
|
||||||
|
property alias flickable: flickable
|
||||||
|
default property alias columnData: column.data
|
||||||
|
|
||||||
|
|
||||||
|
HFlickable {
|
||||||
|
id: flickable
|
||||||
|
anchors.fill: parent
|
||||||
|
clip: true
|
||||||
|
contentWidth: parent.width
|
||||||
|
contentHeight: column.childrenRect.height
|
||||||
|
|
||||||
|
HColumnLayout {
|
||||||
|
id: column
|
||||||
|
width: flickable.width
|
||||||
|
height: flickable.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,74 +2,22 @@
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.12
|
|
||||||
import "../MainPane"
|
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: innerPage
|
leftPadding: currentSpacing < theme.spacing ? 0 : currentSpacing
|
||||||
|
rightPadding: leftPadding
|
||||||
|
background: null
|
||||||
|
|
||||||
|
Component.onCompleted:
|
||||||
|
if (becomeKeyboardFlickableTarget) shortcuts.flickTarget = focusTarget
|
||||||
|
|
||||||
default property alias columnData: contentColumn.data
|
|
||||||
|
|
||||||
property alias flickable: innerFlickable
|
|
||||||
property alias headerLabel: innerHeaderLabel
|
|
||||||
property var hideHeaderUnderHeight: null
|
|
||||||
|
|
||||||
property int currentSpacing:
|
property int currentSpacing:
|
||||||
Math.min(theme.spacing * width / 400, theme.spacing)
|
Math.min(theme.spacing * width / 400, theme.spacing)
|
||||||
|
|
||||||
|
property Item focusTarget: this
|
||||||
property bool becomeKeyboardFlickableTarget: true
|
property bool becomeKeyboardFlickableTarget: true
|
||||||
|
|
||||||
|
|
||||||
background: null
|
|
||||||
|
|
||||||
header: Rectangle {
|
|
||||||
implicitWidth: parent ? parent.width : 0
|
|
||||||
color: theme.controls.header.background
|
|
||||||
|
|
||||||
height: innerHeaderLabel.text && (
|
|
||||||
! hideHeaderUnderHeight ||
|
|
||||||
window.height >=
|
|
||||||
hideHeaderUnderHeight +
|
|
||||||
theme.baseElementsHeight +
|
|
||||||
currentSpacing * 2
|
|
||||||
) ? theme.baseElementsHeight : 0
|
|
||||||
|
|
||||||
Behavior on height { HNumberAnimation {} }
|
|
||||||
visible: height > 0
|
|
||||||
|
|
||||||
HLabel {
|
|
||||||
id: innerHeaderLabel
|
|
||||||
anchors.fill: parent
|
|
||||||
textFormat: Text.StyledText
|
|
||||||
font.pixelSize: theme.fontSize.big
|
|
||||||
elide: Text.ElideRight
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
|
|
||||||
leftPadding: currentSpacing
|
|
||||||
rightPadding: leftPadding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
leftPadding: currentSpacing < theme.spacing ? 0 : currentSpacing
|
|
||||||
rightPadding: leftPadding
|
|
||||||
Behavior on leftPadding { HNumberAnimation {} }
|
Behavior on leftPadding { HNumberAnimation {} }
|
||||||
|
|
||||||
HFlickable {
|
|
||||||
id: innerFlickable
|
|
||||||
anchors.fill: parent
|
|
||||||
clip: true
|
|
||||||
contentWidth: parent.width
|
|
||||||
contentHeight: contentColumn.childrenRect.height
|
|
||||||
|
|
||||||
Component.onCompleted:
|
|
||||||
if (becomeKeyboardFlickableTarget) shortcuts.flickTarget = this
|
|
||||||
|
|
||||||
HColumnLayout {
|
|
||||||
id: contentColumn
|
|
||||||
width: innerFlickable.width
|
|
||||||
height: innerFlickable.height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,8 @@ import QtQuick.Layouts 1.12
|
||||||
import "../.."
|
import "../.."
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
|
|
||||||
HPage {
|
HFlickableColumnPage {
|
||||||
id: accountSettings
|
id: accountSettings
|
||||||
hideHeaderUnderHeight: avatarPreferredSize
|
|
||||||
headerLabel.text: qsTr("Account settings for %1").arg(
|
|
||||||
utils.coloredNameHtml(headerName, userId)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
property int avatarPreferredSize: 256 * theme.uiScale
|
property int avatarPreferredSize: 256 * theme.uiScale
|
||||||
|
@ -38,9 +34,8 @@ HPage {
|
||||||
Behavior on color { HColorAnimation {} }
|
Behavior on color { HColorAnimation {} }
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
Layout.topMargin: header.visible || index > 0 ? theme.spacing : 0
|
Layout.topMargin: index > 0 ? theme.spacing : 0
|
||||||
Layout.bottomMargin:
|
Layout.bottomMargin: index < repeater.count - 1 ? theme.spacing : 0
|
||||||
header.visible || index < repeater.count - 1? theme.spacing : 0
|
|
||||||
|
|
||||||
Layout.maximumWidth: Math.min(parent.width, 640)
|
Layout.maximumWidth: Math.min(parent.width, 640)
|
||||||
Layout.preferredWidth:
|
Layout.preferredWidth:
|
||||||
|
|
|
@ -4,7 +4,7 @@ import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
|
|
||||||
HPage {
|
HFlickableColumnPage {
|
||||||
HTabContainer {
|
HTabContainer {
|
||||||
tabModel: [
|
tabModel: [
|
||||||
qsTr("Sign in"), qsTr("Register"), qsTr("Reset"),
|
qsTr("Sign in"), qsTr("Register"), qsTr("Reset"),
|
||||||
|
|
|
@ -5,7 +5,7 @@ import QtQuick.Layouts 1.12
|
||||||
import "../.."
|
import "../.."
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
|
|
||||||
HPage {
|
HFlickableColumnPage {
|
||||||
id: addChatPage
|
id: addChatPage
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import "Banners"
|
||||||
import "Timeline"
|
import "Timeline"
|
||||||
import "FileTransfer"
|
import "FileTransfer"
|
||||||
|
|
||||||
HPage {
|
HColumnPage {
|
||||||
id: chatPage
|
id: chatPage
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user