Warning, /graphics/peruse/src/app/qml/Settings.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) version 3, or any
0008  * later version accepted by the membership of KDE e.V. (or its
0009  * successor approved by the membership of KDE e.V.), which shall
0010  * act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019  *
0020  */
0021 
0022 import QtQuick 2.12
0023 import QtQuick.Controls 2.12 as QQC2
0024 import QtQuick.Dialogs 1.3
0025 import QtQuick.Layouts 1.3
0026 import QtQml.Models 2.3
0027 
0028 import org.kde.kirigami 2.12 as Kirigami
0029 import org.kde.kcm 1.2 as KCM
0030 
0031 import org.kde.peruse 0.1 as Peruse
0032 
0033 import "listcomponents" as ListComponents
0034 
0035 /**
0036  * @brief This holds toggles and dials to configure Peruse.
0037  * 
0038  * Its main purpose is to add and remove entries from the list of booklocations.
0039  */
0040 KCM.ScrollViewKCM {
0041     id: root;
0042     property string categoryName: "settingsPage";
0043     title: i18nc("title of the settings page", "Configure the indexed folders");
0044 
0045     actions.main: Kirigami.Action {
0046         id: addPathAction
0047         icon.name: "list-add"
0048         text: i18n("Add folder")
0049         onTriggered: {
0050             if (Kirigami.Settings.isMobile) {
0051                 applicationWindow().pageStack.push(folderDlg);
0052             } else {
0053                 desktopFolderDlg.open();
0054             }
0055         }
0056     }
0057 
0058     view: ListView {
0059         id:pathList
0060 
0061         Layout.fillWidth: true
0062         Layout.fillHeight: true
0063         boundsBehavior: Flickable.StopAtBounds
0064 
0065         clip: true
0066 
0067         model: DelegateModel {
0068             model: peruseConfig.bookLocations
0069             delegate: pathDelegate
0070         }
0071 
0072         QQC2.ScrollBar.vertical: QQC2.ScrollBar {
0073             id: scrollBar
0074         }
0075 
0076         Component {
0077             id: pathDelegate
0078             
0079             Kirigami.SwipeListItem {
0080                 id: delegateItem
0081                 contentItem: QQC2.Label {
0082                     text: modelData
0083                 }
0084                 actions: [
0085                     Kirigami.Action {
0086                         text: i18nc("remove the search folder from the list", "Delete");
0087                         iconName: "list-remove"
0088                         onTriggered: peruseConfig.removeBookLocation(peruseConfig.bookLocations[index]);
0089                     }
0090                 ]
0091             }
0092         }
0093 
0094         Kirigami.PlaceholderMessage {
0095             anchors.centerIn: parent
0096             width: parent.width - (Kirigami.Units.largeSpacing * 4)
0097             visible: pathList.count === 0
0098             text: i18n("There are no folder currently indexed.")
0099 
0100             helpfulAction: addPathAction
0101         }
0102     }
0103 
0104     Component {
0105         id: folderDlg;
0106         Kirigami.Page {
0107             id: root;
0108             title: i18nc("@title:window Dialogue used to add a new search folder", "Select a folder")
0109             FileFinder {
0110                 anchors.fill: parent;
0111                 folder: peruseConfig.homeDir();
0112                 showFiles: false;
0113                 onAccepted: {
0114                     peruseConfig.addBookLocation(selectedItem());
0115                     applicationWindow().pageStack.pop();
0116                     root.doSearch();
0117                 }
0118                 onAborted: applicationWindow().pageStack.pop();
0119             }
0120         }
0121     }
0122 
0123     FileDialog {
0124         id: desktopFolderDlg;
0125         title: i18nc("@title:window dialogue used to add a new search folder", "Select a Folder");
0126         selectFolder: true;
0127         folder: shortcuts.home;
0128         onAccepted: {
0129             peruseConfig.addBookLocation(desktopFolderDlg.fileUrl);
0130             root.doSearch();
0131         }
0132     }
0133 
0134     function doSearch() {
0135         // Now search for new items in that locations...
0136         var locations = peruseConfig.bookLocations;
0137         contentList.contentModel.startSearch();
0138     }
0139 }