Debian Codegraph @

resources/qml/ChatPage.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import QtQuick 2.15
6 import QtQuick.Controls 2.15
7 import QtQuick.Layouts 1.3
8 import "components"
9 import im.nheko 1.0
10
11 // this needs to be last
12 import QtQml 2.15
13
14 Rectangle {
15 id: chatPage
16
17 color: palette.window
18
19 ColumnLayout {
20 anchors.fill: parent
21 spacing: 0
22
23 Rectangle {
24 id: offlineIndicator
25
26 Layout.fillWidth: true
27 Layout.preferredHeight: offlineLabel.height + Nheko.paddingMedium
28 color: Nheko.theme.error
29 visible: !TimelineManager.isConnected
30 z: 1
31
32 Label {
33 id: offlineLabel
34
35 anchors.centerIn: parent
36 text: qsTr("No network connection")
37 }
38 }
39 AdaptiveLayout {
40 id: adaptiveView
41
42 function initializePageIndex() {
43 if (!singlePageMode)
44 adaptiveView.pageIndex = 0;
45 else if (Rooms.currentRoom || Rooms.currentRoomPreview.roomid)
46 adaptiveView.pageIndex = 2;
47 else
48 adaptiveView.pageIndex = 1;
49 }
50
51 Layout.fillHeight: true
52 Layout.fillWidth: true
53 pageIndex: 1
54 singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
55
56 Component.onCompleted: initializePageIndex()
57 onSinglePageModeChanged: initializePageIndex()
58
59 Connections {
60 function onCurrentRoomChanged() {
61 adaptiveView.initializePageIndex();
62 }
63
64 target: Rooms
65 }
66 AdaptiveLayoutElement {
67 id: communityListC
68
69 collapsedWidth: communitiesList.avatarSize + 2 * Nheko.paddingMedium
70 maximumWidth: communitiesList.avatarSize * 10 + 2 * Nheko.paddingMedium
71 minimumWidth: communitiesList.avatarSize * 4 + Nheko.paddingMedium * 2
72 preferredWidth: Settings.communityListWidth >= minimumWidth ? Settings.communityListWidth : collapsedWidth
73 visible: Settings.groupView
74
75 CommunitiesList {
76 id: communitiesList
77
78 collapsed: parent.collapsed
79 }
80 Binding {
81 delayed: true
82 property: 'communityListWidth'
83 restoreMode: Binding.RestoreBindingOrValue
84 target: Settings
85 value: communityListC.preferredWidth
86 when: !adaptiveView.singlePageMode
87 }
88 }
89 AdaptiveLayoutElement {
90 id: roomListC
91
92 collapsedWidth: roomlist.avatarSize + 2 * Nheko.paddingMedium
93 maximumWidth: roomlist.avatarSize * 10 + Nheko.paddingSmall * 2
94 minimumWidth: roomlist.avatarSize * 4 + Nheko.paddingSmall * 2
95 preferredWidth: (Settings.roomListWidth == -1) ? (roomlist.avatarSize * 5 + Nheko.paddingSmall * 2) : (Settings.roomListWidth >= minimumWidth ? Settings.roomListWidth : collapsedWidth)
96
97 RoomList {
98 id: roomlist
99
100 collapsed: parent.collapsed
101 height: adaptiveView.height
102 }
103 Binding {
104 delayed: true
105 property: 'roomListWidth'
106 restoreMode: Binding.RestoreBindingOrValue
107 target: Settings
108 value: roomListC.preferredWidth
109 when: !adaptiveView.singlePageMode
110 }
111 }
112 AdaptiveLayoutElement {
113 id: timlineViewC
114
115 minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2 * Nheko.paddingMedium
116
117 TimelineView {
118 id: timeline
119
120 privacyScreen: privacyScreen
121 room: Rooms.currentRoom
122 roomPreview: Rooms.currentRoomPreview.roomid ? Rooms.currentRoomPreview : null
123 showBackButton: adaptiveView.singlePageMode
124 }
125 }
126 }
127 }
128 PrivacyScreen {
129 id: privacyScreen
130
131 anchors.fill: parent
132 screenTimeout: Settings.privacyScreenTimeout
133 timelineRoot: adaptiveView
134 visible: Settings.privacyScreen
135 windowTarget: MainWindow
136 }
137 }