diff --git a/wallpapers/image/backgroundlistmodel.h b/wallpapers/image/backgroundlistmodel.h --- a/wallpapers/image/backgroundlistmodel.h +++ b/wallpapers/image/backgroundlistmodel.h @@ -67,7 +67,8 @@ PathRole, PackageNameRole, RemovableRole, - PendingDeletionRole + PendingDeletionRole, + ToggleRole }; static const int BLUR_INCREMENT = 9; diff --git a/wallpapers/image/image.h b/wallpapers/image/image.h --- a/wallpapers/image/image.h +++ b/wallpapers/image/image.h @@ -64,6 +64,7 @@ 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 @@ 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 @@ QString photosPath() const; + QStringList uncheckedSlides() const; + void setUncheckedSlides(const QStringList &uncheckedSlides); + public Q_SLOTS: void nextSlide(); void removeWallpaper(QString name); @@ -134,6 +140,7 @@ void slidePathsChanged(); void resizeMethodChanged(); void customWallpaperPicked(const QString &path); + void uncheckedSlidesChanged(); protected Q_SLOTS: void showAddSlidePathsDialog(); @@ -179,6 +186,7 @@ QStringList m_slideshowBackgrounds; QStringList m_unseenSlideshowBackgrounds; QStringList m_slidePaths; + QStringList m_uncheckedSlides; QTimer m_timer; int m_currentSlide; BackgroundListModel *m_model; diff --git a/wallpapers/image/image.cpp b/wallpapers/image/image.cpp --- a/wallpapers/image/image.cpp +++ b/wallpapers/image/image.cpp @@ -620,6 +620,9 @@ return; } m_slideshowBackgrounds = paths; + Q_FOREACH(const QString &slide, m_uncheckedSlides) { + m_slideshowBackgrounds.removeAll(QUrl(slide).path()); + } m_unseenSlideshowBackgrounds.clear(); // start slideshow if (m_slideshowBackgrounds.isEmpty()) { @@ -896,3 +899,31 @@ { 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(); +} diff --git a/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml b/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml --- a/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml +++ b/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml @@ -116,6 +116,13 @@ return QPixmapItem.PreserveAspectFit; } } + QtControls2.CheckBox { + visible: configDialog.currentWallpaper == "org.kde.slideshow" + anchors.right: parent.right + anchors.top: parent.top + checked: visible ? model.toggled : false + onToggled: imageWallpaper.toggleSlide(model.path, checked) + } } onClicked: { diff --git a/wallpapers/image/imagepackage/contents/ui/config.qml b/wallpapers/image/imagepackage/contents/ui/config.qml --- a/wallpapers/image/imagepackage/contents/ui/config.qml +++ b/wallpapers/image/imagepackage/contents/ui/config.qml @@ -38,6 +38,7 @@ 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 @@ 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 diff --git a/wallpapers/image/imagepackage/contents/ui/main.qml b/wallpapers/image/imagepackage/contents/ui/main.qml --- a/wallpapers/image/imagepackage/contents/ui/main.qml +++ b/wallpapers/image/imagepackage/contents/ui/main.qml @@ -68,6 +68,7 @@ targetSize: Qt.size(root.width, root.height) slidePaths: wallpaper.configuration.SlidePaths slideTimer: wallpaper.configuration.SlideInterval + uncheckedSlides: wallpaper.configuration.UncheckedSlides } onFillModeChanged: Qt.callLater(loadImage); diff --git a/wallpapers/image/slidemodel.h b/wallpapers/image/slidemodel.h --- a/wallpapers/image/slidemodel.h +++ b/wallpapers/image/slidemodel.h @@ -11,6 +11,8 @@ 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 roleNames() const override; private Q_SLOTS: void removeBackgrounds(const QStringList &paths, const QString &token); void backgroundsFound(const QStringList &paths, const QString &token); diff --git a/wallpapers/image/slidemodel.cpp b/wallpapers/image/slidemodel.cpp --- a/wallpapers/image/slidemodel.cpp +++ b/wallpapers/image/slidemodel.cpp @@ -42,3 +42,18 @@ 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 SlideModel::roleNames() const +{ + QHash roleNames = BackgroundListModel::roleNames(); + roleNames.insert(ToggleRole, "toggled"); + return roleNames; +} diff --git a/wallpapers/image/slideshowpackage/contents/config/main.xml b/wallpapers/image/slideshowpackage/contents/config/main.xml --- a/wallpapers/image/slideshowpackage/contents/config/main.xml +++ b/wallpapers/image/slideshowpackage/contents/config/main.xml @@ -34,6 +34,10 @@ 1000 + + + +