matrixion/resources/qml/ChatPage.qml

138 lines
4.5 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 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 1.0
// this needs to be last
import QtQml 2.15
Rectangle {
id: chatPage
color: palette.window
2022-01-26 04:16:06 +03:00
ColumnLayout {
anchors.fill: parent
2023-06-02 02:45:24 +03:00
spacing: 0
2022-01-26 04:16:06 +03:00
Rectangle {
id: offlineIndicator
2023-06-02 02:45:24 +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
2021-06-06 00:36:08 +03:00
2022-01-26 04:16:06 +03:00
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
2023-06-02 02:45:24 +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
2023-06-02 02:45:24 +03:00
target: Rooms
}
2022-01-26 04:16:06 +03:00
AdaptiveLayoutElement {
id: communityListC
2022-01-26 04:16:06 +03:00
collapsedWidth: communitiesList.avatarSize + 2 * Nheko.paddingMedium
maximumWidth: communitiesList.avatarSize * 10 + 2 * Nheko.paddingMedium
2023-06-02 02:45:24 +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
2021-06-06 00:36:08 +03:00
2022-01-26 04:16:06 +03:00
collapsed: parent.collapsed
}
Binding {
2023-06-02 02:45:24 +03:00
delayed: true
2022-01-26 04:16:06 +03:00
property: 'communityListWidth'
2023-06-02 02:45:24 +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
2023-06-02 02:45:24 +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
2023-06-02 02:45:24 +03:00
height: adaptiveView.height
2022-01-26 04:16:06 +03:00
}
Binding {
2023-06-02 02:45:24 +03:00
delayed: true
2022-01-26 04:16:06 +03:00
property: 'roomListWidth'
2023-06-02 02:45:24 +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
2022-01-26 04:16:06 +03:00
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
2021-06-06 00:36:08 +03:00
privacyScreen: privacyScreen
2022-01-26 04:16:06 +03:00
room: Rooms.currentRoom
roomPreview: Rooms.currentRoomPreview.roomid ? Rooms.currentRoomPreview : null
2023-06-02 02:45:24 +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 {
id: privacyScreen
anchors.fill: parent
screenTimeout: Settings.privacyScreenTimeout
2021-06-11 22:13:16 +03:00
timelineRoot: adaptiveView
2023-06-02 02:45:24 +03:00
visible: Settings.privacyScreen
windowTarget: MainWindow
}
}