Split RoomPane into Base/MultiviewPane

This commit is contained in:
miruka 2020-03-06 08:40:48 -04:00
parent 191e86530f
commit c49f9b98b2
2 changed files with 88 additions and 73 deletions

View File

@ -0,0 +1,65 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
HDrawer {
id: pane
defaultSize: buttonRepeater.summedImplicitWidth
minimumSize:
buttonRepeater.count > 0 ? buttonRepeater.itemAt(0).implicitWidth : 0
background: HColumnLayout{
Rectangle {
color: buttonsBackgroundColor
Layout.fillWidth: true
Layout.preferredHeight: buttonFlow.height
Behavior on Layout.preferredHeight { HNumberAnimation {} }
}
Rectangle {
color: backgroundColor
Layout.fillWidth: true
Layout.fillHeight: true
}
}
property color buttonsBackgroundColor
property color backgroundColor
readonly property alias buttonRepeater: buttonRepeater
readonly property alias swipeView: swipeView
default property alias swipeViewData: swipeView.contentData
HColumnLayout {
anchors.fill: parent
HFlow {
id: buttonFlow
populate: null
Layout.fillWidth: true
HRepeater {
id: buttonRepeater
}
}
HSwipeView {
id: swipeView
clip: true
interactive: ! pane.collapsed
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}

View File

@ -1,89 +1,39 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import "../../../Base"
import "../../.."
HDrawer {
MultiviewPane {
id: roomPane
saveName: "roomPane"
edge: Qt.RightEdge
defaultSize: buttonRepeater.summedImplicitWidth
minimumSize:
buttonRepeater.count > 0 ? buttonRepeater.itemAt(0).implicitWidth : 0
background: HColumnLayout{
Rectangle {
color: theme.chat.roomPaneButtons.background
buttonsBackgroundColor: theme.chat.roomPaneButtons.background
backgroundColor: theme.chat.roomPane.background
Layout.fillWidth: true
Layout.preferredHeight: buttonFlow.height
Behavior on Layout.preferredHeight { HNumberAnimation {} }
}
buttonRepeater.model: [
"members", "files", "notifications", "history", "settings"
]
Rectangle {
color: theme.chat.roomPane.background
buttonRepeater.delegate: HButton {
height: theme.baseElementsHeight
backgroundColor: "transparent"
icon.name: "room-view-" + modelData
toolTip.text: qsTr(
modelData.charAt(0).toUpperCase() + modelData.slice(1)
)
Layout.fillWidth: true
Layout.fillHeight: true
}
autoExclusive: true
checked: swipeView.currentIndex === 0 && index === 0 ||
swipeView.currentIndex === 1 && index === 4
enabled: ["members", "settings"].includes(modelData)
onClicked: swipeView.currentIndex = Math.min(index, 1)
}
readonly property alias buttonRepeater: buttonRepeater
readonly property alias swipeView: swipeView
HColumnLayout {
anchors.fill: parent
HFlow {
id: buttonFlow
populate: null
Layout.fillWidth: true
HRepeater {
id: buttonRepeater
model: [
"members", "files", "notifications", "history", "settings"
]
HButton {
height: theme.baseElementsHeight
backgroundColor: "transparent"
icon.name: "room-view-" + modelData
toolTip.text: qsTr(
modelData.charAt(0).toUpperCase() + modelData.slice(1)
)
autoExclusive: true
checked: swipeView.currentIndex === 0 && index === 0 ||
swipeView.currentIndex === 1 && index === 4
enabled: ["members", "settings"].includes(modelData)
onClicked: swipeView.currentIndex = Math.min(index, 1)
}
}
}
HSwipeView {
id: swipeView
clip: true
interactive: ! roomPane.collapsed
saveName: "roomPaneView"
saveId: chat.roomId
Layout.fillWidth: true
Layout.fillHeight: true
MemberView {}
SettingsView { fillAvailableHeight: true }
}
}
MemberView {}
SettingsView { fillAvailableHeight: true }
}