on xenial help sign in
Check gsettings for remote-content-search.
commita93fb7024687e43b874dde77e2112692c77346cd authorPawel Stolowski <pawel.stolowski@canonical.com> dateTue 8 Oct 2013, 12:50 (13 years ago) parent8058215
3 files changed+27−1
plugins/Utils/CMakeLists.txt+5 plugins/Utils/albumartprovider.cpp+18 plugins/Utils/albumartprovider.h+4−1
plugins/Utils/CMakeLists.txt+5
@@ -1,10 +1,13 @@
11# Dependencies
22include(FindPkgConfig)
33
4+pkg_search_module(GLIB REQUIRED glib-2.0)
5+
46include_directories(
57 ${CMAKE_CURRENT_SOURCE_DIR}
68 ${CMAKE_CURRENT_BINARY_DIR}
79 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
10+ ${GLIB_INCLUDE_DIRS}
811)
912
1013set(QMLPLUGIN_SRC
@@ -22,6 +25,8 @@ add_library(Utils-qml SHARED
2225 ${QMLPLUGIN_SRC}
2326 )
2427
28+target_link_libraries(Utils-qml ${GLIB_LDFLAGS})
29+
2530# Because this is an internal support library, we want
2631# to expose all symbols in it. Consider changing this
2732# either to a static library or just using the
plugins/Utils/albumartprovider.cpp+18
@@ -39,6 +39,18 @@ using namespace std;
3939
4040const std::string AlbumArtProvider::DEFAULT_ALBUM_ART = "/usr/share/unity/icons/album_missing.png";
4141
42+AlbumArtProvider::AlbumArtProvider()
43+ : QQuickImageProvider(QQmlImageProviderBase::Image, QQmlImageProviderBase::ForceAsynchronousImageLoading)
44+{
45+ m_settings = g_settings_new ("com.canonical.Unity.Lenses");
46+}
47+
48+AlbumArtProvider::~AlbumArtProvider()
49+{
50+ if (m_settings)
51+ g_object_unref(m_settings);
52+}
53+
4254std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
4355 QString artist = QString::fromStdString(ai.artist);
4456 QString album = QString::fromStdString(ai.album);
@@ -130,6 +142,12 @@ std::string AlbumArtProvider::get_image(const std::string &artist, const std::st
130142 // It might expire before we return. C'est la vie.
131143 return cache.get_art_file(info.artist, info.album);
132144 }
145+
146+ if (m_settings != nullptr && g_settings_get_boolean(m_settings, "remote-content-search") == false) {
147+ qDebug() << "Remote content disabled";
148+ return "";
149+ }
150+
133151 std::string image_url = get_lastfm_url(info);
134152 if(image_url.empty()) {
135153 return DEFAULT_ALBUM_ART;
plugins/Utils/albumartprovider.h+4−1
@@ -22,6 +22,7 @@
2222#include <string>
2323#include <stdexcept>
2424#include <QQuickImageProvider>
25+#include <gio/gio.h>
2526
2627#include "mediaartcache.h"
2728
@@ -33,7 +34,8 @@ struct albuminfo {
3334class AlbumArtProvider : public QQuickImageProvider
3435{
3536public:
36− AlbumArtProvider() : QQuickImageProvider(QQmlImageProviderBase::Image, QQmlImageProviderBase::ForceAsynchronousImageLoading) {}
37+ AlbumArtProvider();
38+ ~AlbumArtProvider();
3739 QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
3840
3941 std::string get_image(const std::string &artist, const std::string &album);
@@ -41,6 +43,7 @@ public:
4143 const static std::string DEFAULT_ALBUM_ART;
4244private:
4345 MediaArtCache cache;
46+ GSettings *m_settings;
4447
4548 void fix_format(const std::string &fname);
4649