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