Warning, /multimedia/kid3/src/qml/app/BatchImportPage.qml is written in an unsupported language. File is not indexed.
0001 /**
0002 * \file BatchImportPage.qml
0003 * Batch import 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.Layouts 1.11
0026 import QtQuick.Controls 2.4
0027 import Kid3 1.1 as Kid3
0028
0029 Page {
0030 id: page
0031
0032 title: qsTr("Automatic Import")
0033
0034 Connections {
0035 target: app.batchImporter
0036 onReportImportEvent: {
0037 var str
0038 switch (type) {
0039 case Kid3.BatchImporter.ReadingDirectory:
0040 str = qsTr("Reading Folder")
0041 break
0042 case Kid3.BatchImporter.Started:
0043 str = qsTr("Started")
0044 break
0045 case Kid3.BatchImporter.SourceSelected:
0046 str = qsTr("Source")
0047 break
0048 case Kid3.BatchImporter.QueryingAlbumList:
0049 str = qsTr("Querying")
0050 break
0051 case Kid3.BatchImporter.FetchingTrackList:
0052 case Kid3.BatchImporter.FetchingCoverArt:
0053 str = qsTr("Fetching")
0054 break
0055 case Kid3.BatchImporter.TrackListReceived:
0056 str = qsTr("Data received")
0057 break
0058 case Kid3.BatchImporter.CoverArtReceived:
0059 str = qsTr("Cover")
0060 break
0061 case Kid3.BatchImporter.Finished:
0062 str = qsTr("Finished")
0063 break
0064 case Kid3.BatchImporter.Aborted:
0065 str = qsTr("Aborted")
0066 break
0067 case Kid3.BatchImporter.Error:
0068 str = qsTr("Error")
0069 break
0070 }
0071 if (text) {
0072 str += ": "
0073 str += text
0074 }
0075 str += "\n"
0076 textArea.text += str
0077 textArea.cursorPosition = textArea.text.length
0078 }
0079 }
0080
0081 header: ToolBar {
0082 IconButton {
0083 id: prevButton
0084 anchors.left: parent.left
0085 anchors.verticalCenter: parent.verticalCenter
0086 iconName: "go-previous"
0087 color: titleLabel.color
0088 width: visible ? height : 0
0089 visible: page.StackView.view && page.StackView.view.depth > 1
0090 onClicked: page.StackView.view.pop()
0091 }
0092 Label {
0093 id: titleLabel
0094 anchors.left: prevButton.right
0095 anchors.right: startButton.left
0096 anchors.verticalCenter: parent.verticalCenter
0097 clip: true
0098 text: page.title
0099 }
0100 ToolButton {
0101 id: startButton
0102 anchors.right: parent.right
0103 anchors.margins: constants.margins
0104 text: qsTr("Start")
0105 onClicked: {
0106 textArea.text = ""
0107 app.batchImport(profileComboBox.currentText,
0108 script.toTagVersion(destinationComboBox.getTagVersion()))
0109 }
0110 }
0111 }
0112
0113 Grid {
0114 id: profileRow
0115 property int labelWidth: constants.gu(10)
0116 property int valueWidth: width - labelWidth -spacing
0117 anchors {
0118 left: parent.left
0119 right: parent.right
0120 top: parent.top
0121 margins: constants.margins
0122 }
0123 columns: 2
0124 spacing: constants.spacing
0125 Label {
0126 text: qsTr("Destination:")
0127 width: parent.labelWidth
0128 }
0129 ComboBox {
0130 id: destinationComboBox
0131 readonly property var tagVersions: [
0132 Kid3.Frame.TagV1, Kid3.Frame.TagV2, Kid3.Frame.TagV3,
0133 Kid3.Frame.TagV2V1, Kid3.Frame.TagVAll
0134 ]
0135 width: parent.valueWidth
0136 model: [ qsTr("Tag 1"),
0137 qsTr("Tag 2"),
0138 qsTr("Tag 3"),
0139 qsTr("Tag 1 and Tag 2"),
0140 qsTr("All Tags") ]
0141 currentIndex: tagVersions.indexOf(configs.batchImportConfig().importDest)
0142 function getTagVersion() {
0143 return tagVersions[currentIndex]
0144 }
0145 }
0146
0147 Label {
0148 id: profileLabel
0149 width: parent.labelWidth
0150 height: profileComboBox.height
0151 verticalAlignment: Text.AlignVCenter
0152 text: qsTr("Profile:")
0153 }
0154 RowLayout {
0155 width: parent.valueWidth
0156 IconButton {
0157 iconName: "edit"
0158 color: profileLabel.color
0159 onClicked: {
0160 editProfilesPage.currentIndex = profileComboBox.currentIndex
0161 page.StackView.view.push(editProfilesPage)
0162 }
0163
0164 ImportProfilesEditPage {
0165 id: editProfilesPage
0166 visible: false
0167 onFinished: {
0168 profileComboBox.currentIndex = currentIndex
0169 profileComboBox.currentIndexChanged()
0170 }
0171 }
0172 }
0173 ComboBox {
0174 id: profileComboBox
0175 Layout.fillWidth: true
0176 model: configs.batchImportConfig().profileNames
0177 currentIndex: configs.batchImportConfig().profileIndex
0178 }
0179 }
0180 }
0181
0182 ScrollView {
0183 id: flick
0184 anchors {
0185 left: parent.left
0186 right: parent.right
0187 top: profileRow.bottom
0188 bottom: parent.bottom
0189 margins: constants.margins
0190 }
0191
0192 TextArea {
0193 id: textArea
0194 readOnly: true
0195 selectByMouse: false
0196 }
0197 }
0198
0199 StackView.onActivated: textArea.text = ""
0200 StackView.onDeactivated: {
0201 app.batchImporter.abort()
0202 configs.batchImportConfig().importDest = destinationComboBox.getTagVersion()
0203 configs.batchImportConfig().profileIndex = profileComboBox.currentIndex
0204 }
0205 }