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
=== modified file 'res/mainwindow.ui'
--- res/mainwindow.ui 2011-01-29 22:13:23 +0000
+++ res/mainwindow.ui 2013-08-27 13:29:21 +0000
@@ -157,6 +157,13 @@
157 </property>157 </property>
158 </widget>158 </widget>
159 </item>159 </item>
160 <item row="1" column="0">
161 <widget class="QLabel" name="mpdHostLabel">
162 <property name="text">
163 <string>MPD Host</string>
164 </property>
165 </widget>
166 </item>
160 <item row="1" column="1">167 <item row="1" column="1">
161 <widget class="QLineEdit" name="mpdHostEdit">168 <widget class="QLineEdit" name="mpdHostEdit">
162 <property name="sizePolicy">169 <property name="sizePolicy">
@@ -234,13 +241,6 @@
234 </property>241 </property>
235 </widget>242 </widget>
236 </item>243 </item>
237 <item row="1" column="0">
238 <widget class="QLabel" name="mpdHostLabel">
239 <property name="text">
240 <string>MPD Host</string>
241 </property>
242 </widget>
243 </item>
244 <item row="4" column="0">244 <item row="4" column="0">
245 <widget class="QLabel" name="albumArtLabel">245 <widget class="QLabel" name="albumArtLabel">
246 <property name="text">246 <property name="text">
@@ -279,6 +279,37 @@
279 </property>279 </property>
280 </widget>280 </widget>
281 </item>281 </item>
282 <item row="6" column="0">
283 <widget class="QLabel" name="albumArtSizeLabel">
284 <property name="text">
285 <string>Album Art Size</string>
286 </property>
287 </widget>
288 </item>
289 <item row="6" column="1">
290 <widget class="QComboBox" name="albumArtSizeComboBox">
291 <item>
292 <property name="text">
293 <string>Small</string>
294 </property>
295 </item>
296 <item>
297 <property name="text">
298 <string>Medium</string>
299 </property>
300 </item>
301 <item>
302 <property name="text">
303 <string>Large</string>
304 </property>
305 </item>
306 <item>
307 <property name="text">
308 <string>Extra large</string>
309 </property>
310 </item>
311 </widget>
312 </item>
282 </layout>313 </layout>
283 </widget>314 </widget>
284 </widget>315 </widget>
285316
=== modified file 'res/mpd-sound-menu.conf'
--- res/mpd-sound-menu.conf 2011-04-15 22:12:19 +0000
+++ res/mpd-sound-menu.conf 2013-08-27 13:29:21 +0000
@@ -30,6 +30,13 @@
30# Default value: "1"30# Default value: "1"
31artwork "1"31artwork "1"
3232
33# artwork_size
34# Option to set size of artwork from internet sources.
35# "0" - Small, "1" - Medium, "2" - Large, "3" - Extra large.
36#
37# Default value: "0"
38artwork_size "0"
39
33# debug40# debug
34# option to enable debug output to terminal41# option to enable debug output to terminal
35#42#
3643
=== modified file 'src/mpdconnector.cpp'
--- src/mpdconnector.cpp 2012-06-18 05:42:23 +0000
+++ src/mpdconnector.cpp 2013-08-27 13:29:21 +0000
@@ -83,8 +83,7 @@
8383
84/**84/**
85 * @brief find Cover Art URL on Last.fm85 * @brief find Cover Art URL on Last.fm
86 * api_key b25b959554ed76058ac220b7b2e0a026 posted86 * api_key ec379790504799417bf43e4533089f18 is used
87 * in last.fm api documentation is used :)
88 *87 *
89 * @param d metadata already fetched88 * @param d metadata already fetched
90 *89 *
@@ -97,17 +96,25 @@
97 request.addQueryItem("track", d["xesam:title"].toString());96 request.addQueryItem("track", d["xesam:title"].toString());
98 if (d.contains("xesam:artist") && !d["xesam:artist"].toStringList()[0].isNull())97 if (d.contains("xesam:artist") && !d["xesam:artist"].toStringList()[0].isNull())
99 request.addQueryItem("artist", d["xesam:artist"].toStringList()[0]);98 request.addQueryItem("artist", d["xesam:artist"].toStringList()[0]);
100 request.addQueryItem("api_key", "b25b959554ed76058ac220b7b2e0a026");99 request.addQueryItem("api_key", "ec379790504799417bf43e4533089f18");
101 qDebug() << "Sending cover request:" << request.toEncoded();100 qDebug() << "Sending cover request:" << request.toEncoded();
102 QXmlQuery query;101 QXmlQuery query;
103 query.setFocus(request);102 query.setFocus(request);
104 query.setQuery("lfm/results/trackmatches/track[1]/image[1]/text()");103 query.setQuery("lfm/results/trackmatches/track[1]/image/string()");
105 QString result;104 //QString::number(Options::instance()["ArtworkSize"].toInt()+1
106 query.evaluateTo(&result);105 QStringList results;
107 result = result.trimmed();106 query.evaluateTo(&results);
108 qDebug() << "Cover result:" << result;107 if(results.count() > 0)
109 if (!result.isEmpty())108 {
109 QString result;
110 if(results.count() <= Options::instance()["ArtworkSize"].toInt())
111 result = results.last();
112 else
113 result = results.at(Options::instance()["ArtworkSize"].toInt());
114 result = result.trimmed();
115 qDebug() << "Cover result:" << result;
110 return result;116 return result;
117 }
111 return QString();118 return QString();
112}119}
113120
114121
=== modified file 'src/options.cpp'
--- src/options.cpp 2011-04-15 22:12:19 +0000
+++ src/options.cpp 2013-08-27 13:29:21 +0000
@@ -48,6 +48,7 @@
48 /* Default values */48 /* Default values */
49 options["LibraryPath"] = QString::fromUtf8("file:///var/lib/mpd/music");49 options["LibraryPath"] = QString::fromUtf8("file:///var/lib/mpd/music");
50 options["NoArtwork"] = false;50 options["NoArtwork"] = false;
51 options["ArtworkSize"] = 0;
51 options["debug"] = false;52 options["debug"] = false;
52 /* MPD Connection */53 /* MPD Connection */
53 options["MpdHost"] = "localhost";54 options["MpdHost"] = "localhost";
@@ -177,6 +178,8 @@
177 options["MpdPort"] = parameterTuple.cap(2).toInt();178 options["MpdPort"] = parameterTuple.cap(2).toInt();
178 else if(parameterTuple.cap(1).compare("artwork") == 0 && parameterTuple.cap(2).compare("0") == 0)179 else if(parameterTuple.cap(1).compare("artwork") == 0 && parameterTuple.cap(2).compare("0") == 0)
179 options["NoArtwork"] = true;180 options["NoArtwork"] = true;
181 else if(parameterTuple.cap(1).compare("artwork_size") == 0)
182 options["ArtworkSize"] = parameterTuple.cap(2).toInt();
180 else if(parameterTuple.cap(1).compare("debug") == 0 && parameterTuple.cap(2).compare("0") != 0)183 else if(parameterTuple.cap(1).compare("debug") == 0 && parameterTuple.cap(2).compare("0") != 0)
181 options["debug"] = true;184 options["debug"] = true;
182 else if(parameterTuple.cap(1).compare("library_path") == 0)185 else if(parameterTuple.cap(1).compare("library_path") == 0)
@@ -256,6 +259,11 @@
256 ? 0259 ? 0
257 : 1260 : 1
258 );261 );
262 mainWindowUi->albumArtSizeComboBox->setCurrentIndex(
263 (options.contains("ArtworkSize"))
264 ? options["ArtworkSize"].toInt()
265 : 0
266 );
259 /* TODO: option for debug */267 /* TODO: option for debug */
260}268}
261269
@@ -265,6 +273,7 @@
265 options["MpdPort"] = mainWindowUi->mpdPortSpinBox->value();273 options["MpdPort"] = mainWindowUi->mpdPortSpinBox->value();
266 options["MpdPassword"] = mainWindowUi->mpdPasswordEdit->text();274 options["MpdPassword"] = mainWindowUi->mpdPasswordEdit->text();
267 options["NoArtwork"] = (mainWindowUi->albumArtComboBox->currentIndex() == 0);275 options["NoArtwork"] = (mainWindowUi->albumArtComboBox->currentIndex() == 0);
276 options["ArtworkSize"] = mainWindowUi->albumArtSizeComboBox->currentIndex();
268 options["LibraryPath"] = mainWindowUi->libraryPathEdit->text();277 options["LibraryPath"] = mainWindowUi->libraryPathEdit->text();
269 QFile configFile(QDir::homePath()+"/.config/mpd-sound-menu.conf");278 QFile configFile(QDir::homePath()+"/.config/mpd-sound-menu.conf");
270 if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))279 if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
@@ -278,6 +287,7 @@
278 writer << "port \"" << options["MpdPort"].toInt() << "\"\n";287 writer << "port \"" << options["MpdPort"].toInt() << "\"\n";
279 writer << "password \"" << options["MpdPassword"].toString() << "\"\n";288 writer << "password \"" << options["MpdPassword"].toString() << "\"\n";
280 writer << "artwork \"" << (options["NoArtwork"].toBool() ? 0 : 1) << "\"\n";289 writer << "artwork \"" << (options["NoArtwork"].toBool() ? 0 : 1) << "\"\n";
290 writer << "artwork_size \"" << options["ArtworkSize"].toInt() << "\"\n";
281 writer << "library_path \"" << options["LibraryPath"].toString() << "\"\n";291 writer << "library_path \"" << options["LibraryPath"].toString() << "\"\n";
282 configFile.close();292 configFile.close();
283 }293 }

Subscribers

People subscribed via source and target branches