diff --git a/wallpapers/image/image.cpp b/wallpapers/image/image.cpp index 55c9efb44..e18df00d7 100644 --- a/wallpapers/image/image.cpp +++ b/wallpapers/image/image.cpp @@ -101,6 +101,11 @@ void Image::componentComplete() } } +QString Image::photosPath() const +{ + return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); +} + QString Image::wallpaperPath() const { return m_wallpaperPath; diff --git a/wallpapers/image/image.h b/wallpapers/image/image.h index f032804c7..b7760ab2d 100644 --- a/wallpapers/image/image.h +++ b/wallpapers/image/image.h @@ -60,6 +60,7 @@ class Image : public QObject, public QQmlParserStatus Q_PROPERTY(QStringList slidePaths READ slidePaths WRITE setSlidePaths NOTIFY slidePathsChanged) Q_PROPERTY(int width MEMBER m_width READ width WRITE setWidth NOTIFY sizeChanged) Q_PROPERTY(int height MEMBER m_height READ height WRITE setHeight NOTIFY sizeChanged) + Q_PROPERTY(QString photosPath READ photosPath CONSTANT) public: @@ -116,6 +117,8 @@ class Image : public QObject, public QQmlParserStatus void classBegin() override; void componentComplete() override; + QString photosPath() const; + public Q_SLOTS: void nextSlide(); void removeWallpaper(QString name); diff --git a/wallpapers/image/imagepackage/platformcontents/phone/ui/WallpaperDelegate.qml b/wallpapers/image/imagepackage/platformcontents/phone/ui/WallpaperDelegate.qml index c5f7606b9..e46a2c715 100644 --- a/wallpapers/image/imagepackage/platformcontents/phone/ui/WallpaperDelegate.qml +++ b/wallpapers/image/imagepackage/platformcontents/phone/ui/WallpaperDelegate.qml @@ -94,13 +94,6 @@ MouseArea { flat: false visible: model.removable onClicked: imageWallpaper.removeWallpaper(model.packageName) - opacity: wallpaperDelegate.containsMouse ? 1 : 0 - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } - } } } } diff --git a/wallpapers/image/imagepackage/platformcontents/phone/ui/config.qml b/wallpapers/image/imagepackage/platformcontents/phone/ui/config.qml index 9f8ce30d4..3f309ae00 100644 --- a/wallpapers/image/imagepackage/platformcontents/phone/ui/config.qml +++ b/wallpapers/image/imagepackage/platformcontents/phone/ui/config.qml @@ -75,4 +75,19 @@ Item { } } } + + QtControls.Button { + anchors { + bottom: parent.bottom + horizontalCenter: parent.horizontalCenter + } + iconName: "list-add" + text: i18nd("plasma_applet_org.kde.image","Add Custom Wallpaper") + onClicked: customWallpaperLoader.source = Qt.resolvedUrl("customwallpaper.qml") + } + + Loader { + id: customWallpaperLoader + anchors.fill: parent + } } diff --git a/wallpapers/image/imagepackage/platformcontents/phone/ui/customwallpaper.qml b/wallpapers/image/imagepackage/platformcontents/phone/ui/customwallpaper.qml new file mode 100644 index 000000000..53e5ed284 --- /dev/null +++ b/wallpapers/image/imagepackage/platformcontents/phone/ui/customwallpaper.qml @@ -0,0 +1,88 @@ +/* + * Copyright 2015 Marco Martin + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.0 +import Qt.labs.folderlistmodel 2.1 +//We need units from it +import org.kde.plasma.core 2.0 as Plasmacore +import org.kde.plasma.wallpapers.image 2.0 as Wallpaper +import org.kde.kquickcontrolsaddons 2.0 +import QtQuick.Controls 1.0 as QtControls + +Rectangle { + id: root + color: syspal.window + anchors.fill: parent + + SystemPalette {id: syspal} + + QtControls.ScrollView { + anchors.fill: parent + + frameVisible: true + + GridView { + id: customGrid + model: FolderListModel { + folder: imageWallpaper.photosPath + nameFilters: ["*.jpg", "*.png", "*.jpeg"] + showDirs: false + } + currentIndex: -1 + + cellWidth: Math.floor(customGrid.width / Math.max(Math.floor(customGrid.width / (units.gridUnit*12)), 3)) + cellHeight: cellWidth / (imageWallpaper.width / imageWallpaper.height) + + anchors.margins: 4 + boundsBehavior: Flickable.DragAndOvershootBounds + + delegate: MouseArea { + width: customGrid.cellWidth + height: customGrid.cellHeight + + onClicked: { + imageWallpaper.addUsersWallpaper(model.fileURL); + customWallpaperLoader.source = ""; + } + Rectangle { + color: "white" + anchors { + fill: parent + margins: units.smallSpacing + } + Image { + anchors { + fill: parent + margins: units.smallSpacing * 2 + } + source: model.fileURL + } + } + } + } + } + QtControls.Button { + anchors { + bottom: parent.bottom + horizontalCenter: parent.horizontalCenter + } + width: height + iconName: "go-previous" + onClicked: customWallpaperLoader.source = "" + } +}