2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2022-09-19 22:39:37 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import ".."
|
2023-10-26 17:43:09 +03:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Window
|
|
|
|
import im.nheko
|
2022-09-19 22:39:37 +03:00
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: allowedDialog
|
|
|
|
|
|
|
|
property var roomSettings
|
|
|
|
|
|
|
|
minimumWidth: 340
|
|
|
|
minimumHeight: 450
|
|
|
|
width: 450
|
|
|
|
height: 680
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.window
|
2022-09-19 22:39:37 +03:00
|
|
|
modality: Qt.NonModal
|
|
|
|
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
|
|
|
title: qsTr("Allowed rooms settings")
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Cancel
|
|
|
|
onActivated: roomSettingsDialog.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
|
|
|
|
MatrixText {
|
|
|
|
text: qsTr("List of rooms that allow access to this room. Anyone who is in any of those rooms can join this room.")
|
|
|
|
font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.1)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: false
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.text
|
2022-09-19 22:39:37 +03:00
|
|
|
Layout.bottomMargin: Nheko.paddingMedium
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
id: view
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
2024-06-12 23:24:53 +03:00
|
|
|
Loader {
|
|
|
|
source: NHEKO_USE_KIRIGAMI ? "../components/KirigamiWheelHandler.qml" : ""
|
|
|
|
}
|
2022-09-19 22:39:37 +03:00
|
|
|
|
|
|
|
model: roomSettings.allowedRoomsModel
|
|
|
|
spacing: 4
|
|
|
|
cacheBuffer: 50
|
|
|
|
|
|
|
|
delegate: RowLayout {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: model.name
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.text
|
2022-09-19 22:39:37 +03:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: model.isParent ? qsTr("Parent community") : qsTr("Other room")
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.buttonText
|
2022-09-19 22:39:37 +03:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
checked: model.allowed
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
onCheckedChanged: model.allowed = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Column{
|
|
|
|
id: roomEntryCompleter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
spacing: 1
|
|
|
|
z: 5
|
|
|
|
|
|
|
|
Completer {
|
|
|
|
id: roomCompleter
|
|
|
|
|
|
|
|
visible: roomEntry.text.length > 0
|
|
|
|
width: parent.width
|
|
|
|
roomId: allowedDialog.roomSettings.roomId
|
|
|
|
completerName: "room"
|
|
|
|
bottomToTop: true
|
|
|
|
fullWidth: true
|
|
|
|
avatarHeight: Nheko.avatarSize / 2
|
|
|
|
avatarWidth: Nheko.avatarSize / 2
|
|
|
|
centerRowContent: false
|
|
|
|
rowMargin: 2
|
|
|
|
rowSpacing: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixTextField {
|
|
|
|
id: roomEntry
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
placeholderText: qsTr("Enter additional rooms not in the list yet...")
|
|
|
|
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.text
|
2022-09-19 22:39:37 +03:00
|
|
|
onTextEdited: {
|
|
|
|
roomCompleter.completer.searchString = text;
|
|
|
|
}
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (event.key == Qt.Key_Up || event.key == Qt.Key_Backtab) {
|
|
|
|
event.accepted = true;
|
|
|
|
roomCompleter.up();
|
|
|
|
} else if (event.key == Qt.Key_Down || event.key == Qt.Key_Tab) {
|
|
|
|
event.accepted = true;
|
|
|
|
if (event.key == Qt.Key_Tab && (event.modifiers & Qt.ShiftModifier))
|
|
|
|
roomCompleter.up();
|
|
|
|
else
|
|
|
|
roomCompleter.down();
|
|
|
|
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
|
|
|
roomCompleter.finishCompletion();
|
|
|
|
event.accepted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
function onCompletionSelected(id) {
|
|
|
|
console.log("selected: " + id);
|
|
|
|
roomSettings.allowedRoomsModel.addRoom(id);
|
|
|
|
roomEntry.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCountChanged() {
|
|
|
|
if (roomCompleter.count > 0 && (roomCompleter.currentIndex < 0 || roomCompleter.currentIndex >= roomCompleter.count))
|
|
|
|
roomCompleter.currentIndex = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
target: roomCompleter
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: DialogButtonBox {
|
|
|
|
id: dbb
|
|
|
|
|
|
|
|
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
|
|
|
|
onAccepted: {
|
|
|
|
roomSettings.applyAllowedFromModel();
|
|
|
|
allowedDialog.close();
|
|
|
|
}
|
|
|
|
onRejected: allowedDialog.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|