Code cleanup.

This commit is contained in:
Jonas Kvinge 2018-03-10 13:02:56 +01:00
parent 07a95b56ff
commit 16cabf33a2
25 changed files with 179 additions and 590 deletions

View File

@ -99,6 +99,10 @@ pkg_check_modules(GSTREAMER_APP gstreamer-app-1.0)
pkg_check_modules(GSTREAMER_AUDIO gstreamer-audio-1.0)
pkg_check_modules(GSTREAMER_TAG gstreamer-tag-1.0)
pkg_check_modules(GSTREAMER_PBUTILS gstreamer-pbutils-1.0)
#pkg_check_modules(GSTREAMER_QTGLIB Qt5GLib-2.0)
#pkg_check_modules(GSTREAMER_QTGST Qt5GStreamer-1.0)
#pkg_check_modules(GSTREAMER_QTGSTUI Qt5GStreamerUi-1.0)
#pkg_check_modules(GSTREAMER_QTGSTUTILS Qt5GStreamerUtils-1.0)
pkg_check_modules(LIBXINE libxine)
pkg_check_modules(LIBVLC libvlc)
pkg_check_modules(PHONON phonon4qt5)
@ -106,13 +110,10 @@ pkg_check_modules(LIBGPOD libgpod-1.0>=0.7.92)
pkg_check_modules(LIBMTP libmtp>=1.0)
pkg_check_modules(LIBPULSE libpulse)
pkg_check_modules(LIBXML libxml-2.0)
#pkg_check_modules(QCA qca2)
pkg_check_modules(TAGLIB REQUIRED taglib>=1.8)
pkg_check_modules(SQLITE REQUIRED sqlite3>=3.7)
#pkg_check_modules(QJSON qjson-qt5)
find_library(PROTOBUF_STATIC_LIBRARY libprotobuf.a libprotobuf)
#find_library(QJSON_LIBRARIES qjson-qt5)
find_library(PROTOBUF_STATIC_LIBRARY libprotobuf.a libprotobuf)
if (WIN32)
find_package(ZLIB REQUIRED)
@ -142,9 +143,6 @@ if(LASTFM5_INCLUDE_DIRS AND LASTFM51_INCLUDE_DIRS)
set(HAVE_LIBLASTFM1 ON)
endif()
# QJSON
#CHECK_INCLUDE_FILES(qjson/parser.h QJSON_PARSER_H)
# CHROMAPRINT
CHECK_INCLUDE_FILES(chromaprint.h CHROMAPRINT_H)
@ -164,7 +162,6 @@ endif(${CMAKE_BUILD_TYPE} MATCHES "Release")
# Set up definitions and paths
add_definitions(${QT_DEFINITIONS})
link_directories(${TAGLIB_LIBRARY_DIRS})
#link_directories(${QJSON_LIBRARY_DIRS})
link_directories(${GSTREAMER_LIBRARY_DIRS})
# Don't try to use webkit if their include directories couldn't be found.
@ -183,7 +180,10 @@ include_directories(${GSTREAMER_AUDIO_INCLUDE_DIRS})
include_directories(${GSTREAMER_BASE_INCLUDE_DIRS})
include_directories(${GSTREAMER_TAG_INCLUDE_DIRS})
include_directories(${GSTREAMER_PBUTILS_INCLUDE_DIRS})
#include_directories(${QJSON_INCLUDE_DIRS})
#include_directories(${GSTREAMER_QTGLIB})
#include_directories(${GSTREAMER_QTGST})
#include_directories(${GSTREAMER_QTGSTUI})
#include_directories(${GSTREAMER_QTGSTUTILS})
if (WIN32)
# RC compiler
@ -368,10 +368,6 @@ endif()
# Qocoa
add_subdirectory(3rdparty/qocoa)
# QJSON
#add_subdirectory(3rdparty/qjson)
#set(QJSON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qjson ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qjson/include)
# Subdirectories
add_subdirectory(src)
if (WIN32)

5
TODO
View File

@ -2,10 +2,5 @@ Strawberry Music Player
=======================
TODO
- Fix freeze on exit caused by GStreamer
- Fix Audio CD playback
- Finalize / Improve status/context
- Fix crash when switching backend while playing
.

View File

@ -56,7 +56,6 @@ include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS})
include_directories(${QXT_INCLUDE_DIRS})
include_directories(${SHA2_INCLUDE_DIRS})
include_directories(${CHROMAPRINT_INCLUDE_DIRS})
#include_directories(${QJSON_INCLUDE_DIRS})
find_package(OpenGL)
include_directories(${OPENGL_INCLUDE_DIR})
@ -534,6 +533,7 @@ option(USE_INSTALL_PREFIX "Look for data in CMAKE_INSTALL_PREFIX" ON)
set(GST_ENGINE_SRC engine/gstengine.cpp engine/gstenginepipeline.cpp engine/gstelementdeleter.cpp)
set(GST_ENGINE_MOC engine/gstengine.h engine/gstenginepipeline.h engine/gstelementdeleter.h engine/bufferconsumer.h)
#set(GST_ENGINE_LIB GSTREAMER GSTREAMER_BASE GSTREAMER_APP GSTREAMER_AUDIO GSTREAMER_TAG GSTREAMER_PBUTILS GSTREAMER_QTGLIB GSTREAMER_QTGST GSTREAMER_QTGSTUI GSTREAMER_QTGSTUTILS)
set(GST_ENGINE_LIB GSTREAMER GSTREAMER_BASE GSTREAMER_APP GSTREAMER_AUDIO GSTREAMER_TAG GSTREAMER_PBUTILS)
#set(GST_ENGINE_LIB gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 streamer-audio-1.0 gstreamer-tag-1.0 gstreamer-pbutils-1.0)
#set(GST_ENGINE_LIB ${GSTREAMER_BASE_LIBRARIES} ${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARIES} ${GSTREAMER_TAG_LIBRARIES} ${GSTREAMER_PBUTILS_LIBRARIES})
@ -920,7 +920,6 @@ target_link_libraries(strawberry_lib
${QTSINGLEAPPLICATION_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${SQLITE_LIBRARIES}
#${QJSON_LIBRARIES}
z
Qocoa
)
@ -990,9 +989,6 @@ endif (APPLE)
set(3RDPARTY_SQLITE_LIBRARY qsqlite)
target_link_libraries(strawberry_lib qsqlite)
#set(3RDPARTY_QJSON_LIBRARY qjson)
#target_link_libraries(strawberry_lib qjson)
if (WIN32)
target_link_libraries(strawberry_lib
${ZLIB_LIBRARIES}

View File

@ -185,8 +185,6 @@ SubdirectoryList CollectionBackend::SubdirsInDirectory(int id, QSqlDatabase &db)
}
void CollectionBackend::UpdateTotalSongCount() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
@ -202,8 +200,6 @@ void CollectionBackend::UpdateTotalSongCount() {
}
void CollectionBackend::UpdateTotalArtistCount() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
@ -221,8 +217,6 @@ void CollectionBackend::UpdateTotalArtistCount() {
}
void CollectionBackend::UpdateTotalAlbumCount() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());

View File

@ -57,12 +57,10 @@ const int CollectionModel::kPrettyCoverSize = 32;
const qint64 CollectionModel::kIconCacheSize = 100000000; //~100MB
static bool IsArtistGroupBy(const CollectionModel::GroupBy by) {
//qLog(Debug) << __PRETTY_FUNCTION__;
return by == CollectionModel::GroupBy_Artist || by == CollectionModel::GroupBy_AlbumArtist;
}
static bool IsCompilationArtistNode(const CollectionItem *node) {
//qLog(Debug) << __PRETTY_FUNCTION__;
return node == node->parent->compilation_artist_node_;
}
@ -84,8 +82,6 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
show_dividers_(true)
{
//qLog(Debug) << __PRETTY_FUNCTION__;
root_->lazy_loaded = true;
group_by_[0] = GroupBy_Artist;
@ -123,8 +119,6 @@ CollectionModel::~CollectionModel() { delete root_; }
void CollectionModel::set_pretty_covers(bool use_pretty_covers) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (use_pretty_covers != use_pretty_covers_) {
use_pretty_covers_ = use_pretty_covers;
Reset();
@ -133,8 +127,6 @@ void CollectionModel::set_pretty_covers(bool use_pretty_covers) {
void CollectionModel::set_show_dividers(bool show_dividers) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (show_dividers != show_dividers_) {
show_dividers_ = show_dividers;
Reset();
@ -143,8 +135,6 @@ void CollectionModel::set_show_dividers(bool show_dividers) {
void CollectionModel::SaveGrouping(QString name) {
//qLog(Debug) << __PRETTY_FUNCTION__;
qLog(Debug) << "Model, save to: " << name;
QByteArray buffer;
@ -160,8 +150,6 @@ void CollectionModel::SaveGrouping(QString name) {
void CollectionModel::Init(bool async) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (async) {
// Show a loading indicator in the model.
CollectionItem *loading = new CollectionItem(CollectionItem::Type_LoadingIndicator, root_);
@ -183,8 +171,6 @@ void CollectionModel::Init(bool async) {
void CollectionModel::SongsDiscovered(const SongList &songs) {
//qLog(Debug) << __PRETTY_FUNCTION__;
for (const Song &song : songs) {
// Sanity check to make sure we don't add songs that are outside the user's filter
if (!query_options_.Matches(song)) continue;
@ -212,8 +198,7 @@ void CollectionModel::SongsDiscovered(const SongList &songs) {
container = container->compilation_artist_node_;
}
else {
// Otherwise find the proper container at this level based on the
// item's key
// Otherwise find the proper container at this level based on the item's key
QString key;
switch (type) {
case GroupBy_Album: key = song.album(); break;
@ -250,7 +235,6 @@ void CollectionModel::SongsDiscovered(const SongList &songs) {
// Does it exist already?
if (!container_nodes_[i].contains(key)) {
// Create the container
//qLog(Debug) << "Adding song:" << song.album();
container_nodes_[i][key] = ItemFromSong(type, true, i == 0, container, song, i);
}
container = container_nodes_[i][key];
@ -285,8 +269,6 @@ void CollectionModel::SongsSlightlyChanged(const SongList &songs) {
CollectionItem *CollectionModel::CreateCompilationArtistNode(bool signal, CollectionItem *parent) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (signal) beginInsertRows(ItemToIndex(parent), parent->children.count(), parent->children.count());
parent->compilation_artist_node_ = new CollectionItem(CollectionItem::Type_Container, parent);
@ -303,8 +285,6 @@ CollectionItem *CollectionModel::CreateCompilationArtistNode(bool signal, Collec
QString CollectionModel::DividerKey(GroupBy type, CollectionItem *item) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Items which are to be grouped under the same divider must produce the
// same divider key. This will only get called for top-level items.
@ -351,8 +331,6 @@ QString CollectionModel::DividerKey(GroupBy type, CollectionItem *item) const {
QString CollectionModel::DividerDisplayText(GroupBy type, const QString &key) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Pretty display text for the dividers.
switch (type) {
@ -393,8 +371,6 @@ QString CollectionModel::DividerDisplayText(GroupBy type, const QString &key) co
void CollectionModel::SongsDeleted(const SongList &songs) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Delete the actual song nodes first, keeping track of each parent so we
// might check to see if they're empty later.
QSet<CollectionItem*> parents;
@ -478,16 +454,12 @@ void CollectionModel::SongsDeleted(const SongList &songs) {
QString CollectionModel::AlbumIconPixmapCacheKey(const QModelIndex &index) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
QStringList path;
QModelIndex index_copy(index);
while (index_copy.isValid()) {
path.prepend(index_copy.data().toString());
index_copy = index_copy.parent();
}
//qLog(Debug) << __PRETTY_FUNCTION__ << "collectionart:" << path.join("/");
return "collectionart:" + path.join("/");
@ -495,15 +467,11 @@ QString CollectionModel::AlbumIconPixmapCacheKey(const QModelIndex &index) const
QVariant CollectionModel::AlbumIcon(const QModelIndex &index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
CollectionItem *item = IndexToItem(index);
if (!item) return no_cover_icon_;
// Check the cache for a pixmap we already loaded.
const QString cache_key = AlbumIconPixmapCacheKey(index);
//qLog(Debug) << cache_key ;
QPixmap cached_pixmap;
if (QPixmapCache::find(cache_key, &cached_pixmap)) {
@ -541,8 +509,6 @@ QVariant CollectionModel::AlbumIcon(const QModelIndex &index) {
void CollectionModel::AlbumArtLoaded(quint64 id, const QImage &image) {
//qLog(Debug) << __PRETTY_FUNCTION__;
ItemAndCacheKey item_and_cache_key = pending_art_.take(id);
CollectionItem *item = item_and_cache_key.first;
const QString &cache_key = item_and_cache_key.second;
@ -585,8 +551,6 @@ void CollectionModel::AlbumArtLoaded(quint64 id, const QImage &image) {
QVariant CollectionModel::data(const QModelIndex &index, int role) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
const CollectionItem *item = IndexToItem(index);
// Handle a special case for returning album artwork instead of a generic CD icon.
@ -611,8 +575,6 @@ QVariant CollectionModel::data(const QModelIndex &index, int role) const {
QVariant CollectionModel::data(const CollectionItem *item, int role) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
GroupBy container_type = item->type == CollectionItem::Type_Container ? group_by_[item->container_level] : GroupBy_None;
switch (role) {
@ -663,8 +625,7 @@ QVariant CollectionModel::data(const CollectionItem *item, int role) const {
}
if (item->type == CollectionItem::Type_Container) {
// if we have even one non editable item as a child, we ourselves
// are not available for edit
// if we have even one non editable item as a child, we ourselves are not available for edit
if (!item->children.isEmpty()) {
for (CollectionItem *child : item->children) {
if (!data(child, role).toBool()) {
@ -692,8 +653,6 @@ QVariant CollectionModel::data(const CollectionItem *item, int role) const {
bool CollectionModel::HasCompilations(const CollectionQuery &query) {
//qLog(Debug) << __PRETTY_FUNCTION__;
CollectionQuery q = query;
q.AddCompilationRequirement(true);
q.SetLimit(1);
@ -707,16 +666,13 @@ bool CollectionModel::HasCompilations(const CollectionQuery &query) {
CollectionModel::QueryResult CollectionModel::RunQuery(CollectionItem *parent) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QueryResult result;
// Information about what we want the children to be
int child_level = parent == root_ ? 0 : parent->container_level + 1;
GroupBy child_type = child_level >= 3 ? GroupBy_None : group_by_[child_level];
// Initialise the query. child_type says what type of thing we want (artists,
// songs, etc.)
// Initialise the query. child_type says what type of thing we want (artists, songs, etc.)
CollectionQuery q(query_options_);
InitQuery(child_type, &q);
@ -751,8 +707,6 @@ CollectionModel::QueryResult CollectionModel::RunQuery(CollectionItem *parent) {
void CollectionModel::PostQuery(CollectionItem *parent, const CollectionModel::QueryResult &result, bool signal) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Information about what we want the children to be
int child_level = parent == root_ ? 0 : parent->container_level + 1;
GroupBy child_type = child_level >= 3 ? GroupBy_None : group_by_[child_level];
@ -777,8 +731,6 @@ void CollectionModel::PostQuery(CollectionItem *parent, const CollectionModel::Q
void CollectionModel::LazyPopulate(CollectionItem *parent, bool signal) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (parent->lazy_loaded) return;
parent->lazy_loaded = true;
@ -789,8 +741,6 @@ void CollectionModel::LazyPopulate(CollectionItem *parent, bool signal) {
void CollectionModel::ResetAsync() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QFuture<CollectionModel::QueryResult> future = QtConcurrent::run(this, &CollectionModel::RunQuery, root_);
NewClosure(future, this, SLOT(ResetAsyncQueryFinished(QFuture<CollectionModel::QueryResult>)), future);
@ -798,8 +748,6 @@ void CollectionModel::ResetAsync() {
void CollectionModel::ResetAsyncQueryFinished(QFuture<CollectionModel::QueryResult> future) {
//qLog(Debug) << __PRETTY_FUNCTION__;
const struct QueryResult result = future.result();
BeginReset();
@ -818,8 +766,6 @@ void CollectionModel::ResetAsyncQueryFinished(QFuture<CollectionModel::QueryResu
void CollectionModel::BeginReset() {
//qLog(Debug) << __PRETTY_FUNCTION__;
beginResetModel();
delete root_;
song_nodes_.clear();
@ -837,8 +783,6 @@ void CollectionModel::BeginReset() {
void CollectionModel::Reset() {
//qLog(Debug) << __PRETTY_FUNCTION__;
BeginReset();
// Populate top level
@ -850,8 +794,6 @@ void CollectionModel::Reset() {
void CollectionModel::InitQuery(GroupBy type, CollectionQuery *q) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Say what type of thing we want to get back from the database.
switch (type) {
case GroupBy_Artist:
@ -905,10 +847,7 @@ void CollectionModel::InitQuery(GroupBy type, CollectionQuery *q) {
void CollectionModel::FilterQuery(GroupBy type, CollectionItem *item, CollectionQuery *q) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Say how we want the query to be filtered. This is done once for each
// parent going up the tree.
// Say how we want the query to be filtered. This is done once for each parent going up the tree.
switch (type) {
case GroupBy_Artist:
@ -980,27 +919,21 @@ void CollectionModel::FilterQuery(GroupBy type, CollectionItem *item, Collection
CollectionItem *CollectionModel::InitItem(GroupBy type, bool signal, CollectionItem *parent, int container_level) {
//qLog(Debug) << __PRETTY_FUNCTION__;
CollectionItem::Type item_type = type == GroupBy_None ? CollectionItem::Type_Song : CollectionItem::Type_Container;
if (signal) beginInsertRows(ItemToIndex(parent), parent->children.count(),parent->children.count());
if (signal) beginInsertRows(ItemToIndex(parent), parent->children.count(), parent->children.count());
// Initialise the item depending on what type it's meant to be
CollectionItem *item = new CollectionItem(item_type, parent);
item->compilation_artist_node_ = nullptr;
item->container_level = container_level;
//qLog(Debug) << __PRETTY_FUNCTION__ << "end";
return item;
}
CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool create_divider, CollectionItem *parent, const SqlRow &row, int container_level) {
//qLog(Debug) << __PRETTY_FUNCTION__;
CollectionItem *item = InitItem(type, signal, parent, container_level);
int year = 0;
int effective_originalyear = 0;
@ -1083,16 +1016,12 @@ CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool c
FinishItem(type, signal, create_divider, parent, item);
//qLog(Debug) << __PRETTY_FUNCTION__ << "end";
return item;
}
CollectionItem *CollectionModel::ItemFromSong(GroupBy type, bool signal, bool create_divider, CollectionItem *parent, const Song &s, int container_level) {
//qLog(Debug) << __PRETTY_FUNCTION__;
CollectionItem *item = InitItem(type, signal, parent, container_level);
int year = 0;
int originalyear = 0;
@ -1171,8 +1100,6 @@ CollectionItem *CollectionModel::ItemFromSong(GroupBy type, bool signal, bool cr
break;
}
// qLog(Debug) << s.url().scheme();
FinishItem(type, signal, create_divider, parent, item);
if (s.url().scheme() == "cdda") item->lazy_loaded = true;
return item;
@ -1181,8 +1108,6 @@ CollectionItem *CollectionModel::ItemFromSong(GroupBy type, bool signal, bool cr
void CollectionModel::FinishItem(GroupBy type, bool signal, bool create_divider, CollectionItem *parent, CollectionItem *item) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (type == GroupBy_None) item->lazy_loaded = true;
if (signal) endInsertRows();
@ -1211,8 +1136,6 @@ void CollectionModel::FinishItem(GroupBy type, bool signal, bool create_divider,
QString CollectionModel::TextOrUnknown(const QString &text) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (text.isEmpty()) return tr("Unknown");
return text;
@ -1220,8 +1143,6 @@ QString CollectionModel::TextOrUnknown(const QString &text) {
QString CollectionModel::PrettyYearAlbum(int year, const QString &album) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (year <= 0) return TextOrUnknown(album);
return QString::number(year) + " - " + TextOrUnknown(album);
@ -1229,8 +1150,6 @@ QString CollectionModel::PrettyYearAlbum(int year, const QString &album) {
QString CollectionModel::SortText(QString text) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (text.isEmpty()) {
text = " unknown";
}
@ -1245,8 +1164,6 @@ QString CollectionModel::SortText(QString text) {
QString CollectionModel::SortTextForArtist(QString artist) {
//qLog(Debug) << __PRETTY_FUNCTION__;
artist = SortText(artist);
if (artist.startsWith("the ")) {
@ -1265,15 +1182,11 @@ QString CollectionModel::SortTextForArtist(QString artist) {
QString CollectionModel::SortTextForNumber(int number) {
//qLog(Debug) << __PRETTY_FUNCTION__;
return QString("%1").arg(number, 4, 10, QChar('0'));
}
QString CollectionModel::SortTextForYear(int year) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QString str = QString::number(year);
return QString("0").repeated(qMax(0, 4 - str.length())) + str;
@ -1288,8 +1201,6 @@ QString CollectionModel::SortTextForBitrate(int bitrate) {
QString CollectionModel::SortTextForSong(const Song &song) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QString ret = QString::number(qMax(0, song.disc()) * 1000 + qMax(0, song.track()));
ret.prepend(QString("0").repeated(6 - ret.length()));
ret.append(song.url().toString());
@ -1299,8 +1210,6 @@ QString CollectionModel::SortTextForSong(const Song &song) {
Qt::ItemFlags CollectionModel::flags(const QModelIndex &index) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch (IndexToItem(index)->type) {
case CollectionItem::Type_Song:
case CollectionItem::Type_Container:
@ -1320,8 +1229,6 @@ QStringList CollectionModel::mimeTypes() const {
QMimeData *CollectionModel::mimeData(const QModelIndexList &indexes) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (indexes.isEmpty()) return nullptr;
SongMimeData *data = new SongMimeData;
@ -1343,8 +1250,6 @@ QMimeData *CollectionModel::mimeData(const QModelIndexList &indexes) const {
bool CollectionModel::CompareItems(const CollectionItem *a, const CollectionItem *b) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
QVariant left(data(a, CollectionModel::Role_SortText));
QVariant right(data(b, CollectionModel::Role_SortText));
@ -1355,8 +1260,6 @@ bool CollectionModel::CompareItems(const CollectionItem *a, const CollectionItem
void CollectionModel::GetChildSongs(CollectionItem *item, QList<QUrl> *urls, SongList *songs, QSet<int> *song_ids) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch (item->type) {
case CollectionItem::Type_Container: {
const_cast<CollectionModel*>(this)->LazyPopulate(item);
@ -1385,8 +1288,6 @@ void CollectionModel::GetChildSongs(CollectionItem *item, QList<QUrl> *urls, Son
SongList CollectionModel::GetChildSongs(const QModelIndexList &indexes) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
QList<QUrl> dontcare;
SongList ret;
QSet<int> song_ids;
@ -1399,32 +1300,27 @@ SongList CollectionModel::GetChildSongs(const QModelIndexList &indexes) const {
}
SongList CollectionModel::GetChildSongs(const QModelIndex &index) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
return GetChildSongs(QModelIndexList() << index);
}
void CollectionModel::SetFilterAge(int age) {
//qLog(Debug) << __PRETTY_FUNCTION__;
query_options_.set_max_age(age);
ResetAsync();
}
void CollectionModel::SetFilterText(const QString &text) {
//qLog(Debug) << __PRETTY_FUNCTION__;
query_options_.set_filter(text);
ResetAsync();
}
void CollectionModel::SetFilterQueryMode(QueryOptions::QueryMode query_mode) {
//qLog(Debug) << __PRETTY_FUNCTION__;
query_options_.set_query_mode(query_mode);
ResetAsync();
}
bool CollectionModel::canFetchMore(const QModelIndex &parent) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!parent.isValid()) return false;
@ -1435,7 +1331,6 @@ bool CollectionModel::canFetchMore(const QModelIndex &parent) const {
void CollectionModel::SetGroupBy(const Grouping &g) {
//qLog(Debug) << __PRETTY_FUNCTION__;
group_by_ = g;
ResetAsync();
@ -1445,8 +1340,6 @@ void CollectionModel::SetGroupBy(const Grouping &g) {
const CollectionModel::GroupBy &CollectionModel::Grouping::operator[](int i) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch (i) {
case 0: return first;
case 1: return second;
@ -1459,8 +1352,6 @@ const CollectionModel::GroupBy &CollectionModel::Grouping::operator[](int i) con
CollectionModel::GroupBy &CollectionModel::Grouping::operator[](int i) {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch (i) {
case 0: return first;
case 1: return second;
@ -1475,8 +1366,6 @@ CollectionModel::GroupBy &CollectionModel::Grouping::operator[](int i) {
void CollectionModel::TotalSongCountUpdatedSlot(int count) {
//qLog(Debug) << __PRETTY_FUNCTION__;
total_song_count_ = count;
emit TotalSongCountUpdated(count);
@ -1484,8 +1373,6 @@ void CollectionModel::TotalSongCountUpdatedSlot(int count) {
void CollectionModel::TotalArtistCountUpdatedSlot(int count) {
//qLog(Debug) << __PRETTY_FUNCTION__;
total_artist_count_ = count;
emit TotalArtistCountUpdated(count);
@ -1493,22 +1380,18 @@ void CollectionModel::TotalArtistCountUpdatedSlot(int count) {
void CollectionModel::TotalAlbumCountUpdatedSlot(int count) {
//qLog(Debug) << __PRETTY_FUNCTION__;
total_album_count_ = count;
emit TotalAlbumCountUpdated(count);
}
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping &g) {
//qLog(Debug) << __PRETTY_FUNCTION__;
s << quint32(g.first) << quint32(g.second) << quint32(g.third);
return s;
}
QDataStream &operator>>(QDataStream &s, CollectionModel::Grouping &g) {
//qLog(Debug) << __PRETTY_FUNCTION__;
quint32 buf;
s >> buf;
g.first = CollectionModel::GroupBy(buf);

View File

@ -39,7 +39,7 @@ CollectionViewContainer::CollectionViewContainer(QWidget *parent) : QWidget(pare
CollectionViewContainer::~CollectionViewContainer() { delete ui_; }
CollectionView* CollectionViewContainer::view() const { return ui_->view; }
CollectionView *CollectionViewContainer::view() const { return ui_->view; }
CollectionFilterWidget *CollectionViewContainer::filter() const {
return ui_->filter;

View File

@ -2191,11 +2191,11 @@ void MainWindow::Exit() {
return; // Don't quit the application now: wait for the fadeout finished signal
}
}
#ifdef HAVE_GSTREAMER
gst_deinit();
//gst_deinit();
#endif
qApp->quit();
}

View File

@ -106,9 +106,7 @@ SongLoader::Result SongLoader::Load(const QUrl &url) {
}
if (sRawUriSchemes.contains(url_.scheme()) || player_->HandlerForUrl(url) != nullptr) {
// The URI scheme indicates that it can't possibly be a playlist, or we have
// a custom handler for the URL, so add it as a raw stream.
//AddAsRawStream();
// The URI scheme indicates that it can't possibly be a playlist, or we have a custom handler for the URL, so add it as a raw stream. AddAsRawStream();
return Success;
}
@ -117,6 +115,7 @@ SongLoader::Result SongLoader::Load(const QUrl &url) {
#endif
return BlockingLoadRequired;
}
void SongLoader::LoadFilenamesBlocking() {
@ -130,8 +129,7 @@ void SongLoader::LoadFilenamesBlocking() {
SongLoader::Result SongLoader::LoadLocalPartial(const QString &filename) {
qLog(Debug) << "Fast Loading local file" << filename;
// First check to see if it's a directory - if so we can load all the songs
// inside right away.
// First check to see if it's a directory - if so we can load all the songs inside right away.
if (QFileInfo(filename).isDir()) {
LoadLocalDirectory(filename);
return Success;
@ -204,15 +202,13 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) {
void SongLoader::LoadLocalAsync(const QString &filename) {
// First check to see if it's a directory - if so we will load all the songs
// inside right away.
// First check to see if it's a directory - if so we will load all the songs inside right away.
if (QFileInfo(filename).isDir()) {
LoadLocalDirectory(filename);
return;
}
// It's a local file, so check if it looks like a playlist.
// Read the first few bytes.
// It's a local file, so check if it looks like a playlist. Read the first few bytes.
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) return;
QByteArray data(file.read(PlaylistParser::kMagicSize));
@ -277,6 +273,7 @@ void SongLoader::EffectiveSongLoad(Song *song) {
QString filename = song->url().toLocalFile();
TagReaderClient::Instance()->ReadFileBlocking(filename, song);
}
}
void SongLoader::LoadPlaylist(ParserBase *parser, const QString &filename) {
@ -297,6 +294,7 @@ static bool CompareSongs(const Song &left, const Song &right) {
if (left.track() < right.track()) return true;
if (left.track() > right.track()) return false;
return left.url() < right.url();
}
void SongLoader::LoadLocalDirectory(const QString &filename) {
@ -314,16 +312,8 @@ void SongLoader::LoadLocalDirectory(const QString &filename) {
// when adding to playlist" preference behaviour set, it can enjoy the first
// song being played (seek it, have moodbar, etc.)
if (!songs_.isEmpty()) EffectiveSongLoad(&(*songs_.begin()));
}
//void SongLoader::AddAsRawStream() {
// Song song;
// song.set_valid(true);
// song.set_filetype(Song::Type_Stream);
// song.set_url(url_);
// song.set_title(url_.toString());
// songs_ << song;
//}
}
void SongLoader::Timeout() {
state_ = Finished;
@ -359,6 +349,7 @@ void SongLoader::StopTypefind() {
}
emit LoadRemoteFinished();
}
#ifdef HAVE_GSTREAMER
@ -523,8 +514,7 @@ void SongLoader::ErrorMessageReceived(GstMessage *msg) {
free(debugs);
if (state_ == WaitingForType && message_str == gst_error_get_message(GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND)) {
// Don't give up - assume it's a playlist and see if one of our parsers can
// read it.
// Don't give up - assume it's a playlist and see if one of our parsers can read it.
state_ = WaitingForMagic;
return;
}
@ -569,22 +559,21 @@ void SongLoader::MagicReady() {
parser_ = playlist_parser_->ParserForMagic(buffer_, mime_type_);
if (!parser_) {
qLog(Warning) << url_.toString() << "is text, but not a recognised playlist";
// It doesn't look like a playlist, so just finish
StopTypefindAsync(false);
return;
}
qLog(Warning) << url_.toString() << "is text, but not a recognised playlist";
// It doesn't look like a playlist, so just finish
StopTypefindAsync(false);
return;
}
// We'll get more data and parse the whole thing in EndOfStreamReached
qLog(Debug) << "Magic says" << parser_->name();
if (parser_->name() == "ASX/INI" && url_.scheme() == "http") {
// This is actually a weird MS-WMSP stream. Changing the protocol to MMS from
// HTTP makes it playable.
parser_ = nullptr;
url_.setScheme("mms");
StopTypefindAsync(true);
}
qLog(Debug) << "Magic says" << parser_->name();
if (parser_->name() == "ASX/INI" && url_.scheme() == "http") {
// This is actually a weird MS-WMSP stream. Changing the protocol to MMS from HTTP makes it playable.
parser_ = nullptr;
url_.setScheme("mms");
StopTypefindAsync(true);
}
state_ = WaitingForData;

View File

@ -47,8 +47,6 @@ QString AlbumCoverLoader::ImageCacheDir() {
void AlbumCoverLoader::CancelTask(quint64 id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QMutexLocker l(&mutex_);
for (QQueue<Task>::iterator it = tasks_.begin(); it != tasks_.end(); ++it) {
if (it->id == id) {
@ -60,8 +58,6 @@ void AlbumCoverLoader::CancelTask(quint64 id) {
void AlbumCoverLoader::CancelTasks(const QSet<quint64> &ids) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QMutexLocker l(&mutex_);
for (QQueue<Task>::iterator it = tasks_.begin(); it != tasks_.end();) {
if (ids.contains(it->id)) {
@ -79,8 +75,6 @@ quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions& options,
quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options, const QString &art_automatic, const QString &art_manual, const QString &song_filename, const QImage &embedded_image) {
//qLog(Debug) << __PRETTY_FUNCTION__ << art_automatic << art_manual << song_filename;
Task task;
task.options = options;
task.art_automatic = art_automatic;
@ -102,8 +96,6 @@ quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options,
void AlbumCoverLoader::ProcessTasks() {
//qLog(Debug) << __PRETTY_FUNCTION__;
while (!stop_requested_) {
// Get the next task
Task task;
@ -119,12 +111,9 @@ void AlbumCoverLoader::ProcessTasks() {
void AlbumCoverLoader::ProcessTask(Task *task) {
//qLog(Debug) << __PRETTY_FUNCTION__;
TryLoadResult result = TryLoadImage(*task);
if (result.started_async) {
// The image is being loaded from a remote URL, we'll carry on later
// when it's done
// The image is being loaded from a remote URL, we'll carry on later when it's done
return;
}
@ -140,8 +129,6 @@ void AlbumCoverLoader::ProcessTask(Task *task) {
void AlbumCoverLoader::NextState(Task *task) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (task->state == State_TryingManual) {
// Try the automatic one next
task->state = State_TryingAuto;
@ -155,8 +142,6 @@ void AlbumCoverLoader::NextState(Task *task) {
}
AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// An image embedded in the song itself takes priority
if (!task.embedded_image.isNull())
@ -198,8 +183,6 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task)
}
void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply) {
//qLog(Debug) << __PRETTY_FUNCTION__;
reply->deleteLater();
@ -236,8 +219,6 @@ void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply) {
QImage AlbumCoverLoader::ScaleAndPad(const AlbumCoverLoaderOptions &options, const QImage &image) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (image.isNull()) return image;
// Scale the image down
@ -264,8 +245,6 @@ QImage AlbumCoverLoader::ScaleAndPad(const AlbumCoverLoaderOptions &options, con
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString &manual, const QString &filename) {
//qLog(Debug) << __PRETTY_FUNCTION__ << automatic << manual << filename;
QPixmap ret;
if (manual == Song::kManuallyUnsetCover) return ret;
if (!manual.isEmpty()) ret.load(manual);

View File

@ -47,8 +47,6 @@ DiscogsCoverProvider::DiscogsCoverProvider(QObject *parent) : CoverProvider("Dis
bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &album, int s_id) {
//qLog(Debug) << __PRETTY_FUNCTION__ << artist << album << s_id;
DiscogsCoverSearchContext *s_ctx = new DiscogsCoverSearchContext;
if (s_ctx == nullptr) return false;
s_ctx->id = s_id;
@ -64,8 +62,6 @@ bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &alb
bool DiscogsCoverProvider::StartRelease(DiscogsCoverSearchContext *s_ctx, int r_id, QString resource_url) {
//qLog(Debug) << __PRETTY_FUNCTION__ << resource_url;
DiscogsCoverReleaseContext *r_ctx = new DiscogsCoverReleaseContext;
if (r_ctx == nullptr) return false;
@ -84,8 +80,6 @@ bool DiscogsCoverProvider::StartRelease(DiscogsCoverSearchContext *s_ctx, int r_
}
void DiscogsCoverProvider::SendSearchRequest(DiscogsCoverSearchContext *s_ctx) {
//qLog(Debug) << __PRETTY_FUNCTION__;
typedef QPair<QString, QString> Arg;
typedef QList<Arg> ArgList;
@ -135,8 +129,6 @@ void DiscogsCoverProvider::SendSearchRequest(DiscogsCoverSearchContext *s_ctx) {
void DiscogsCoverProvider::SendReleaseRequest(DiscogsCoverSearchContext *s_ctx, DiscogsCoverReleaseContext *r_ctx) {
//qLog(Debug) << __PRETTY_FUNCTION__;
typedef QPair<QString, QString> Arg;
typedef QList<Arg> ArgList;
@ -180,8 +172,6 @@ void DiscogsCoverProvider::SendReleaseRequest(DiscogsCoverSearchContext *s_ctx,
void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, int s_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
//QString text(reply->readAll());
//qLog(Debug) << "text: " << text << "\n";
@ -256,8 +246,6 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, int s_id) {
void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, int s_id, int r_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
//QString text(reply->readAll());
//qLog(Debug) << "text: " << text << "\n";
@ -338,16 +326,12 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, int s_id, in
void DiscogsCoverProvider::CancelSearch(int id) {
//qLog(Debug) << __PRETTY_FUNCTION__ << id;
delete requests_search_.take(id);
}
void DiscogsCoverProvider::SearchRequestError(QNetworkReply::NetworkError error, QNetworkReply *reply, int s_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
DiscogsCoverSearchContext *s_ctx;
if (!requests_search_.contains(s_id)) {
qLog(Error) << "Discogs: got reply for cancelled request: " << s_id;
@ -362,8 +346,6 @@ void DiscogsCoverProvider::SearchRequestError(QNetworkReply::NetworkError error,
void DiscogsCoverProvider::ReleaseRequestError(QNetworkReply::NetworkError error, QNetworkReply *reply, int s_id, int r_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
DiscogsCoverSearchContext *s_ctx;
if (!requests_search_.contains(s_id)) {
qLog(Error) << "Discogs: got reply for cancelled request: " << s_id << r_id;
@ -386,8 +368,6 @@ void DiscogsCoverProvider::ReleaseRequestError(QNetworkReply::NetworkError error
void DiscogsCoverProvider::EndSearch(DiscogsCoverSearchContext *s_ctx, DiscogsCoverReleaseContext *r_ctx) {
//qLog(Debug) << __PRETTY_FUNCTION__;
(void)requests_release_.remove(r_ctx->id);
delete r_ctx;

View File

@ -76,7 +76,7 @@ QVariantMap CddaLister::DeviceHardwareInfo(const QString &) {
QString CddaLister::MakeFriendlyName(const QString &id) {
CdIo_t* cdio = cdio_open(id.toLocal8Bit().constData(), DRIVER_DEVICE);
CdIo_t *cdio = cdio_open(id.toLocal8Bit().constData(), DRIVER_DEVICE);
cdio_hwinfo_t cd_info;
if (cdio_get_hwinfo(cdio, &cd_info)) {
cdio_destroy(cdio);

View File

@ -45,7 +45,7 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
model_(nullptr),
song_count_(0) {
qLog(Info) << "connected" << url << unique_id << first_time;
qLog(Info) << "Connected" << url << unique_id << first_time;
// Create the backend in the database thread.
backend_ = new CollectionBackend();
@ -61,6 +61,7 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
// Create the model
model_ = new CollectionModel(backend_, app_, this);
}
ConnectedDevice::~ConnectedDevice() { backend_->deleteLater(); }
@ -77,8 +78,7 @@ void ConnectedDevice::InitBackendDirectory(const QString &mount_point, bool firs
// the database to fix it. This can be done entirely in sqlite so it's
// relatively fast...
// Get the directory it was mounted at last time. Devices only have one
// directory (the root).
// Get the directory it was mounted at last time. Devices only have one directory (the root).
Directory dir = backend_->GetAllDirectories()[0];
if (dir.path != mount_point) {
// The directory is different, commence the munging.
@ -90,6 +90,7 @@ void ConnectedDevice::InitBackendDirectory(const QString &mount_point, bool firs
// Load the directory properly now
backend_->LoadDirectoriesAsync();
}
}
void ConnectedDevice::Eject() {

View File

@ -37,7 +37,6 @@
DeviceKitLister::DeviceKitLister() {}
DeviceKitLister::~DeviceKitLister() {}
//qLog(Debug) << __PRETTY_FUNCTION__;
QString DeviceKitLister::DeviceData::unique_id() const {
return QString("DeviceKit/%1/%2/%3/%4").arg(drive_serial, drive_vendor, drive_model).arg(device_size);

View File

@ -394,6 +394,7 @@ int DeviceManager::FindDeviceById(const QString &id) const {
if (backend.unique_id_ == id) return i;
}
}
return -1;
}
@ -406,13 +407,13 @@ int DeviceManager::FindDeviceByUrl(const QList<QUrl> &urls) const {
for (const DeviceInfo::Backend &backend : devices_[i].backends_) {
if (!backend.lister_) continue;
QList<QUrl> device_urls =
backend.lister_->MakeDeviceUrls(backend.unique_id_);
QList<QUrl> device_urls = backend.lister_->MakeDeviceUrls(backend.unique_id_);
for (const QUrl &url : device_urls) {
if (urls.contains(url)) return i;
}
}
}
return -1;
}
@ -435,7 +436,8 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
}
emit dataChanged(index(i, 0), index(i, 0));
} else {
}
else {
// Check if we have another device with the same URL
i = FindDeviceByUrl(lister->MakeDeviceUrls(id));
if (i != -1) {
@ -452,7 +454,8 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
}
emit dataChanged(index(i, 0), index(i, 0));
} else {
}
else {
// It's a completely new device
DeviceInfo info;
info.backends_ << DeviceInfo::Backend(lister, id);

View File

@ -144,6 +144,7 @@ void DeviceItemDelegate::paint(QPainter *p, const QStyleOptionViewItem &opt, con
p->drawText(line2, Qt::AlignLeft | Qt::AlignTop, status_text);
p->restore();
}
DeviceView::DeviceView(QWidget *parent)
@ -232,13 +233,14 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
eject_action_->setEnabled(is_plugged_in);
device_menu_->popup(e->globalPos());
} else if (collection_index.isValid()) {
}
else if (collection_index.isValid()) {
const QModelIndex parent_device_index = FindParentDevice(menu_index_);
bool is_filesystem_device = false;
if (parent_device_index.isValid()) {
std::shared_ptr<ConnectedDevice> device =
app_->device_manager()->GetConnectedDevice(parent_device_index.row());
std::shared_ptr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(parent_device_index.row());
qLog(Debug) << device->LocalPath();
if (device && !device->LocalPath().isEmpty()) is_filesystem_device = true;
}
@ -286,8 +288,7 @@ void DeviceView::Connect() {
void DeviceView::DeviceConnected(int row) {
std::shared_ptr<ConnectedDevice> device =
app_->device_manager()->GetConnectedDevice(row);
std::shared_ptr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(row);
if (!device) return;
QModelIndex sort_idx = sort_model_->mapFromSource(app_->device_manager()->index(row));
@ -300,6 +301,7 @@ void DeviceView::DeviceConnected(int row) {
merged_model_->AddSubModel(sort_idx, sort_model);
expand(menu_index_);
}
void DeviceView::DeviceDisconnected(int row) {

View File

@ -61,10 +61,10 @@ bool GioLister::DeviceInfo::is_suitable() const {
}
template <typename T, typename F>
void OperationFinished(F f, GObject* object, GAsyncResult* result) {
void OperationFinished(F f, GObject *object, GAsyncResult *result) {
T* obj = reinterpret_cast<T*>(object);
GError* error = nullptr;
T *obj = reinterpret_cast<T*>(object);
GError *error = nullptr;
f(obj, result, &error);
@ -75,7 +75,7 @@ void OperationFinished(F f, GObject* object, GAsyncResult* result) {
}
void GioLister::VolumeMountFinished(GObject* object, GAsyncResult* result, gpointer) {
void GioLister::VolumeMountFinished(GObject *object, GAsyncResult *result, gpointer) {
OperationFinished<GVolume>(std::bind(g_volume_mount_finish, _1, _2, _3), object, result);
}
@ -84,9 +84,9 @@ void GioLister::Init() {
monitor_.reset_without_add(g_volume_monitor_get());
// Get existing volumes
GList* const volumes = g_volume_monitor_get_volumes(monitor_);
for (GList* p = volumes; p; p = p->next) {
GVolume* volume = static_cast<GVolume*>(p->data);
GList *const volumes = g_volume_monitor_get_volumes(monitor_);
for (GList *p = volumes; p; p = p->next) {
GVolume *volume = static_cast<GVolume*>(p->data);
VolumeAdded(volume);
g_object_unref(volume);
@ -94,9 +94,9 @@ void GioLister::Init() {
g_list_free(volumes);
// Get existing mounts
GList* const mounts = g_volume_monitor_get_mounts(monitor_);
for (GList* p = mounts; p; p = p->next) {
GMount* mount = static_cast<GMount*>(p->data);
GList *const mounts = g_volume_monitor_get_mounts(monitor_);
for (GList *p = mounts; p; p = p->next) {
GMount *mount = static_cast<GMount*>(p->data);
MountAdded(mount);
g_object_unref(mount);
@ -123,13 +123,13 @@ QStringList GioLister::DeviceUniqueIDs() {
return devices_.keys();
}
QVariantList GioLister::DeviceIcons(const QString& id) {
QVariantList GioLister::DeviceIcons(const QString &id) {
QVariantList ret;
QMutexLocker l(&mutex_);
if (!devices_.contains(id)) return ret;
const DeviceInfo& info = devices_[id];
const DeviceInfo &info = devices_[id];
if (info.mount) {
ret << DeviceLister::GuessIconForPath(info.mount_path);
@ -142,37 +142,37 @@ QVariantList GioLister::DeviceIcons(const QString& id) {
}
QString GioLister::DeviceManufacturer(const QString& id) { return QString(); }
QString GioLister::DeviceManufacturer(const QString &id) { return QString(); }
QString GioLister::DeviceModel(const QString& id) {
QString GioLister::DeviceModel(const QString &id) {
QMutexLocker l(&mutex_);
if (!devices_.contains(id)) return QString();
const DeviceInfo& info = devices_[id];
const DeviceInfo &info = devices_[id];
return info.drive_name.isEmpty() ? info.volume_name : info.drive_name;
}
quint64 GioLister::DeviceCapacity(const QString& id) {
quint64 GioLister::DeviceCapacity(const QString &id) {
return LockAndGetDeviceInfo(id, &DeviceInfo::filesystem_size);
}
quint64 GioLister::DeviceFreeSpace(const QString& id) {
quint64 GioLister::DeviceFreeSpace(const QString &id) {
return LockAndGetDeviceInfo(id, &DeviceInfo::filesystem_free);
}
QString GioLister::MakeFriendlyName(const QString& id) {
QString GioLister::MakeFriendlyName(const QString &id) {
return DeviceModel(id);
}
QVariantMap GioLister::DeviceHardwareInfo(const QString& id) {
QVariantMap GioLister::DeviceHardwareInfo(const QString &id) {
QVariantMap ret;
QMutexLocker l(&mutex_);
if (!devices_.contains(id)) return ret;
const DeviceInfo& info = devices_[id];
const DeviceInfo &info = devices_[id];
ret[QT_TR_NOOP("Mount point")] = info.mount_path;
ret[QT_TR_NOOP("Device")] = info.volume_unix_device;
@ -181,7 +181,7 @@ QVariantMap GioLister::DeviceHardwareInfo(const QString& id) {
}
QList<QUrl> GioLister::MakeDeviceUrls(const QString& id) {
QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
QString mount_point;
QString uri;
@ -198,40 +198,41 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString& id) {
QList<QUrl> ret;
// Special case for file:// GIO URIs - we have to check whether they point
// to an ipod.
// Special case for file:// GIO URIs - we have to check whether they point to an ipod.
if (url.isValid() && url.scheme() == "file") {
ret << MakeUrlFromLocalPath(url.path());
} else {
}
else {
ret << url;
}
ret << MakeUrlFromLocalPath(mount_point);
return ret;
}
void GioLister::VolumeAddedCallback(GVolumeMonitor*, GVolume* v, gpointer d) {
void GioLister::VolumeAddedCallback(GVolumeMonitor*, GVolume *v, gpointer d) {
static_cast<GioLister*>(d)->VolumeAdded(v);
}
void GioLister::VolumeRemovedCallback(GVolumeMonitor*, GVolume* v, gpointer d) {
void GioLister::VolumeRemovedCallback(GVolumeMonitor*, GVolume *v, gpointer d) {
static_cast<GioLister*>(d)->VolumeRemoved(v);
}
void GioLister::MountAddedCallback(GVolumeMonitor*, GMount* m, gpointer d) {
void GioLister::MountAddedCallback(GVolumeMonitor*, GMount *m, gpointer d) {
static_cast<GioLister*>(d)->MountAdded(m);
}
void GioLister::MountChangedCallback(GVolumeMonitor*, GMount* m, gpointer d) {
void GioLister::MountChangedCallback(GVolumeMonitor*, GMount *m, gpointer d) {
static_cast<GioLister*>(d)->MountChanged(m);
}
void GioLister::MountRemovedCallback(GVolumeMonitor*, GMount* m, gpointer d) {
void GioLister::MountRemovedCallback(GVolumeMonitor*, GMount *m, gpointer d) {
static_cast<GioLister*>(d)->MountRemoved(m);
}
void GioLister::VolumeAdded(GVolume* volume) {
void GioLister::VolumeAdded(GVolume *volume) {
g_object_ref(volume);
@ -255,7 +256,7 @@ void GioLister::VolumeAdded(GVolume* volume) {
}
void GioLister::VolumeRemoved(GVolume* volume) {
void GioLister::VolumeRemoved(GVolume *volume) {
QString id;
@ -270,7 +271,7 @@ void GioLister::VolumeRemoved(GVolume* volume) {
emit DeviceRemoved(id);
}
void GioLister::MountAdded(GMount* mount) {
void GioLister::MountAdded(GMount *mount) {
g_object_ref(mount);
@ -316,7 +317,7 @@ void GioLister::MountAdded(GMount* mount) {
}
void GioLister::MountChanged(GMount* mount) {
void GioLister::MountChanged(GMount *mount) {
QString id;
{
@ -344,7 +345,7 @@ void GioLister::MountChanged(GMount* mount) {
}
void GioLister::MountRemoved(GMount* mount) {
void GioLister::MountRemoved(GMount *mount) {
QString id;
{
@ -359,13 +360,13 @@ void GioLister::MountRemoved(GMount* mount) {
}
QString GioLister::DeviceInfo::ConvertAndFree(char* str) {
QString GioLister::DeviceInfo::ConvertAndFree(char *str) {
QString ret = QString::fromUtf8(str);
g_free(str);
return ret;
}
void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {
// Get basic information
this->mount.reset_without_add(mount);
@ -375,16 +376,16 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
// Get the icon name(s)
mount_icon_names.clear();
GIcon* icon = g_mount_get_icon(mount);
GIcon *icon = g_mount_get_icon(mount);
if (G_IS_THEMED_ICON(icon)) {
const char* const* icons = g_themed_icon_get_names(G_THEMED_ICON(icon));
for (const char* const* p = icons; *p; ++p) {
const char *const *icons = g_themed_icon_get_names(G_THEMED_ICON(icon));
for (const char *const *p = icons; *p; ++p) {
mount_icon_names << QString::fromUtf8(*p);
}
}
g_object_unref(icon);
GFile* root = g_mount_get_root(mount);
GFile *root = g_mount_get_root(mount);
// Get the mount path
mount_path = ConvertAndFree(g_file_get_path(root));
@ -393,8 +394,8 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
// Do a sanity check to make sure the root is actually this mount - when a
// device is unmounted GIO sends a changed signal before the removed signal,
// and we end up reading information about the / filesystem by mistake.
GError* error = nullptr;
GMount* actual_mount = g_file_find_enclosing_mount(root, nullptr, &error);
GError *error = nullptr;
GMount *actual_mount = g_file_find_enclosing_mount(root, nullptr, &error);
if (error || !actual_mount) {
g_error_free(error);
invalid_enclosing_mount = true;
@ -405,21 +406,15 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
// Query the filesystem info for size, free space, and type
error = nullptr;
GFileInfo* info = g_file_query_filesystem_info(
root, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE
"," G_FILE_ATTRIBUTE_FILESYSTEM_FREE "," G_FILE_ATTRIBUTE_FILESYSTEM_TYPE,
nullptr, &error);
GFileInfo *info = g_file_query_filesystem_info(root, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE "," G_FILE_ATTRIBUTE_FILESYSTEM_FREE "," G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, nullptr, &error);
if (error) {
qLog(Warning) << error->message;
g_error_free(error);
}
else {
filesystem_size = g_file_info_get_attribute_uint64(
info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
filesystem_free = g_file_info_get_attribute_uint64(
info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
filesystem_type = QString::fromUtf8(g_file_info_get_attribute_string(
info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE));
filesystem_size = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
filesystem_free = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
filesystem_type = QString::fromUtf8(g_file_info_get_attribute_string(info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE));
g_object_unref(info);
}
@ -442,7 +437,7 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount* mount) {
}
void GioLister::DeviceInfo::ReadVolumeInfo(GVolume* volume) {
void GioLister::DeviceInfo::ReadVolumeInfo(GVolume *volume) {
this->volume.reset_without_add(volume);
if (!volume) return;
@ -451,7 +446,7 @@ void GioLister::DeviceInfo::ReadVolumeInfo(GVolume* volume) {
volume_uuid = ConvertAndFree(g_volume_get_uuid(volume));
volume_unix_device = ConvertAndFree(g_volume_get_identifier(volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE));
GFile* root = g_volume_get_activation_root(volume);
GFile *root = g_volume_get_activation_root(volume);
if (root) {
volume_root_uri = g_file_get_uri(root);
g_object_unref(root);
@ -459,7 +454,7 @@ void GioLister::DeviceInfo::ReadVolumeInfo(GVolume* volume) {
}
void GioLister::DeviceInfo::ReadDriveInfo(GDrive* drive) {
void GioLister::DeviceInfo::ReadDriveInfo(GDrive *drive) {
this->drive.reset_without_add(drive);
if (!drive) return;
@ -467,38 +462,38 @@ void GioLister::DeviceInfo::ReadDriveInfo(GDrive* drive) {
drive_removable = g_drive_is_media_removable(drive);
}
QString GioLister::FindUniqueIdByMount(GMount* mount) const {
for (const DeviceInfo& info : devices_) {
QString GioLister::FindUniqueIdByMount(GMount *mount) const {
for (const DeviceInfo &info : devices_) {
if (info.mount == mount) return info.unique_id();
}
return QString();
}
QString GioLister::FindUniqueIdByVolume(GVolume* volume) const {
for (const DeviceInfo& info : devices_) {
QString GioLister::FindUniqueIdByVolume(GVolume *volume) const {
for (const DeviceInfo &info : devices_) {
if (info.volume == volume) return info.unique_id();
}
return QString();
}
void GioLister::VolumeEjectFinished(GObject* object, GAsyncResult* result, gpointer) {
void GioLister::VolumeEjectFinished(GObject *object, GAsyncResult *result, gpointer) {
OperationFinished<GVolume>(std::bind(g_volume_eject_with_operation_finish, _1, _2, _3), object, result);
}
void GioLister::MountEjectFinished(GObject* object, GAsyncResult* result, gpointer) {
void GioLister::MountEjectFinished(GObject *object, GAsyncResult *result, gpointer) {
OperationFinished<GMount>(std::bind(g_mount_eject_with_operation_finish, _1, _2, _3), object, result);
}
void GioLister::MountUnmountFinished(GObject* object, GAsyncResult* result, gpointer) {
void GioLister::MountUnmountFinished(GObject *object, GAsyncResult *result, gpointer) {
OperationFinished<GMount>(std::bind(g_mount_unmount_with_operation_finish, _1, _2, _3), object, result);
}
void GioLister::UnmountDevice(const QString& id) {
void GioLister::UnmountDevice(const QString &id) {
QMutexLocker l(&mutex_);
if (!devices_.contains(id)) return;
const DeviceInfo& info = devices_[id];
const DeviceInfo &info = devices_[id];
if (!info.mount) return;
@ -519,18 +514,18 @@ void GioLister::UnmountDevice(const QString& id) {
}
void GioLister::UpdateDeviceFreeSpace(const QString& id) {
void GioLister::UpdateDeviceFreeSpace(const QString &id) {
{
QMutexLocker l(&mutex_);
if (!devices_.contains(id)) return;
DeviceInfo& device_info = devices_[id];
DeviceInfo &device_info = devices_[id];
GFile* root = g_mount_get_root(device_info.mount);
GFile *root = g_mount_get_root(device_info.mount);
GError* error = nullptr;
GFileInfo* info = g_file_query_filesystem_info(root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, nullptr, &error);
GError *error = nullptr;
GFileInfo *info = g_file_query_filesystem_info(root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, nullptr, &error);
if (error) {
qLog(Warning) << error->message;
g_error_free(error);
@ -547,18 +542,18 @@ void GioLister::UpdateDeviceFreeSpace(const QString& id) {
}
bool GioLister::DeviceNeedsMount(const QString& id) {
bool GioLister::DeviceNeedsMount(const QString &id) {
QMutexLocker l(&mutex_);
return devices_.contains(id) && !devices_[id].mount;
}
int GioLister::MountDevice(const QString& id) {
int GioLister::MountDevice(const QString &id) {
const int request_id = next_mount_request_id_++;
metaObject()->invokeMethod(this, "DoMountDevice", Qt::QueuedConnection, Q_ARG(QString, id), Q_ARG(int, request_id));
return request_id;
}
void GioLister::DoMountDevice(const QString& id, int request_id) {
void GioLister::DoMountDevice(const QString &id, int request_id) {
QMutexLocker l(&mutex_);
if (!devices_.contains(id)) {
@ -566,7 +561,7 @@ void GioLister::DoMountDevice(const QString& id, int request_id) {
return;
}
const DeviceInfo& info = devices_[id];
const DeviceInfo &info = devices_[id];
if (info.mount) {
// Already mounted
emit DeviceMounted(id, request_id, true);

View File

@ -28,6 +28,8 @@
#include "mtpconnection.h"
#include "core/song.h"
#include "core/taskmanager.h"
#include "core/logging.h"
#include "collection/collectionbackend.h"
MtpLoader::MtpLoader(const QUrl &url, TaskManager *task_manager, CollectionBackend *backend, std::shared_ptr<ConnectedDevice> device)

View File

@ -112,9 +112,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
QReadLocker locker(&device_data_lock_);
if (!device_data_.contains(id)) return;
OrgFreedesktopUDisks2FilesystemInterface filesystem(
udisks2_service_, device_data_[id].dbus_path,
QDBusConnection::systemBus());
OrgFreedesktopUDisks2FilesystemInterface filesystem(udisks2_service_, device_data_[id].dbus_path, QDBusConnection::systemBus());
if (filesystem.isValid()) {
auto unmount_result = filesystem.Unmount(QVariantMap());
@ -177,6 +175,7 @@ void Udisks2Lister::Init() {
connect(udisks2_interface_.get(), SIGNAL(InterfacesAdded(QDBusObjectPath, InterfacesAndProperties)), SLOT(DBusInterfaceAdded(QDBusObjectPath, InterfacesAndProperties)));
connect(udisks2_interface_.get(), SIGNAL(InterfacesRemoved(QDBusObjectPath, QStringList)), SLOT(DBusInterfaceRemoved(QDBusObjectPath, QStringList)));
}
void Udisks2Lister::DBusInterfaceAdded(const QDBusObjectPath &path, const InterfacesAndProperties &interfaces) {
@ -223,12 +222,14 @@ void Udisks2Lister::DBusInterfaceRemoved(const QDBusObjectPath &path, const QStr
}
bool Udisks2Lister::isPendingJob(const QDBusObjectPath &job_path) {
QMutexLocker locker(&jobs_lock_);
if (!mounting_jobs_.contains(job_path)) return false;
mounting_jobs_.remove(job_path);
return true;
}
void Udisks2Lister::RemoveDevice(const QDBusObjectPath &device_path) {
@ -281,6 +282,7 @@ void Udisks2Lister::JobCompleted(bool success, const QString &message) {
mounting_jobs_[jobPath].is_mount ? HandleFinishedMountJob(partition_data) : HandleFinishedUnmountJob(partition_data, mounted_object);
}
}
void Udisks2Lister::HandleFinishedMountJob(const Udisks2Lister::PartitionData &partition_data) {
@ -306,8 +308,7 @@ void Udisks2Lister::HandleFinishedUnmountJob(const Udisks2Lister::PartitionData
}
if (!id.isEmpty()) {
qLog(Debug) << "Partition " << partition_data.dbus_path
<< " has no more mount points, removing it from device list";
qLog(Debug) << "Partition " << partition_data.dbus_path << " has no more mount points, removing it from device list";
device_data_.remove(id);
DeviceRemoved(id);
}

View File

@ -66,8 +66,6 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
cover_art_is_set_(false),
results_dialog_(new TrackSelectionDialog(this))
{
//qLog(Debug) << __PRETTY_FUNCTION__;
//QIcon nocover = IconLoader::Load("nocover");
//cover_options_.default_output_image_ = AlbumCoverLoader::ScaleAndPad(cover_options_, nocover.pixmap(nocover.availableSizes().last()).toImage());
@ -197,8 +195,6 @@ EditTagDialog::~EditTagDialog() {
bool EditTagDialog::SetLoading(const QString &message) {
//qLog(Debug) << __PRETTY_FUNCTION__;
const bool loading = !message.isEmpty();
if (loading == loading_) return false;
loading_ = loading;
@ -210,12 +206,11 @@ bool EditTagDialog::SetLoading(const QString &message) {
ui_->loading_label->setVisible(loading);
ui_->loading_label->set_text(message);
return true;
}
QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList &songs) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
QList<Data> ret;
for (const Song &song : songs) {
@ -236,8 +231,6 @@ QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList &songs) const
void EditTagDialog::SetSongs(const SongList &s, const PlaylistItemList &items) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Show the loading indicator
if (!SetLoading(tr("Loading tracks") + "...")) return;
@ -251,8 +244,6 @@ void EditTagDialog::SetSongs(const SongList &s, const PlaylistItemList &items) {
}
void EditTagDialog::SetSongsFinished(QFuture<QList<Data>> future) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!SetLoading(QString())) return;
@ -291,8 +282,6 @@ void EditTagDialog::SetSongListVisibility(bool visible) {
QVariant EditTagDialog::Data::value(const Song &song, const QString &id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (id == "title") return song.title();
if (id == "artist") return song.artist();
if (id == "album") return song.album();
@ -311,8 +300,6 @@ QVariant EditTagDialog::Data::value(const Song &song, const QString &id) {
}
void EditTagDialog::Data::set_value(const QString &id, const QVariant &value) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (id == "title") current_.set_title(value.toString());
else if (id == "artist") current_.set_artist(value.toString());
@ -345,12 +332,11 @@ bool EditTagDialog::IsValueModified(const QModelIndexList &sel, const QString &i
return true;
}
return false;
}
void EditTagDialog::InitFieldValue(const FieldData &field, const QModelIndexList &sel) {
//qLog(Debug) << __PRETTY_FUNCTION__;
const bool varies = DoesValueVary(sel, field.id_);
// const bool modified = IsValueModified(sel, field.id_);
@ -366,12 +352,11 @@ void EditTagDialog::InitFieldValue(const FieldData &field, const QModelIndexList
}
UpdateModifiedField(field, sel);
}
void EditTagDialog::UpdateFieldValue(const FieldData &field, const QModelIndexList &sel) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Get the value from the field
QVariant value;
if (ExtendedEditor *editor = dynamic_cast<ExtendedEditor*>(field.editor_)) {
@ -389,11 +374,10 @@ void EditTagDialog::UpdateFieldValue(const FieldData &field, const QModelIndexLi
}
UpdateModifiedField(field, sel);
}
void EditTagDialog::UpdateModifiedField(const FieldData &field, const QModelIndexList &sel) {
//qLog(Debug) << __PRETTY_FUNCTION__;
const bool modified = IsValueModified(sel, field.id_);
@ -402,12 +386,11 @@ void EditTagDialog::UpdateModifiedField(const FieldData &field, const QModelInde
new_font.setBold(modified);
field.label_->setFont(new_font);
field.editor_->setFont(new_font);
}
void EditTagDialog::ResetFieldValue(const FieldData &field, const QModelIndexList &sel) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Reset each selected song
for (const QModelIndex &i : sel) {
Data &data = data_[i.row()];
@ -416,12 +399,11 @@ void EditTagDialog::ResetFieldValue(const FieldData &field, const QModelIndexLis
// Reset the field
InitFieldValue(field, sel);
}
void EditTagDialog::SelectionChanged() {
//qLog(Debug) << __PRETTY_FUNCTION__;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty())
return;
@ -438,41 +420,35 @@ void EditTagDialog::SelectionChanged() {
UpdateSummaryTab(song);
UpdateStatisticsTab(song);
}
}
void EditTagDialog::UpdateUI(const QModelIndexList &sel){
//qLog(Debug) << __PRETTY_FUNCTION__;
ignore_edits_ = true;
for (const FieldData &field : fields_) {
InitFieldValue(field, sel);
}
ignore_edits_ = false;
}
static void SetText(QLabel *label, int value, const QString &suffix, const QString &def = QString()) {
//qLog(Debug) << __PRETTY_FUNCTION__;
label->setText(value <= 0 ? def : (QString::number(value) + " " + suffix));
}
static void SetDate(QLabel *label, uint time) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (time == std::numeric_limits<uint>::max()) { // -1
label->setText(QObject::tr("Unknown"));
}
else {
label->setText(QDateTime::fromTime_t(time).toString(QLocale::system().dateTimeFormat(QLocale::LongFormat)));
}
}
void EditTagDialog::UpdateSummaryTab(const Song &song) {
//qLog(Debug) << __PRETTY_FUNCTION__;
cover_art_id_ = app_->album_cover_loader()->LoadImageAsync(cover_options_, song);
@ -531,28 +507,24 @@ void EditTagDialog::UpdateSummaryTab(const Song &song) {
void EditTagDialog::UpdateStatisticsTab(const Song &song) {
//qLog(Debug) << __PRETTY_FUNCTION__;
ui_->playcount->setText(QString::number(qMax(0, song.playcount())));
ui_->skipcount->setText(QString::number(qMax(0, song.skipcount())));
ui_->lastplayed->setText(song.lastplayed() <= 0 ? tr("Never") : QDateTime::fromTime_t(song.lastplayed()).toString(QLocale::system().dateTimeFormat(QLocale::LongFormat)));
}
void EditTagDialog::ArtLoaded(quint64 id, const QImage &scaled, const QImage &original) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (id == cover_art_id_) {
ui_->art->setPixmap(QPixmap::fromImage(scaled));
original_ = original;
}
}
void EditTagDialog::FieldValueEdited() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (ignore_edits_) return;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
@ -568,12 +540,11 @@ void EditTagDialog::FieldValueEdited() {
return;
}
}
}
void EditTagDialog::ResetField() {
//qLog(Debug) << __PRETTY_FUNCTION__;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty())
return;
@ -589,21 +560,19 @@ void EditTagDialog::ResetField() {
return;
}
}
}
Song *EditTagDialog::GetFirstSelected() {
//qLog(Debug) << __PRETTY_FUNCTION__;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty()) return nullptr;
return &data_[sel.first().row()].original_;
}
void EditTagDialog::LoadCoverFromFile() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Song *song = GetFirstSelected();
if (!song) return;
@ -612,21 +581,19 @@ void EditTagDialog::LoadCoverFromFile() {
QString cover = album_cover_choice_controller_->LoadCoverFromFile(song);
if (!cover.isEmpty()) UpdateCoverOf(*song, sel, cover);
}
void EditTagDialog::SaveCoverToFile() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Song *song = GetFirstSelected();
if (!song) return;
album_cover_choice_controller_->SaveCoverToFile(*song, original_);
}
void EditTagDialog::LoadCoverFromURL() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Song *song = GetFirstSelected();
if (!song) return;
@ -639,8 +606,6 @@ void EditTagDialog::LoadCoverFromURL() {
}
void EditTagDialog::SearchForCover() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Song *song = GetFirstSelected();
if (!song) return;
@ -653,8 +618,6 @@ void EditTagDialog::SearchForCover() {
}
void EditTagDialog::UnsetCover() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Song *song = GetFirstSelected();
if (!song) return;
@ -666,8 +629,6 @@ void EditTagDialog::UnsetCover() {
}
void EditTagDialog::ShowCover() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Song *song = GetFirstSelected();
if (!song) {
@ -678,8 +639,6 @@ void EditTagDialog::ShowCover() {
}
void EditTagDialog::UpdateCoverOf(const Song &selected, const QModelIndexList &sel, const QString &cover) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!selected.is_valid() || selected.id() == -1) return;
@ -701,8 +660,6 @@ void EditTagDialog::UpdateCoverOf(const Song &selected, const QModelIndexList &s
void EditTagDialog::NextSong() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (ui_->song_list->count() == 0) {
return;
}
@ -713,8 +670,6 @@ void EditTagDialog::NextSong() {
void EditTagDialog::PreviousSong() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (ui_->song_list->count() == 0) {
return;
}
@ -730,8 +685,6 @@ void EditTagDialog::ButtonClicked(QAbstractButton *button) {
}
void EditTagDialog::SaveData(const QList<Data> &data) {
//qLog(Debug) << __PRETTY_FUNCTION__;
for (int i = 0; i < data.count(); ++i) {
const Data &ref = data[i];
@ -744,8 +697,6 @@ void EditTagDialog::SaveData(const QList<Data> &data) {
}
void EditTagDialog::accept() {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Show the loading indicator
if (!SetLoading(tr("Saving tracks") + "...")) return;
@ -756,8 +707,6 @@ void EditTagDialog::accept() {
}
void EditTagDialog::AcceptFinished() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!SetLoading(QString())) return;
QDialog::accept();
@ -765,8 +714,6 @@ void EditTagDialog::AcceptFinished() {
}
bool EditTagDialog::eventFilter(QObject *o, QEvent *e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (o == ui_->art) {
switch (e->type()) {
@ -803,8 +750,6 @@ bool EditTagDialog::eventFilter(QObject *o, QEvent *e) {
}
void EditTagDialog::showEvent(QShowEvent *e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Set the dialog's height to the smallest possible
resize(width(), sizeHint().height());
@ -818,8 +763,6 @@ void EditTagDialog::showEvent(QShowEvent *e) {
}
void EditTagDialog::hideEvent(QHideEvent *e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Save the current tab
QSettings s;
@ -830,8 +773,6 @@ void EditTagDialog::hideEvent(QHideEvent *e) {
}
void EditTagDialog::ResetPlayCounts() {
//qLog(Debug) << __PRETTY_FUNCTION__;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty())
@ -853,8 +794,6 @@ void EditTagDialog::ResetPlayCounts() {
#ifdef HAVE_GSTREAMER
void EditTagDialog::FetchTag() {
//qLog(Debug) << __PRETTY_FUNCTION__;
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
@ -875,11 +814,10 @@ void EditTagDialog::FetchTag() {
tag_fetcher_->StartFetch(songs);
results_dialog_->show();
}
void EditTagDialog::FetchTagSongChosen(const Song &original_song, const Song &new_metadata) {
//qLog(Debug) << __PRETTY_FUNCTION__;
const QString filename = original_song.url().toLocalFile();

View File

@ -28,6 +28,7 @@
#include "enginebase.h"
#include "enginedevice.h"
#include "core/timeconstants.h"
#include "core/logging.h"
#include "settings/playbacksettingspage.h"

View File

@ -110,8 +110,6 @@ GstEngine::GstEngine(TaskManager *task_manager)
has_faded_out_(false),
scope_chunk_(0),
have_new_buffer_(false) {
//qLog(Debug) << __PRETTY_FUNCTION__;
seek_timer_->setSingleShot(true);
seek_timer_->setInterval(kSeekDelayNanosec / kNsecPerMsec);
@ -130,25 +128,16 @@ GstEngine::GstEngine(TaskManager *task_manager)
GstEngine::~GstEngine() {
//qLog(Debug) << __PRETTY_FUNCTION__;
EnsureInitialised();
current_pipeline_.reset();
// Save configuration
//gst_deinit();
//qDeleteAll(device_finders_);
#ifdef Q_OS_DARWIN
g_object_unref(tls_database_);
#endif
}
bool GstEngine::Init() {
//qLog(Debug) << __PRETTY_FUNCTION__;
SetEnvironment();
@ -160,58 +149,14 @@ bool GstEngine::Init() {
void GstEngine::InitialiseGStreamer() {
//qLog(Debug) << __PRETTY_FUNCTION__;
#if 0
gst_init(nullptr, nullptr);
gst_pb_utils_init();
#endif
#if 0
QSet<QString> plugin_names;
for (const PluginDetails &plugin : GetPluginList("Sink/Audio")) {
plugin_names.insert(plugin.name);
}
#endif
#if 0
QList<DeviceFinder*> device_finders;
#ifdef Q_OS_LINUX
device_finders.append(new AlsaDeviceFinder);
#endif
#ifdef HAVE_LIBPULSE
device_finders.append(new PulseDeviceFinder);
#endif
#ifdef Q_OS_DARWIN
device_finders.append(new OsxDeviceFinder);
#endif
#ifdef Q_OS_WIN32
device_finders.append(new DirectSoundDeviceFinder);
#endif
for (DeviceFinder *finder : device_finders) {
if (!plugin_names.contains(finder->gstreamer_sink())) {
qLog(Info) << "Skipping DeviceFinder for" << finder->gstreamer_sink() << "known plugins:" << plugin_names;
delete finder;
continue;
}
if (!finder->Initialise()) {
qLog(Warning) << "Failed to initialise DeviceFinder for" << finder->gstreamer_sink();
delete finder;
continue;
}
device_finders_.append(finder);
}
#endif
}
void GstEngine::SetEnvironment() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QString scanner_path;
QString plugin_path;
@ -250,8 +195,6 @@ void GstEngine::SetEnvironment() {
}
void GstEngine::ReloadSettings() {
//qLog(Debug) << __PRETTY_FUNCTION__;
Engine::Base::ReloadSettings();
@ -318,8 +261,6 @@ Engine::State GstEngine::state() const {
}
void GstEngine::ConsumeBuffer(GstBuffer *buffer, int pipeline_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Schedule this to run in the GUI thread. The buffer gets added to the
// queue and unreffed by UpdateScope.
@ -330,8 +271,6 @@ void GstEngine::ConsumeBuffer(GstBuffer *buffer, int pipeline_id) {
}
void GstEngine::AddBufferToScope(GstBuffer *buf, int pipeline_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!current_pipeline_ || current_pipeline_->id() != pipeline_id) {
gst_buffer_unref(buf);
@ -427,26 +366,24 @@ void GstEngine::StartPreloading(const QUrl &url, bool force_stop_at_end, qint64
// pipeline and get gapless playback (hopefully)
if (current_pipeline_)
current_pipeline_->SetNextUrl(gst_url, beginning_nanosec, force_stop_at_end ? end_nanosec : 0);
}
QUrl GstEngine::FixupUrl(const QUrl &url) {
QUrl copy = url;
// It's a file:// url with a hostname set. QUrl::fromLocalFile does this
// when given a \\host\share\file path on Windows. Munge it back into a
// path that gstreamer will recognise.
// It's a file:// url with a hostname set. QUrl::fromLocalFile does this when given a \\host\share\file path on Windows. Munge it back into a path that gstreamer will recognise.
if (url.scheme() == "file" && !url.host().isEmpty()) {
copy.setPath("//" + copy.host() + copy.path());
copy.setHost(QString());
}
return copy;
}
bool GstEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) {
//qLog(Debug) << __PRETTY_FUNCTION__;
EnsureInitialised();
@ -463,7 +400,7 @@ bool GstEngine::Load(const QUrl &url, Engine::TrackChangeFlags change, bool forc
// We're not crossfading, and the pipeline is already playing the URI we want, so just do nothing.
return true;
}
//SetEqualizerEnabled(equalizer_enabled_);
//SetEqualizerParameters(equalizer_preamp_, equalizer_gains_);
//SetStereoBalance(stereo_balance_);
@ -498,6 +435,7 @@ void GstEngine::StartFadeout() {
fadeout_pipeline_->StartFader(fadeout_duration_nanosec_, QTimeLine::Backward);
connect(fadeout_pipeline_.get(), SIGNAL(FaderFinished()), SLOT(FadeoutFinished()));
}
void GstEngine::StartFadeoutPause() {
@ -514,8 +452,6 @@ void GstEngine::StartFadeoutPause() {
}
bool GstEngine::Play(quint64 offset_nanosec) {
//qLog(Debug) << __PRETTY_FUNCTION__;
EnsureInitialised();
@ -532,8 +468,6 @@ bool GstEngine::Play(quint64 offset_nanosec) {
}
void GstEngine::PlayDone(QFuture<GstStateChangeReturn> future, const quint64 offset_nanosec, const int pipeline_id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
GstStateChangeReturn ret = future.result();
@ -571,8 +505,6 @@ void GstEngine::PlayDone(QFuture<GstStateChangeReturn> future, const quint64 off
}
void GstEngine::Stop(bool stop_after) {
//qLog(Debug) << __PRETTY_FUNCTION__;
StopTimers();
@ -617,8 +549,6 @@ void GstEngine::FadeoutPauseFinished() {
}
void GstEngine::Pause() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!current_pipeline_ || current_pipeline_->is_buffering()) return;
@ -646,17 +576,14 @@ void GstEngine::Pause() {
}
void GstEngine::Unpause() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!current_pipeline_ || current_pipeline_->is_buffering()) return;
if (current_pipeline_->state() == GST_STATE_PAUSED) {
current_pipeline_->SetState(GST_STATE_PLAYING);
// Check if we faded out last time. If yes, fade in no matter what the
// settings say. If we pause with fadeout, deactivate fadeout and resume
// playback, the player would be muted if not faded in.
// Check if we faded out last time. If yes, fade in no matter what the settings say.
// If we pause with fadeout, deactivate fadeout and resume playback, the player would be muted if not faded in.
if (has_faded_out_) {
disconnect(current_pipeline_.get(), SIGNAL(FaderFinished()), 0, 0);
current_pipeline_->StartFader(fadeout_pause_duration_nanosec_, QTimeLine::Forward, QTimeLine::EaseInOutCurve, false);
@ -696,8 +623,6 @@ void GstEngine::SeekNow() {
void GstEngine::SetEqualizerEnabled(bool enabled) {
//qLog(Debug) << "equalizer ENABLED: " << enabled;
equalizer_enabled_ = enabled;
if (current_pipeline_) current_pipeline_->SetEqualizerEnabled(enabled);
@ -761,8 +686,6 @@ void GstEngine::timerEvent(QTimerEvent *e) {
}
void GstEngine::HandlePipelineError(int pipeline_id, const QString &message, int domain, int error_code) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!current_pipeline_.get() || current_pipeline_->id() != pipeline_id)
return;
@ -793,8 +716,6 @@ void GstEngine::HandlePipelineError(int pipeline_id, const QString &message, int
}
void GstEngine::EndOfStreamReached(int pipeline_id, bool has_next_track) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (!current_pipeline_.get() || current_pipeline_->id() != pipeline_id)
return;
@ -815,8 +736,6 @@ void GstEngine::NewMetaData(int pipeline_id, const Engine::SimpleMetaBundle &bun
}
GstElement *GstEngine::CreateElement(const QString &factoryName, GstElement *bin) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Make a unique name
QString name = factoryName + "-" + QString::number(next_element_id_++);
@ -836,15 +755,11 @@ GstElement *GstEngine::CreateElement(const QString &factoryName, GstElement *bin
GstEngine::PluginDetailsList GstEngine::GetPluginList(const QString &classname) const {
//qLog(Debug) << __PRETTY_FUNCTION__;
PluginDetailsList ret;
GstRegistry *registry = gst_registry_get();
GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY);
//qLog(Debug) << __PRETTY_FUNCTION__ << registry << features;
GList *p = features;
while (p) {
GstElementFactory *factory = GST_ELEMENT_FACTORY(p->data);
@ -865,8 +780,6 @@ GstEngine::PluginDetailsList GstEngine::GetPluginList(const QString &classname)
shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
//qLog(Debug) << __PRETTY_FUNCTION__ << sink_ << device_;
EnsureInitialised();
shared_ptr<GstEnginePipeline> ret(new GstEnginePipeline(this));
@ -892,8 +805,6 @@ shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
}
shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QUrl &url, qint64 end_nanosec) {
//qLog(Debug) << __PRETTY_FUNCTION__;
shared_ptr<GstEnginePipeline> ret = CreatePipeline();
@ -905,6 +816,7 @@ shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QUrl &url, qint64
if (!ret->InitFromUrl(url, end_nanosec)) ret.reset();
return ret;
}
bool GstEngine::ALSADeviceSupport(const QString &name) {
@ -931,6 +843,7 @@ void GstEngine::BufferingStarted() {
buffering_task_id_ = task_manager_->StartTask(tr("Buffering"));
task_manager_->SetTaskProgress(buffering_task_id_, 0, 100);
}
void GstEngine::BufferingProgress(int percent) {
@ -946,25 +859,8 @@ void GstEngine::BufferingFinished() {
EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
//qLog(Debug) << __PRETTY_FUNCTION__;
//const_cast<GstEngine *>(this)->EnsureInitialised();
EngineBase::OutputDetailsList ret;
#if 0
for (DeviceFinder *finder : device_finders_) {
for (const DeviceFinder::Device &device : finder->ListDevices()) {
OutputDetails output;
output.description = device.description;
output.icon_name = device.icon_name;
output.name = finder->gstreamer_sink();
output.device_property_value = device.device_property_value;
ret.append(output);
}
}
#endif
PluginDetailsList plugins = GetPluginList("Sink/Audio");
for (const PluginDetails &plugin : plugins) {
OutputDetails output;
@ -980,5 +876,5 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
}
return ret;
}
}

View File

@ -219,39 +219,30 @@ signals:
bool mono_playback_;
// The URL that is currently playing, and the URL that is to be preloaded
// when the current track is close to finishing.
// The URL that is currently playing, and the URL that is to be preloaded when the current track is close to finishing.
QUrl url_;
QUrl next_url_;
// If this is > 0 then the pipeline will be forced to stop when playback goes
// past this position.
// If this is > 0 then the pipeline will be forced to stop when playback goes past this position.
qint64 end_offset_nanosec_;
// We store the beginning and end for the preloading song too, so we can just
// carry on without reloading the file if the sections carry on from each
// other.
// We store the beginning and end for the preloading song too, so we can just carry on without reloading the file if the sections carry on from each other.
qint64 next_beginning_offset_nanosec_;
qint64 next_end_offset_nanosec_;
// Set temporarily when moving to the next contiguous section in a multi-part
// file.
// Set temporarily when moving to the next contiguous section in a multi-part file.
bool ignore_next_seek_;
// Set temporarily when switching out the decode bin, so metadata doesn't
// get sent while the Player still thinks it's playing the last song
// Set temporarily when switching out the decode bin, so metadata doesn't get sent while the Player still thinks it's playing the last song
bool ignore_tags_;
// When the gstreamer source requests a redirect we store the URL here and
// callers can pick it up after the state change to PLAYING fails.
// When the gstreamer source requests a redirect we store the URL here and callers can pick it up after the state change to PLAYING fails.
QUrl redirect_url_;
// When we need to specify the device to use as source (for CD device)
QString source_device_;
// Seeking while the pipeline is in the READY state doesn't work, so we have
// to wait until it goes to PAUSED or PLAYING.
// Also we have to wait for the decodebin to be connected.
// Seeking while the pipeline is in the READY state doesn't work, so we have to wait until it goes to PAUSED or PLAYING. Also we have to wait for the decodebin to be connected.
bool pipeline_is_initialised_;
bool pipeline_is_connected_;
qint64 pending_seek_nanosec_;

View File

@ -435,11 +435,13 @@ void PlaylistManager::SelectionChanged(const QItemSelection &selection) {
}
void PlaylistManager::SongsDiscovered(const SongList &songs) {
qLog(Debug) << __PRETTY_FUNCTION__;
// Some songs might've changed in the collection, let's update any playlist
// items we have that match those songs
// Some songs might've changed in the collection, let's update any playlist items we have that match those songs
for (const Song &song : songs) {
qLog(Debug);
for (const Data &data : playlists_) {
PlaylistItemList items = data.p->collection_items_by_id(song.id());
for (PlaylistItemPtr item : items) {

View File

@ -134,8 +134,7 @@ void SongLoaderInserter::AsyncLoad() {
// First, quick load raw songs.
int async_progress = 0;
int async_load_id = task_manager_->StartTask(tr("Loading tracks"));
task_manager_->SetTaskProgress(async_load_id, async_progress,
pending_.count());
task_manager_->SetTaskProgress(async_load_id, async_progress, pending_.count());
for (int i = 0; i < pending_.count(); ++i) {
SongLoader *loader = pending_[i];
loader->LoadFilenamesBlocking();

View File

@ -47,8 +47,7 @@ const char *PlayingWidget::kSettingsGroup = "PlayingWidget";
// Space between the cover and the details in small mode
const int PlayingWidget::kPadding = 2;
// Width of the transparent to black gradient above and below the text in large
// mode
// Width of the transparent to black gradient above and below the text in large mode
const int PlayingWidget::kGradientHead = 40;
const int PlayingWidget::kGradientTail = 20;
@ -65,7 +64,7 @@ PlayingWidget::PlayingWidget(QWidget *parent)
: QWidget(parent),
app_(nullptr),
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
//mode_(SmallSongDetails),
mode_(SmallSongDetails),
menu_(new QMenu(this)),
fit_cover_width_action_(nullptr),
enabled_(false),
@ -79,8 +78,6 @@ PlayingWidget::PlayingWidget(QWidget *parent)
previous_track_opacity_(0.0),
downloading_covers_(false) {
//qLog(Debug) << __PRETTY_FUNCTION__;
enabled_ = false;
visible_ = false;
active_ = false;
@ -152,14 +149,9 @@ PlayingWidget::PlayingWidget(QWidget *parent)
}
PlayingWidget::~PlayingWidget() {
//qLog(Debug) << __PRETTY_FUNCTION__;
}
void PlayingWidget::SetApplication(Application *app) {
//qLog(Debug) << __PRETTY_FUNCTION__;
app_ = app;
@ -180,8 +172,6 @@ void PlayingWidget::CreateModeAction(Mode mode, const QString &text, QActionGrou
}
void PlayingWidget::set_ideal_height(int height) {
//qLog(Debug) << __PRETTY_FUNCTION__;
small_ideal_height_ = height;
UpdateHeight();
@ -190,16 +180,12 @@ void PlayingWidget::set_ideal_height(int height) {
QSize PlayingWidget::sizeHint() const {
//qLog(Debug) << __PRETTY_FUNCTION__;
return QSize(cover_loader_options_.desired_height_, total_height_);
}
void PlayingWidget::UpdateHeight() {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch (mode_) {
case SmallSongDetails:
cover_loader_options_.desired_height_ = small_ideal_height_;
@ -227,8 +213,6 @@ void PlayingWidget::UpdateHeight() {
}
void PlayingWidget::Stopped() {
//qLog(Debug) << __PRETTY_FUNCTION__;
active_ = false;
SetVisible(false);
@ -236,8 +220,6 @@ void PlayingWidget::Stopped() {
}
void PlayingWidget::UpdateDetailsText() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QString html;
@ -279,16 +261,12 @@ void PlayingWidget::UpdateDetailsText() {
void PlayingWidget::ScaleCover() {
//qLog(Debug) << __PRETTY_FUNCTION__;
cover_ = QPixmap::fromImage(AlbumCoverLoader::ScaleAndPad(cover_loader_options_, original_));
update();
}
void PlayingWidget::AlbumArtLoaded(const Song &metadata, const QString &, const QImage &image) {
//qLog(Debug) << __PRETTY_FUNCTION__;
active_ = true;
@ -304,8 +282,6 @@ void PlayingWidget::AlbumArtLoaded(const Song &metadata, const QString &, const
void PlayingWidget::SetImage(const QImage &image) {
//qLog(Debug) << __PRETTY_FUNCTION__;
active_ = true;
if (visible_) {
@ -333,17 +309,12 @@ void PlayingWidget::SetImage(const QImage &image) {
void PlayingWidget::SetHeight(int height) {
//qLog(Debug) << __PRETTY_FUNCTION__;
setMaximumHeight(height);
}
void PlayingWidget::SetVisible(bool visible) {
//qLog(Debug) << __PRETTY_FUNCTION__ << visible;
//if (enabled_ == false) return;
if (visible == visible_) return;
visible_ = visible;
@ -353,8 +324,6 @@ void PlayingWidget::SetVisible(bool visible) {
}
void PlayingWidget::paintEvent(QPaintEvent *e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QPainter p(this);
@ -369,8 +338,6 @@ void PlayingWidget::paintEvent(QPaintEvent *e) {
void PlayingWidget::DrawContents(QPainter *p) {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch (mode_) {
case SmallSongDetails:
// Draw the cover
@ -412,8 +379,6 @@ void PlayingWidget::DrawContents(QPainter *p) {
}
void PlayingWidget::FadePreviousTrack(qreal value) {
//qLog(Debug) << __PRETTY_FUNCTION__;
previous_track_opacity_ = value;
if (qFuzzyCompare(previous_track_opacity_, qreal(0.0))) {
@ -446,8 +411,6 @@ void PlayingWidget::SetMode(int mode) {
}
void PlayingWidget::resizeEvent(QResizeEvent* e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (visible_ && e->oldSize() != e->size()) {
if (mode_ == LargeSongDetails) {
@ -459,8 +422,6 @@ void PlayingWidget::resizeEvent(QResizeEvent* e) {
}
void PlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
// show the menu
menu_->popup(mapToGlobal(e->pos()));
@ -472,8 +433,6 @@ void PlayingWidget::mouseReleaseEvent(QMouseEvent*) {
}
void PlayingWidget::FitCoverWidth(bool fit) {
//qLog(Debug) << __PRETTY_FUNCTION__;
fit_width_ = fit;
UpdateHeight();
@ -520,8 +479,6 @@ void PlayingWidget::SearchCoverAutomatically() {
}
void PlayingWidget::dragEnterEvent(QDragEnterEvent *e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (AlbumCoverChoiceController::CanAcceptDrag(e)) {
e->acceptProposedAction();
@ -532,8 +489,6 @@ void PlayingWidget::dragEnterEvent(QDragEnterEvent *e) {
}
void PlayingWidget::dropEvent(QDropEvent *e) {
//qLog(Debug) << __PRETTY_FUNCTION__;
album_cover_choice_controller_->SaveCover(&metadata_, e);
@ -542,8 +497,6 @@ void PlayingWidget::dropEvent(QDropEvent *e) {
}
bool PlayingWidget::GetCoverAutomatically() {
//qLog(Debug) << __PRETTY_FUNCTION__;
// Search for cover automatically?
bool search =
@ -570,8 +523,6 @@ bool PlayingWidget::GetCoverAutomatically() {
void PlayingWidget::AutomaticCoverSearchDone() {
//qLog(Debug) << __PRETTY_FUNCTION__;
downloading_covers_ = false;
spinner_animation_.reset();
update();
@ -580,8 +531,6 @@ void PlayingWidget::AutomaticCoverSearchDone() {
void PlayingWidget::SetEnabled() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (enabled_ == true) return;
if ((active_ == true) && (visible_ == false)) SetVisible(true);
@ -591,8 +540,6 @@ void PlayingWidget::SetEnabled() {
}
void PlayingWidget::SetDisabled() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (enabled_ == false) return;