Merge lp:~egormatirov/mpd-sound-menu/mpd-sound-menu into lp:mpd-sound-menu

Proposed by Mikhail Ivchenko
Status: Merged
Approved by: Vsevolod Velichko
Approved revision: 34
Merged at revision: 32
Proposed branch: lp:~egormatirov/mpd-sound-menu/mpd-sound-menu
Merge into: lp:mpd-sound-menu
Diff against target: 183 lines (+71/-16)
4 files modified
res/mainwindow.ui (+38/-7)
res/mpd-sound-menu.conf (+7/-0)
src/mpdconnector.cpp (+16/-9)
src/options.cpp (+10/-0)
To merge this branch: bzr merge lp:~egormatirov/mpd-sound-menu/mpd-sound-menu
Reviewer Review Type Date Requested Status
Vsevolod Velichko Needs Fixing
Review via email: mp+182338@code.launchpad.net

Description of the change

Add option for choose size of artworks.
Last.fm api key changed because the test API key was deprecated (http://www.lastfm.ru/group/Last.fm+Web+Services/forum/21604/_/2188288).

To post a comment you must log in.
Revision history for this message
Vsevolod Velichko (torkvemada) wrote :

Hi, you have indentation broken in src/options.cpp. Fix it and I'll accept the merge.

Have you thought about the situation when there's no image of required size available? I suppose you need to fetch the lesser one in such situation but in your patch image wouldn't be fetched at all.

review: Needs Fixing
Revision history for this message
Mikhail Ivchenko (egormatirov) wrote :

OK, I fixed indentation. I'll try to realize your idea.

Revision history for this message
Vsevolod Velichko (torkvemada) wrote :

"mainWindowUi->albumArtSizeComboBox..." block indentation is still broken.

Revision history for this message
Mikhail Ivchenko (egormatirov) wrote :

OK, I think, I fixed it. Thank you.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'res/mainwindow.ui'
2--- res/mainwindow.ui 2011-01-29 22:13:23 +0000
3+++ res/mainwindow.ui 2013-08-27 13:29:21 +0000
4@@ -157,6 +157,13 @@
5 </property>
6 </widget>
7 </item>
8+ <item row="1" column="0">
9+ <widget class="QLabel" name="mpdHostLabel">
10+ <property name="text">
11+ <string>MPD Host</string>
12+ </property>
13+ </widget>
14+ </item>
15 <item row="1" column="1">
16 <widget class="QLineEdit" name="mpdHostEdit">
17 <property name="sizePolicy">
18@@ -234,13 +241,6 @@
19 </property>
20 </widget>
21 </item>
22- <item row="1" column="0">
23- <widget class="QLabel" name="mpdHostLabel">
24- <property name="text">
25- <string>MPD Host</string>
26- </property>
27- </widget>
28- </item>
29 <item row="4" column="0">
30 <widget class="QLabel" name="albumArtLabel">
31 <property name="text">
32@@ -279,6 +279,37 @@
33 </property>
34 </widget>
35 </item>
36+ <item row="6" column="0">
37+ <widget class="QLabel" name="albumArtSizeLabel">
38+ <property name="text">
39+ <string>Album Art Size</string>
40+ </property>
41+ </widget>
42+ </item>
43+ <item row="6" column="1">
44+ <widget class="QComboBox" name="albumArtSizeComboBox">
45+ <item>
46+ <property name="text">
47+ <string>Small</string>
48+ </property>
49+ </item>
50+ <item>
51+ <property name="text">
52+ <string>Medium</string>
53+ </property>
54+ </item>
55+ <item>
56+ <property name="text">
57+ <string>Large</string>
58+ </property>
59+ </item>
60+ <item>
61+ <property name="text">
62+ <string>Extra large</string>
63+ </property>
64+ </item>
65+ </widget>
66+ </item>
67 </layout>
68 </widget>
69 </widget>
70
71=== modified file 'res/mpd-sound-menu.conf'
72--- res/mpd-sound-menu.conf 2011-04-15 22:12:19 +0000
73+++ res/mpd-sound-menu.conf 2013-08-27 13:29:21 +0000
74@@ -30,6 +30,13 @@
75 # Default value: "1"
76 artwork "1"
77
78+# artwork_size
79+# Option to set size of artwork from internet sources.
80+# "0" - Small, "1" - Medium, "2" - Large, "3" - Extra large.
81+#
82+# Default value: "0"
83+artwork_size "0"
84+
85 # debug
86 # option to enable debug output to terminal
87 #
88
89=== modified file 'src/mpdconnector.cpp'
90--- src/mpdconnector.cpp 2012-06-18 05:42:23 +0000
91+++ src/mpdconnector.cpp 2013-08-27 13:29:21 +0000
92@@ -83,8 +83,7 @@
93
94 /**
95 * @brief find Cover Art URL on Last.fm
96- * api_key b25b959554ed76058ac220b7b2e0a026 posted
97- * in last.fm api documentation is used :)
98+ * api_key ec379790504799417bf43e4533089f18 is used
99 *
100 * @param d metadata already fetched
101 *
102@@ -97,17 +96,25 @@
103 request.addQueryItem("track", d["xesam:title"].toString());
104 if (d.contains("xesam:artist") && !d["xesam:artist"].toStringList()[0].isNull())
105 request.addQueryItem("artist", d["xesam:artist"].toStringList()[0]);
106- request.addQueryItem("api_key", "b25b959554ed76058ac220b7b2e0a026");
107+ request.addQueryItem("api_key", "ec379790504799417bf43e4533089f18");
108 qDebug() << "Sending cover request:" << request.toEncoded();
109 QXmlQuery query;
110 query.setFocus(request);
111- query.setQuery("lfm/results/trackmatches/track[1]/image[1]/text()");
112- QString result;
113- query.evaluateTo(&result);
114- result = result.trimmed();
115- qDebug() << "Cover result:" << result;
116- if (!result.isEmpty())
117+ query.setQuery("lfm/results/trackmatches/track[1]/image/string()");
118+ //QString::number(Options::instance()["ArtworkSize"].toInt()+1
119+ QStringList results;
120+ query.evaluateTo(&results);
121+ if(results.count() > 0)
122+ {
123+ QString result;
124+ if(results.count() <= Options::instance()["ArtworkSize"].toInt())
125+ result = results.last();
126+ else
127+ result = results.at(Options::instance()["ArtworkSize"].toInt());
128+ result = result.trimmed();
129+ qDebug() << "Cover result:" << result;
130 return result;
131+ }
132 return QString();
133 }
134
135
136=== modified file 'src/options.cpp'
137--- src/options.cpp 2011-04-15 22:12:19 +0000
138+++ src/options.cpp 2013-08-27 13:29:21 +0000
139@@ -48,6 +48,7 @@
140 /* Default values */
141 options["LibraryPath"] = QString::fromUtf8("file:///var/lib/mpd/music");
142 options["NoArtwork"] = false;
143+ options["ArtworkSize"] = 0;
144 options["debug"] = false;
145 /* MPD Connection */
146 options["MpdHost"] = "localhost";
147@@ -177,6 +178,8 @@
148 options["MpdPort"] = parameterTuple.cap(2).toInt();
149 else if(parameterTuple.cap(1).compare("artwork") == 0 && parameterTuple.cap(2).compare("0") == 0)
150 options["NoArtwork"] = true;
151+ else if(parameterTuple.cap(1).compare("artwork_size") == 0)
152+ options["ArtworkSize"] = parameterTuple.cap(2).toInt();
153 else if(parameterTuple.cap(1).compare("debug") == 0 && parameterTuple.cap(2).compare("0") != 0)
154 options["debug"] = true;
155 else if(parameterTuple.cap(1).compare("library_path") == 0)
156@@ -256,6 +259,11 @@
157 ? 0
158 : 1
159 );
160+ mainWindowUi->albumArtSizeComboBox->setCurrentIndex(
161+ (options.contains("ArtworkSize"))
162+ ? options["ArtworkSize"].toInt()
163+ : 0
164+ );
165 /* TODO: option for debug */
166 }
167
168@@ -265,6 +273,7 @@
169 options["MpdPort"] = mainWindowUi->mpdPortSpinBox->value();
170 options["MpdPassword"] = mainWindowUi->mpdPasswordEdit->text();
171 options["NoArtwork"] = (mainWindowUi->albumArtComboBox->currentIndex() == 0);
172+ options["ArtworkSize"] = mainWindowUi->albumArtSizeComboBox->currentIndex();
173 options["LibraryPath"] = mainWindowUi->libraryPathEdit->text();
174 QFile configFile(QDir::homePath()+"/.config/mpd-sound-menu.conf");
175 if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
176@@ -278,6 +287,7 @@
177 writer << "port \"" << options["MpdPort"].toInt() << "\"\n";
178 writer << "password \"" << options["MpdPassword"].toString() << "\"\n";
179 writer << "artwork \"" << (options["NoArtwork"].toBool() ? 0 : 1) << "\"\n";
180+ writer << "artwork_size \"" << options["ArtworkSize"].toInt() << "\"\n";
181 writer << "library_path \"" << options["LibraryPath"].toString() << "\"\n";
182 configFile.close();
183 }

Subscribers

People subscribed via source and target branches