moment/src/qml/Chat/RoomHeader.qml

103 lines
2.7 KiB
QML
Raw Normal View History

2019-07-08 13:52:41 +10:00
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
2019-03-22 14:28:14 +11:00
import QtQuick 2.7
import QtQuick.Layouts 1.3
import "../Base"
2019-03-22 14:28:14 +11:00
HRectangle {
2019-07-07 07:58:59 +10:00
property string displayName: ""
property string topic: ""
property alias buttonsImplicitWidth: viewButtons.implicitWidth
property int buttonsWidth: viewButtons.Layout.preferredWidth
property var activeButton: "members"
property bool collapseButtons: width < 400
2019-05-13 03:17:42 +10:00
id: roomHeader
color: theme.chat.roomHeader.background
2019-03-22 14:28:14 +11:00
HRowLayout {
id: row
spacing: 8
2019-03-26 09:29:46 +11:00
anchors.fill: parent
2019-03-22 14:28:14 +11:00
HRoomAvatar {
id: avatar
roomId: chatPage.roomId
dimension: roomHeader.height
Layout.alignment: Qt.AlignTop
2019-03-26 09:29:46 +11:00
}
HLabel {
id: roomName
text: displayName
font.pixelSize: theme.fontSize.big
2019-03-26 09:29:46 +11:00
elide: Text.ElideRight
maximumLineCount: 1
2019-05-13 03:17:42 +10:00
Layout.maximumWidth: Math.max(
0,
2019-05-17 05:50:14 +10:00
row.width - row.totalSpacing - avatar.width -
2019-05-13 03:17:42 +10:00
viewButtons.width -
(expandButton.visible ? expandButton.width : 0)
)
2019-03-26 09:29:46 +11:00
}
2019-03-22 14:28:14 +11:00
HLabel {
id: roomTopic
text: topic
font.pixelSize: theme.fontSize.small
2019-03-26 09:29:46 +11:00
elide: Text.ElideRight
maximumLineCount: 1
2019-05-13 03:17:42 +10:00
Layout.maximumWidth: Math.max(
0,
row.width - row.totalSpacing - avatar.width -
2019-05-13 03:17:42 +10:00
roomName.width - viewButtons.width -
(expandButton.visible ? expandButton.width : 0)
)
2019-03-22 14:28:14 +11:00
}
2019-03-26 09:29:46 +11:00
2019-04-29 05:22:53 +10:00
HSpacer {}
2019-05-13 03:17:42 +10:00
Row {
id: viewButtons
Layout.preferredWidth: collapseButtons ? 0 : implicitWidth
Layout.fillHeight: true
Repeater {
model: [
"members", "files", "notifications", "history", "settings"
]
HButton {
iconName: "room_view_" + modelData
iconDimension: 22
autoExclusive: true
checked: activeButton == modelData
onClicked: activeButton = activeButton == modelData ?
null : modelData
}
2019-05-13 03:17:42 +10:00
}
Behavior on Layout.preferredWidth {
HNumberAnimation { id: buttonsAnimation }
2019-05-13 03:17:42 +10:00
}
}
}
HButton {
id: expandButton
z: 1
anchors.right: parent.right
opacity: collapseButtons ? 1 : 0
visible: opacity > 0
iconName: "reduced_room_buttons"
Behavior on opacity {
HNumberAnimation { duration: buttonsAnimation.duration * 2 }
2019-05-13 03:17:42 +10:00
}
2019-03-22 14:28:14 +11:00
}
}