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

0001 /**
0002  * \file Standard.qml
0003  * Standard list item.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 23 Oct 2015
0008  *
0009  * Copyright (C) 2015-2019  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 
0026 Rectangle {
0027   id: listItem
0028 
0029   property bool selected: false
0030   property alias text: textLabel.text
0031   property alias labelColor: textLabel.color
0032   property alias control: controlContainer.control
0033 
0034   property bool horizontal : !control ||
0035                  control.width + textLabel.width + 2 * constants.margins < width
0036 
0037   signal clicked()
0038 
0039   width: parent ? parent.width : constants.gu(31)
0040   height: horizontal ? constants.rowHeight : 2 * constants.rowHeight
0041   color: selected
0042          ? constants.highlightColor : "transparent"
0043 
0044   MouseArea {
0045     id: mouseArea
0046     anchors.fill: parent
0047     onClicked: {
0048       if (control && mouseX >= control.x) {
0049         if (control.enabled && control.hasOwnProperty("clicked"))
0050           control.clicked();
0051       } else {
0052         listItem.clicked();
0053       }
0054     }
0055   }
0056 
0057   Text {
0058     id: textLabel
0059     height: constants.rowHeight
0060     anchors.left: listItem.left
0061     anchors.top: listItem.top
0062     anchors.margins: constants.margins
0063     anchors.topMargin: 2 * constants.margins
0064     color: selected
0065            ? constants.highlightedTextColor :constants.textColor
0066   }
0067   Item {
0068     id: controlContainer
0069     property Item control
0070     width: horizontal ? parent.width - 2 * constants.margins - textLabel.width
0071                       : parent.width - 1 * constants.margins
0072     height: constants.rowHeight
0073     anchors.right: listItem.right
0074     anchors.bottom: divider.top
0075     onControlChanged: {
0076       if (control) {
0077         control.parent = controlContainer
0078         control.anchors.right = controlContainer.right
0079         control.anchors.verticalCenter = controlContainer.verticalCenter
0080         control.anchors.margins = constants.margins
0081       }
0082     }
0083   }
0084   ThinDivider {
0085     id: divider
0086     anchors {
0087       left: listItem.left
0088       right: listItem.right
0089       bottom: listItem.bottom
0090     }
0091   }
0092 }