Changeset View
Changeset View
Standalone View
Standalone View
src/qml/EditableMetaDataDelegate.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2016 Matthieu Gallien <matthieu_gallien@yahoo.fr> | ||||
3 | * | ||||
4 | * This program is free software: you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 3 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | * Lesser General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public License | ||||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||
16 | */ | ||||
17 | | ||||
18 | import QtQuick 2.10 | ||||
19 | import QtQuick.Controls 2.2 | ||||
20 | import QtQuick.Layouts 1.2 | ||||
21 | | ||||
22 | import org.kde.elisa 1.0 | ||||
23 | | ||||
24 | RowLayout { | ||||
25 | id: delegateRow | ||||
26 | spacing: 0 | ||||
27 | | ||||
28 | signal radioEdited() | ||||
29 | | ||||
30 | TextMetrics { | ||||
31 | id: metaDataLabelMetric | ||||
32 | | ||||
33 | text: 'Metadata Name' | ||||
34 | } | ||||
35 | | ||||
36 | Label { | ||||
37 | id: metaDataLabels | ||||
38 | | ||||
39 | text: { | ||||
40 | if (model.name !== undefined) { | ||||
41 | return i18nc("Label for a piece of metadata, e.g. 'Album Artist:'", "%1:", model.name) | ||||
42 | } | ||||
43 | return "" | ||||
44 | } | ||||
45 | | ||||
46 | font.weight: Font.Bold | ||||
47 | | ||||
48 | horizontalAlignment: Text.AlignRight | ||||
49 | | ||||
50 | Layout.alignment: Qt.AlignCenter | ||||
51 | Layout.preferredWidth: 0.8 * elisaTheme.coverImageSize | ||||
52 | Layout.rightMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin / 2 : 0 | ||||
53 | Layout.leftMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin / 2 : 0 | ||||
54 | } | ||||
55 | | ||||
56 | Loader { | ||||
57 | id: textDisplayLoader | ||||
58 | | ||||
59 | active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||||
60 | visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||||
61 | | ||||
62 | Layout.fillWidth: true | ||||
63 | Layout.alignment: Qt.AlignTop | ||||
64 | | ||||
65 | sourceComponent: TextField { | ||||
66 | text: model.display | ||||
67 | | ||||
68 | horizontalAlignment: Text.AlignLeft | ||||
69 | | ||||
70 | anchors.fill: parent | ||||
71 | | ||||
72 | onEditingFinished: { | ||||
73 | if (model.display !== text) { | ||||
74 | model.display = text | ||||
75 | delegateRow.radioEdited() | ||||
76 | } | ||||
77 | } | ||||
78 | } | ||||
79 | } | ||||
80 | } |