Warning, /network/neochat/src/qml/RoomDrawer.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2018-2019 Black Hat <bhat@encom.eu.org> 0002 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-3.0-only 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import QtQuick.Layouts 0008 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.kitemmodels 0011 0012 import org.kde.neochat 0013 import org.kde.neochat.config 0014 0015 Kirigami.OverlayDrawer { 0016 id: root 0017 0018 readonly property NeoChatRoom room: RoomManager.currentRoom 0019 required property NeoChatConnection connection 0020 0021 width: actualWidth 0022 0023 readonly property int minWidth: Kirigami.Units.gridUnit * 15 0024 readonly property int maxWidth: Kirigami.Units.gridUnit * 25 0025 readonly property int defaultWidth: Kirigami.Units.gridUnit * 20 0026 property int actualWidth: { 0027 if (Config.roomDrawerWidth === -1) { 0028 return Kirigami.Units.gridUnit * 20; 0029 } else { 0030 return Config.roomDrawerWidth 0031 } 0032 } 0033 0034 MouseArea { 0035 anchors.left: parent.left 0036 anchors.top: parent.top 0037 anchors.bottom: parent.bottom 0038 anchors.right: undefined 0039 width: 2 0040 z: 500 0041 cursorShape: !Kirigami.Settings.isMobile ? Qt.SplitHCursor : undefined 0042 enabled: true 0043 visible: true 0044 onPressed: _lastX = mapToGlobal(mouseX, mouseY).x 0045 onReleased: { 0046 Config.roomDrawerWidth = root.actualWidth; 0047 Config.save(); 0048 } 0049 property real _lastX: -1 0050 0051 onPositionChanged: { 0052 if (_lastX === -1) { 0053 return; 0054 } 0055 if (Qt.application.layoutDirection === Qt.RightToLeft) { 0056 root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, Config.roomDrawerWidth - _lastX + mapToGlobal(mouseX, mouseY).x)) 0057 } else { 0058 root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, Config.roomDrawerWidth + _lastX - mapToGlobal(mouseX, mouseY).x)) 0059 } 0060 } 0061 } 0062 enabled: true 0063 0064 edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge 0065 0066 // If modal has been changed and the drawer is closed automatically then dim on popup open will have been switched off in main.qml so switch it back on after the animation completes. 0067 // This is to avoid dim being active for a split second when the drawer is switched to modal which looks terrible. 0068 onAnimatingChanged: if (dim === false) dim = undefined 0069 0070 topPadding: 0 0071 bottomPadding: 0 0072 leftPadding: 0 0073 rightPadding: 0 0074 0075 Kirigami.Theme.colorSet: Kirigami.Theme.View 0076 0077 contentItem: Loader { 0078 id: loader 0079 active: root.drawerOpen 0080 0081 sourceComponent: ColumnLayout { 0082 spacing: 0 0083 0084 Component.onCompleted: infoAction.toggle() 0085 0086 QQC2.ToolBar { 0087 Layout.fillWidth: true 0088 0089 Layout.preferredHeight: pageStack.globalToolBar.preferredHeight 0090 0091 contentItem: RowLayout { 0092 Kirigami.Heading { 0093 Layout.fillWidth: true 0094 text: drawerItemLoader.item ? drawerItemLoader.item.title : "" 0095 } 0096 0097 QQC2.ToolButton { 0098 id: settingsButton 0099 0100 icon.name: "settings-configure" 0101 text: i18n("Room settings") 0102 display: QQC2.AbstractButton.IconOnly 0103 0104 onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/Categories.qml', {room: room, connection: root.connection}, { title: i18n("Room Settings") }) 0105 0106 QQC2.ToolTip.text: text 0107 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0108 QQC2.ToolTip.visible: hovered 0109 } 0110 } 0111 } 0112 0113 Loader { 0114 id: drawerItemLoader 0115 Layout.fillWidth: true 0116 Layout.fillHeight: true 0117 sourceComponent: roomInformation 0118 } 0119 0120 Component { 0121 id: roomInformation 0122 RoomInformation { 0123 room: root.room 0124 connection: root.connection 0125 } 0126 } 0127 0128 Component { 0129 id: roomMedia 0130 RoomMedia { 0131 currentRoom: root.room 0132 connection: root.connection 0133 } 0134 } 0135 0136 Kirigami.NavigationTabBar { 0137 id: navigationBar 0138 Layout.fillWidth: true 0139 visible: !root.room.isSpace 0140 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0141 Kirigami.Theme.inherit: false 0142 0143 actions: [ 0144 Kirigami.Action { 0145 id: infoAction 0146 text: i18n("Information") 0147 icon.name: "documentinfo" 0148 onTriggered: drawerItemLoader.sourceComponent = roomInformation 0149 }, 0150 Kirigami.Action { 0151 text: i18n("Media") 0152 icon.name: "mail-attachment-symbollic" 0153 onTriggered: drawerItemLoader.sourceComponent = roomMedia 0154 } 0155 ] 0156 } 0157 } 0158 } 0159 }