nheko/resources/qml/ChatPage.qml

103 lines
3.0 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2021 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-05 23:36:08 +02:00
import "components"
import im.nheko 1.0
// this needs to be last
import QtQml 2.15
Rectangle {
id: chatPage
color: Nheko.colors.window
2021-06-05 23:36:08 +02:00
AdaptiveLayout {
2021-06-08 22:18:51 +02:00
id: adaptiveView
anchors.fill: parent
2021-06-14 23:07:20 +02:00
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
pageIndex: (Rooms.currentRoom || Rooms.currentRoomPreview.roomid) ? 2 : 1
2021-06-05 23:36:08 +02:00
AdaptiveLayoutElement {
id: communityListC
2021-07-02 12:36:33 +02:00
visible: Settings.groupView
2021-06-11 13:12:43 +02:00
minimumWidth: communitiesList.avatarSize * 4 + Nheko.paddingMedium * 2
2021-06-11 14:51:29 +02:00
collapsedWidth: communitiesList.avatarSize + 2 * Nheko.paddingMedium
2021-06-12 14:07:32 +02:00
preferredWidth: Settings.communityListWidth >= minimumWidth ? Settings.communityListWidth : collapsedWidth
2021-06-11 14:51:29 +02:00
maximumWidth: communitiesList.avatarSize * 10 + 2 * Nheko.paddingMedium
2021-06-11 13:12:43 +02:00
CommunitiesList {
id: communitiesList
2021-06-11 14:51:29 +02:00
2021-06-11 13:12:43 +02:00
collapsed: parent.collapsed
2021-06-05 23:36:08 +02:00
}
2021-05-14 23:35:34 +02:00
2021-06-12 14:07:32 +02:00
Binding {
target: Settings
property: 'communityListWidth'
value: communityListC.preferredWidth
when: !adaptiveView.singlePageMode
delayed: true
restoreMode: Binding.RestoreBindingOrValue
2021-06-12 14:07:32 +02:00
}
}
2021-06-05 23:36:08 +02:00
AdaptiveLayoutElement {
id: roomListC
2021-06-12 14:07:32 +02:00
minimumWidth: roomlist.avatarSize * 4 + Nheko.paddingSmall * 2
preferredWidth: Settings.roomListWidth >= minimumWidth ? Settings.roomListWidth : roomlist.avatarSize * 5 + Nheko.paddingSmall * 2
maximumWidth: roomlist.avatarSize * 10 + Nheko.paddingSmall * 2
2021-06-08 22:18:51 +02:00
collapsedWidth: roomlist.avatarSize + 2 * Nheko.paddingMedium
2021-06-05 23:36:08 +02:00
RoomList {
2021-06-08 22:18:51 +02:00
id: roomlist
implicitHeight: chatPage.height
2021-06-08 22:18:51 +02:00
collapsed: parent.collapsed
2021-06-05 23:36:08 +02:00
}
2021-06-12 14:07:32 +02:00
Binding {
target: Settings
property: 'roomListWidth'
value: roomListC.preferredWidth
when: !adaptiveView.singlePageMode
delayed: true
restoreMode: Binding.RestoreBindingOrValue
2021-06-12 14:07:32 +02:00
}
}
2021-06-05 23:36:08 +02:00
AdaptiveLayoutElement {
id: timlineViewC
2021-06-18 16:22:06 +02:00
minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2 * Nheko.paddingMedium
2021-06-05 23:36:08 +02:00
TimelineView {
id: timeline
2021-06-08 22:18:51 +02:00
showBackButton: adaptiveView.singlePageMode
2021-06-05 23:36:08 +02:00
room: Rooms.currentRoom
roomPreview: Rooms.currentRoomPreview.roomid ? Rooms.currentRoomPreview : null
2021-06-05 23:36:08 +02:00
}
2021-05-14 23:35:34 +02:00
}
}
PrivacyScreen {
anchors.fill: parent
visible: Settings.privacyScreen
screenTimeout: Settings.privacyScreenTimeout
2021-06-11 21:13:16 +02:00
timelineRoot: adaptiveView
}
}