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

0001 /**
0002  * \file FilterPage.qml
0003  * Filter 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 import Kid3 1.1 as Kid3
0027 
0028 Page {
0029   id: page
0030 
0031   title: qsTr("Filter")
0032 
0033   Connections {
0034     target: app
0035     onFileFiltered: {
0036       var str
0037       switch (type) {
0038       case Kid3.FileFilter.Started:
0039         str = qsTr("Started")
0040         break
0041       case Kid3.FileFilter.Directory:
0042         str = " "
0043         str += fileName
0044         break
0045       case Kid3.FileFilter.ParseError:
0046         str = "parse error"
0047         break
0048       case Kid3.FileFilter.FilePassed:
0049         str = "+ "
0050         str += fileName
0051         break
0052       case Kid3.FileFilter.FileFilteredOut:
0053         str = "- "
0054         str += fileName
0055         break
0056       case Kid3.FileFilter.Finished:
0057         str = qsTr("Finished")
0058         break
0059       case Kid3.FileFilter.Aborted:
0060         str = qsTr("Aborted")
0061         break
0062       }
0063       str += "\n"
0064       textArea.text += str
0065       textArea.cursorPosition = textArea.text.length
0066     }
0067   }
0068 
0069   header: ToolBar {
0070     IconButton {
0071       id: prevButton
0072       anchors.left: parent.left
0073       anchors.verticalCenter: parent.verticalCenter
0074       iconName: "go-previous"
0075       color: titleLabel.color
0076       width: visible ? height : 0
0077       visible: page.StackView.view && page.StackView.view.depth > 1
0078       onClicked: page.StackView.view.pop()
0079     }
0080     Label {
0081       id: titleLabel
0082       anchors.left: prevButton.right
0083       anchors.right: startButton.left
0084       anchors.verticalCenter: parent.verticalCenter
0085       clip: true
0086       text: page.title
0087     }
0088     ToolButton {
0089       id: startButton
0090       anchors.right: parent.right
0091       anchors.margins: constants.margins
0092       text: qsTr("Start")
0093       onClicked: {
0094         textArea.text = ""
0095         app.applyFilter(expressionEdit.text)
0096       }
0097     }
0098   }
0099 
0100   Grid {
0101     id: filterGrid
0102     property int labelWidth: Math.max(filterLabel.implicitWidth,
0103                                       expressionLabel.implicitWidth)
0104     property int valueWidth: width - labelWidth -spacing
0105     anchors {
0106       left: parent.left
0107       right: parent.right
0108       top: parent.top
0109       margins: constants.margins
0110     }
0111     columns: 2
0112     spacing: constants.spacing
0113     Label {
0114       id: filterLabel
0115       width: parent.labelWidth
0116       height: filterComboBox.height
0117       verticalAlignment: Text.AlignVCenter
0118       text: qsTr("Filter:")
0119     }
0120     ComboBox {
0121       id: filterComboBox
0122       width: parent.valueWidth
0123       model: configs.filterConfig().filterNames
0124       currentIndex: configs.filterConfig().filterIndex
0125     }
0126     Label {
0127       id: expressionLabel
0128       width: parent.labelWidth
0129       height: expressionEdit.height
0130       verticalAlignment: Text.AlignVCenter
0131       text: qsTr("Expression:")
0132     }
0133     TextField {
0134       id: expressionEdit
0135       width: parent.valueWidth
0136       text: configs.filterConfig().filterExpressions[filterComboBox.currentIndex]
0137       selectByMouse: true
0138     }
0139   }
0140 
0141   ScrollView {
0142     id: flick
0143     anchors {
0144       left: parent.left
0145       right: parent.right
0146       top: filterGrid.bottom
0147       bottom: parent.bottom
0148       margins: constants.margins
0149     }
0150 
0151     TextArea {
0152       id: textArea
0153       readOnly: true
0154       selectByMouse: false
0155     }
0156   }
0157 
0158   StackView.onActivated: {
0159     textArea.text = ""
0160   }
0161   StackView.onDeactivated: {
0162     app.abortFilter()
0163   }
0164 }