From 3c5ee404c3c74bcddea625c34d84ebe652036157 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 11 Dec 2020 22:37:53 +0100 Subject: [PATCH] Get rid of Neochat.Effect --- .../Component/Timeline/AudioDelegate.qml | 1 - .../Component/Timeline/FileDelegate.qml | 1 - .../Component/Timeline/ImageDelegate.qml | 21 +- .../Component/Timeline/StateDelegate.qml | 1 - .../Component/Timeline/VideoDelegate.qml | 1 - imports/NeoChat/Dialog/RoomSettingsDialog.qml | 1 - imports/NeoChat/Dialog/UserDetailDialog.qml | 1 - imports/NeoChat/Effect/CircleMask.qml | 35 --- imports/NeoChat/Effect/ElevationEffect.qml | 151 ----------- imports/NeoChat/Effect/RippleEffect.qml | 244 ------------------ imports/NeoChat/Effect/qmldir | 3 - imports/NeoChat/Page/RoomPage.qml | 1 - imports/NeoChat/Panel/RoomDrawer.qml | 1 - res.qrc | 4 - 14 files changed, 14 insertions(+), 452 deletions(-) delete mode 100644 imports/NeoChat/Effect/CircleMask.qml delete mode 100644 imports/NeoChat/Effect/ElevationEffect.qml delete mode 100644 imports/NeoChat/Effect/RippleEffect.qml delete mode 100644 imports/NeoChat/Effect/qmldir diff --git a/imports/NeoChat/Component/Timeline/AudioDelegate.qml b/imports/NeoChat/Component/Timeline/AudioDelegate.qml index 9daff9091..cc7525cd0 100644 --- a/imports/NeoChat/Component/Timeline/AudioDelegate.qml +++ b/imports/NeoChat/Component/Timeline/AudioDelegate.qml @@ -17,7 +17,6 @@ import NeoChat.Setting 1.0 import NeoChat.Component 1.0 import NeoChat.Dialog 1.0 import NeoChat.Menu.Timeline 1.0 -import NeoChat.Effect 1.0 Control { id: root diff --git a/imports/NeoChat/Component/Timeline/FileDelegate.qml b/imports/NeoChat/Component/Timeline/FileDelegate.qml index ed5e831a0..8056d1347 100644 --- a/imports/NeoChat/Component/Timeline/FileDelegate.qml +++ b/imports/NeoChat/Component/Timeline/FileDelegate.qml @@ -17,7 +17,6 @@ import NeoChat.Setting 1.0 import NeoChat.Component 1.0 import NeoChat.Dialog 1.0 import NeoChat.Menu.Timeline 1.0 -import NeoChat.Effect 1.0 RowLayout { property bool openOnFinished: false diff --git a/imports/NeoChat/Component/Timeline/ImageDelegate.qml b/imports/NeoChat/Component/Timeline/ImageDelegate.qml index 9daf36f04..352f650c1 100644 --- a/imports/NeoChat/Component/Timeline/ImageDelegate.qml +++ b/imports/NeoChat/Component/Timeline/ImageDelegate.qml @@ -15,7 +15,6 @@ import NeoChat.Setting 1.0 import NeoChat.Component 1.0 import NeoChat.Dialog 1.0 import NeoChat.Menu.Timeline 1.0 -import NeoChat.Effect 1.0 Image { readonly property bool isAnimated: contentType === "image/gif" @@ -85,15 +84,23 @@ Image { } } - RippleEffect { - anchors.fill: parent - + MouseArea { id: messageMouseArea - onPrimaryClicked: fullScreenImage.createObject(parent, {"filename": eventId, "localPath": currentRoom.urlToDownload(eventId)}).showFullScreen() + anchors.fill: parent - onSecondaryClicked: { - var contextMenu = imageDelegateContextMenu.createObject(root, {'room': currentRoom}); + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onClicked: { + if(mouse.button === Qt.LeftButton) { + fullScreenImage.createObject(parent, {"filename": eventId, "localPath": currentRoom.urlToDownload(eventId)}).showFullScreen() + } else { + openContextMenu() + } + } + + function openContextMenu() { + var contextMenu = imageDelegateContextMenu.createObject(root, {'room': currentRoom, 'author': author}); contextMenu.viewSource.connect(function() { messageSourceSheet.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open() }) diff --git a/imports/NeoChat/Component/Timeline/StateDelegate.qml b/imports/NeoChat/Component/Timeline/StateDelegate.qml index db5e6d94c..4294a06f1 100644 --- a/imports/NeoChat/Component/Timeline/StateDelegate.qml +++ b/imports/NeoChat/Component/Timeline/StateDelegate.qml @@ -11,7 +11,6 @@ import org.kde.kirigami 2.13 as Kirigami import NeoChat.Component 1.0 import NeoChat.Dialog 1.0 -import NeoChat.Effect 1.0 import NeoChat.Setting 1.0 RowLayout { diff --git a/imports/NeoChat/Component/Timeline/VideoDelegate.qml b/imports/NeoChat/Component/Timeline/VideoDelegate.qml index e376dbd4d..5e79be27f 100644 --- a/imports/NeoChat/Component/Timeline/VideoDelegate.qml +++ b/imports/NeoChat/Component/Timeline/VideoDelegate.qml @@ -17,7 +17,6 @@ import org.kde.neochat 1.0 import NeoChat.Component 1.0 import NeoChat.Dialog 1.0 import NeoChat.Menu.Timeline 1.0 -import NeoChat.Effect 1.0 Video { id: vid diff --git a/imports/NeoChat/Dialog/RoomSettingsDialog.qml b/imports/NeoChat/Dialog/RoomSettingsDialog.qml index d6aed9511..970757c60 100644 --- a/imports/NeoChat/Dialog/RoomSettingsDialog.qml +++ b/imports/NeoChat/Dialog/RoomSettingsDialog.qml @@ -9,7 +9,6 @@ import QtQuick.Layouts 1.12 import org.kde.kirigami 2.13 as Kirigami import NeoChat.Component 1.0 -import NeoChat.Effect 1.0 import NeoChat.Setting 1.0 import org.kde.neochat 1.0 diff --git a/imports/NeoChat/Dialog/UserDetailDialog.qml b/imports/NeoChat/Dialog/UserDetailDialog.qml index bd34e2381..34d442075 100644 --- a/imports/NeoChat/Dialog/UserDetailDialog.qml +++ b/imports/NeoChat/Dialog/UserDetailDialog.qml @@ -10,7 +10,6 @@ import QtQuick.Layouts 1.12 import org.kde.kirigami 2.13 as Kirigami import NeoChat.Component 1.0 -import NeoChat.Effect 1.0 import NeoChat.Setting 1.0 Kirigami.OverlaySheet { diff --git a/imports/NeoChat/Effect/CircleMask.qml b/imports/NeoChat/Effect/CircleMask.qml deleted file mode 100644 index 51e25519c..000000000 --- a/imports/NeoChat/Effect/CircleMask.qml +++ /dev/null @@ -1,35 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2018 Black Hat - * SPDX-FileCopyrightText: 2020 Carl Schwan - * - * SPDX-License-Identifier: GPL-3.0-only - */ -import QtQuick 2.12 -import QtGraphicalEffects 1.0 - -Item { - id: item - - property alias source: mask.source - - Rectangle { - id: circleMask - - width: parent.width - height: parent.height - - smooth: true - visible: false - - radius: Math.max(width/2, height/2) - } - - OpacityMask { - id: mask - - width: parent.width - height: parent.height - - maskSource: circleMask - } -} diff --git a/imports/NeoChat/Effect/ElevationEffect.qml b/imports/NeoChat/Effect/ElevationEffect.qml deleted file mode 100644 index 9c80d2b3d..000000000 --- a/imports/NeoChat/Effect/ElevationEffect.qml +++ /dev/null @@ -1,151 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2018 Black Hat - * - * SPDX-License-Identifier: GPL-3.0-only - */ -import QtQuick 2.12 -import QtGraphicalEffects 1.0 - -/*! - An effect for standard Material Design elevation shadows - */ -Item { - id: effect - - property var source - readonly property Item sourceItem: source.sourceItem - - property int elevation: 0 - - // Shadow details follow Material Design (taken from Angular Material) - readonly property var _shadows: [ - [{offset: 0, blur: 0, spread: 0}, - {offset: 0, blur: 0, spread: 0}, - {offset: 0, blur: 0, spread: 0}], - - [{offset: 1, blur: 3, spread: 0}, - {offset: 1, blur: 1, spread: 0}, - {offset: 2, blur: 1, spread: -1}], - - [{offset: 1, blur: 5, spread: 0}, - {offset: 2, blur: 2, spread: 0}, - {offset: 3, blur: 1, spread: -2}], - - [{offset: 1, blur: 8, spread: 0}, - {offset: 3, blur: 4, spread: 0}, - {offset: 3, blur: 3, spread: -2}], - - [{offset: 2, blur: 4, spread: -1}, - {offset: 4, blur: 5, spread: 0}, - {offset: 1, blur: 10, spread: 0}], - - [{offset: 3, blur: 5, spread: -1}, - {offset: 5, blur: 8, spread: 0}, - {offset: 1, blur: 14, spread: 0}], - - [{offset: 3, blur: 5, spread: -1}, - {offset: 6, blur: 10, spread: 0}, - {offset: 1, blur: 18, spread: 0}], - - [{offset: 4, blur: 5, spread: -2}, - {offset: 7, blur: 10, spread: 1}, - {offset: 2, blur: 16, spread: 1}], - - [{offset: 5, blur: 5, spread: -3}, - {offset: 8, blur: 10, spread: 1}, - {offset: 3, blur: 14, spread: 2}], - - [{offset: 5, blur: 6, spread: -3}, - {offset: 9, blur: 12, spread: 1}, - {offset: 3, blur: 16, spread: 2}], - - [{offset: 6, blur: 6, spread: -3}, - {offset: 10, blur: 14, spread: 1}, - {offset: 4, blur: 18, spread: 3}], - - [{offset: 6, blur: 7, spread: -4}, - {offset: 11, blur: 15, spread: 1}, - {offset: 4, blur: 20, spread: 3}], - - [{offset: 7, blur: 8, spread: -4}, - {offset: 12, blur: 17, spread: 2}, - {offset: 5, blur: 22, spread: 4}], - - [{offset: 7, blur: 8, spread: -4}, - {offset: 13, blur: 19, spread: 2}, - {offset: 5, blur: 24, spread: 4}], - - [{offset: 7, blur: 9, spread: -4}, - {offset: 14, blur: 21, spread: 2}, - {offset: 5, blur: 26, spread: 4}], - - [{offset: 8, blur: 9, spread: -5}, - {offset: 15, blur: 22, spread: 2}, - {offset: 6, blur: 28, spread: 5}], - - [{offset: 8, blur: 10, spread: -5}, - {offset: 16, blur: 24, spread: 2}, - {offset: 6, blur: 30, spread: 5}], - - [{offset: 8, blur: 11, spread: -5}, - {offset: 17, blur: 26, spread: 2}, - {offset: 6, blur: 32, spread: 5}], - - [{offset: 9, blur: 11, spread: -5}, - {offset: 18, blur: 28, spread: 2}, - {offset: 7, blur: 34, spread: 6}], - - [{offset: 9, blur: 12, spread: -6}, - {offset: 19, blur: 29, spread: 2}, - {offset: 7, blur: 36, spread: 6}], - - [{offset: 10, blur: 13, spread: -6}, - {offset: 20, blur: 31, spread: 3}, - {offset: 8, blur: 38, spread: 7}], - - [{offset: 10, blur: 13, spread: -6}, - {offset: 21, blur: 33, spread: 3}, - {offset: 8, blur: 40, spread: 7}], - - [{offset: 10, blur: 14, spread: -6}, - {offset: 22, blur: 35, spread: 3}, - {offset: 8, blur: 42, spread: 7}], - - [{offset: 11, blur: 14, spread: -7}, - {offset: 23, blur: 36, spread: 3}, - {offset: 9, blur: 44, spread: 8}], - - [{offset: 11, blur: 15, spread: -7}, - {offset: 24, blur: 38, spread: 3}, - {offset: 9, blur: 46, spread: 8}] - ] - - readonly property var _shadowColors: [ - Qt.rgba(0,0,0, 0.2), - Qt.rgba(0,0,0, 0.14), - Qt.rgba(0,0,0, 0.12) - ] - - Repeater { - model: _shadows[elevation] - - delegate: RectangularGlow { - anchors { - centerIn: parent - verticalCenterOffset: modelData.offset - } - - width: parent.width + 2 * modelData.spread - height: parent.height + 2 * modelData.spread - glowRadius: modelData.blur/2 - spread: 0.05 - color: _shadowColors[index] - cornerRadius: modelData.blur + (effect.sourceItem.radius ?? 0) - } - } - - ShaderEffect { - anchors.fill: parent - property alias source: effect.source; - } -} diff --git a/imports/NeoChat/Effect/RippleEffect.qml b/imports/NeoChat/Effect/RippleEffect.qml deleted file mode 100644 index adf8bcce1..000000000 --- a/imports/NeoChat/Effect/RippleEffect.qml +++ /dev/null @@ -1,244 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2018 Black Hat - * - * SPDX-License-Identifier: GPL-3.0-only - */ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtGraphicalEffects 1.0 - -import NeoChat.Component 1.0 -import NeoChat.Setting 1.0 - -AutoMouseArea { - id: ripple - - property color color: MSettings.darkTheme ? Qt.rgba(255, 255, 255, 0.16) : Qt.rgba(0, 0, 0, 0.08) - property bool circular: false - property bool centered: false - property bool focused - property color focusColor: "transparent" - property int focusWidth: width - 32 - property Item control - - clip: true - - Connections { - target: control - - onPressedChanged: { - if (!control.pressed) - __private.removeLastCircle() - } - } - - onPressed: { - __private.createTapCircle(mouse.x, mouse.y) - - if (control) - mouse.accepted = false - } - - onReleased: __private.removeLastCircle() - onCanceled: __private.removeLastCircle() - - QtObject { - id: __private - - property int startRadius: 0 - property int endRadius - property bool showFocus: true - - property Item lastCircle - - function createTapCircle(x, y) { - endRadius = centered ? width/2 : radius(x, y) + 5 - showFocus = false - - lastCircle = tapCircle.createObject(ripple, { - "circleX": centered ? width/2 : x, - "circleY": centered ? height/2 : y - }) - } - - function removeLastCircle() { - if (lastCircle) - lastCircle.removeCircle() - } - - function radius(x, y) { - var dist1 = Math.max(dist(x, y, 0, 0), dist(x, y, width, height)) - var dist2 = Math.max(dist(x, y, width, 0), dist(x, y, 0, height)) - - return Math.max(dist1, dist2) - } - - function dist(x1, y1, x2, y2) { - var distX = x2 - x1 - var distY = y2 - y1 - - return Math.sqrt(distX * distX + distY * distY) - } - } - - Rectangle { - id: focusBackground - objectName: "focusBackground" - - width: parent.width - height: parent.height - - color: Qt.rgba(0,0,0,0.2) - - opacity: __private.showFocus && focused ? 1 : 0 - - Behavior on opacity { - NumberAnimation { duration: 500; easing.type: Easing.InOutQuad } - } - } - - Rectangle { - id: focusCircle - objectName: "focusRipple" - - property bool focusedState - - x: (parent.width - width)/2 - y: (parent.height - height)/2 - - width: focused - ? focusedState ? focusWidth - : Math.min(parent.width - 8, focusWidth + 12) - : parent.width/5 - height: width - - radius: width/2 - - opacity: __private.showFocus && focused ? 1 : 0 - - color: focusColor.a === 0 ? Qt.rgba(1,1,1,0.4) : focusColor - - Behavior on opacity { - NumberAnimation { duration: 500; easing.type: Easing.InOutQuad } - } - - Behavior on width { - NumberAnimation { duration: focusTimer.interval; } - } - - Timer { - id: focusTimer - running: focused - repeat: true - interval: 800 - - onTriggered: focusCircle.focusedState = !focusCircle.focusedState - } - } - - Component { - id: tapCircle - - Item { - id: circleItem - objectName: "tapRipple" - - property bool done - - property real circleX - property real circleY - - property bool closed - - width: parent.width - height: parent.height - - function removeCircle() { - done = true - - if (fillSizeAnimation.running) { - fillOpacityAnimation.stop() - closeAnimation.start() - - circleItem.destroy(500); - } else { - __private.showFocus = true - fadeAnimation.start(); - - circleItem.destroy(300); - } - } - - Item { - id: circleParent - - width: parent.width - height: parent.height - - visible: !circular - - Rectangle { - id: circleRectangle - - x: circleItem.circleX - radius - y: circleItem.circleY - radius - - width: radius * 2 - height: radius * 2 - - opacity: 0 - color: ripple.color - - NumberAnimation { - id: fillSizeAnimation - running: true - - target: circleRectangle; property: "radius"; duration: 500; - from: __private.startRadius; to: __private.endRadius; - easing.type: Easing.InOutQuad - - onStopped: { - if (done) - __private.showFocus = true - } - } - - NumberAnimation { - id: fillOpacityAnimation - running: true - - target: circleRectangle; property: "opacity"; duration: 300; - from: 0; to: 1; easing.type: Easing.InOutQuad - } - - NumberAnimation { - id: fadeAnimation - - target: circleRectangle; property: "opacity"; duration: 300; - from: 1; to: 0; easing.type: Easing.InOutQuad - } - - SequentialAnimation { - id: closeAnimation - - NumberAnimation { - target: circleRectangle; property: "opacity"; duration: 250; - to: 1; easing.type: Easing.InOutQuad - } - - NumberAnimation { - target: circleRectangle; property: "opacity"; duration: 250; - from: 1; to: 0; easing.type: Easing.InOutQuad - } - } - } - } - - CircleMask { - anchors.fill: parent - source: circleParent - visible: circular - } - } - } -} diff --git a/imports/NeoChat/Effect/qmldir b/imports/NeoChat/Effect/qmldir deleted file mode 100644 index 1d17b23e2..000000000 --- a/imports/NeoChat/Effect/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module NeoChat.Effect -ElevationEffect 1.0 ElevationEffect.qml -RippleEffect 1.0 RippleEffect.qml diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index 9d2f5237a..ec5c46682 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -18,7 +18,6 @@ import org.kde.neochat 1.0 import NeoChat.Component 1.0 import NeoChat.Component.Timeline 1.0 import NeoChat.Dialog 1.0 -import NeoChat.Effect 1.0 import NeoChat.Menu.Timeline 1.0 Kirigami.ScrollablePage { diff --git a/imports/NeoChat/Panel/RoomDrawer.qml b/imports/NeoChat/Panel/RoomDrawer.qml index bc1f1c5ca..5705a8c0e 100644 --- a/imports/NeoChat/Panel/RoomDrawer.qml +++ b/imports/NeoChat/Panel/RoomDrawer.qml @@ -14,7 +14,6 @@ import org.kde.kitemmodels 1.0 import NeoChat.Component 1.0 import NeoChat.Dialog 1.0 -import NeoChat.Effect 1.0 import NeoChat.Setting 1.0 import org.kde.neochat 1.0 diff --git a/res.qrc b/res.qrc index 9355200dc..3b39f2cea 100644 --- a/res.qrc +++ b/res.qrc @@ -36,10 +36,6 @@ imports/NeoChat/Setting/Palette.qml imports/NeoChat/Panel/qmldir imports/NeoChat/Panel/RoomDrawer.qml - imports/NeoChat/Effect/RippleEffect.qml - imports/NeoChat/Effect/CircleMask.qml - imports/NeoChat/Effect/ElevationEffect.qml - imports/NeoChat/Effect/qmldir imports/NeoChat/Dialog/qmldir imports/NeoChat/Dialog/RoomSettingsDialog.qml imports/NeoChat/Dialog/UserDetailDialog.qml