mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
homescreen: Add launch delegate animation
This commit is contained in:
parent
b7c8c462c5
commit
62f7ffc074
2 changed files with 134 additions and 23 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.4
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Controls 2.3 as Controls
|
import QtQuick.Controls 2.3 as Controls
|
||||||
import QtGraphicalEffects 1.6
|
import QtGraphicalEffects 1.6
|
||||||
|
|
@ -54,6 +54,17 @@ ContainmentLayoutManager.ItemContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function launchApp() {
|
||||||
|
if (modelData.applicationRunning) {
|
||||||
|
delegate.launch(0, 0, "", modelData.applicationName);
|
||||||
|
} else {
|
||||||
|
delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, modelData.applicationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileShell.ApplicationListModel.setMinimizedDelegate(index, delegate);
|
||||||
|
MobileShell.ApplicationListModel.runApplication(modelData.applicationStorageId);
|
||||||
|
}
|
||||||
|
|
||||||
readonly property bool applicationRunning: model.applicationRunning
|
readonly property bool applicationRunning: model.applicationRunning
|
||||||
onApplicationRunningChanged: {
|
onApplicationRunningChanged: {
|
||||||
syncDelegateGeometry();
|
syncDelegateGeometry();
|
||||||
|
|
@ -88,18 +99,54 @@ ContainmentLayoutManager.ItemContainer {
|
||||||
|
|
||||||
contentItem: MouseArea {
|
contentItem: MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
onClicked: {
|
|
||||||
if (modelData.applicationRunning) {
|
|
||||||
delegate.launch(0, 0, "", modelData.applicationName);
|
|
||||||
} else {
|
|
||||||
delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, modelData.applicationName);
|
|
||||||
}
|
|
||||||
|
|
||||||
MobileShell.ApplicationListModel.setMinimizedDelegate(index, delegate);
|
// grow/shrink animation
|
||||||
MobileShell.ApplicationListModel.runApplication(modelData.applicationStorageId);
|
property real zoomScale: 1
|
||||||
|
transform: Scale {
|
||||||
|
origin.x: mouseArea.width / 2;
|
||||||
|
origin.y: mouseArea.height / 2;
|
||||||
|
xScale: mouseArea.zoomScale
|
||||||
|
yScale: mouseArea.zoomScale
|
||||||
}
|
}
|
||||||
|
|
||||||
//preventStealing: true
|
property bool launchAppRequested: false
|
||||||
|
|
||||||
|
NumberAnimation on zoomScale {
|
||||||
|
id: shrinkAnim
|
||||||
|
duration: 80
|
||||||
|
to: 0.8
|
||||||
|
onFinished: {
|
||||||
|
if (!mouseArea.pressed) {
|
||||||
|
growAnim.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberAnimation on zoomScale {
|
||||||
|
id: growAnim
|
||||||
|
duration: 80
|
||||||
|
to: 1
|
||||||
|
onFinished: {
|
||||||
|
if (mouseArea.launchAppRequested) {
|
||||||
|
delegate.launchApp();
|
||||||
|
mouseArea.launchAppRequested = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
hoverEnabled: true
|
||||||
|
onPressedChanged: {
|
||||||
|
if (pressed) {
|
||||||
|
growAnim.stop();
|
||||||
|
shrinkAnim.restart();
|
||||||
|
} else if (!pressed && !shrinkAnim.running) {
|
||||||
|
growAnim.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// launch app handled by press animation
|
||||||
|
onClicked: launchAppRequested = true;
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
|
|
@ -132,6 +179,15 @@ ContainmentLayoutManager.ItemContainer {
|
||||||
height: width
|
height: width
|
||||||
color: PlasmaCore.Theme.highlightColor
|
color: PlasmaCore.Theme.highlightColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// darken effect when hovered/pressed
|
||||||
|
layer {
|
||||||
|
enabled: mouseArea.pressed || mouseArea.containsMouse
|
||||||
|
effect: ColorOverlay {
|
||||||
|
color: Qt.rgba(0, 0, 0, 0.3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: in loader?
|
//TODO: in loader?
|
||||||
Private.DelegateRemoveButton {
|
Private.DelegateRemoveButton {
|
||||||
id: removeButton
|
id: removeButton
|
||||||
|
|
@ -165,10 +221,10 @@ ContainmentLayoutManager.ItemContainer {
|
||||||
layer.effect: DropShadow {
|
layer.effect: DropShadow {
|
||||||
horizontalOffset: 0
|
horizontalOffset: 0
|
||||||
verticalOffset: 2
|
verticalOffset: 2
|
||||||
radius: 8.0
|
radius: 6.0
|
||||||
samples: 16
|
samples: 10
|
||||||
cached: true
|
cached: true
|
||||||
color: Qt.rgba(0, 0, 0, 1)
|
color: Qt.rgba(0, 0, 0, 0.3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {Layout.fillHeight:true}
|
Item {Layout.fillHeight:true}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.4
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Controls 2.3 as Controls
|
import QtQuick.Controls 2.3 as Controls
|
||||||
import QtGraphicalEffects 1.6
|
import QtGraphicalEffects 1.6
|
||||||
|
|
@ -28,14 +28,7 @@ MouseArea {
|
||||||
signal launch(int x, int y, var source, string title, string storageId)
|
signal launch(int x, int y, var source, string title, string storageId)
|
||||||
signal dragStarted(string imageSource, int x, int y, string mimeData)
|
signal dragStarted(string imageSource, int x, int y, string mimeData)
|
||||||
|
|
||||||
onPressAndHold: {
|
function launchApp() {
|
||||||
delegate.grabToImage(function(result) {
|
|
||||||
delegate.Drag.imageSource = result.url
|
|
||||||
dragStarted(result.url, width/2, height/2, model.applicationStorageId)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
// launch app
|
// launch app
|
||||||
if (model.applicationRunning) {
|
if (model.applicationRunning) {
|
||||||
delegate.launch(0, 0, "", model.applicationName, model.applicationStorageId);
|
delegate.launch(0, 0, "", model.applicationName, model.applicationStorageId);
|
||||||
|
|
@ -44,6 +37,60 @@ MouseArea {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPressAndHold: {
|
||||||
|
delegate.grabToImage(function(result) {
|
||||||
|
delegate.Drag.imageSource = result.url
|
||||||
|
dragStarted(result.url, width/2, height/2, model.applicationStorageId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// grow/shrink animation
|
||||||
|
property real zoomScale: 1
|
||||||
|
transform: Scale {
|
||||||
|
origin.x: delegate.width / 2;
|
||||||
|
origin.y: delegate.height / 2;
|
||||||
|
xScale: delegate.zoomScale
|
||||||
|
yScale: delegate.zoomScale
|
||||||
|
}
|
||||||
|
|
||||||
|
property bool launchAppRequested: false
|
||||||
|
|
||||||
|
NumberAnimation on zoomScale {
|
||||||
|
id: shrinkAnim
|
||||||
|
duration: 80
|
||||||
|
to: 0.8
|
||||||
|
onFinished: {
|
||||||
|
if (!delegate.pressed) {
|
||||||
|
growAnim.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberAnimation on zoomScale {
|
||||||
|
id: growAnim
|
||||||
|
duration: 80
|
||||||
|
to: 1
|
||||||
|
onFinished: {
|
||||||
|
if (delegate.launchAppRequested) {
|
||||||
|
delegate.launchApp();
|
||||||
|
delegate.launchAppRequested = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
hoverEnabled: true
|
||||||
|
onPressedChanged: {
|
||||||
|
if (pressed) {
|
||||||
|
growAnim.stop();
|
||||||
|
shrinkAnim.restart();
|
||||||
|
} else if (!pressed && !shrinkAnim.running) {
|
||||||
|
growAnim.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// launch app handled by press animation
|
||||||
|
onClicked: launchAppRequested = true;
|
||||||
|
|
||||||
//preventStealing: true
|
//preventStealing: true
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors {
|
anchors {
|
||||||
|
|
@ -77,6 +124,14 @@ MouseArea {
|
||||||
height: width
|
height: width
|
||||||
color: theme.highlightColor
|
color: theme.highlightColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// darken effect when hovered/pressed
|
||||||
|
layer {
|
||||||
|
enabled: delegate.pressed || delegate.containsMouse
|
||||||
|
effect: ColorOverlay {
|
||||||
|
color: Qt.rgba(0, 0, 0, 0.3)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue