Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/imagepackage/contents/ui/main.qml
Show All 21 Lines | |||||
22 | import QtQuick.Controls 2.1 as QQC2 | 22 | import QtQuick.Controls 2.1 as QQC2 | ||
23 | import QtQuick.Window 2.2 | 23 | import QtQuick.Window 2.2 | ||
24 | import QtGraphicalEffects 1.0 | 24 | import QtGraphicalEffects 1.0 | ||
25 | import org.kde.plasma.wallpapers.image 2.0 as Wallpaper | 25 | import org.kde.plasma.wallpapers.image 2.0 as Wallpaper | ||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
27 | 27 | | |||
28 | QQC2.StackView { | 28 | QQC2.StackView { | ||
29 | id: root | 29 | id: root | ||
30 | 30 | anchors.fill: parent | |||
31 | readonly property string modelImage: imageWallpaper.wallpaperPath | 31 | readonly property string modelImage: imageWallpaper.wallpaperPath | ||
32 | readonly property string configuredImage: wallpaper.configuration.Image | 32 | readonly property string configuredImage: wallpaper.configuration.Image | ||
33 | readonly property int fillMode: wallpaper.configuration.FillMode | 33 | readonly property int fillMode: wallpaper.configuration.FillMode | ||
34 | readonly property string configColor: wallpaper.configuration.Color | 34 | readonly property string configColor: wallpaper.configuration.Color | ||
35 | readonly property bool blur: wallpaper.configuration.Blur | 35 | readonly property bool blur: wallpaper.configuration.Blur | ||
36 | readonly property size sourceSize: Qt.size(root.width * Screen.devicePixelRatio, root.height * Screen.devicePixelRatio) | 36 | readonly property size sourceSize: Qt.size(root.width * Screen.devicePixelRatio, root.height * Screen.devicePixelRatio) | ||
37 | 37 | | |||
38 | //public API, the C++ part will look for those | 38 | //public API, the C++ part will look for those | ||
39 | function setUrl(url) { | 39 | function setUrl(url) { | ||
40 | wallpaper.configuration.Image = url | 40 | wallpaper.configuration.Image = url | ||
41 | imageWallpaper.addUsersWallpaper(url); | 41 | imageWallpaper.addUsersWallpaper(url); | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | function action_next() { | 44 | function action_next() { | ||
45 | imageWallpaper.nextSlide(); | 45 | imageWallpaper.nextSlide(); | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | function action_open() { | 48 | function action_open() { | ||
49 | Qt.openUrlExternally(modelImage) | 49 | Qt.openUrlExternally(modelImage) | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | WindowModel { | ||||
53 | id: windowModel | ||||
54 | } | ||||
55 | | ||||
52 | //private | 56 | //private | ||
53 | 57 | | |||
54 | onConfiguredImageChanged: { | 58 | onConfiguredImageChanged: { | ||
55 | if (modelImage != configuredImage && configuredImage != "") { | 59 | if (modelImage != configuredImage && configuredImage != "") { | ||
56 | imageWallpaper.addUrl(configuredImage); | 60 | imageWallpaper.addUrl(configuredImage); | ||
57 | } | 61 | } | ||
58 | } | 62 | } | ||
59 | Component.onCompleted: { | 63 | Component.onCompleted: { | ||
Show All 29 Lines | |||||
89 | function loadImage() { | 93 | function loadImage() { | ||
90 | var isFirst = (root.currentItem == undefined); | 94 | var isFirst = (root.currentItem == undefined); | ||
91 | var pendingImage = baseImage.createObject(root, { "source": root.modelImage, | 95 | var pendingImage = baseImage.createObject(root, { "source": root.modelImage, | ||
92 | "fillMode": root.fillMode, | 96 | "fillMode": root.fillMode, | ||
93 | "sourceSize": root.sourceSize, | 97 | "sourceSize": root.sourceSize, | ||
94 | "color": root.configColor, | 98 | "color": root.configColor, | ||
95 | "blur": root.blur, | 99 | "blur": root.blur, | ||
96 | "opacity": isFirst ? 1: 0}); | 100 | "opacity": isFirst ? 1: 0}); | ||
101 | var pendingBlur = baseBlur.createObject(root, {"source": pendingImage, | ||||
102 | "anchors.fill": pendingImage | ||||
103 | }) | ||||
97 | 104 | | |||
98 | function replaceWhenLoaded() { | 105 | function replaceWhenLoaded() { | ||
99 | if (pendingImage.status !== Image.Loading) { | 106 | if (pendingImage.status !== Image.Loading) { | ||
100 | root.replace(pendingImage, {}, | 107 | root.replace(pendingImage, {}, | ||
101 | isFirst ? QQC2.StackView.Immediate : QQC2.StackView.Transition);//dont' animate first show | 108 | isFirst ? QQC2.StackView.Immediate : QQC2.StackView.Transition);//dont' animate first show | ||
102 | pendingImage.statusChanged.disconnect(replaceWhenLoaded); | 109 | pendingImage.statusChanged.disconnect(replaceWhenLoaded); | ||
103 | 110 | | |||
104 | wallpaper.loading = false; | 111 | wallpaper.loading = false; | ||
105 | } | 112 | } | ||
106 | } | 113 | } | ||
107 | pendingImage.statusChanged.connect(replaceWhenLoaded); | 114 | pendingImage.statusChanged.connect(replaceWhenLoaded); | ||
108 | replaceWhenLoaded(); | 115 | replaceWhenLoaded(); | ||
109 | } | 116 | } | ||
110 | 117 | | |||
111 | Component { | 118 | Component { | ||
119 | id: baseBlur | ||||
120 | FastBlur { | ||||
121 | radius: ((!wallpaper.configuration.BlurWallpaper) || windowModel.noWindowActive) ? 0 : wallpaper.configuration.BlurRadius | ||||
122 | Behavior on radius { | ||||
123 | NumberAnimation { duration: wallpaper.configuration.BlurAnimationDuration } | ||||
124 | } | ||||
125 | } | ||||
126 | } | ||||
127 | | ||||
128 | Component { | ||||
112 | id: baseImage | 129 | id: baseImage | ||
113 | 130 | | |||
114 | Image { | 131 | Image { | ||
115 | id: mainImage | 132 | id: mainImage | ||
116 | 133 | | |||
117 | property alias color: backgroundColor.color | 134 | property alias color: backgroundColor.color | ||
118 | property bool blur: false | 135 | property bool blur: false | ||
119 | 136 | | |||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |