Warning, /plasma/kinfocenter/Modules/samba/ui/main.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
0003 
0004 import org.kde.kcmutils as KCM
0005 import QtQuick 2.14
0006 import org.kde.kirigami 2.12 as Kirigami
0007 import org.kde.kirigami.delegates as KD
0008 import QtQuick.Controls 2.14 as QQC2
0009 import QtQuick.Layouts 1.14
0010 import org.kde.kinfocenter.samba 1.0 as Samba
0011 
0012 KCM.AbstractKCM {
0013     GridLayout {
0014         anchors.fill: parent
0015         columns: 2
0016 
0017         Kirigami.Heading {
0018             text: i18nc("@title heading above listview", "User-Created Shares")
0019             level: 2
0020         }
0021 
0022         Kirigami.Heading {
0023             text: i18nc("@title heading above listview", "Mounted Remote Shares")
0024             level: 2
0025         }
0026 
0027         QQC2.ScrollView {
0028             Layout.fillWidth: true
0029             Layout.fillHeight: true
0030 
0031             Kirigami.Theme.colorSet: Kirigami.Theme.View
0032             Kirigami.Theme.inherit: false
0033             Component.onCompleted: background.visible = true // crashes when initialized with this. god knows why
0034 
0035             ListView {
0036                 id: view
0037                 keyNavigationEnabled: false
0038                 model: Samba.ShareModel{}
0039 
0040                 delegate: ShareListItem {
0041                     width: view.width
0042 
0043                     // The view isn't navigatable nor interactable. Disable highlighting.
0044                     highlighted: false
0045                     hoverEnabled: false
0046                     down: false
0047                 }
0048 
0049                 Kirigami.PlaceholderMessage {
0050                     anchors.centerIn: parent
0051                     width: parent.width - (Kirigami.Units.largeSpacing * 4)
0052                     visible: parent.count == 0
0053                     icon.name: "network-server"
0054                     text: i18nc("@info place holder for empty listview", "There are no directories shared by users")
0055                 }
0056             }
0057         }
0058 
0059         QQC2.ScrollView {
0060             Layout.fillWidth: true
0061             Layout.fillHeight: true
0062 
0063             Kirigami.Theme.colorSet: Kirigami.Theme.View
0064             Kirigami.Theme.inherit: false
0065             Component.onCompleted: background.visible = true // crashes when initialized with this. god knows why
0066 
0067             ListView {
0068                 currentIndex: -1
0069                 model: Samba.MountModel {}
0070 
0071                 delegate: KD.SubtitleDelegate {
0072                     // TODO document-open-remote is actually pretty cool but lacks a visualization for not connected
0073                     //   emblem icons are kind of a crutch
0074                     icon.name: ROLE_Accessible ? "emblem-mounted" : "emblem-unmounted"
0075                     text: ROLE_Path
0076                     subtitle: ROLE_Share
0077                     onClicked: {
0078                         // Append a slash as openurlexternally fucks with perfectly valid urls and turns them into
0079                         // invalid ones (file:///srv => file://srv) that KIO then thinks is a windows UNC path
0080                         // (file://srv => smb://srv).
0081                         // By appending a slash we effectively trick Qt. Kinda meh.
0082                         Qt.openUrlExternally("file://" + ROLE_Path + "/")
0083                     }
0084                 }
0085 
0086                 Kirigami.PlaceholderMessage {
0087                     anchors.centerIn: parent
0088                     width: parent.width - (Kirigami.Units.largeSpacing * 4)
0089                     visible: parent.count == 0
0090                     icon.name: "folder-network"
0091                     text: i18nc("@info place holder for empty listview",
0092                                 "There are no Samba shares mounted on this system")
0093                 }
0094             }
0095         }
0096     }
0097 }