2015-01-15 17:07:43 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BACKGROUNDLISTMODEL_H
|
|
|
|
#define BACKGROUNDLISTMODEL_H
|
|
|
|
|
2024-04-18 00:44:07 +03:00
|
|
|
#include <QAbstractListModel>
|
2015-01-15 17:07:43 +00:00
|
|
|
#include <QPixmap>
|
|
|
|
#include <QThread>
|
|
|
|
#include <KDirWatch>
|
|
|
|
#include <KFileItem>
|
|
|
|
#include <Plasma/Wallpaper>
|
|
|
|
|
|
|
|
class KProgressDialog;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class Package;
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
class BackgroundListModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BackgroundListModel(Plasma::Wallpaper *listener, QObject *parent);
|
|
|
|
virtual ~BackgroundListModel();
|
|
|
|
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
|
|
Plasma::Package *package(int index) const;
|
|
|
|
|
|
|
|
void reload(const QStringList &selected);
|
|
|
|
void addBackground(const QString &path);
|
|
|
|
QModelIndex indexOf(const QString &path) const;
|
|
|
|
virtual bool contains(const QString &bg) const;
|
|
|
|
|
|
|
|
void setWallpaperSize(const QSize& size);
|
|
|
|
void setResizeMethod(Plasma::Wallpaper::ResizeMethod resizeMethod);
|
|
|
|
|
|
|
|
protected Q_SLOTS:
|
2022-12-21 00:27:21 +02:00
|
|
|
void reload();
|
2015-01-15 17:07:43 +00:00
|
|
|
void showPreview(const KFileItem &item, const QPixmap &preview);
|
|
|
|
void previewFailed(const KFileItem &item);
|
|
|
|
void processPaths(const QStringList &paths);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QSize bestSize(Plasma::Package *package) const;
|
|
|
|
|
|
|
|
Plasma::Wallpaper *m_structureParent;
|
|
|
|
QList<Plasma::Package *> m_packages;
|
2023-08-12 01:04:41 +03:00
|
|
|
mutable QHash<Plasma::Package *, QSize> m_sizeCache;
|
2015-01-15 17:07:43 +00:00
|
|
|
QHash<Plasma::Package *, QPixmap> m_previews;
|
|
|
|
QHash<KUrl, QPersistentModelIndex> m_previewJobs;
|
|
|
|
KDirWatch m_dirwatch;
|
|
|
|
|
|
|
|
QSize m_size;
|
|
|
|
Plasma::Wallpaper::ResizeMethod m_resizeMethod;
|
|
|
|
QPixmap m_previewUnavailablePix;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BackgroundFinder : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BackgroundFinder(Plasma::Wallpaper *structureParent, const QStringList &p);
|
|
|
|
~BackgroundFinder();
|
|
|
|
|
|
|
|
signals:
|
2022-03-20 16:14:33 +02:00
|
|
|
void backgroundsFound(const QStringList &paths);
|
2015-01-15 17:07:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Plasma::PackageStructure::Ptr m_structure;
|
|
|
|
QStringList m_paths;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BACKGROUNDLISTMODEL_H
|