matrixion/qml/ChatPage.qml

123 lines
4.4 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.3
2021-06-06 00:36:08 +03:00
import "components"
import im.nheko
// this needs to be last
import QtQml 2.15
Rectangle {
id: chatPage
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.window
2022-01-26 04:16:06 +03:00
ColumnLayout {
anchors.fill: parent
2022-04-16 03:13:01 +03:00
spacing: 0
2022-01-26 04:16:06 +03:00
Rectangle {
id: offlineIndicator
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
Layout.preferredHeight: offlineLabel.height + Nheko.paddingMedium
2022-01-26 04:16:06 +03:00
color: Nheko.theme.error
visible: !TimelineManager.isConnected
2022-02-14 06:05:33 +03:00
z: 1
2022-01-26 04:16:06 +03:00
Label {
2022-02-04 02:31:29 +03:00
id: offlineLabel
2022-01-26 04:16:06 +03:00
anchors.centerIn: parent
text: qsTr("No network connection")
}
}
2022-01-26 04:16:06 +03:00
AdaptiveLayout {
id: adaptiveView
function initializePageIndex() {
if (!singlePageMode)
adaptiveView.pageIndex = 0;
else if (Rooms.currentRoom || Rooms.currentRoomPreview.roomid)
adaptiveView.pageIndex = 2;
else
adaptiveView.pageIndex = 1;
2021-06-06 00:36:08 +03:00
}
2021-05-15 00:35:34 +03:00
2022-04-16 03:13:01 +03:00
Layout.fillHeight: true
Layout.fillWidth: true
pageIndex: 1
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
Component.onCompleted: initializePageIndex()
onSinglePageModeChanged: initializePageIndex()
2022-01-26 04:16:06 +03:00
Connections {
function onCurrentRoomChanged() {
adaptiveView.initializePageIndex();
}
2021-06-12 15:07:32 +03:00
2022-04-16 03:13:01 +03:00
target: Rooms
}
2022-01-26 04:16:06 +03:00
AdaptiveLayoutElement {
id: communityListC
collapsedWidth: communitiesList.avatarSize + 2 * Nheko.paddingMedium
maximumWidth: communitiesList.avatarSize * 10 + 2 * Nheko.paddingMedium
2022-04-16 03:13:01 +03:00
minimumWidth: communitiesList.avatarSize * 4 + Nheko.paddingMedium * 2
preferredWidth: Settings.communityListWidth >= minimumWidth ? Settings.communityListWidth : collapsedWidth
visible: Settings.groupView
2021-06-06 00:36:08 +03:00
2022-01-26 04:16:06 +03:00
CommunitiesList {
id: communitiesList
collapsed: parent.collapsed
}
Binding {
2022-04-16 03:13:01 +03:00
delayed: true
2022-01-26 04:16:06 +03:00
property: 'communityListWidth'
2022-04-16 03:13:01 +03:00
restoreMode: Binding.RestoreBindingOrValue
target: Settings
2022-01-26 04:16:06 +03:00
value: communityListC.preferredWidth
when: !adaptiveView.singlePageMode
}
2021-06-06 00:36:08 +03:00
}
2022-01-26 04:16:06 +03:00
AdaptiveLayoutElement {
id: roomListC
collapsedWidth: roomlist.avatarSize + 2 * Nheko.paddingMedium
2022-04-16 03:13:01 +03:00
maximumWidth: roomlist.avatarSize * 10 + Nheko.paddingSmall * 2
minimumWidth: roomlist.avatarSize * 4 + Nheko.paddingSmall * 2
preferredWidth: (Settings.roomListWidth == -1) ? (roomlist.avatarSize * 5 + Nheko.paddingSmall * 2) : (Settings.roomListWidth >= minimumWidth ? Settings.roomListWidth : collapsedWidth)
2022-01-26 04:16:06 +03:00
RoomList {
id: roomlist
collapsed: parent.collapsed
2022-04-16 03:13:01 +03:00
height: adaptiveView.height
2022-01-26 04:16:06 +03:00
}
Binding {
2022-04-16 03:13:01 +03:00
delayed: true
2022-01-26 04:16:06 +03:00
property: 'roomListWidth'
2022-04-16 03:13:01 +03:00
restoreMode: Binding.RestoreBindingOrValue
target: Settings
2022-01-26 04:16:06 +03:00
value: roomListC.preferredWidth
when: !adaptiveView.singlePageMode
}
2021-06-12 15:07:32 +03:00
}
2022-01-26 04:16:06 +03:00
AdaptiveLayoutElement {
id: timlineViewC
minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2 * Nheko.paddingMedium
2021-06-06 00:36:08 +03:00
2022-01-26 04:16:06 +03:00
TimelineView {
id: timeline
room: Rooms.currentRoom
roomPreview: Rooms.currentRoomPreview.roomid ? Rooms.currentRoomPreview : null
2022-04-16 03:13:01 +03:00
showBackButton: adaptiveView.singlePageMode
2022-01-26 04:16:06 +03:00
}
2021-06-06 00:36:08 +03:00
}
2021-05-15 00:35:34 +03:00
}
}
PrivacyScreen {
anchors.fill: parent
screenTimeout: Settings.privacyScreenTimeout
2021-06-11 22:13:16 +03:00
timelineRoot: adaptiveView
2022-04-16 03:13:01 +03:00
visible: Settings.privacyScreen
}
}