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) 0069 dim = undefined 0070 0071 topPadding: 0 0072 bottomPadding: 0 0073 leftPadding: 0 0074 rightPadding: 0 0075 0076 Kirigami.Theme.colorSet: Kirigami.Theme.View 0077 0078 contentItem: Loader { 0079 id: loader 0080 active: root.drawerOpen 0081 0082 sourceComponent: ColumnLayout { 0083 spacing: 0 0084 0085 Component.onCompleted: infoAction.toggle() 0086 0087 QQC2.ToolBar { 0088 Layout.fillWidth: true 0089 0090 Layout.preferredHeight: pageStack.globalToolBar.preferredHeight 0091 0092 contentItem: RowLayout { 0093 Kirigami.Heading { 0094 Layout.fillWidth: true 0095 text: drawerItemLoader.item ? drawerItemLoader.item.title : "" 0096 } 0097 0098 QQC2.ToolButton { 0099 id: settingsButton 0100 0101 icon.name: "settings-configure" 0102 text: i18n("Room settings") 0103 display: QQC2.AbstractButton.IconOnly 0104 0105 onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/Categories.qml', { 0106 room: room, 0107 connection: root.connection 0108 }, { 0109 title: i18n("Room Settings") 0110 }) 0111 0112 QQC2.ToolTip.text: text 0113 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0114 QQC2.ToolTip.visible: hovered 0115 } 0116 } 0117 } 0118 0119 Loader { 0120 id: drawerItemLoader 0121 Layout.fillWidth: true 0122 Layout.fillHeight: true 0123 sourceComponent: roomInformation 0124 } 0125 0126 Component { 0127 id: roomInformation 0128 RoomInformation { 0129 room: root.room 0130 connection: root.connection 0131 } 0132 } 0133 0134 Component { 0135 id: roomMedia 0136 RoomMedia { 0137 currentRoom: root.room 0138 connection: root.connection 0139 } 0140 } 0141 0142 Kirigami.NavigationTabBar { 0143 id: navigationBar 0144 Layout.fillWidth: true 0145 visible: !root.room.isSpace 0146 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0147 Kirigami.Theme.inherit: false 0148 0149 actions: [ 0150 Kirigami.Action { 0151 id: infoAction 0152 text: i18n("Information") 0153 icon.name: "documentinfo" 0154 onTriggered: drawerItemLoader.sourceComponent = roomInformation 0155 }, 0156 Kirigami.Action { 0157 text: i18n("Media") 0158 icon.name: "mail-attachment-symbollic" 0159 onTriggered: drawerItemLoader.sourceComponent = roomMedia 0160 } 0161 ] 0162 } 0163 } 0164 } 0165 }