Warning, /network/neochat/src/qml/SelectSpacesDialog.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003 
0004 import QtQuick
0005 import QtQuick.Controls as QQC2
0006 import QtQuick.Layouts
0007 
0008 import org.kde.kirigami as Kirigami
0009 import org.kde.kirigamiaddons.formcard as FormCard
0010 import org.kde.kirigamiaddons.labs.components as Components
0011 
0012 import org.kde.neochat
0013 
0014 Kirigami.Dialog {
0015     id: root
0016 
0017     /**
0018      * @brief The current room this dialog is opened for.
0019      */
0020     required property NeoChatRoom room
0021 
0022     /**
0023      * @brief The current list of space IDs that members of can join this room.
0024      */
0025     property list<string> restrictedIds: room.restrictedIds
0026 
0027     parent: applicationWindow().overlay
0028 
0029     leftPadding: 0
0030     rightPadding: 0
0031     topPadding: 0
0032     bottomPadding: 0
0033 
0034     width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24)
0035     title: i18nc("@title", "Select Spaces")
0036 
0037     standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
0038     onAccepted: {
0039         let ids = [];
0040         for (var i in spaceGroup.buttons) {
0041             if (spaceGroup.buttons[i].checked) {
0042                 ids.push(spaceGroup.buttons[i].modelData.id);
0043             }
0044         }
0045         root.room.setJoinRule("restricted", ids);
0046         console.warn(ids);
0047     }
0048 
0049     QQC2.ButtonGroup {
0050         id: spaceGroup
0051         exclusive: false
0052     }
0053 
0054     contentItem: ColumnLayout {
0055         spacing: 0
0056         Repeater {
0057             model: root.room.parentObjects(true)
0058 
0059             delegate: FormCard.FormCheckDelegate {
0060                 required property var modelData
0061 
0062                 text: modelData.displayName
0063                 description: modelData.canonicalAlias
0064                 checked: root.restrictedIds.includes(modelData.id)
0065                 QQC2.ButtonGroup.group: spaceGroup
0066 
0067                 leading: Components.Avatar {
0068                     Layout.preferredWidth: Kirigami.Units.gridUnit * 2
0069                     Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0070 
0071                     source: modelData.avatarUrl.toString().length > 0 ? connection.makeMediaUrl(modelData.avatarUrl) : ""
0072                     name: modelData.displayName
0073                 }
0074             }
0075         }
0076     }
0077 }