Commit b1ae890a authored by David Redondo's avatar David Redondo 🏎 Committed by Nate Graham

Allow single images to be excluded from the slideshow

Summary:
This allows to exlude single images from the slideshow by unchecking the little checkbox in the top right corner.
Feature or todo?: If a folder is removed I don't touch the unchecked Slides. So the list could get very big but if a formerly removed folder is
added again an excluded image will be excluded again.

Test Plan:
{F6684113}
- Uncheck some images
- They don't appear in the slideshow

Reviewers: #plasma, #vdg, ngraham, davidedmundson

Reviewed By: #plasma, #vdg, ngraham, davidedmundson

Subscribers: davidedmundson, filipf, abetts, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19687
parent 2a63696f
......@@ -67,7 +67,8 @@ public:
PathRole,
PackageNameRole,
RemovableRole,
PendingDeletionRole
PendingDeletionRole,
ToggleRole
};
static const int BLUR_INCREMENT = 9;
......
......@@ -620,6 +620,9 @@ void Image::backgroundsFound(const QStringList &paths, const QString &token)
return;
}
m_slideshowBackgrounds = paths;
for(const QString &slide : qAsConst(m_uncheckedSlides)) {
m_slideshowBackgrounds.removeAll(QUrl(slide).path());
}
m_unseenSlideshowBackgrounds.clear();
// start slideshow
if (m_slideshowBackgrounds.isEmpty()) {
......@@ -896,3 +899,31 @@ void Image::openFolder(const QString& path)
{
new KRun(QUrl::fromLocalFile(path), nullptr);
}
void Image::toggleSlide(const QString& path, bool checked)
{
if (checked && m_uncheckedSlides.contains(path)) {
m_uncheckedSlides.removeAll(path);
emit uncheckedSlidesChanged();
startSlideshow();
} else if (!checked && ! m_uncheckedSlides.contains(path)) {
m_uncheckedSlides.append(path);
emit uncheckedSlidesChanged();
startSlideshow();
}
}
QStringList Image::uncheckedSlides() const
{
return m_uncheckedSlides;
}
void Image::setUncheckedSlides(const QStringList &uncheckedSlides)
{
if (uncheckedSlides == m_uncheckedSlides) {
return;
}
m_uncheckedSlides = uncheckedSlides;
emit uncheckedSlidesChanged();
startSlideshow();
}
......@@ -64,6 +64,7 @@ class Image : public QObject, public QQmlParserStatus
Q_PROPERTY(QStringList slidePaths READ slidePaths WRITE setSlidePaths NOTIFY slidePathsChanged)
Q_PROPERTY(QSize targetSize READ targetSize WRITE setTargetSize NOTIFY targetSizeChanged)
Q_PROPERTY(QString photosPath READ photosPath CONSTANT)
Q_PROPERTY(QStringList uncheckedSlides READ uncheckedSlides WRITE setUncheckedSlides NOTIFY uncheckedSlidesChanged)
public:
......@@ -92,6 +93,8 @@ class Image : public QObject, public QQmlParserStatus
Q_INVOKABLE void addUsersWallpaper(const QString &file);
Q_INVOKABLE void commitDeletion();
Q_INVOKABLE void toggleSlide(const QString &path, bool checked);
RenderingMode renderingMode() const;
void setRenderingMode(RenderingMode mode);
......@@ -120,6 +123,9 @@ class Image : public QObject, public QQmlParserStatus
QString photosPath() const;
QStringList uncheckedSlides() const;
void setUncheckedSlides(const QStringList &uncheckedSlides);
public Q_SLOTS:
void nextSlide();
void removeWallpaper(QString name);
......@@ -134,6 +140,7 @@ class Image : public QObject, public QQmlParserStatus
void slidePathsChanged();
void resizeMethodChanged();
void customWallpaperPicked(const QString &path);
void uncheckedSlidesChanged();
protected Q_SLOTS:
void showAddSlidePathsDialog();
......@@ -179,6 +186,7 @@ class Image : public QObject, public QQmlParserStatus
QStringList m_slideshowBackgrounds;
QStringList m_unseenSlideshowBackgrounds;
QStringList m_slidePaths;
QStringList m_uncheckedSlides;
QTimer m_timer;
int m_currentSlide;
BackgroundListModel *m_model;
......
......@@ -116,6 +116,13 @@ KCM.GridDelegate {
return QPixmapItem.PreserveAspectFit;
}
}
QtControls2.CheckBox {
visible: configDialog.currentWallpaper == "org.kde.slideshow"
anchors.right: parent.right
anchors.top: parent.top
checked: visible ? model.checked : false
onToggled: imageWallpaper.toggleSlide(model.path, checked)
}
}
onClicked: {
......
......@@ -38,6 +38,7 @@ ColumnLayout {
property alias cfg_Blur: blurRadioButton.checked
property var cfg_SlidePaths: ""
property int cfg_SlideInterval: 0
property var cfg_UncheckedSlides: []
function saveConfig() {
imageWallpaper.commitDeletion();
......@@ -57,11 +58,15 @@ ColumnLayout {
return Qt.size(Screen.width, Screen.height)
}
onSlidePathsChanged: cfg_SlidePaths = slidePaths
onUncheckedSlidesChanged: cfg_UncheckedSlides = uncheckedSlides
}
onCfg_SlidePathsChanged: {
imageWallpaper.slidePaths = cfg_SlidePaths
}
onCfg_UncheckedSlidesChanged: {
imageWallpaper.uncheckedSlides = cfg_UncheckedSlides
}
property int hoursIntervalValue: Math.floor(cfg_SlideInterval / 3600)
property int minutesIntervalValue: Math.floor(cfg_SlideInterval % 3600) / 60
......
......@@ -68,6 +68,7 @@ QQC2.StackView {
targetSize: Qt.size(root.width, root.height)
slidePaths: wallpaper.configuration.SlidePaths
slideTimer: wallpaper.configuration.SlideInterval
uncheckedSlides: wallpaper.configuration.UncheckedSlides
}
onFillModeChanged: Qt.callLater(loadImage);
......
......@@ -42,3 +42,18 @@ void SlideModel::removeBackgrounds(const QStringList &paths, const QString &toke
removeBackground(file);
}
}
QVariant SlideModel::data(const QModelIndex& index, int role) const
{
if (role == ToggleRole) {
return !m_wallpaper.data()->uncheckedSlides().contains(data(index, PathRole).toString());
}
return BackgroundListModel::data(index, role);
}
QHash<int, QByteArray> SlideModel::roleNames() const
{
QHash<int, QByteArray> roleNames = BackgroundListModel::roleNames();
roleNames.insert(ToggleRole, "checked");
return roleNames;
}
......@@ -11,6 +11,8 @@ public:
void reload(const QStringList &selected);
void addDirs(const QStringList &selected);
void removeDir(const QString &selected);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
private Q_SLOTS:
void removeBackgrounds(const QStringList &paths, const QString &token);
void backgroundsFound(const QStringList &paths, const QString &token);
......
......@@ -34,6 +34,10 @@
<label>Fade Transition Animation (ms)</label>
<default>1000</default>
</entry>
<entry name="UncheckedSlides" type="StringList">
<label>Unchecked Slides</label>
<default></default>
</entry>
</group>
</kcfg>
Markdown is supported
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