Warning, /network/tokodon/src/content/ui/LanguageSelector.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Controls 2.15 as QQC2
0006 import QtQuick.Layouts 1.15
0007 import QtQuick.Dialogs 1.3
0008 import org.kde.kirigami 2.19 as Kirigami
0009 import org.kde.kmasto 1.0
0010 import QtQuick.Templates 2.15 as T
0011 
0012 QQC2.ComboBox {
0013     id: controlRoot
0014 
0015     model: LanguageModel {}
0016 
0017     textRole: "name"
0018     valueRole: "code"
0019 
0020     // 1-to-1 copy of qqc2-desktop-style combobox
0021     popup: T.Popup {
0022         y: controlRoot.height
0023         width: controlRoot.width
0024         implicitHeight: contentItem.implicitHeight
0025         topMargin: 6
0026         bottomMargin: 6
0027         Kirigami.Theme.colorSet: Kirigami.Theme.View
0028         Kirigami.Theme.inherit: false
0029 
0030         modal: true
0031         dim: true
0032         closePolicy: QQC2.Popup.CloseOnEscape | QQC2.Popup.CloseOnPressOutside
0033 
0034         QQC2.Overlay.modal: Item {}
0035 
0036         contentItem: QQC2.ScrollView {
0037             LayoutMirroring.enabled: controlRoot.mirrored
0038             LayoutMirroring.childrenInherit: true
0039 
0040             background: Rectangle {
0041                 color: Kirigami.Theme.backgroundColor
0042             }
0043 
0044             QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
0045 
0046             ListView {
0047                 cacheBuffer: 1
0048 
0049                 implicitHeight: contentHeight
0050                 model: controlRoot.delegateModel
0051                 delegate: controlRoot.delegate
0052                 currentIndex: controlRoot.highlightedIndex
0053                 boundsBehavior: Flickable.StopAtBounds
0054 
0055                 section.property: "preferred"
0056                 section.criteria: ViewSection.FullString
0057                 section.delegate: ColumnLayout {
0058                     width: ListView.view.width
0059 
0060                     required property string section
0061 
0062                     QQC2.ItemDelegate {
0063                         Layout.fillWidth: true
0064                         text: section === "true" ? i18nc("@item:inlistbox Group of preferred languages", "Preferred Languages") :
0065                                                    i18nc("@item:inlistbox Group of all languages", "All Languages")
0066 
0067                         enabled: false
0068 
0069                         Kirigami.Theme.colorSet: controlRoot.Kirigami.Theme.inherit ? controlRoot.Kirigami.Theme.colorSet : Kirigami.Theme.View
0070                         Kirigami.Theme.inherit: controlRoot.Kirigami.Theme.inherit
0071                     }
0072 
0073                     Kirigami.Separator {
0074                         Layout.fillWidth: true
0075                     }
0076                 }
0077             }
0078         }
0079 
0080         background: Kirigami.ShadowedRectangle {
0081             color: Kirigami.Theme.backgroundColor
0082 
0083             property color borderColor: Kirigami.Theme.textColor
0084             border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3)
0085             border.width: 1
0086 
0087             shadow.xOffset: 0
0088             shadow.yOffset: 2
0089             shadow.color: Qt.rgba(0, 0, 0, 0.3)
0090             shadow.size: 8
0091         }
0092     }
0093 }