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