moment/src/gui/Pages/Chat/RoomPane/RoomPane.qml

112 lines
3.0 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
2019-12-18 19:53:08 +11:00
import "../../../Base"
2020-03-06 23:40:48 +11:00
import "../../.."
import "MemberView"
2019-05-13 03:17:42 +10:00
2020-03-06 23:40:48 +11:00
MultiviewPane {
2019-12-11 05:57:54 +11:00
id: roomPane
readonly property QtObject accountModel:
ModelStore.get("accounts").find(chat.roomInfo.for_account)
function toggleFocus() {
if (roomPane.activeFocus) {
if (roomPane.collapse) roomPane.close()
pageLoader.takeFocus()
return
}
roomPane.forceCollapse = false
roomPane.open()
swipeView.currentItem.keybindFocusItem.forceActiveFocus()
}
saveName: "roomPane"
2019-12-09 20:25:31 +11:00
edge: Qt.RightEdge
2020-03-19 15:13:19 +11:00
defaultSize:
(buttonRepeater.count - (roomPane.collapse ? 0 : 1)) * buttonWidth
buttonWidth:
buttonRepeater.count >= 1 ? buttonRepeater.itemAt(1).implicitWidth : 0
requireDefaultSize:
swipeView.currentIndex !== 0 ||
swipeView.currentItem.viewDepth > 1 ||
swipeView.currentItem.filterField.activeFocus
2020-03-13 16:09:04 +11:00
buttonsBackgroundColor: theme.chat.roomPane.topBar.background
background: Rectangle { color: theme.chat.roomPane.background }
2020-03-06 23:40:48 +11:00
buttonRepeater.model: [
"back", "members", "files", "notifications", "history", "settings"
2020-03-06 23:40:48 +11:00
]
2020-03-06 23:40:48 +11:00
buttonRepeater.delegate: HButton {
visible: width > 0
width: modelData === "back" && ! roomPane.collapse ? 0 : implicitWidth
2020-03-06 23:40:48 +11:00
height: theme.baseElementsHeight
2020-03-06 23:40:48 +11:00
backgroundColor: "transparent"
icon.name:
modelData === "back" ?
"go-back-to-chat-from-room-pane" : "room-view-" + modelData
toolTip.text:
modelData === "back" ?
qsTr("Go back to chat") :
qsTr(modelData.charAt(0).toUpperCase() + modelData.slice(1))
2020-03-06 23:40:48 +11:00
autoExclusive: true
checked: swipeView.currentIndex === 0 && index === 1 ||
swipeView.currentIndex === 1 && index === 5
enabled: ["back", "members", "settings"].includes(modelData)
2019-12-09 20:25:31 +11:00
onClicked:
modelData === "back" ?
roomPane.toggleFocus() :
(modelData === "members" && swipeView.currentIndex === 0) ||
(modelData === "settings" && swipeView.currentIndex === 1) ?
roomPane.forceCollapse = true :
modelData === "members" ?
swipeView.currentIndex = 0 :
2020-03-22 06:02:37 +11:00
swipeView.currentIndex = 1
Behavior on width {
enabled: modelData === "back"
HNumberAnimation {}
}
2019-05-13 03:17:42 +10:00
}
2020-03-06 23:40:48 +11:00
Connections {
target: swipeView
function onCurrentItemChanged() {
swipeView.currentItem.keybindFocusItem.forceActiveFocus()
}
}
2020-03-06 23:40:48 +11:00
MemberView {}
SettingsView {
enabled: accountModel.presence !== "offline"
}
HShortcut {
sequences: window.settings.keys.toggleFocusRoomPane
2020-05-14 16:14:54 +10:00
onActivated: roomPane.toggleFocus()
}
HShortcut {
sequences: window.settings.keys.toggleHideRoomPane
onActivated: roomPane.forceCollapse = ! roomPane.forceCollapse
}
2019-05-13 03:17:42 +10:00
}