From 4bf06466f1f2b637499fa5a7ebe07ccccdf92d56 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 13 Feb 2023 15:00:54 +0200 Subject: [PATCH] effects/{desktopgrid,overview,windowview}: Port to SceneView --- src/effects/desktopgrid/desktopgrideffect.cpp | 8 ------- src/effects/desktopgrid/desktopgrideffect.h | 3 --- src/effects/desktopgrid/qml/main.qml | 4 ++-- src/effects/overview/overvieweffect.cpp | 8 ------- src/effects/overview/overvieweffect.h | 3 --- src/effects/overview/qml/ScreenView.qml | 4 ++-- src/effects/windowview/qml/main.qml | 7 +++--- src/effects/windowview/windowvieweffect.cpp | 23 +++++++++---------- src/effects/windowview/windowvieweffect.h | 6 ++--- 9 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/effects/desktopgrid/desktopgrideffect.cpp b/src/effects/desktopgrid/desktopgrideffect.cpp index afe82c0b6d..37b18e24ac 100644 --- a/src/effects/desktopgrid/desktopgrideffect.cpp +++ b/src/effects/desktopgrid/desktopgrideffect.cpp @@ -85,14 +85,6 @@ DesktopGridEffect::~DesktopGridEffect() { } -QVariantMap DesktopGridEffect::initialProperties(EffectScreen *screen) -{ - return QVariantMap{ - {QStringLiteral("effect"), QVariant::fromValue(this)}, - {QStringLiteral("targetScreen"), QVariant::fromValue(screen)}, - }; -} - void DesktopGridEffect::reconfigure(ReconfigureFlags) { DesktopGridConfig::self()->read(); diff --git a/src/effects/desktopgrid/desktopgrideffect.h b/src/effects/desktopgrid/desktopgrideffect.h index b680c2530f..eb87d3f464 100644 --- a/src/effects/desktopgrid/desktopgrideffect.h +++ b/src/effects/desktopgrid/desktopgrideffect.h @@ -82,9 +82,6 @@ public Q_SLOTS: void deactivate(int timeout); void toggle(); -protected: - QVariantMap initialProperties(EffectScreen *screen) override; - Q_SIGNALS: void gridRowsChanged(); void gridColumnsChanged(); diff --git a/src/effects/desktopgrid/qml/main.qml b/src/effects/desktopgrid/qml/main.qml index 87f322ed10..32aaf9439d 100644 --- a/src/effects/desktopgrid/qml/main.qml +++ b/src/effects/desktopgrid/qml/main.qml @@ -18,8 +18,8 @@ import org.kde.plasma.components 3.0 as PC3 Rectangle { id: container - required property QtObject effect - required property QtObject targetScreen + readonly property QtObject effect: KWinComponents.SceneView.effect + readonly property QtObject targetScreen: KWinComponents.SceneView.screen property bool animationEnabled: false property bool organized: false diff --git a/src/effects/overview/overvieweffect.cpp b/src/effects/overview/overvieweffect.cpp index 0b6d99d3a5..c25f0f510a 100644 --- a/src/effects/overview/overvieweffect.cpp +++ b/src/effects/overview/overvieweffect.cpp @@ -80,14 +80,6 @@ OverviewEffect::~OverviewEffect() { } -QVariantMap OverviewEffect::initialProperties(EffectScreen *screen) -{ - return QVariantMap{ - {QStringLiteral("effect"), QVariant::fromValue(this)}, - {QStringLiteral("targetScreen"), QVariant::fromValue(screen)}, - }; -} - void OverviewEffect::reconfigure(ReconfigureFlags) { OverviewConfig::self()->read(); diff --git a/src/effects/overview/overvieweffect.h b/src/effects/overview/overvieweffect.h index 7dba6fe0e5..d1f8582179 100644 --- a/src/effects/overview/overvieweffect.h +++ b/src/effects/overview/overvieweffect.h @@ -69,9 +69,6 @@ public Q_SLOTS: void quickDeactivate(); void toggle(); -protected: - QVariantMap initialProperties(EffectScreen *screen) override; - private: void realDeactivate(); diff --git a/src/effects/overview/qml/ScreenView.qml b/src/effects/overview/qml/ScreenView.qml index c2a8d0afa9..b84a894dcd 100644 --- a/src/effects/overview/qml/ScreenView.qml +++ b/src/effects/overview/qml/ScreenView.qml @@ -19,8 +19,8 @@ FocusScope { id: container focus: true - required property QtObject effect - required property QtObject targetScreen + readonly property QtObject effect: KWinComponents.SceneView.effect + readonly property QtObject targetScreen: KWinComponents.SceneView.screen readonly property bool lightBackground: Math.max(PlasmaCore.ColorScope.backgroundColor.r, PlasmaCore.ColorScope.backgroundColor.g, diff --git a/src/effects/windowview/qml/main.qml b/src/effects/windowview/qml/main.qml index 2f52c2bdb9..93fb148222 100644 --- a/src/effects/windowview/qml/main.qml +++ b/src/effects/windowview/qml/main.qml @@ -17,9 +17,8 @@ import org.kde.KWin.Effect.WindowView 1.0 Item { id: container - required property QtObject effect - required property QtObject targetScreen - required property var selectedIds + readonly property QtObject effect: KWinComponents.SceneView.effect + readonly property QtObject targetScreen: KWinComponents.SceneView.screen property bool animationEnabled: false property bool organized: false @@ -176,7 +175,7 @@ Item { case WindowView.ModeWindowClassCurrentDesktop: return "activeClass"; default: - return selectedIds; + return container.effect.selectedIds; } } layout.mode: effect.layout diff --git a/src/effects/windowview/windowvieweffect.cpp b/src/effects/windowview/windowvieweffect.cpp index afee211835..89c08bcb19 100644 --- a/src/effects/windowview/windowvieweffect.cpp +++ b/src/effects/windowview/windowvieweffect.cpp @@ -137,15 +137,6 @@ WindowViewEffect::~WindowViewEffect() QDBusConnection::sessionBus().unregisterObject(s_dbusObjectPath); } -QVariantMap WindowViewEffect::initialProperties(EffectScreen *screen) -{ - return QVariantMap{ - {QStringLiteral("effect"), QVariant::fromValue(this)}, - {QStringLiteral("targetScreen"), QVariant::fromValue(screen)}, - {QStringLiteral("selectedIds"), QVariant::fromValue(m_windowIds)}, - }; -} - int WindowViewEffect::animationDuration() const { return m_animationDuration; @@ -333,7 +324,7 @@ void WindowViewEffect::activate(const QStringList &windowIds) } } if (!internalIds.isEmpty()) { - m_windowIds = internalIds; + setSelectedIds(internalIds); m_searchText = QString(); setRunning(true); } @@ -346,7 +337,7 @@ void WindowViewEffect::activate() } m_status = Status::Active; - m_windowIds.clear(); + setSelectedIds(QList()); setGestureInProgress(false); setPartialActivationFactor(0); @@ -417,7 +408,7 @@ void WindowViewEffect::setMode(WindowViewEffect::PresentWindowsMode mode) } if (mode != ModeWindowGroup) { - m_windowIds.clear(); + setSelectedIds(QList()); } m_mode = mode; @@ -464,4 +455,12 @@ bool WindowViewEffect::borderActivated(ElectricBorder border) return true; } +void WindowViewEffect::setSelectedIds(const QList &ids) +{ + if (m_windowIds != ids) { + m_windowIds = ids; + Q_EMIT selectedIdsChanged(); + } +} + } // namespace KWin diff --git a/src/effects/windowview/windowvieweffect.h b/src/effects/windowview/windowvieweffect.h index 1295bfd3b9..800a5cbf18 100644 --- a/src/effects/windowview/windowvieweffect.h +++ b/src/effects/windowview/windowvieweffect.h @@ -25,6 +25,7 @@ class WindowViewEffect : public QuickSceneEffect Q_PROPERTY(qreal partialActivationFactor READ partialActivationFactor NOTIFY partialActivationFactorChanged) Q_PROPERTY(bool gestureInProgress READ gestureInProgress NOTIFY gestureInProgressChanged) Q_PROPERTY(QString searchText MEMBER m_searchText NOTIFY searchTextChanged) + Q_PROPERTY(QList selectedIds MEMBER m_windowIds NOTIFY selectedIdsChanged) public: enum PresentWindowsMode { @@ -87,12 +88,11 @@ Q_SIGNALS: void layoutChanged(); void ignoreMinimizedChanged(); void searchTextChanged(); - -protected: - QVariantMap initialProperties(EffectScreen *screen) override; + void selectedIdsChanged(); private: void realDeactivate(); + void setSelectedIds(const QList &ids); QTimer *m_shutdownTimer; QList m_windowIds;