A very basic ui to add custom wallpapers

add from ~/Pictures, the concept is to make
easy to add a new wallpaper from the photos taken
with the camera
wilder-5.14
Marco Martin 11 years ago
parent fa01d9d8a6
commit 67bec94567
  1. 5
      wallpapers/image/image.cpp
  2. 3
      wallpapers/image/image.h
  3. 7
      wallpapers/image/imagepackage/platformcontents/phone/ui/WallpaperDelegate.qml
  4. 15
      wallpapers/image/imagepackage/platformcontents/phone/ui/config.qml
  5. 88
      wallpapers/image/imagepackage/platformcontents/phone/ui/customwallpaper.qml

@ -101,6 +101,11 @@ void Image::componentComplete()
}
}
QString Image::photosPath() const
{
return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
}
QString Image::wallpaperPath() const
{
return m_wallpaperPath;

@ -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);

@ -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
}
}
}
}
}

@ -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
}
}

@ -0,0 +1,88 @@
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* 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 = ""
}
}
Loading…
Cancel
Save