From b1c35943678dfd83c419a0419d3ca82b37826ebf Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 6 Jan 2022 12:55:15 +0200 Subject: [PATCH] provide ParabolicEffect spread option --this way the user can choose to use a much greater parabolic effect that will influence five or seven of its neighbours instead of just three. The new option can be found at Latte Global Preferences. --- app/data/preferencesdata.cpp | 8 + app/data/preferencesdata.h | 2 + app/settings/settingsdialog/settingsdialog.ui | 652 ++++++++++-------- .../settingsdialog/tabpreferenceshandler.cpp | 26 +- .../settingsdialog/tabpreferenceshandler.h | 1 + app/settings/universalsettings.cpp | 18 + app/settings/universalsettings.h | 8 + .../contents/ui/abilities/ParabolicEffect.qml | 1 + .../privates/ParabolicEffectPrivate.qml | 44 +- .../contents/ui/applet/ParabolicArea.qml | 98 +-- containment/package/contents/ui/main.qml | 1 + .../abilities/bridge/ParabolicEffect.qml | 8 +- .../abilities/client/ParabolicEffect.qml | 68 +- .../abilities/definition/ParabolicEffect.qml | 51 +- .../abilities/host/ParabolicEffect.qml | 1 + .../items/basicitem/ParabolicEventsArea.qml | 81 ++- .../items/basicitem/ParabolicItem.qml | 4 +- 17 files changed, 612 insertions(+), 460 deletions(-) diff --git a/app/data/preferencesdata.cpp b/app/data/preferencesdata.cpp index 86cc2872e..eb46f04a4 100644 --- a/app/data/preferencesdata.cpp +++ b/app/data/preferencesdata.cpp @@ -15,6 +15,7 @@ const bool Preferences::BORDERLESSMAXIMIZED; const bool Preferences::ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA; const bool Preferences::METAPRESSFORAPPLAUNCHER; const bool Preferences::METAHOLDFORBADGES; +const int Preferences::PARABOLICSPREAD; const int Preferences::SCREENSDELAY; const Settings::MouseSensitivity Preferences::MOUSESENSITIVITY; @@ -32,6 +33,7 @@ Preferences::Preferences(Preferences &&o) metaPressForAppLauncher(o.metaPressForAppLauncher), metaHoldForBadges(o.metaHoldForBadges), mouseSensitivity(o.mouseSensitivity), + parabolicSpread(o.parabolicSpread), screensDelay(o.screensDelay) { } @@ -46,6 +48,7 @@ Preferences::Preferences(const Preferences &o) metaPressForAppLauncher(o.metaPressForAppLauncher), metaHoldForBadges(o.metaHoldForBadges), mouseSensitivity(o.mouseSensitivity), + parabolicSpread(o.parabolicSpread), screensDelay(o.screensDelay) { } @@ -61,6 +64,7 @@ Preferences &Preferences::operator=(const Preferences &rhs) metaPressForAppLauncher = rhs.metaPressForAppLauncher; metaHoldForBadges = rhs.metaHoldForBadges; mouseSensitivity = rhs.mouseSensitivity; + parabolicSpread = rhs.parabolicSpread; screensDelay = rhs.screensDelay; return (*this); @@ -77,6 +81,7 @@ Preferences &Preferences::operator=(Preferences &&rhs) metaPressForAppLauncher = rhs.metaPressForAppLauncher; metaHoldForBadges = rhs.metaHoldForBadges; mouseSensitivity = rhs.mouseSensitivity; + parabolicSpread = rhs.parabolicSpread; screensDelay = rhs.screensDelay; return (*this); @@ -93,6 +98,7 @@ bool Preferences::operator==(const Preferences &rhs) const && (metaPressForAppLauncher == rhs.metaPressForAppLauncher) && (metaHoldForBadges == rhs.metaHoldForBadges) && (mouseSensitivity == rhs.mouseSensitivity) + && (parabolicSpread == rhs.parabolicSpread) && (screensDelay == rhs.screensDelay); } @@ -112,6 +118,7 @@ bool Preferences::inDefaultValues() const && (metaPressForAppLauncher == METAPRESSFORAPPLAUNCHER) && (metaHoldForBadges == METAHOLDFORBADGES) && (mouseSensitivity == MOUSESENSITIVITY) + && (parabolicSpread == PARABOLICSPREAD) && (screensDelay == SCREENSDELAY); } @@ -126,6 +133,7 @@ void Preferences::setToDefaults() metaPressForAppLauncher = METAPRESSFORAPPLAUNCHER; metaHoldForBadges = METAHOLDFORBADGES; mouseSensitivity = MOUSESENSITIVITY; + parabolicSpread = PARABOLICSPREAD; screensDelay = SCREENSDELAY; } diff --git a/app/data/preferencesdata.h b/app/data/preferencesdata.h index 6676f9c7a..d05a1df17 100644 --- a/app/data/preferencesdata.h +++ b/app/data/preferencesdata.h @@ -26,6 +26,7 @@ public: static const bool ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA = true; static const bool METAPRESSFORAPPLAUNCHER = false; static const bool METAHOLDFORBADGES = true; + static const int PARABOLICSPREAD = 3; static const int SCREENSDELAY = 2500; static const Settings::MouseSensitivity MOUSESENSITIVITY = Settings::HighMouseSensitivity; @@ -41,6 +42,7 @@ public: bool isAvailableGeometryBroadcastedToPlasma{ISAVAILABLEGEOMETRYBROADCASTEDTOPLASMA}; bool metaPressForAppLauncher{METAPRESSFORAPPLAUNCHER}; bool metaHoldForBadges{METAHOLDFORBADGES}; + int parabolicSpread{PARABOLICSPREAD}; int screensDelay{SCREENSDELAY}; QStringList contextMenuAlwaysActions{Data::ContextMenu::ACTIONSALWAYSVISIBLE}; Settings::MouseSensitivity mouseSensitivity{MOUSESENSITIVITY}; diff --git a/app/settings/settingsdialog/settingsdialog.ui b/app/settings/settingsdialog/settingsdialog.ui index df483a43b..39617d1a4 100644 --- a/app/settings/settingsdialog/settingsdialog.ui +++ b/app/settings/settingsdialog/settingsdialog.ui @@ -522,7 +522,7 @@ 0 0 1068 - 428 + 469 @@ -534,102 +534,28 @@ - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 110 - 16777215 - - - - Different hardware can have different delays during screen changes. -This tracker is used in order to not lose any screen related update. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - ms. - - - 1000 - - - 10000 - - - 100 - - - 2500 - - - - - - - - 0 - 0 - - - - Different hardware can have different delays during screen changes. -This tracker is used in order to not lose any screen related update. - - - reaction delay for changes - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - + + + + Inform Plasma desktop for available desktop space + + - - + + - Provide visual feedback when layouts are activated automatically + Activate support for borderless maximized windows between different layouts - Show informative window for layouts automatic activation + Support borderless maximized windows in different layouts - - + + + + + Qt::Vertical @@ -644,8 +570,8 @@ This tracker is used in order to not lose any screen related update. - - + + Qt::Vertical @@ -660,55 +586,18 @@ This tracker is used in order to not lose any screen related update. - - + + - Activate support for borderless maximized windows between different layouts - - - Support borderless maximized windows in different layouts + Provide visual feedback when layouts are activated automatically - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Actions: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - Use 3D style for notification and shortcut badges + Show informative window for layouts automatic activation - - - - - + + Qt::Vertical @@ -723,7 +612,10 @@ This tracker is used in order to not lose any screen related update. - + + + + Press and hold ⌘ to show shortcuts badges for applets and tasks @@ -733,26 +625,10 @@ This tracker is used in order to not lose any screen related update. - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - + + - + Qt::Horizontal @@ -765,7 +641,7 @@ This tracker is used in order to not lose any screen related update. - + 0 @@ -773,7 +649,7 @@ This tracker is used in order to not lose any screen related update. - Parabolic Effect: + Screens: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -782,10 +658,45 @@ This tracker is used in order to not lose any screen related update. - - + + + + Forward ⌘ press from KWin to Latte in order to activate Application Launcher. It is suggested to disable that option if you remove Latte. + + + Press ⌘ to activate Application Launcher + + + + + - + + + + 0 + 0 + + + + + 150 + 0 + + + + + 16777215 + 16777215 + + + + Actions... + + + + + Qt::Horizontal @@ -797,28 +708,120 @@ This tracker is used in order to not lose any screen related update. + + + + - + - + + 0 + 0 + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + Small + + + true + + + + + + + 0 0 + + + 150 + 0 + + + + + 150 + 16777215 + + - Behavior: + Medium - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + true + + + + + + + + 0 + 0 + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + Large + + + true + + + + + + + spread + + + + Qt::Horizontal + + + + 40 + 20 + + + + - - + + - + Qt::Horizontal @@ -831,53 +834,48 @@ This tracker is used in order to not lose any screen related update. - - - - 0 - 0 - - + - Screens: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Context Menu: - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - Start the application automatically after each relogin - - - Enable autostart during startup - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Behavior: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + - + @@ -997,26 +995,10 @@ This tracker is used in order to not lose any screen related update. - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - + + - + Qt::Horizontal @@ -1029,9 +1011,9 @@ This tracker is used in order to not lose any screen related update. - + - Appearance: + Actions: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -1040,69 +1022,176 @@ This tracker is used in order to not lose any screen related update. - - - - Forward ⌘ press from KWin to Latte in order to activate Application Launcher. It is suggested to disable that option if you remove Latte. - - - Press ⌘ to activate Application Launcher - - - - - + + - - - Qt::Horizontal + + + + 0 + 0 + - + - 40 - 20 + 70 + 0 - - - - - - Context Menu: + + + 110 + 16777215 + + + + Different hardware can have different delays during screen changes. +This tracker is used in order to not lose any screen related update. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + ms. + + + 1000 + + + 10000 + + + 100 + + + 2500 - - - - - + - + 0 0 - + + Different hardware can have different delays during screen changes. +This tracker is used in order to not lose any screen related update. + + + reaction delay for changes + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + - 150 - 0 + 20 + 20 - + + + + + + + + + + Qt::Horizontal + + - 16777215 - 16777215 + 40 + 20 + + + + + + + 0 + 0 + + - Actions... + Parabolic Effect: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Use 3D style for notification and shortcut badges + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Start the application automatically after each relogin + + + Enable autostart during startup + + + + + - + Qt::Horizontal @@ -1114,14 +1203,33 @@ This tracker is used in order to not lose any screen related update. + + + + Appearance: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + - - - - Inform Plasma desktop for available desktop space + + + + Qt::Vertical - + + QSizePolicy::Fixed + + + + 20 + 10 + + + diff --git a/app/settings/settingsdialog/tabpreferenceshandler.cpp b/app/settings/settingsdialog/tabpreferenceshandler.cpp index 5cadfe952..8a7e526cd 100644 --- a/app/settings/settingsdialog/tabpreferenceshandler.cpp +++ b/app/settings/settingsdialog/tabpreferenceshandler.cpp @@ -33,13 +33,19 @@ TabPreferences::TabPreferences(Latte::Settings::Dialog::SettingsDialog *parent) void TabPreferences::initUi() { - //! exclusive group + //! exclusive groups m_mouseSensitivityButtons = new QButtonGroup(this); m_mouseSensitivityButtons->addButton(m_ui->lowSensitivityBtn, Latte::Settings::LowMouseSensitivity); m_mouseSensitivityButtons->addButton(m_ui->mediumSensitivityBtn, Latte::Settings::MediumMouseSensitivity); m_mouseSensitivityButtons->addButton(m_ui->highSensitivityBtn, Latte::Settings::HighMouseSensitivity); m_mouseSensitivityButtons->setExclusive(true); + m_parabolicSpreadButtons = new QButtonGroup(this); + m_parabolicSpreadButtons->addButton(m_ui->smallParabolicBtn, Data::Preferences::PARABOLICSPREAD); + m_parabolicSpreadButtons->addButton(m_ui->mediumParabolicBtn, 5); + m_parabolicSpreadButtons->addButton(m_ui->largeParabolicBtn, 7); + m_parabolicSpreadButtons->setExclusive(true); + //! Buttons connect(m_ui->contextMenuActionsBtn, &QPushButton::clicked, this, &TabPreferences::onActionsBtnPressed); @@ -52,6 +58,14 @@ void TabPreferences::initUi() } }); + connect(m_parabolicSpreadButtons, static_cast(&QButtonGroup::buttonToggled), + [ = ](int id, bool checked) { + if (checked) { + m_preferences.parabolicSpread = id; + emit dataChanged(); + } + }); + connect(m_ui->screenTrackerSpinBox, QOverload::of(&QSpinBox::valueChanged), [ = ](int i) { m_preferences.screensDelay = m_ui->screenTrackerSpinBox->value(); emit dataChanged(); @@ -111,6 +125,7 @@ void TabPreferences::initSettings() o_preferences.metaHoldForBadges = m_corona->universalSettings()->metaPressAndHoldEnabled(); o_preferences.borderlessMaximized = m_corona->universalSettings()->canDisableBorders(); o_preferences.mouseSensitivity = m_corona->universalSettings()->sensitivity(); + o_preferences.parabolicSpread = m_corona->universalSettings()->parabolicSpread(); o_preferences.screensDelay = m_corona->universalSettings()->screenTrackerInterval(); m_preferences = o_preferences; @@ -153,6 +168,14 @@ void TabPreferences::updateUi() m_ui->highSensitivityBtn->setChecked(true); } + if (m_preferences.parabolicSpread == Data::Preferences::PARABOLICSPREAD) { + m_ui->smallParabolicBtn->setChecked(true); + } else if (m_preferences.parabolicSpread == 5) { + m_ui->mediumParabolicBtn->setChecked(true); + } else if (m_preferences.parabolicSpread == 7) { + m_ui->largeParabolicBtn->setChecked(true); + } + emit dataChanged(); } @@ -195,6 +218,7 @@ void TabPreferences::save() m_corona->universalSettings()->setMetaPressAndHoldEnabled(m_preferences.metaHoldForBadges); m_corona->universalSettings()->setShowInfoWindow(m_preferences.layoutsInformationWindow); m_corona->universalSettings()->setCanDisableBorders(m_preferences.borderlessMaximized); + m_corona->universalSettings()->setParabolicSpread(m_preferences.parabolicSpread); m_corona->universalSettings()->setScreenTrackerInterval(m_preferences.screensDelay); o_preferences = m_preferences; diff --git a/app/settings/settingsdialog/tabpreferenceshandler.h b/app/settings/settingsdialog/tabpreferenceshandler.h index 214941d7b..743a7d0f7 100644 --- a/app/settings/settingsdialog/tabpreferenceshandler.h +++ b/app/settings/settingsdialog/tabpreferenceshandler.h @@ -70,6 +70,7 @@ private: Latte::Corona *m_corona{nullptr}; QButtonGroup *m_mouseSensitivityButtons; + QButtonGroup *m_parabolicSpreadButtons; //! current data Data::Preferences m_preferences; diff --git a/app/settings/universalsettings.cpp b/app/settings/universalsettings.cpp index c95371db4..46897bd9d 100644 --- a/app/settings/universalsettings.cpp +++ b/app/settings/universalsettings.cpp @@ -50,6 +50,7 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent) connect(this, &UniversalSettings::launchersChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::layoutsMemoryUsageChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::metaPressAndHoldEnabledChanged, this, &UniversalSettings::saveConfig); + connect(this, &UniversalSettings::parabolicSpreadChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::sensitivityChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::screenTrackerIntervalChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::showInfoWindowChanged, this, &UniversalSettings::saveConfig); @@ -193,6 +194,21 @@ void UniversalSettings::setScreenTrackerInterval(int duration) emit screenTrackerIntervalChanged(); } +int UniversalSettings::parabolicSpread() const +{ + return m_parabolicSpread; +} + +void UniversalSettings::setParabolicSpread(const int &spread) +{ + if (m_parabolicSpread == spread) { + return; + } + + m_parabolicSpread = spread; + emit parabolicSpreadChanged(); +} + QString UniversalSettings::singleModeLayoutName() const { return m_singleModeLayoutName; @@ -527,6 +543,7 @@ void UniversalSettings::loadConfig() m_screenTrackerInterval = m_universalGroup.readEntry("screenTrackerInterval", 2500); m_showInfoWindow = m_universalGroup.readEntry("showInfoWindow", true); m_singleModeLayoutName = m_universalGroup.readEntry("singleModeLayoutName", QString()); + m_parabolicSpread = m_universalGroup.readEntry("parabolicSpread", Data::Preferences::PARABOLICSPREAD); m_memoryUsage = static_cast(m_universalGroup.readEntry("memoryUsage", (int)MemoryUsage::SingleLayout)); m_sensitivity = static_cast(m_universalGroup.readEntry("mouseSensitivity", (int)Settings::HighMouseSensitivity)); @@ -550,6 +567,7 @@ void UniversalSettings::saveConfig() m_universalGroup.writeEntry("screenTrackerInterval", m_screenTrackerInterval); m_universalGroup.writeEntry("showInfoWindow", m_showInfoWindow); m_universalGroup.writeEntry("singleModeLayoutName", m_singleModeLayoutName); + m_universalGroup.writeEntry("parabolicSpread", m_parabolicSpread); m_universalGroup.writeEntry("memoryUsage", (int)m_memoryUsage); m_universalGroup.writeEntry("mouseSensitivity", (int)m_sensitivity); syncSettings(); diff --git a/app/settings/universalsettings.h b/app/settings/universalsettings.h index 64d7a52d3..057d1e23a 100644 --- a/app/settings/universalsettings.h +++ b/app/settings/universalsettings.h @@ -12,6 +12,7 @@ #include #include "../apptypes.h" #include "../lattecorona.h" +#include "../data/preferencesdata.h" // Qt #include @@ -47,6 +48,8 @@ class UniversalSettings : public QObject Q_PROPERTY(bool colorsScriptIsPresent READ colorsScriptIsPresent NOTIFY colorsScriptIsPresentChanged) Q_PROPERTY(bool showInfoWindow READ showInfoWindow WRITE setShowInfoWindow NOTIFY showInfoWindowChanged) + Q_PROPERTY(int parabolicSpread READ parabolicSpread WRITE setParabolicSpread NOTIFY parabolicSpreadChanged) + Q_PROPERTY(QString singleModeLayoutName READ singleModeLayoutName WRITE setSingleModeLayoutName NOTIFY singleModeLayoutNameChanged) Q_PROPERTY(QStringList launchers READ launchers WRITE setLaunchers NOTIFY launchersChanged) @@ -91,6 +94,9 @@ public: bool showInfoWindow() const; void setShowInfoWindow(bool show); + int parabolicSpread() const; + void setParabolicSpread(const int &spread); + int version() const; void setVersion(int ver); @@ -138,6 +144,7 @@ signals: void layoutsMemoryUsageChanged(); void isAvailableGeometryBroadcastedToPlasmaChanged(); void metaPressAndHoldEnabledChanged(); + void parabolicSpreadChanged(); void sensitivityChanged(); void screensCountChanged(); void screenScalesChanged(); @@ -182,6 +189,7 @@ private: int m_version{1}; int m_screenTrackerInterval{2500}; + int m_parabolicSpread{Data::Preferences::PARABOLICSPREAD}; QString m_singleModeLayoutName; diff --git a/containment/package/contents/ui/abilities/ParabolicEffect.qml b/containment/package/contents/ui/abilities/ParabolicEffect.qml index d0a1ce97f..0a1d04388 100644 --- a/containment/package/contents/ui/abilities/ParabolicEffect.qml +++ b/containment/package/contents/ui/abilities/ParabolicEffect.qml @@ -25,6 +25,7 @@ Ability.ParabolicEffectPrivate { } factor.maxZoom: Math.max(factor.zoom, animations.requirements.zoomFactor) restoreZoomIsBlocked: restoreZoomIsBlockedFromApplet || (view && view.contextMenuIsShown) + spread: settings ? settings.parabolicSpread : 3 currentParabolicItem: view ? view.parabolic.currentItem : null } diff --git a/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml b/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml index c891c01b0..08a80fbde 100644 --- a/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml +++ b/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml @@ -19,6 +19,7 @@ AbilityHost.ParabolicEffect { property Item debug: null property Item layouts: null property QtObject view: null + property QtObject settings: null readonly property bool horizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal @@ -132,49 +133,6 @@ AbilityHost.ParabolicEffect { lastParabolicItemIndex = index; } - function applyParabolicEffect(index, currentMousePosition, center) { - var rDistance = Math.abs(currentMousePosition - center); - - //check if the mouse goes right or down according to the center - var positiveDirection = ((currentMousePosition - center) >= 0 ); - - if (Qt.application.layoutDirection === Qt.RightToLeft && horizontal) { - positiveDirection = !positiveDirection; - } - - //finding the zoom center e.g. for zoom:1.7, calculates 0.35 - var zoomCenter = (factor.zoom - 1) / 2 - - //computes the in the scale e.g. 0...0.35 according to the mouse distance - //0.35 on the edge and 0 in the center - var firstComputation = (rDistance / center) * zoomCenter; - - //calculates the scaling for the neighbour tasks - var bigNeighbourZoom = Math.min(1 + zoomCenter + firstComputation, factor.zoom); - var smallNeighbourZoom = Math.max(1 + zoomCenter - firstComputation, 1); - - //bigNeighbourZoom = Number(bigNeighbourZoom.toFixed(4)); - //smallNeighbourZoom = Number(smallNeighbourZoom.toFixed(4)); - - var leftScale; - var rightScale; - - if(positiveDirection === true){ - rightScale = bigNeighbourZoom; - leftScale = smallNeighbourZoom; - } - else { - rightScale = smallNeighbourZoom; - leftScale = bigNeighbourZoom; - } - - sglUpdateHigherItemScale(index+1 , rightScale, 0); - sglUpdateLowerItemScale(index-1, leftScale, 0); - - return {leftScale:leftScale, rightScale:rightScale}; - } - - //! TIMERS //! Timer to check if the mouse is still outside the latteView in order to restore applets scales to 1.0 diff --git a/containment/package/contents/ui/applet/ParabolicArea.qml b/containment/package/contents/ui/applet/ParabolicArea.qml index b56e8443f..1f2697463 100644 --- a/containment/package/contents/ui/applet/ParabolicArea.qml +++ b/containment/package/contents/ui/applet/ParabolicArea.qml @@ -18,7 +18,7 @@ Item { readonly property bool isParabolicEnabled: parabolicAreaLoader.isParabolicEnabled readonly property bool isThinTooltipEnabled: parabolicAreaLoader.isThinTooltipEnabled - property real center: (root.isHorizontal ? appletItem.width : appletItem.height) / 2 + property real length: root.isHorizontal ? appletItem.width : appletItem.height MouseArea { id: parabolicMouseArea @@ -111,7 +111,7 @@ Item { } //use the new parabolic effect manager in order to handle all parabolic effect messages - var scales = parabolic.applyParabolicEffect(index, currentMousePosition, center); + var scales = parabolic.applyParabolicEffect(index, currentMousePosition, length); //Left hiddenSpacer if(appletItem.firstAppletInContainer){ @@ -127,71 +127,81 @@ Item { } //scale - function updateScale(nIndex, nScale, step){ - if(appletItem && !appletItem.containsMouse && (appletItem.index === nIndex)){ + function updateScale(nIndex, nScale){ + if(appletItem && (appletItem.index === nIndex) /*&& !appletItem.containsMouse*/){ /*disable it in order to increase parabolic effect responsiveness*/ if ( (parabolicEffectIsSupported && !appletItem.originalAppletBehavior && !appletItem.communicator.indexerIsSupported) && (applet && applet.status !== PlasmaCore.Types.HiddenStatus)){ - if(nScale >= 0) { - wrapper.zoomScale = nScale + step; - } else { - wrapper.zoomScale = wrapper.zoomScale + step; - } + wrapper.zoomScale = Math.max(1, nScale); } } } - function sltUpdateLowerItemScale(delegateIndex, newScale, step) { + function sltUpdateItemScale(delegateIndex, newScales, islower) { + var ishigher = !islower; + var clearrequestedfromlastacceptedsignal = (newScales.length===1) && (newScales[0]===1); + var sideindex = islower ? appletItem.index-1 : appletItem.index+1; + if (delegateIndex === appletItem.index) { if (communicator.parabolicEffectIsSupported) { - communicator.bridge.parabolic.client.hostRequestUpdateLowerItemScale(newScale, step); + if (islower) { + communicator.bridge.parabolic.client.hostRequestUpdateLowerItemScale(newScales); + } else { + communicator.bridge.parabolic.client.hostRequestUpdateHigherItemScale(newScales); + } return; } - if (!appletItem.isSeparator && !appletItem.isMarginsAreaSeparator && !appletItem.isHidden) { - //! when accepted - updateScale(delegateIndex, newScale, step); + if (newScales.length <= 0) { + return + } + + var nextscales = newScales.slice(); //first copy scales in order to not touch referenced/same array to other slots - if (newScale > 1) { // clear lower items - parabolic.sglUpdateLowerItemScale(delegateIndex-1, 1, 0); + if (!appletItem.isSeparator && !appletItem.isMarginsAreaSeparator && !appletItem.isHidden) { //accept signal and apply the first scale in the stack + updateScale(delegateIndex, nextscales[0]); //apply scale + nextscales.splice(0, 1); //remove accepted and previously applied scale + + if ((nextscales.length===1) && (nextscales[0]===1)) { //send clearrequestedfromlastacceptedsignal to inform neighbours in that direction to release zoom + if (islower) { + parabolic.sglUpdateLowerItemScale(sideindex, nextscales); + } else { + parabolic.sglUpdateHigherItemScale(sideindex, nextscales); + } + return; } + } + + if (!clearrequestedfromlastacceptedsignal) { //send remaining scales in the stack as long as this is not the clearrequestedfromlastacceptedsignal, in order to not send twice + if (islower) { + parabolic.sglUpdateLowerItemScale(appletItem.index-1, nextscales); + } else { + parabolic.sglUpdateHigherItemScale(appletItem.index+1, nextscales); + } + } + } else if (islower && clearrequestedfromlastacceptedsignal && (appletItem.index < delegateIndex)) { //accept requestedfromlastacceptedsignal in lower direction if that is the case + if (communicator.parabolicEffectIsSupported) { + communicator.bridge.parabolic.client.hostRequestUpdateLowerItemScale(newScales); } else { - parabolic.sglUpdateLowerItemScale(delegateIndex-1, newScale, step); + updateScale(sideindex, 1); } - } else if ((newScale === 1) && (appletItem.index < delegateIndex)) { - //! apply zoom clearing + } else if (ishigher && clearrequestedfromlastacceptedsignal && (appletItem.index > delegateIndex)) { //accept requestedfromlastacceptedsignal in higher direction if that is the case if (communicator.parabolicEffectIsSupported) { - communicator.bridge.parabolic.client.hostRequestUpdateLowerItemScale(1, step); + communicator.bridge.parabolic.client.hostRequestUpdateHigherItemScale(newScales); } else { - updateScale(appletItem.index, 1, 0); + updateScale(sideindex, 1); } } } - function sltUpdateHigherItemScale(delegateIndex, newScale, step) { - if (delegateIndex === appletItem.index) { - if (communicator.parabolicEffectIsSupported) { - communicator.bridge.parabolic.client.hostRequestUpdateHigherItemScale(newScale, step); - return; - } - if (!appletItem.isSeparator && !appletItem.isMarginsAreaSeparator && !appletItem.isHidden) { - //! when accepted - updateScale(delegateIndex, newScale, step); + function sltUpdateLowerItemScale(delegateIndex, newScales) { + var islower = true; + sltUpdateItemScale(delegateIndex, newScales, islower); + } - if (newScale > 1) { // clear higher items - parabolic.sglUpdateHigherItemScale(delegateIndex+1, 1, 0); - } - } else { - parabolic.sglUpdateHigherItemScale(delegateIndex+1, newScale, step); - } - } else if ((newScale === 1) && (appletItem.index > delegateIndex)) { - //! apply zoom clearing - if (communicator.parabolicEffectIsSupported) { - communicator.bridge.parabolic.client.hostRequestUpdateHigherItemScale(1, step); - } else { - updateScale(appletItem.index, 1, 0); - } - } + function sltUpdateHigherItemScale(delegateIndex, newScales) { + var ishigher = false; + sltUpdateItemScale(delegateIndex, newScales, ishigher); } Component.onCompleted: { diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 98238a1c5..2af4312fa 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -1015,6 +1015,7 @@ Item { debug: _debug layouts: layoutsContainer view: latteView + settings: universalSettings } Ability.PositionShortcuts { diff --git a/declarativeimports/abilities/bridge/ParabolicEffect.qml b/declarativeimports/abilities/bridge/ParabolicEffect.qml index 726474e57..8c85bdf31 100644 --- a/declarativeimports/abilities/bridge/ParabolicEffect.qml +++ b/declarativeimports/abilities/bridge/ParabolicEffect.qml @@ -8,12 +8,12 @@ import QtQuick 2.0 BridgeItem { id: parabolicBridge - function clientRequestUpdateLowerItemScale(newScale, step) { - host.sglUpdateLowerItemScale(appletIndex-1, newScale, step); + function clientRequestUpdateLowerItemScale(newScales) { + host.sglUpdateLowerItemScale(appletIndex-1, newScales); } - function clientRequestUpdateHigherItemScale(newScale, step) { - host.sglUpdateHigherItemScale(appletIndex+1, newScale, step); + function clientRequestUpdateHigherItemScale(newScales) { + host.sglUpdateHigherItemScale(appletIndex+1, newScales); } /*Be Careful, needs to be considered how to not create diff --git a/declarativeimports/abilities/client/ParabolicEffect.qml b/declarativeimports/abilities/client/ParabolicEffect.qml index da477ee76..e156f23fa 100644 --- a/declarativeimports/abilities/client/ParabolicEffect.qml +++ b/declarativeimports/abilities/client/ParabolicEffect.qml @@ -20,6 +20,7 @@ AbilityDefinition.ParabolicEffect { factor: ref.parabolic.factor restoreZoomIsBlocked: bridge ? (bridge.parabolic.host.restoreZoomIsBlocked || local.restoreZoomIsBlocked) : local.restoreZoomIsBlocked currentParabolicItem: ref.parabolic.currentParabolicItem + spread: ref.parabolic.spread readonly property bool isActive: bridge !== null //! private properties can not go to definition because can not be made readonly in there @@ -37,6 +38,7 @@ AbilityDefinition.ParabolicEffect { readonly property AbilityDefinition.ParabolicEffect local: AbilityDefinition.ParabolicEffect { id: _localref readonly property bool directRenderingEnabled: _localref._privates.directRenderingEnabled + spread: 3 } Item { @@ -127,34 +129,34 @@ AbilityDefinition.ParabolicEffect { } } - function hostRequestUpdateLowerItemScale(newScale, step){ + function hostRequestUpdateLowerItemScale(newScales){ //! function called from host - sglUpdateLowerItemScale(indexer.itemsCount-1, newScale, step); + sglUpdateLowerItemScale(indexer.itemsCount-1, newScales); } - function hostRequestUpdateHigherItemScale(newScale, step){ + function hostRequestUpdateHigherItemScale(newScales){ //! function called from host - sglUpdateHigherItemScale(0, newScale, step); + sglUpdateHigherItemScale(0, newScales); } - function sltTrackLowerItemScale(delegateIndex, newScale, step){ + function sltTrackLowerItemScale(delegateIndex, newScales){ //! send update signal to host if (bridge) { if (delegateIndex === -1) { - bridge.parabolic.clientRequestUpdateLowerItemScale(newScale, step); - } else if (newScale === 1 && delegateIndex>=0) { - bridge.parabolic.clientRequestUpdateLowerItemScale(1, 0); + bridge.parabolic.clientRequestUpdateLowerItemScale(newScales); + } else if ((newScales.length===1) && (newScales[0]===1) && delegateIndex>=0) { + bridge.parabolic.clientRequestUpdateLowerItemScale(newScales); } } } - function sltTrackHigherItemScale(delegateIndex, newScale, step) { + function sltTrackHigherItemScale(delegateIndex, newScales) { //! send update signal to host if (bridge) { if (delegateIndex >= indexer.itemsCount) { - bridge.parabolic.clientRequestUpdateHigherItemScale(newScale, step); - } else if (newScale === 1 && delegateIndex= 0 ); - - if (Qt.application.layoutDirection === Qt.RightToLeft && horizontal) { - positiveDirection = !positiveDirection; - } - - //finding the zoom center e.g. for zoom:1.7, calculates 0.35 - var zoomCenter = (factor.zoom - 1) / 2 - - //computes the in the scale e.g. 0...0.35 according to the mouse distance - //0.35 on the edge and 0 in the center - var firstComputation = (rDistance / center) * zoomCenter; - - //calculates the scaling for the neighbour tasks - var bigNeighbourZoom = Math.min(1 + zoomCenter + firstComputation, factor.zoom); - var smallNeighbourZoom = Math.max(1 + zoomCenter - firstComputation, 1); - - //bigNeighbourZoom = Number(bigNeighbourZoom.toFixed(4)); - //smallNeighbourZoom = Number(smallNeighbourZoom.toFixed(4)); - - var leftScale; - var rightScale; - - if(positiveDirection === true){ - rightScale = bigNeighbourZoom; - leftScale = smallNeighbourZoom; - } - else { - rightScale = smallNeighbourZoom; - leftScale = bigNeighbourZoom; - } - - sglUpdateHigherItemScale(index+1 , rightScale, 0); - sglUpdateLowerItemScale(index-1, leftScale, 0); - - return {leftScale:leftScale, rightScale:rightScale}; - } - function invkClearZoom() { if (parabolic.restoreZoomIsBlocked) { return diff --git a/declarativeimports/abilities/definition/ParabolicEffect.qml b/declarativeimports/abilities/definition/ParabolicEffect.qml index 9f5e96cad..e0ea7c743 100644 --- a/declarativeimports/abilities/definition/ParabolicEffect.qml +++ b/declarativeimports/abilities/definition/ParabolicEffect.qml @@ -5,12 +5,17 @@ import QtQuick 2.0 +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + import "./paraboliceffect" as ParabolicEffectTypes Item { property bool isEnabled: false property bool restoreZoomIsBlocked: false + property int spread: 3 + property ParabolicEffectTypes.Factor factor: ParabolicEffectTypes.Factor{ zoom: 1.6 maxZoom: 1.6 @@ -23,6 +28,48 @@ Item { property Item currentParabolicItem: null signal sglClearZoom(); - signal sglUpdateLowerItemScale(int delegateIndex, real newScale, real step); - signal sglUpdateHigherItemScale(int delegateIndex, real newScale, real step); + signal sglUpdateLowerItemScale(int delegateIndex, variant newScales); + signal sglUpdateHigherItemScale(int delegateIndex, variant newScales); + + readonly property int _spreadSteps: (spread - 1) / 2 + + function applyParabolicEffect(itemIndex, itemMousePosition, itemLength) { + var percentage = Math.max(0, Math.min(1, itemMousePosition / itemLength)); + + //! left scales + var leftScales = []; + for (var i=_spreadSteps; i>=1; --i) { + leftScales.push(linearEffect(1-percentage, i, _spreadSteps)); + } + leftScales.push(1); //! clearing + + //! right scales + var rightScales = []; + for (var j=_spreadSteps; j>=1; --j) { + rightScales.push(linearEffect(percentage, j, _spreadSteps)); + } + rightScales.push(1); //! clearing + + var reversed = Qt.application.layoutDirection === Qt.RightToLeft && (plasmoid.formFactor === PlasmaCore.Types.Horizontal); + + if (reversed) { + var temp = leftScales; + leftScales = rightScales; + rightScales = temp; + } + + sglUpdateHigherItemScale(itemIndex+1, rightScales); + sglUpdateLowerItemScale(itemIndex-1, leftScales); + + return {leftScale:leftScales[0], rightScale:rightScales[0]}; + } + + function linearEffect(mousePosPercentage, partIndex, partsCount) { + var part = 1/partsCount; + var min = (partIndex-1) * part; + var max = partIndex * part; + var x = min + (max-min) * mousePosPercentage; + var yl = (factor.zoom - 1) * x; + return 1+yl; + } } diff --git a/declarativeimports/abilities/host/ParabolicEffect.qml b/declarativeimports/abilities/host/ParabolicEffect.qml index 4e6259a91..fa57fb67e 100644 --- a/declarativeimports/abilities/host/ParabolicEffect.qml +++ b/declarativeimports/abilities/host/ParabolicEffect.qml @@ -19,6 +19,7 @@ AbilityDefinition.ParabolicEffect { readonly property alias directRenderingEnabled: apis.directRenderingEnabled readonly property alias factor: apis.factor readonly property alias restoreZoomIsBlocked: apis.restoreZoomIsBlocked + readonly property alias spread: apis.spread readonly property alias currentParabolicItem: apis.currentParabolicItem signal sglClearZoom(); diff --git a/declarativeimports/abilities/items/basicitem/ParabolicEventsArea.qml b/declarativeimports/abilities/items/basicitem/ParabolicEventsArea.qml index 893f9c464..acddc3aaa 100644 --- a/declarativeimports/abilities/items/basicitem/ParabolicEventsArea.qml +++ b/declarativeimports/abilities/items/basicitem/ParabolicEventsArea.qml @@ -20,7 +20,7 @@ Item { readonly property bool isParabolicEnabled: parabolicEventsAreaLoader.isParabolicEnabled readonly property bool isThinTooltipEnabled: parabolicEventsAreaLoader.isThinTooltipEnabled - readonly property real center: abilityItem.parabolicItem.center + readonly property real length: abilityItem.isHorizontal ? abilityItem.width : abilityItem.height MouseArea { id: parabolicMouseArea @@ -131,7 +131,7 @@ Item { } //use the new parabolic ability in order to handle all parabolic effect messages - var scales = abilityItem.abilities.parabolic.applyParabolicEffect(index, currentMousePosition, center); + var scales = abilityItem.abilities.parabolic.applyParabolicEffect(index, currentMousePosition, length); //Left hiddenSpacer for first task if((index === abilityItem.abilities.indexer.firstVisibleItemIndex) && abilityItem.abilities.containment.isFirstAppletInContainment) { @@ -153,61 +153,68 @@ Item { } } //zoom - function updateScale(nIndex, nScale, step){ - if (!_parabolicArea.containsMouse && (index === nIndex) && !parabolicItem.isParabolicEventBlocked){ + function updateScale(nIndex, nScale){ + if (index === nIndex /*&& !_parabolicArea.containsMouse*/ /*&& !parabolicItem.isParabolicEventBlocked*/){ //!disabled them in order to provide smoother parabolic effect during dock showing and first hovering if (parabolicItem.isUpdatingOnlySpacers) { var subSpacerScale = (nScale-1)/2; hiddenSpacerLeft.nScale = subSpacerScale; hiddenSpacerRight.nScale = subSpacerScale; } else { - var newScale = 1; - - if(nScale >= 0) { - newScale = nScale + step; - } else { - newScale = abilityItem.parabolicItem.zoom + step; - } - - abilityItem.parabolicItem.zoom = newScale; + abilityItem.parabolicItem.zoom = Math.max(1, nScale); } } } - function sltUpdateLowerItemScale(delegateIndex, newScale, step) { + function sltUpdateItemScale(delegateIndex, newScales, islower) { + var ishigher = !islower; + var clearrequestedfromlastacceptedsignal = (newScales.length===1) && (newScales[0]===1); + var sideindex = islower ? index-1 : index+1; + if (delegateIndex === index) { - if (!abilityItem.isSeparator && !abilityItem.isHidden) { - //! when accepted - updateScale(delegateIndex, newScale, step); + if (newScales.length <= 0) { + return + } + + var nextscales = newScales.slice(); //first copy scales in order to not touch referenced/same array to other slots + + if (!abilityItem.isSeparator && !abilityItem.isHidden) { //accept signal and apply the first scale in the stack + updateScale(delegateIndex, nextscales[0]); //apply scale + nextscales.splice(0,1); //remove accepted and previously applied scale - if (newScale > 1) { // clear lower items - abilityItem.abilities.parabolic.sglUpdateLowerItemScale(delegateIndex-1, 1, 0); + if ((nextscales.length===1) && (nextscales[0]===1)) { //send clearrequestedfromlastacceptedsignal to inform neighbours in that direction to release zoom + if (islower) { + abilityItem.abilities.parabolic.sglUpdateLowerItemScale(sideindex, nextscales); + } else { + abilityItem.abilities.parabolic.sglUpdateHigherItemScale(sideindex, nextscales); + } + return; } - } else { - abilityItem.abilities.parabolic.sglUpdateLowerItemScale(delegateIndex-1, newScale, step); } - } else if ((newScale === 1) && (index < delegateIndex)) { - updateScale(index, 1, 0); - } - } - - function sltUpdateHigherItemScale(delegateIndex, newScale, step) { - if (delegateIndex === index) { - if (!abilityItem.isSeparator && !abilityItem.isHidden) { - //! when accepted - updateScale(delegateIndex, newScale, step); - if (newScale > 1) { // clear lower items - abilityItem.abilities.parabolic.sglUpdateHigherItemScale(delegateIndex+1, 1, 0); // clear higher items + if (!clearrequestedfromlastacceptedsignal) { //send remaining scales in the stack as long as this is not the clearrequestedfromlastacceptedsignal, in order to not send twice + if (islower) { + abilityItem.abilities.parabolic.sglUpdateLowerItemScale(sideindex, nextscales); + } else { + abilityItem.abilities.parabolic.sglUpdateHigherItemScale(sideindex, nextscales); } - } else { - abilityItem.abilities.parabolic.sglUpdateHigherItemScale(delegateIndex+1, newScale, step); } - } else if ((newScale === 1) && (index > delegateIndex)) { - updateScale(index, 1, 0); + } else if ((islower && clearrequestedfromlastacceptedsignal && (index < delegateIndex)) //accept requestedfromlastacceptedsignal in lower direction if that is the case + || (ishigher && clearrequestedfromlastacceptedsignal && (index > delegateIndex))) { //accept requestedfromlastacceptedsignal in higher direction if that is the case + updateScale(index, 1); } } + function sltUpdateLowerItemScale(delegateIndex, newScales) { + var islower = true; + sltUpdateItemScale(delegateIndex, newScales, islower); + } + + function sltUpdateHigherItemScale(delegateIndex, newScales) { + var ishigher = false; + sltUpdateItemScale(delegateIndex, newScales, ishigher); + } + Component.onCompleted: { abilityItem.abilities.parabolic.sglUpdateLowerItemScale.connect(sltUpdateLowerItemScale); abilityItem.abilities.parabolic.sglUpdateHigherItemScale.connect(sltUpdateHigherItemScale); diff --git a/declarativeimports/abilities/items/basicitem/ParabolicItem.qml b/declarativeimports/abilities/items/basicitem/ParabolicItem.qml index 78fa7a8cc..1c22541eb 100644 --- a/declarativeimports/abilities/items/basicitem/ParabolicItem.qml +++ b/declarativeimports/abilities/items/basicitem/ParabolicItem.qml @@ -49,9 +49,7 @@ Item{ property real visualScaledLength: (abilityItem.abilities.metrics.iconSize + abilityItem.abilities.metrics.totals.lengthPaddings) * zoom property real visualScaledThickness: abilityItem.abilities.metrics.totals.thickness * zoom - /// end of Scalers/////// - - property real center: (abilityItem.isHorizontal ? abilityItem.width : abilityItem.height) / 2 + /// end of Scalers/////// readonly property alias contentItemContainer: _contentItemContainer readonly property alias titleTooltipVisualParent: _titleTooltipVisualParent