Warning, /network/neochat/src/qml/PowerLevelDialog.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 
0011 import org.kde.neochat
0012 
0013 Kirigami.Dialog {
0014     id: root
0015     title: i18nc("@title", "Edit User Power Level")
0016 
0017     property NeoChatRoom room
0018     property var userId
0019     property int powerLevel
0020 
0021     width: Kirigami.Units.gridUnit * 24
0022 
0023     standardButtons: QQC2.Dialog.NoButton
0024 
0025     onOpened: {
0026         if (root.opened) {
0027             powerLevelComboBox.currentIndex = powerLevelComboBox.indexOfValue(root.powerLevel);
0028         }
0029     }
0030 
0031     FormCard.FormCard {
0032         FormCard.FormComboBoxDelegate {
0033             id: powerLevelComboBox
0034 
0035             text: i18n("New power level")
0036             model: ListModel {
0037                 id: powerLevelModel
0038             }
0039             textRole: "text"
0040             valueRole: "powerLevel"
0041 
0042             // Done this way so we can have translated strings.
0043             Component.onCompleted: {
0044                 powerLevelModel.append({
0045                     "text": i18n("Member (0)"),
0046                     "powerLevel": 0
0047                 });
0048                 powerLevelModel.append({
0049                     "text": i18n("Moderator (50)"),
0050                     "powerLevel": 50
0051                 });
0052                 powerLevelModel.append({
0053                     "text": i18n("Admin (100)"),
0054                     "powerLevel": 100
0055                 });
0056             }
0057         }
0058     }
0059     customFooterActions: [
0060         Kirigami.Action {
0061             text: i18n("Confirm")
0062             icon.name: "dialog-ok"
0063             onTriggered: {
0064                 root.room.setUserPowerLevel(root.userId, powerLevelComboBox.currentValue);
0065                 root.close();
0066                 root.destroy();
0067             }
0068         }
0069     ]
0070 }