diff --git a/wallpapers/image/CMakeLists.txt b/wallpapers/image/CMakeLists.txt --- a/wallpapers/image/CMakeLists.txt +++ b/wallpapers/image/CMakeLists.txt @@ -6,6 +6,11 @@ backgroundlistmodel.cpp ) +ecm_qt_declare_logging_category(image_SRCS HEADER debug.h + IDENTIFIER IMAGEWALLPAPER + CATEGORY_NAME kde.wallpapers.image + DEFAULT_SEVERITY Info) + add_library(plasma_wallpaper_imageplugin SHARED ${image_SRCS}) target_link_libraries(plasma_wallpaper_imageplugin diff --git a/wallpapers/image/backgroundlistmodel.cpp b/wallpapers/image/backgroundlistmodel.cpp --- a/wallpapers/image/backgroundlistmodel.cpp +++ b/wallpapers/image/backgroundlistmodel.cpp @@ -20,6 +20,7 @@ #ifndef BACKGROUNDLISTMODEL_CPP #define BACKGROUNDLISTMODEL_CPP +#include "debug.h" #include "backgroundlistmodel.h" #include @@ -123,12 +124,12 @@ } if (!selected.isEmpty()) { - qDebug() << "selected" << selected; + qCDebug(IMAGEWALLPAPER) << "selected" << selected; processPaths(selected); } const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers/"), QStandardPaths::LocateDirectory); - qDebug() << " WP : -------" << dirs; + qCDebug(IMAGEWALLPAPER) << "Looking into" << dirs << "for wallpapers"; BackgroundFinder *finder = new BackgroundFinder(m_wallpaper.data(), dirs); connect(finder, &BackgroundFinder::backgroundsFound, this, &BackgroundListModel::backgroundsFound); @@ -206,7 +207,7 @@ endInsertRows(); emit countChanged(); } - //qDebug() << t.elapsed(); + //qCDebug(IMAGEWALLPAPER) << t.elapsed(); } void BackgroundListModel::addBackground(const QString& path) @@ -221,7 +222,7 @@ m_removableWallpapers.insert(path); package.setPath(path); m_wallpaper->findPreferedImageInPackage(package); - qDebug() << "WP Bckground added " << path << package.isValid(); + qCDebug(IMAGEWALLPAPER) << "Background added " << path << package.isValid(); m_packages.prepend(package); endInsertRows(); emit countChanged(); @@ -242,7 +243,7 @@ if (filteredPath.startsWith(package)) { // FIXME: ugly hack to make a difference between local files in the same dir // package->path does not contain the actual file name - qDebug() << "WP prefix" << m_packages[i].contentsPrefixPaths() << m_packages[i].filePath("preferred") << package << filteredPath; + qCDebug(IMAGEWALLPAPER) << "prefix" << m_packages[i].contentsPrefixPaths() << m_packages[i].filePath("preferred") << package << filteredPath; QStringList ps = m_packages[i].contentsPrefixPaths(); bool prefixempty = ps.count() == 0; if (!prefixempty) { @@ -257,7 +258,6 @@ //E.X. filteredPath = /usr/share/wallpapers/Next/" //m_packages[i].filePath("preferred") = "/usr/share/wallpapers/Next/contents/images/1920x1080.png" if ((filteredPath == m_packages[i].filePath("preferred")) || m_packages[i].filePath("preferred").contains(filteredPath)) { - qDebug() << "WP TRUE" << (!m_packages[i].contentsPrefixPaths().isEmpty()) << (filteredPath == m_packages[i].filePath("preferred")); return i; } } @@ -267,7 +267,7 @@ bool BackgroundListModel::contains(const QString &path) const { - //qDebug() << "WP contains: " << path << indexOf(path).isValid(); + //qCDebug(IMAGEWALLPAPER) << "WP contains: " << path << indexOf(path).isValid(); return indexOf(path) >= 0; } @@ -344,8 +344,8 @@ if (m_imageCache->findPixmap(b.filePath("preferred"), &preview)) { return preview; } -// qDebug() << "WP preferred: " << b.filePath("preferred"); -// qDebug() << "WP screenshot: " << b.filePath("screenshot"); +// qCDebug(IMAGEWALLPAPER) << "WP preferred: " << b.filePath("preferred"); +// qCDebug(IMAGEWALLPAPER) << "WP screenshot: " << b.filePath("screenshot"); QUrl file = QUrl::fromLocalFile(b.filePath("preferred")); if (!m_previewJobs.contains(file) && file.isValid()) { @@ -456,7 +456,7 @@ } m_imageCache->insertPixmap(b.filePath("preferred"), preview); - //qDebug() << "WP preview size:" << preview.size(); + //qCDebug(IMAGEWALLPAPER) << "WP preview size:" << preview.size(); emit dataChanged(index, index); } @@ -551,7 +551,7 @@ const QFileInfoList files = dir.entryInfoList(); Q_FOREACH (const QFileInfo &wp, files) { if (wp.isDir()) { - //qDebug() << "scanning directory" << wp.fileName(); + //qCDebug(IMAGEWALLPAPER) << "scanning directory" << wp.fileName(); const QString name = wp.fileName(); if (name == QString::fromLatin1(".") || name == QString::fromLatin1("..")) { @@ -566,21 +566,21 @@ if (!package.filePath("images").isEmpty()) { papersFound << package.path(); } - //qDebug() << "adding package" << wp.filePath(); + //qCDebug(IMAGEWALLPAPER) << "adding package" << wp.filePath(); continue; } } // add this to the directories we should be looking at m_paths.append(filePath); } else { - //qDebug() << "adding image file" << wp.filePath(); + //qCDebug(IMAGEWALLPAPER) << "adding image file" << wp.filePath(); papersFound << wp.filePath(); } } } - //qDebug() << "WP background found!" << papersFound.size() << "in" << i << "dirs, taking" << t.elapsed() << "ms"; + //qCDebug(IMAGEWALLPAPER) << "WP background found!" << papersFound.size() << "in" << i << "dirs, taking" << t.elapsed() << "ms"; Q_EMIT backgroundsFound(papersFound, m_token); deleteLater(); } diff --git a/wallpapers/image/image.cpp b/wallpapers/image/image.cpp --- a/wallpapers/image/image.cpp +++ b/wallpapers/image/image.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "image.h" +#include "debug.h" #include #include // FLT_MAX @@ -180,7 +181,7 @@ } //float targetAspectRatio = (m_targetSize.height() > 0 ) ? m_targetSize.width() / (float)m_targetSize.height() : 0; - //qDebug() << "wanted" << m_targetSize << "options" << images << "aspect ratio" << targetAspectRatio; + //qCDebug(IMAGEWALLPAPER) << "wanted" << m_targetSize << "options" << images << "aspect ratio" << targetAspectRatio; float best = FLT_MAX; QString bestImage; @@ -192,16 +193,16 @@ //float candidateAspectRatio = (candidate.height() > 0 ) ? candidate.width() / (float)candidate.height() : FLT_MAX; float dist = distance(candidate, m_targetSize); - //qDebug() << "candidate" << candidate << "distance" << dist << "aspect ratio" << candidateAspectRatio; + //qCDebug(IMAGEWALLPAPER) << "candidate" << candidate << "distance" << dist << "aspect ratio" << candidateAspectRatio; if (bestImage.isEmpty() || dist < best) { bestImage = entry; best = dist; - //qDebug() << "best" << bestImage; + //qCDebug(IMAGEWALLPAPER) << "best" << bestImage; } } - //qDebug() << "best image" << bestImage; + //qCDebug(IMAGEWALLPAPER) << "best image" << bestImage; return bestImage; } @@ -753,7 +754,7 @@ // open in image viewer QUrl filepath(m_wallpaperPackage.filePath("preferred")); - qDebug() << "opening file " << filepath.path(); + qCDebug(IMAGEWALLPAPER) << "opening file " << filepath.path(); new KRun(filepath, NULL); }