Warning, /multimedia/haruna/src/qml/Settings/SettingsWindow.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Window
0009 import QtQuick.Layouts
0010 import QtQuick.Controls
0011 
0012 import org.kde.kirigami as Kirigami
0013 import org.kde.haruna
0014 
0015 Kirigami.ApplicationWindow {
0016     id: root
0017 
0018     property string settingsPath: "qrc:/qt/qml/org/kde/haruna/qml/Settings"
0019     property int currentPage: SettingsWindow.Page.General
0020     enum Page {
0021         General = 0,
0022         Playback,
0023         Video,
0024         Audio,
0025         Subtitles,
0026         Playlist,
0027         Mouse,
0028         Shortcuts,
0029         CustomCommands,
0030         Debug,
0031         About
0032     }
0033 
0034     width: Kirigami.Units.gridUnit * 45
0035     height: Kirigami.Units.gridUnit * 35
0036     title: i18nc("@title:window", "Settings")
0037     pageStack.initialPage: Kirigami.ScrollablePage {
0038         bottomPadding: 0
0039         leftPadding: 0
0040         rightPadding: 0
0041         topPadding: 0
0042         Kirigami.Theme.colorSet: Kirigami.Theme.View
0043 
0044         ListView {
0045             id: settingsPagesList
0046 
0047             currentIndex: root.currentPage
0048             Component.onCompleted: {
0049                 pages[root.currentPage].trigger()
0050                 currentIndex = root.currentPage
0051             }
0052 
0053             property list<Kirigami.Action> pages: [
0054                 Kirigami.Action {
0055                     text: i18nc("@action", "General")
0056                     icon.name: "configure"
0057                     onTriggered: {
0058                         applicationWindow().pageStack.removePage(1)
0059                         applicationWindow().pageStack.push(`${root.settingsPath}/GeneralSettings.qml`)
0060                     }
0061                 },
0062                 Kirigami.Action {
0063                     text: i18nc("@action", "Playback")
0064                     icon.name: "media-playback-start"
0065                     onTriggered: {
0066                         applicationWindow().pageStack.removePage(1)
0067                         applicationWindow().pageStack.push(`${root.settingsPath}/PlaybackSettings.qml`)
0068                     }
0069                 },
0070                 Kirigami.Action {
0071                     text: i18nc("@action", "Video")
0072                     icon.name: "video-x-generic"
0073                     onTriggered: {
0074                         applicationWindow().pageStack.removePage(1)
0075                         applicationWindow().pageStack.push(`${root.settingsPath}/VideoSettings.qml`)
0076                     }
0077                 },
0078                 Kirigami.Action {
0079                     text: i18nc("@action", "Audio")
0080                     icon.name: "player-volume"
0081                     onTriggered: {
0082                         applicationWindow().pageStack.removePage(1)
0083                         applicationWindow().pageStack.push(`${root.settingsPath}/AudioSettings.qml`)
0084                     }
0085                 },
0086                 Kirigami.Action {
0087                     text: i18nc("@action", "Subtitles")
0088                     icon.name: "add-subtitle"
0089                     onTriggered: {
0090                         applicationWindow().pageStack.removePage(1)
0091                         applicationWindow().pageStack.push(`${root.settingsPath}/SubtitlesSettings.qml`)
0092                     }
0093                 },
0094                 Kirigami.Action {
0095                     text: i18nc("@action", "Playlist")
0096                     icon.name: "view-media-playlist"
0097                     onTriggered: {
0098                         applicationWindow().pageStack.removePage(1)
0099                         applicationWindow().pageStack.push(`${root.settingsPath}/PlaylistSettings.qml`)
0100                     }
0101                 },
0102                 Kirigami.Action {
0103                     text: i18nc("@action", "Mouse")
0104                     icon.name: "input-mouse"
0105                     onTriggered: {
0106                         applicationWindow().pageStack.removePage(1)
0107                         applicationWindow().pageStack.push(`${root.settingsPath}/MouseSettings.qml`)
0108                     }
0109                 },
0110                 Kirigami.Action {
0111                     text: i18nc("@action", "Shortcuts")
0112                     icon.name: "configure-shortcuts"
0113                     onTriggered: {
0114                         applicationWindow().pageStack.removePage(1)
0115                         applicationWindow().pageStack.push(`${root.settingsPath}/ShortcutsSettings.qml`)
0116                     }
0117                 },
0118                 Kirigami.Action {
0119                     text: i18nc("@action", "Custom commands")
0120                     icon.name: "configure"
0121                     onTriggered: {
0122                         applicationWindow().pageStack.removePage(1)
0123                         applicationWindow().pageStack.push(`${root.settingsPath}/CustomCommandsSettings.qml`)
0124                     }
0125                 },
0126                 Kirigami.Action {
0127                     text: i18nc("@action", "Debug")
0128                     icon.name: "help-about"
0129                     onTriggered: {
0130                         applicationWindow().pageStack.removePage(1)
0131                         applicationWindow().pageStack.push(`${root.settingsPath}/DebugSettings.qml`)
0132                     }
0133                 },
0134                 Kirigami.Action {
0135                     text: i18nc("@action", "About")
0136                     icon.name: "help-about"
0137                     onTriggered: {
0138                         applicationWindow().pageStack.removePage(1)
0139                         applicationWindow().pageStack.push(aboutPage)
0140                     }
0141                 }
0142             ]
0143 
0144             anchors.fill: parent
0145             model: pages
0146             delegate: ItemDelegate {
0147                 width: settingsPagesList.width
0148                 action: modelData
0149                 highlighted: model.index === ListView.view.currentIndex
0150                 onClicked: {
0151                     ListView.view.currentIndex = model.index
0152                 }
0153             }
0154         }
0155 
0156         Component {
0157             id: aboutPage
0158 
0159             Kirigami.AboutPage {
0160                 aboutData: harunaAboutData
0161             }
0162         }
0163     }
0164 
0165 
0166     onCurrentPageChanged: {
0167         settingsPagesList.pages[root.currentPage].trigger()
0168         settingsPagesList.currentIndex = root.currentPage
0169     }
0170 
0171     Component.onCompleted: pageStack.columnView.columnWidth = Kirigami.Units.gridUnit * 15
0172 
0173     Shortcut {
0174         sequence: "Esc"
0175         onActivated: root.close()
0176     }
0177 
0178     Window {
0179         id: helpWindow
0180 
0181         width: Kirigami.Units.gridUnit * 40
0182         height: Kirigami.Units.gridUnit * 35
0183         title: i18nc("@title:window", "Help")
0184         color: Kirigami.Theme.backgroundColor
0185         onVisibleChanged: info.text = app.getFileContent(applicationWindow().pageStack.currentItem.helpFile)
0186 
0187         Flickable {
0188             id: scrollView
0189 
0190             property int scrollStepSize: 100
0191 
0192             anchors.fill: parent
0193             contentHeight: info.height
0194 
0195             ScrollBar.vertical: ScrollBar {
0196                 id: scrollbar
0197                 policy: ScrollBar.AlwaysOn
0198                 stepSize: scrollView.scrollStepSize/scrollView.contentHeight
0199             }
0200 
0201             MouseArea {
0202                 anchors.fill: parent
0203                 onWheel: {
0204                     if (wheel.angleDelta.y > 0) {
0205                         scrollbar.decrease()
0206                     } else {
0207                         scrollbar.increase()
0208                     }
0209                 }
0210             }
0211 
0212             TextArea {
0213                 id: info
0214 
0215                 background: Rectangle {
0216                     color: "transparent"
0217                     border.color: "transparent"
0218                 }
0219                 width: parent.width
0220                 color: Kirigami.Theme.textColor
0221                 readOnly: true
0222                 textFormat: Text.RichText
0223                 wrapMode: Text.WordWrap
0224                 selectByMouse: true
0225                 rightPadding: scrollbar.width
0226                 onLinkActivated: Qt.openUrlExternally(link)
0227                 onHoveredLinkChanged: hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
0228             }
0229         }
0230     }
0231 }