Warning, /graphics/koko/src/qml/BottomNavBar.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: Copyright 2021 Devin Lin <espidev@gmail.com>
0003  * SPDX-FileCopyrightText: Copyright 2021 Mikel Johnson <mikel5764@gmail.com>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 import QtQuick 2.15
0009 import QtQuick.Controls 2.15 as QQC2
0010 import QtQuick.Layouts 1.15
0011 import org.kde.kirigami 2.19 as Kirigami
0012 import org.kde.koko 0.1 as Koko
0013 
0014 Loader {
0015     id: root
0016 
0017     enum Category {
0018         Pictures,
0019         Videos,
0020         Favorites,
0021         Places
0022     }
0023 
0024     property int lastCategoryRequested: BottomNavBar.Category.Pictures // tracks last page selected
0025 
0026     height: active ? implicitHeight : 0
0027     active: Kirigami.Settings.isMobile && QQC2.ApplicationWindow.window.width <= applicationWindow().wideScreenWidth && applicationWindow().pageStack.layers.depth < 2;
0028     sourceComponent: bottomNavBar
0029 
0030     Connections {
0031         target: applicationWindow()
0032         function onFilterChanged(value, query) {
0033             switch (value) {
0034                 case "Pictures": {
0035                     root.lastCategoryRequested = BottomNavBar.Category.Pictures
0036                     break;
0037                 }
0038                 case "Videos": {
0039                     root.lastCategoryRequested = BottomNavBar.Category.Videos
0040                     break;
0041                 }
0042                 case "Favorites": {
0043                     root.lastCategoryRequested = BottomNavBar.Category.Favorites
0044                     break;
0045                 }
0046                 default: {
0047                     root.lastCategoryRequested = BottomNavBar.Category.Places
0048                 }
0049             }
0050         }
0051         function onPlacesOpened() {
0052             root.lastCategoryRequested = BottomNavBar.Category.Places
0053         }
0054     }
0055 
0056     Component {
0057         id: bottomNavBar
0058         ColumnLayout {
0059             spacing: 0
0060             Kirigami.NavigationTabBar {
0061                 Layout.fillWidth: true
0062                 position: Kirigami.NavigationTabBar.Footer
0063                 actions: [
0064                     Kirigami.Action {
0065                         icon.name: "photo"
0066                         text: i18n("Pictures")
0067                         checked: root.lastCategoryRequested === BottomNavBar.Category.Pictures
0068                         onTriggered: applicationWindow().filterBy("Pictures", "")
0069                     },
0070                     Kirigami.Action {
0071                         icon.name: "folder-videos-symbolic"
0072                         text: i18n("Videos")
0073                         checked: root.lastCategoryRequested === BottomNavBar.Category.Videos
0074                         onTriggered: applicationWindow().filterBy("Videos", "file://" + Koko.DirModelUtils.videos)
0075                     },
0076                     Kirigami.Action {
0077                         icon.name: "emblem-favorite"
0078                         text: i18n("Favorites")
0079                         checked: root.lastCategoryRequested === BottomNavBar.Category.Favorites
0080                         onTriggered: applicationWindow().filterBy("Favorites", "");
0081                     },
0082                     Kirigami.Action {
0083                         icon.name: "compass"
0084                         text: i18n("Places")
0085                         checked: root.lastCategoryRequested === BottomNavBar.Category.Places
0086                         onTriggered: applicationWindow().openPlacesPage();
0087                     }
0088                 ]
0089             }
0090         }
0091     }
0092 }