Warning, /multimedia/kid3/src/qml/app/MainPage.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * \file MainPage.qml
0003  * Main page.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 16 Feb 2015
0008  *
0009  * Copyright (C) 2015-2018  Urs Fleisch
0010  *
0011  * This program is free software; you can redistribute it and/or modify
0012  * it under the terms of the GNU Lesser General Public License as published by
0013  * the Free Software Foundation; version 3.
0014  *
0015  * This program is distributed in the hope that it will be useful,
0016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  * GNU Lesser General Public License for more details.
0019  *
0020  * You should have received a copy of the GNU Lesser General Public License
0021  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  */
0023 
0024 import QtQuick 2.11
0025 import QtQuick.Controls 2.4
0026 
0027 Page {
0028   id: page
0029 
0030   signal confirmedOpenRequested(string path)
0031   signal saveRequested(variant onCompleted)
0032 
0033   function updateCurrentSelection() {
0034     collapsibleV1.acceptEdit()
0035     collapsibleV2.acceptEdit()
0036     collapsibleV3.acceptEdit()
0037     app.frameModelsToTags()
0038     if (app.selectionInfo.singleFileSelected) {
0039       app.selectionInfo.fileName = collapsibleFile.fileName
0040     }
0041   }
0042 
0043   function currentFilePath() {
0044     return fileList.currentFilePath()
0045   }
0046 
0047   title: (app.dirName.split("/").pop() || "/") +
0048          (app.modified ? qsTr(" [modified]") : "") +
0049          (app.filtered ? qsTr(" [filtered %1/%2]")
0050              .arg(app.filterPassedCount).arg(app.filterTotalCount) : "") +
0051          " - Kid3"
0052 
0053   Shortcut {
0054     sequence: "Menu"
0055     onActivated: menu.open()
0056   }
0057 
0058   header: ToolBar {
0059     height: constants.controlHeight
0060     IconButton {
0061       id: prevButton
0062       anchors.left: parent.left
0063       anchors.verticalCenter: parent.verticalCenter
0064       iconName: page.StackView.view.depth > 1 ? "go-previous"
0065                                               : "drawer";
0066       color: titleLabel.color
0067       width: height
0068       onClicked: {
0069         if (page.StackView.view.depth > 1) {
0070           page.StackView.view.pop()
0071         } else if (drawer.position === 1.0) {
0072           drawer.close()
0073         } else {
0074           drawer.open()
0075         }
0076       }
0077     }
0078     Label {
0079       id: titleLabel
0080       anchors.left: prevButton.right
0081       anchors.right: buttonRow.left
0082       anchors.verticalCenter: parent.verticalCenter
0083       clip: true
0084       text: page.title
0085       MouseArea {
0086         anchors.fill: parent
0087         onPressAndHold: {
0088           openDialog.folder = app.dirName
0089           openDialog.open()
0090         }
0091 
0092         FileSelectDialog {
0093           id: openDialog
0094           parent: page.parent  // Overlay.overlay
0095           title: qsTr("Open")
0096           onFinished: if (path) confirmedOpenRequested(path)
0097         }
0098       }
0099     }
0100     Row {
0101       id: buttonRow
0102       anchors.right: parent.right
0103       anchors.verticalCenter: parent.verticalCenter
0104       spacing: constants.spacing
0105       IconButton {
0106         iconName: "go-up"
0107         color: titleLabel.color
0108         width: height
0109         onClicked: {
0110           var parentDir = fileList.parentFilePath()
0111           if (parentDir) {
0112             confirmedOpenDirectory(parentDir)
0113           }
0114         }
0115       }
0116       IconButton {
0117         property bool selectAll: true
0118         iconName: "select"
0119         color: titleLabel.color
0120         width: height
0121         onClicked: {
0122           if (selectAll) {
0123             app.selectAllFiles()
0124           } else {
0125             app.deselectAllFiles()
0126           }
0127           selectAll = !selectAll
0128         }
0129       }
0130       IconButton {
0131         id: previousButton
0132         iconName: "go-previous"
0133         color: titleLabel.color
0134         visible: body.state != "narrow" || drawer.position === 0.0
0135         width: height
0136         onClicked: app.previousFile(true, true)
0137       }
0138       IconButton {
0139         iconName: "go-next"
0140         color: titleLabel.color
0141         visible: previousButton.visible
0142         width: height
0143         onClicked: app.nextFile(true, true)
0144       }
0145       IconButton {
0146         id: menuButton
0147         iconName: "navigation-menu"
0148         color: titleLabel.color
0149         width: height
0150         onClicked: menu.open()
0151         Menu {
0152           id: menu
0153           width: constants.gu(35)
0154           MenuItem {
0155             text: qsTr("About")
0156             onTriggered: aboutDialog.open()
0157 
0158             AboutDialog {
0159               id: aboutDialog
0160               parent: page.parent  // Overlay.overlay
0161             }
0162           }
0163           MenuItem {
0164             text: qsTr("Open")
0165             onTriggered: {
0166               openDialog.folder = app.dirName
0167               openDialog.open()
0168             }
0169           }
0170           MenuItem {
0171             text: qsTr("Save")
0172             onTriggered: {
0173               app.frameModelsToTags()
0174               saveRequested(function() {
0175                 app.tagsToFrameModels()
0176               })
0177             }
0178           }
0179           MenuItem {
0180             text: qsTr("Settings")
0181             onTriggered: page.StackView.view.push(settingsPage)
0182 
0183             SettingsPage {
0184               id: settingsPage
0185               visible: false
0186             }
0187           }
0188           MenuItem {
0189             text: qsTr("Automatic Import")
0190             onTriggered: page.StackView.view.push(batchImportPage)
0191 
0192             BatchImportPage {
0193               id: batchImportPage
0194               visible: false
0195             }
0196           }
0197           MenuItem {
0198             text: qsTr("Create Playlist")
0199             onTriggered: app.writePlaylist()
0200           }
0201           MenuItem {
0202             text: qsTr("Rename Folder")
0203             onTriggered: page.StackView.view.push(renameDirPage)
0204 
0205             RenameDirectoryPage {
0206               id: renameDirPage
0207               visible: false
0208             }
0209           }
0210           MenuItem {
0211             text: qsTr("Number Tracks")
0212             onTriggered: numberTracksDialog.open()
0213 
0214             NumberTracksDialog {
0215               id: numberTracksDialog
0216               parent: page.parent  // Overlay.overlay
0217             }
0218           }
0219           MenuItem {
0220             text: qsTr("Filter")
0221             onTriggered: page.StackView.view.push(filterPage)
0222 
0223             FilterPage {
0224               id: filterPage
0225               visible: false
0226             }
0227           }
0228           MenuItem {
0229             text: qsTr("Apply Filename Format")
0230             onTriggered: app.applyFilenameFormat()
0231           }
0232           MenuItem {
0233             text: qsTr("Apply Tag Format")
0234             onTriggered: app.applyTagFormat()
0235           }
0236           MenuItem {
0237             text: qsTr("Apply Text Encoding")
0238             onTriggered: app.applyTextEncoding()
0239           }
0240           MenuItem {
0241             text: qsTr("Convert ID3v2.3 to ID3v2.4")
0242             onTriggered: app.convertToId3v24()
0243           }
0244           MenuItem {
0245             text: qsTr("Convert ID3v2.4 to ID3v2.3")
0246             onTriggered: app.convertToId3v23()
0247           }
0248           MenuItem {
0249             text: qsTr("Revert")
0250             onTriggered: app.revertFileModifications()
0251           }
0252           MenuItem {
0253             text: qsTr("Quit")
0254             onTriggered: confirmedQuit()
0255           }
0256 
0257         }
0258       }
0259     }
0260   }
0261   Item {
0262     id: body
0263 
0264     property int rightSideSpace: width - drawer.width
0265 
0266     anchors.fill: parent
0267 
0268     Drawer {
0269       id: drawer
0270       y: header.height
0271       width: Math.min(constants.gu(44), body.width - constants.gu(4))
0272       height: parent.height - y
0273       modal: false
0274       interactive: false
0275 
0276       FileList {
0277         id: fileList
0278         color: constants.baseColor
0279         anchors.fill: parent
0280 
0281         onFileActivated: {
0282           if (body.state === "narrow") {
0283             drawer.close()
0284           }
0285         }
0286       }
0287     }
0288 
0289     Rectangle {
0290       id: rightSide
0291 
0292       color: constants.baseColor
0293       anchors.right: parent.right
0294       anchors.top: parent.top
0295       anchors.bottom: parent.bottom
0296       width: body.width - drawer.width * drawer.position
0297 
0298       Flickable {
0299         id: rightSideFlickable
0300         anchors.fill: parent
0301         contentWidth: width
0302         contentHeight: collapsibleColumn.height
0303         clip: true
0304         Column {
0305           id: collapsibleColumn
0306           width: parent.width
0307 
0308           FileCollapsible {
0309             id: collapsibleFile
0310             anchors.topMargin: constants.margins
0311             anchors.left: parent.left
0312             anchors.right: parent.right
0313           }
0314 
0315           TagCollapsible {
0316             id: collapsibleV1
0317             tagNr: 0
0318             anchors.topMargin: constants.margins
0319             anchors.left: parent.left
0320             anchors.right: parent.right
0321           }
0322 
0323           TagCollapsible {
0324             id: collapsibleV2
0325             tagNr: 1
0326             anchors.topMargin: constants.margins
0327             anchors.left: parent.left
0328             anchors.right: parent.right
0329           }
0330 
0331           TagCollapsible {
0332             id: collapsibleV3
0333             tagNr: 2
0334             anchors.topMargin: constants.margins
0335             anchors.left: parent.left
0336             anchors.right: parent.right
0337           }
0338 
0339           PictureCollapsible {
0340             id: collapsiblePicture
0341             anchors.topMargin: constants.margins
0342             anchors.left: parent.left
0343             anchors.right: parent.right
0344           }
0345         }
0346       }
0347     }
0348 
0349     states: [
0350       State {
0351         name: ""
0352         StateChangeScript {
0353           script: drawer.open()
0354         }
0355       },
0356       State {
0357         name: "hidden"
0358         when: page.StackView.view.depth > 1
0359         StateChangeScript {
0360           script: drawer.close()
0361         }
0362       },
0363       State {
0364         name: "narrow"
0365         when: body.rightSideSpace < constants.gu(45)
0366         PropertyChanges {
0367           target: drawer
0368           interactive: page.StackView.view.depth === 1
0369         }
0370         PropertyChanges {
0371           target: rightSide
0372           width: body.width
0373         }
0374       }
0375     ]
0376   }
0377 }