diff --git a/src/libtomahawk/Result.cpp b/src/libtomahawk/Result.cpp index c9bdc8559..503d38ae0 100644 --- a/src/libtomahawk/Result.cpp +++ b/src/libtomahawk/Result.cpp @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2015, Christian Muehlhaeuser + * Copyright 2015, Dominik Schmidt * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -538,9 +539,33 @@ Result::setDownloadFormats( const QList& formats ) foreach ( const DownloadFormat& format, formats ) { if ( format.extension.toLower() == TomahawkSettings::instance()->downloadsPreferredFormat().toLower() ) + { m_formats.insert( 0, format ); + } else + { m_formats << format; + } + } + + if ( !m_formats.isEmpty() ) + { + connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ), Qt::UniqueConnection ); + } + else + { + TomahawkSettings::instance()->disconnect( this ); + } +} + + +void +Result::onSettingsChanged() +{ + if ( TomahawkSettings::instance()->downloadsPreferredFormat().toLower() != m_formats.first().extension.toLower() ) + { + setDownloadFormats( downloadFormats() ); + emit updated(); } } diff --git a/src/libtomahawk/Result.h b/src/libtomahawk/Result.h index d1060da7d..2d98c661b 100644 --- a/src/libtomahawk/Result.h +++ b/src/libtomahawk/Result.h @@ -2,6 +2,7 @@ * * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2011, Jeff Mitchell + * Copyright 2015, Dominik Schmidt * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -152,6 +153,8 @@ private slots: void onResolverRemoved( Tomahawk::Resolver* resolver ); void doneEditing(); + void onSettingsChanged(); + private: // private constructor explicit Result( const QString& url, const Tomahawk::track_ptr& track );