Changeset View
Changeset View
Standalone View
Standalone View
src/qml/MediaRadioMetadataView.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2017 Alexander Stippich <a.stippich@gmx.net> | ||||
3 | * Copyright 2018 Matthieu Gallien <matthieu_gallien@yahoo.fr> | ||||
4 | * Copyright 2019 Jérôme Guidon <guidon@live.fr> | ||||
5 | * | ||||
6 | * This program is free software: you can redistribute it and/or | ||||
7 | * modify it under the terms of the GNU Lesser General Public | ||||
8 | * License as published by the Free Software Foundation; either | ||||
9 | * version 3 of the License, or (at your option) any later version. | ||||
10 | * | ||||
11 | * This program is distributed in the hope that it will be useful, | ||||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
14 | * Lesser General Public License for more details. | ||||
15 | * | ||||
16 | * You should have received a copy of the GNU Lesser General Public License | ||||
17 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.7 | ||||
21 | import QtQuick.Controls 2.2 | ||||
22 | import QtQuick.Window 2.2 | ||||
23 | import QtQml.Models 2.2 | ||||
24 | import QtQuick.Layouts 1.2 | ||||
25 | import QtGraphicalEffects 1.0 | ||||
26 | import org.kde.elisa 1.0 | ||||
27 | | ||||
28 | Window { | ||||
29 | id: trackMetadata | ||||
30 | | ||||
31 | property int databaseId: 0 | ||||
32 | property url fileName | ||||
33 | | ||||
34 | signal rejected() | ||||
35 | | ||||
36 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | ||||
37 | LayoutMirroring.childrenInherit: true | ||||
38 | | ||||
39 | title: i18nc("Window title for track metadata", "View Details") | ||||
40 | | ||||
41 | RadioMetadataModel { | ||||
42 | id: realModel | ||||
43 | | ||||
44 | manager: elisa.musicManager | ||||
45 | } | ||||
46 | | ||||
47 | modality: Qt.NonModal | ||||
48 | flags: Qt.Dialog | Qt.WindowCloseButtonHint | ||||
49 | | ||||
50 | color: myPalette.window | ||||
51 | | ||||
52 | minimumHeight: elisaTheme.coverImageSize * 1.8 | ||||
53 | minimumWidth: elisaTheme.coverImageSize * 5 | ||||
54 | | ||||
55 | ColumnLayout { | ||||
56 | anchors.fill: parent | ||||
57 | anchors.margins: elisaTheme.layoutVerticalMargin | ||||
58 | | ||||
59 | spacing: elisaTheme.layoutVerticalMargin | ||||
60 | | ||||
61 | RowLayout { | ||||
62 | id: metadataView | ||||
63 | | ||||
64 | Layout.fillHeight: true | ||||
65 | Layout.fillWidth: true | ||||
66 | | ||||
67 | spacing: 0 | ||||
68 | | ||||
69 | ListView { | ||||
70 | id: trackData | ||||
71 | | ||||
72 | Layout.fillWidth: true | ||||
73 | Layout.fillHeight: true | ||||
74 | Layout.leftMargin: 2 * elisaTheme.layoutHorizontalMargin | ||||
75 | | ||||
76 | focus: true | ||||
77 | | ||||
78 | ScrollBar.vertical: ScrollBar { | ||||
79 | id: scrollBar | ||||
80 | } | ||||
81 | boundsBehavior: Flickable.StopAtBounds | ||||
82 | clip: true | ||||
83 | | ||||
84 | ScrollHelper { | ||||
85 | id: scrollHelper | ||||
86 | flickable: trackData | ||||
87 | anchors.fill: trackData | ||||
88 | } | ||||
89 | model: realModel | ||||
90 | | ||||
91 | delegate: MetaRadioDataDelegate { | ||||
92 | width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width | ||||
93 | onRadioEdited: applyButton.enabled = true | ||||
94 | } | ||||
95 | } | ||||
96 | } | ||||
97 | | ||||
98 | DialogButtonBox { | ||||
99 | id: buttons | ||||
100 | | ||||
101 | Layout.fillWidth: true | ||||
102 | Layout.minimumHeight: implicitHeight | ||||
103 | | ||||
104 | Button { | ||||
105 | id: applyButton | ||||
106 | text: qsTr("Apply") | ||||
107 | DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole | ||||
108 | onClicked: realModel.saveData() | ||||
109 | enabled: false | ||||
110 | } | ||||
111 | Button { | ||||
112 | text: qsTr("Close") | ||||
113 | DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole | ||||
114 | onClicked: trackMetadata.rejected() | ||||
115 | } | ||||
116 | | ||||
117 | alignment: Qt.AlignRight | ||||
118 | } | ||||
119 | } | ||||
120 | | ||||
121 | Connections { | ||||
122 | target: elisa | ||||
123 | | ||||
124 | onMusicManagerChanged: { | ||||
125 | if (databaseId == -1) { | ||||
126 | realModel.initializeForNewRadio() | ||||
127 | } else if (databaseId !== 0) { | ||||
128 | realModel.initializeByTrackId(databaseId) | ||||
129 | } | ||||
130 | else { | ||||
131 | realModel.initializeByTrackFileName(fileName) | ||||
132 | } | ||||
133 | } | ||||
134 | } | ||||
135 | | ||||
136 | Connections{ | ||||
137 | target: realModel | ||||
138 | | ||||
139 | onDisableApplyButton: applyButton.enabled = false | ||||
140 | } | ||||
141 | | ||||
142 | Component.onCompleted: { | ||||
143 | if (elisa.musicManager) { | ||||
144 | if (databaseId == -1) { | ||||
145 | realModel.initializeForNewRadio() | ||||
146 | } else if (databaseId !== 0) { | ||||
147 | realModel.initializeByTrackId(databaseId) | ||||
148 | } else { | ||||
149 | realModel.initializeByTrackFileName(fileName) | ||||
150 | } | ||||
151 | } | ||||
152 | } | ||||
153 | } |