Verified Commit 5ac90429 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/image: Move ImageSizeFinder to finder/imagesizefinder.cpp

Don't crowd the code in backgroundlistmodel.cpp
parent 41697f9a
......@@ -4,6 +4,7 @@ set(image_SRCS
slidemodel.cpp
slidefiltermodel.cpp
sortingmode.h
finder/imagesizefinder.cpp
)
ecm_qt_declare_logging_category(image_SRCS HEADER debug.h
......
......@@ -36,21 +36,11 @@
#include <algorithm>
#include "finder/imagesizefinder.h"
QStringList BackgroundFinder::s_suffixes;
QMutex BackgroundFinder::s_suffixMutex;
ImageSizeFinder::ImageSizeFinder(const QString &path, QObject *parent)
: QObject(parent)
, m_path(path)
{
}
void ImageSizeFinder::run()
{
QImageReader reader(m_path);
Q_EMIT sizeFound(m_path, reader.size());
}
BackgroundListModel::BackgroundListModel(ImageBackend *wallpaper, QObject *parent)
: QAbstractListModel(parent)
, m_wallpaper(wallpaper)
......
......@@ -12,7 +12,6 @@
#include <QCache>
#include <QMutex>
#include <QPixmap>
#include <QRunnable>
#include <QSet>
#include <QThread>
......@@ -21,20 +20,6 @@
#include <KPackage/PackageStructure>
class ImageSizeFinder : public QObject, public QRunnable
{
Q_OBJECT
public:
explicit ImageSizeFinder(const QString &path, QObject *parent = nullptr);
void run() override;
Q_SIGNALS:
void sizeFound(const QString &path, const QSize &size);
private:
QString m_path;
};
class BackgroundListModel : public QAbstractListModel
{
Q_OBJECT
......
/*
SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "imagesizefinder.h"
#include <QImageReader>
ImageSizeFinder::ImageSizeFinder(const QString &path, QObject *parent)
: QObject(parent)
, m_path(path)
{
}
void ImageSizeFinder::run()
{
const QImageReader reader(m_path);
Q_EMIT sizeFound(m_path, reader.size());
}
/*
SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef IMAGESIZEFINDER_H
#define IMAGESIZEFINDER_H
#include <QObject>
#include <QRunnable>
/**
* A runnable that helps find the dimension of an image.
*/
class ImageSizeFinder : public QObject, public QRunnable
{
Q_OBJECT
public:
explicit ImageSizeFinder(const QString &path, QObject *parent = nullptr);
void run() override;
Q_SIGNALS:
void sizeFound(const QString &path, const QSize &size);
private:
QString m_path;
};
#endif // IMAGESIZEFINDER_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment