Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some warnings and add paralax effect to main screen wallpaper #90

Merged
merged 2 commits into from Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions glacier-home.pro
Expand Up @@ -88,6 +88,9 @@ appswitcher.path = /usr/share/lipstick-glacier-home-qt5/qml/appswitcher
appswitcher.files = src/qml/appswitcher/SwitcherItem.qml \
src/qml/appswitcher/CloseButton.qml

mainscreen.path = /usr/share/lipstick-glacier-home-qt5/qml/mainscreen
mainscreen.files = src/qml/mainscreen/Wallpaper.qml

settingswallpaperplugin.files = src/settings-plugins/wallpaper/wallpaper.qml \
src/settings-plugins/wallpaper/selectImage.qml \
src/settings-plugins/wallpaper/wallpaper.svg
Expand Down Expand Up @@ -127,6 +130,7 @@ INSTALLS += styles \
settingspluginconfig \
applauncher \
appswitcher \
mainscreen \
lockscreen \
systemd \
desktop
Expand Down
1 change: 1 addition & 0 deletions rpm/lipstick-glacier-home-qt5.spec
Expand Up @@ -14,6 +14,7 @@ Requires: nemo-qml-plugin-time-qt5
Requires: nemo-qml-plugin-dbus-qt5
Requires: nemo-qml-plugin-statusnotifier
Requires: qt5-qtdeclarative-import-window2
Requires: qt5-qtdeclarative-import-sensors
Requires: qt5-qtquickcontrols >= 5.3.1
Requires: qt5-qtquickcontrols-nemo >= 5.1.1
Requires: nemo-qml-plugin-contextkit-qt5
Expand Down
15 changes: 4 additions & 11 deletions src/qml/MainScreen.qml
Expand Up @@ -42,6 +42,7 @@ import org.nemomobile.devicelock 1.0
import org.nemomobile.statusnotifier 1.0

import "scripts/desktop.js" as Desktop
import "mainscreen"

Page {
id: desktop
Expand All @@ -59,12 +60,6 @@ Page {
wallClock.enabled = true
}
}
// This is used in the lock screen
ConfigurationValue {
id: wallpaperSource
key: "/home/glacier/homeScreen/wallpaperImage"
defaultValue: "/usr/share/lipstick-glacier-home-qt5/qml/images/wallpaper-portrait-bubbles.png"
}

StatusNotifierModel {
id: statusNotiferModel
Expand Down Expand Up @@ -168,12 +163,10 @@ Page {
currentIndex: 0
}

Image {
id:wallpaper
source: wallpaperSource.value
Wallpaper{
id: wallpaper
anchors.fill: parent
fillMode: Image.PreserveAspectCrop


z: -100
}

Expand Down
13 changes: 9 additions & 4 deletions src/qml/applauncher/LauncherItemWrapper.qml
Expand Up @@ -47,10 +47,15 @@ MouseArea {
transformOrigin: Item.Center
onXChanged: moved()
onYChanged: moved()
drag.minimumX: parentItem.contentItem.x - width/2
drag.maximumX: parentItem.contentItem.width + width/2
drag.minimumY: parentItem.contentItem.y -height/2 -height/4
drag.maximumY: parentItem.contentItem.height +height/2

Component.onCompleted: {
if(parentItem.contentItem !== null) {
drag.minimumX = parentItem.contentItem.x - width/2
drag.maximumX = parentItem.contentItem.width + width/2
drag.minimumY = parentItem.contentItem.y -height/2 -height/4
drag.maximumY = parentItem.contentItem.height +height/2
}
}

onClicked: {
// TODO: disallow if close mode enabled
Expand Down
83 changes: 83 additions & 0 deletions src/qml/mainscreen/Wallpaper.qml
@@ -0,0 +1,83 @@
import QtQuick 2.6
import QtSensors 5.2

import org.nemomobile.lipstick 0.1
import org.nemomobile.devicelock 1.0
import org.nemomobile.configuration 1.0

import "../scripts/desktop.js" as Desktop

Item {
id: wallpaper

property double maxX: wallpaper.width*0.1
property double maxY: wallpaper.height*0.1

ConfigurationValue {
id: wallpaperSource
key: "/home/glacier/homeScreen/wallpaperImage"
defaultValue: "/usr/share/lipstick-glacier-home-qt5/qml/images/wallpaper-portrait-bubbles.png"
}

ConfigurationValue {
id: enableParalax
key: "/home/glacier/homeScreen/enableParalax"
defaultValue: true
}

Accelerometer {
id: accelerometer
active: (enableParalax && !Desktop.instance.lockscreenVisible())
skipDuplicates: true

onReadingChanged: {
var calculateX = -maxX+maxX*accelerometer.reading.x*0.1
var calculateY = -maxY+maxY*accelerometer.reading.y*0.1
if(calculateX > maxX) {
calculateX = maxX
} else if (calculateX < -maxX) {
calculateX = -maxX
}

if(calculateY > maxY) {
calculateY = maxY
} else if (calculateY < -maxY) {
calculateX = -maxY
}

wallpaperImage.x = calculateX
wallpaperImage.y = calculateY
}
}

Image {
id:wallpaperImage
width: wallpaper.width*1.2
height: wallpaper.height*1.2

x: -maxX
y: -maxY

source: wallpaperSource.value
fillMode: Image.PreserveAspectCrop

Behavior on x {
NumberAnimation { duration: 200 }
}

Behavior on y {
NumberAnimation { duration: 200 }
}
}
/*Disable accelerometer when device locked */
Connections {
target: LipstickSettings
onLockscreenVisibleChanged: {
if(!Desktop.instance.lockscreenVisible() && enableParalax) {
accelerometer.active = true
} else {
accelerometer.active = false
}
}
}
}
8 changes: 6 additions & 2 deletions src/qml/notifications/NotificationPreview.qml
Expand Up @@ -70,6 +70,12 @@ Item {

onClicked: if (notificationPreviewPresenter.notification != null) notificationPreviewPresenter.notification.actionInvoked("default")

Component.onCompleted: {
if( notificationPreviewPresenter.notification != null) {
icon.source = formatIcon(notificationPreviewPresenter.notification.icon)
}
}

Rectangle {
id: notificationPreview
width: notificationWindow.width
Expand Down Expand Up @@ -148,8 +154,6 @@ Item {
leftMargin: (notificationArea.height-width)/2
verticalCenter: parent.verticalCenter
}

source: formatIcon(notificationPreviewPresenter.notification.icon)
}

Rectangle{
Expand Down