From 40b4851dac1cd369f13ce0442fa7cc2d31955747 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 12 Feb 2022 22:06:05 +0200 Subject: [PATCH] introduce thickness margin influence option --- app/data/preferencesdata.cpp | 8 + app/data/preferencesdata.h | 2 + app/settings/settingsdialog/settingsdialog.ui | 624 ++++++++---------- .../settingsdialog/tabpreferenceshandler.cpp | 52 +- .../settingsdialog/tabpreferenceshandler.h | 2 +- app/settings/universalsettings.cpp | 28 +- app/settings/universalsettings.h | 6 + .../contents/ui/abilities/ParabolicEffect.qml | 2 +- 8 files changed, 358 insertions(+), 366 deletions(-) diff --git a/app/data/preferencesdata.cpp b/app/data/preferencesdata.cpp index eb46f04a4..f4aa6d3c7 100644 --- a/app/data/preferencesdata.cpp +++ b/app/data/preferencesdata.cpp @@ -17,6 +17,7 @@ const bool Preferences::METAPRESSFORAPPLAUNCHER; const bool Preferences::METAHOLDFORBADGES; const int Preferences::PARABOLICSPREAD; const int Preferences::SCREENSDELAY; +const float Preferences::THICKNESSMARGININFLUENCE = 1.0f; const Settings::MouseSensitivity Preferences::MOUSESENSITIVITY; Preferences::Preferences() @@ -34,6 +35,7 @@ Preferences::Preferences(Preferences &&o) metaHoldForBadges(o.metaHoldForBadges), mouseSensitivity(o.mouseSensitivity), parabolicSpread(o.parabolicSpread), + thicknessMarginInfluence(o.thicknessMarginInfluence), screensDelay(o.screensDelay) { } @@ -49,6 +51,7 @@ Preferences::Preferences(const Preferences &o) metaHoldForBadges(o.metaHoldForBadges), mouseSensitivity(o.mouseSensitivity), parabolicSpread(o.parabolicSpread), + thicknessMarginInfluence(o.thicknessMarginInfluence), screensDelay(o.screensDelay) { } @@ -65,6 +68,7 @@ Preferences &Preferences::operator=(const Preferences &rhs) metaHoldForBadges = rhs.metaHoldForBadges; mouseSensitivity = rhs.mouseSensitivity; parabolicSpread = rhs.parabolicSpread; + thicknessMarginInfluence = rhs.thicknessMarginInfluence; screensDelay = rhs.screensDelay; return (*this); @@ -82,6 +86,7 @@ Preferences &Preferences::operator=(Preferences &&rhs) metaHoldForBadges = rhs.metaHoldForBadges; mouseSensitivity = rhs.mouseSensitivity; parabolicSpread = rhs.parabolicSpread; + thicknessMarginInfluence = rhs.thicknessMarginInfluence; screensDelay = rhs.screensDelay; return (*this); @@ -99,6 +104,7 @@ bool Preferences::operator==(const Preferences &rhs) const && (metaHoldForBadges == rhs.metaHoldForBadges) && (mouseSensitivity == rhs.mouseSensitivity) && (parabolicSpread == rhs.parabolicSpread) + && (thicknessMarginInfluence == rhs.thicknessMarginInfluence) && (screensDelay == rhs.screensDelay); } @@ -119,6 +125,7 @@ bool Preferences::inDefaultValues() const && (metaHoldForBadges == METAHOLDFORBADGES) && (mouseSensitivity == MOUSESENSITIVITY) && (parabolicSpread == PARABOLICSPREAD) + && (thicknessMarginInfluence == THICKNESSMARGININFLUENCE) && (screensDelay == SCREENSDELAY); } @@ -134,6 +141,7 @@ void Preferences::setToDefaults() metaHoldForBadges = METAHOLDFORBADGES; mouseSensitivity = MOUSESENSITIVITY; parabolicSpread = PARABOLICSPREAD; + thicknessMarginInfluence = THICKNESSMARGININFLUENCE; screensDelay = SCREENSDELAY; } diff --git a/app/data/preferencesdata.h b/app/data/preferencesdata.h index d05a1df17..53b7fbe4a 100644 --- a/app/data/preferencesdata.h +++ b/app/data/preferencesdata.h @@ -28,6 +28,7 @@ public: static const bool METAHOLDFORBADGES = true; static const int PARABOLICSPREAD = 3; static const int SCREENSDELAY = 2500; + static const float THICKNESSMARGININFLUENCE; static const Settings::MouseSensitivity MOUSESENSITIVITY = Settings::HighMouseSensitivity; Preferences(); @@ -44,6 +45,7 @@ public: bool metaHoldForBadges{METAHOLDFORBADGES}; int parabolicSpread{PARABOLICSPREAD}; int screensDelay{SCREENSDELAY}; + float thicknessMarginInfluence{THICKNESSMARGININFLUENCE}; QStringList contextMenuAlwaysActions{Data::ContextMenu::ACTIONSALWAYSVISIBLE}; Settings::MouseSensitivity mouseSensitivity{MOUSESENSITIVITY}; diff --git a/app/settings/settingsdialog/settingsdialog.ui b/app/settings/settingsdialog/settingsdialog.ui index 39617d1a4..a6a90f6b4 100644 --- a/app/settings/settingsdialog/settingsdialog.ui +++ b/app/settings/settingsdialog/settingsdialog.ui @@ -533,59 +533,7 @@ - - - - - Inform Plasma desktop for available desktop space - - - - - - - Activate support for borderless maximized windows between different layouts - - - Support borderless maximized windows in different layouts - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - + @@ -596,39 +544,10 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - - - - Press and hold ⌘ to show shortcuts badges for applets and tasks - - - Press and Hold ⌘ to show shortcuts badges - - - - - + + - + Qt::Horizontal @@ -641,7 +560,7 @@ - + 0 @@ -649,7 +568,7 @@ - Screens: + Parabolic Effect: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -658,59 +577,7 @@ - - - - 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 - - - - 40 - 20 - - - - - - - + @@ -818,10 +685,143 @@ - - + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Start the application automatically after each relogin + + + Enable autostart during startup + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Press and hold ⌘ to show shortcuts badges for applets and tasks + + + Press and Hold ⌘ to show shortcuts badges + + + + + + + Use 3D style for notification and shortcut badges + + + + + - + + + + 150 + 0 + + + + 0% + + + true + + + + + + + + 150 + 0 + + + + 50% + + + true + + + + + + + + 150 + 0 + + + + 100% + + + true + + + + + + + thickness margin influence + + + + + Qt::Horizontal @@ -833,15 +833,15 @@ - - - - Context Menu: - - - + + + + Inform Plasma desktop for available desktop space + + + @@ -875,124 +875,44 @@ - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + - - - - 0 - 0 - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Low sensitivity for parabolic effect (low cpu usage and performance) - - - Low - - - true - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Medium sensitivity for parabolic effect (normal cpu usage and performance) - - - Medium - - - true - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - High sensitivity for parabolic effect (high cpu usage and performance) - - - High - - - true - - - - - - - mouse sensitivity - - - - - + Qt::Horizontal - - QSizePolicy::Expanding - - 60 + 40 20 + + + + Context Menu: + + + @@ -1022,7 +942,82 @@ - + + + + + + + 0 + 0 + + + + + 150 + 0 + + + + + 16777215 + 16777215 + + + + Actions... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Screens: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + @@ -1106,85 +1101,13 @@ This tracker is used in order to not lose any screen related update. - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - 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 + Activate support for borderless maximized windows between different layouts - Enable autostart during startup + Support borderless maximized windows in different layouts @@ -1215,8 +1138,8 @@ This tracker is used in order to not lose any screen related update. - - + + Qt::Vertical @@ -1231,6 +1154,35 @@ This tracker is used in order to not lose any screen related update. + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + 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 + + + diff --git a/app/settings/settingsdialog/tabpreferenceshandler.cpp b/app/settings/settingsdialog/tabpreferenceshandler.cpp index 8a7e526cd..262f6d833 100644 --- a/app/settings/settingsdialog/tabpreferenceshandler.cpp +++ b/app/settings/settingsdialog/tabpreferenceshandler.cpp @@ -34,30 +34,26 @@ TabPreferences::TabPreferences(Latte::Settings::Dialog::SettingsDialog *parent) void TabPreferences::initUi() { //! 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); + m_thicknessMarginInfluenceButtons = new QButtonGroup(this); + m_thicknessMarginInfluenceButtons->addButton(m_ui->noMarginInfluenceBtn, 0); // 0% + m_thicknessMarginInfluenceButtons->addButton(m_ui->halfMarginInfluenceBtn, 50); // 50% + m_thicknessMarginInfluenceButtons->addButton(m_ui->fullMarginInfluenceBtn, 100); // 100% + m_thicknessMarginInfluenceButtons->setExclusive(true); + + m_ui->noMarginInfluenceBtn->setText(i18nc("number in percentage, e.g. 85%","%1%").arg(0)); + m_ui->halfMarginInfluenceBtn->setText(i18nc("number in percentage, e.g. 85%","%1%").arg(50)); + m_ui->fullMarginInfluenceBtn->setText(i18nc("number in percentage, e.g. 85%","%1%").arg(100)); + //! Buttons connect(m_ui->contextMenuActionsBtn, &QPushButton::clicked, this, &TabPreferences::onActionsBtnPressed); //! signals - connect(m_mouseSensitivityButtons, static_cast(&QButtonGroup::buttonToggled), - [ = ](int id, bool checked) { - if (checked) { - m_preferences.mouseSensitivity = static_cast(id); - emit dataChanged(); - } - }); - connect(m_parabolicSpreadButtons, static_cast(&QButtonGroup::buttonToggled), [ = ](int id, bool checked) { if (checked) { @@ -66,6 +62,14 @@ void TabPreferences::initUi() } }); + connect(m_thicknessMarginInfluenceButtons, static_cast(&QButtonGroup::buttonToggled), + [ = ](int id, bool checked) { + if (checked) { + m_preferences.thicknessMarginInfluence = (id / 100.0f); + emit dataChanged(); + } + }); + connect(m_ui->screenTrackerSpinBox, QOverload::of(&QSpinBox::valueChanged), [ = ](int i) { m_preferences.screensDelay = m_ui->screenTrackerSpinBox->value(); emit dataChanged(); @@ -124,8 +128,8 @@ void TabPreferences::initSettings() o_preferences.metaPressForAppLauncher = m_corona->universalSettings()->kwin_metaForwardedToLatte(); 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.thicknessMarginInfluence = m_corona->universalSettings()->thicknessMarginInfluence(); o_preferences.screensDelay = m_corona->universalSettings()->screenTrackerInterval(); m_preferences = o_preferences; @@ -160,14 +164,6 @@ void TabPreferences::updateUi() m_ui->noBordersForMaximizedChkBox->setChecked(m_preferences.borderlessMaximized); m_ui->screenTrackerSpinBox->setValue(m_preferences.screensDelay); - if (m_preferences.mouseSensitivity == Settings::LowMouseSensitivity) { - m_ui->lowSensitivityBtn->setChecked(true); - } else if (m_preferences.mouseSensitivity == Settings::MediumMouseSensitivity) { - m_ui->mediumSensitivityBtn->setChecked(true); - } else if (m_preferences.mouseSensitivity == Settings::HighMouseSensitivity) { - m_ui->highSensitivityBtn->setChecked(true); - } - if (m_preferences.parabolicSpread == Data::Preferences::PARABOLICSPREAD) { m_ui->smallParabolicBtn->setChecked(true); } else if (m_preferences.parabolicSpread == 5) { @@ -176,6 +172,14 @@ void TabPreferences::updateUi() m_ui->largeParabolicBtn->setChecked(true); } + if (m_preferences.thicknessMarginInfluence == 0.0f) { + m_ui->noMarginInfluenceBtn->setChecked(true); + } else if (m_preferences.thicknessMarginInfluence == 0.5f) { + m_ui->halfMarginInfluenceBtn->setChecked(true); + } else if (m_preferences.thicknessMarginInfluence == Data::Preferences::THICKNESSMARGININFLUENCE) { + m_ui->fullMarginInfluenceBtn->setChecked(true); + } + emit dataChanged(); } @@ -209,7 +213,6 @@ void TabPreferences::resetDefaults() void TabPreferences::save() { - m_corona->universalSettings()->setSensitivity(m_preferences.mouseSensitivity); m_corona->universalSettings()->setAutostart(m_preferences.autostart); m_corona->universalSettings()->setBadges3DStyle(m_preferences.badgeStyle3D); m_corona->universalSettings()->setContextMenuActionsAlwaysShown(m_preferences.contextMenuAlwaysActions); @@ -219,6 +222,7 @@ void TabPreferences::save() m_corona->universalSettings()->setShowInfoWindow(m_preferences.layoutsInformationWindow); m_corona->universalSettings()->setCanDisableBorders(m_preferences.borderlessMaximized); m_corona->universalSettings()->setParabolicSpread(m_preferences.parabolicSpread); + m_corona->universalSettings()->setThicknessMarginInfluence(m_preferences.thicknessMarginInfluence); 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 743a7d0f7..7677805ad 100644 --- a/app/settings/settingsdialog/tabpreferenceshandler.h +++ b/app/settings/settingsdialog/tabpreferenceshandler.h @@ -69,8 +69,8 @@ private: Ui::SettingsDialog *m_ui{nullptr}; Latte::Corona *m_corona{nullptr}; - QButtonGroup *m_mouseSensitivityButtons; QButtonGroup *m_parabolicSpreadButtons; + QButtonGroup *m_thicknessMarginInfluenceButtons; //! current data Data::Preferences m_preferences; diff --git a/app/settings/universalsettings.cpp b/app/settings/universalsettings.cpp index 46897bd9d..0ff0a42e2 100644 --- a/app/settings/universalsettings.cpp +++ b/app/settings/universalsettings.cpp @@ -55,6 +55,7 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent) connect(this, &UniversalSettings::screenTrackerIntervalChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::showInfoWindowChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::singleModeLayoutNameChanged, this, &UniversalSettings::saveConfig); + connect(this, &UniversalSettings::thicknessMarginInfluenceChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::versionChanged, this, &UniversalSettings::saveConfig); connect(this, &UniversalSettings::screenScalesChanged, this, &UniversalSettings::saveScalesConfig); @@ -209,6 +210,21 @@ void UniversalSettings::setParabolicSpread(const int &spread) emit parabolicSpreadChanged(); } +float UniversalSettings::thicknessMarginInfluence() const +{ + return m_thicknessMarginInfluence; +} + +void UniversalSettings::setThicknessMarginInfluence(const float &influence) +{ + if (m_thicknessMarginInfluence == influence) { + return; + } + + m_thicknessMarginInfluence = influence; + emit thicknessMarginInfluenceChanged(); +} + QString UniversalSettings::singleModeLayoutName() const { return m_singleModeLayoutName; @@ -450,7 +466,9 @@ void UniversalSettings::setLayoutsMemoryUsage(MemoryUsage::LayoutsMemory layouts Settings::MouseSensitivity UniversalSettings::sensitivity() { - return m_sensitivity; + //! return always default option as the users have not shown any interest in that option + return Latte::Settings::HighMouseSensitivity; + // return m_sensitivity; } void UniversalSettings::setSensitivity(Settings::MouseSensitivity sense) @@ -460,7 +478,7 @@ void UniversalSettings::setSensitivity(Settings::MouseSensitivity sense) } m_sensitivity = sense; - emit sensitivityChanged(); + // emit sensitivityChanged(); } float UniversalSettings::screenWidthScale(QString screenName) const @@ -544,8 +562,9 @@ void UniversalSettings::loadConfig() m_showInfoWindow = m_universalGroup.readEntry("showInfoWindow", true); m_singleModeLayoutName = m_universalGroup.readEntry("singleModeLayoutName", QString()); m_parabolicSpread = m_universalGroup.readEntry("parabolicSpread", Data::Preferences::PARABOLICSPREAD); + m_thicknessMarginInfluence = m_universalGroup.readEntry("parabolicThicknessMarginInfluence", Data::Preferences::THICKNESSMARGININFLUENCE); m_memoryUsage = static_cast(m_universalGroup.readEntry("memoryUsage", (int)MemoryUsage::SingleLayout)); - m_sensitivity = static_cast(m_universalGroup.readEntry("mouseSensitivity", (int)Settings::HighMouseSensitivity)); + //m_sensitivity = static_cast(m_universalGroup.readEntry("mouseSensitivity", (int)Settings::HighMouseSensitivity)); loadScalesConfig(); @@ -568,8 +587,9 @@ void UniversalSettings::saveConfig() m_universalGroup.writeEntry("showInfoWindow", m_showInfoWindow); m_universalGroup.writeEntry("singleModeLayoutName", m_singleModeLayoutName); m_universalGroup.writeEntry("parabolicSpread", m_parabolicSpread); + m_universalGroup.writeEntry("parabolicThicknessMarginInfluence", m_thicknessMarginInfluence); m_universalGroup.writeEntry("memoryUsage", (int)m_memoryUsage); - m_universalGroup.writeEntry("mouseSensitivity", (int)m_sensitivity); + //m_universalGroup.writeEntry("mouseSensitivity", (int)m_sensitivity); syncSettings(); } diff --git a/app/settings/universalsettings.h b/app/settings/universalsettings.h index 057d1e23a..eb5ac9589 100644 --- a/app/settings/universalsettings.h +++ b/app/settings/universalsettings.h @@ -49,6 +49,7 @@ class UniversalSettings : public QObject Q_PROPERTY(bool showInfoWindow READ showInfoWindow WRITE setShowInfoWindow NOTIFY showInfoWindowChanged) Q_PROPERTY(int parabolicSpread READ parabolicSpread WRITE setParabolicSpread NOTIFY parabolicSpreadChanged) + Q_PROPERTY(float thicknessMarginInfluence READ thicknessMarginInfluence WRITE setThicknessMarginInfluence NOTIFY thicknessMarginInfluenceChanged) Q_PROPERTY(QString singleModeLayoutName READ singleModeLayoutName WRITE setSingleModeLayoutName NOTIFY singleModeLayoutNameChanged) @@ -103,6 +104,9 @@ public: int screenTrackerInterval() const; void setScreenTrackerInterval(int duration); + float thicknessMarginInfluence() const; + void setThicknessMarginInfluence(const float &influence); + QString singleModeLayoutName() const; void setSingleModeLayoutName(QString layoutName); @@ -151,6 +155,7 @@ signals: void screenTrackerIntervalChanged(); void showInfoWindowChanged(); void singleModeLayoutNameChanged(); + void thicknessMarginInfluenceChanged(); void versionChanged(); private slots: @@ -190,6 +195,7 @@ private: int m_screenTrackerInterval{2500}; int m_parabolicSpread{Data::Preferences::PARABOLICSPREAD}; + float m_thicknessMarginInfluence{Data::Preferences::THICKNESSMARGININFLUENCE}; QString m_singleModeLayoutName; diff --git a/containment/package/contents/ui/abilities/ParabolicEffect.qml b/containment/package/contents/ui/abilities/ParabolicEffect.qml index 01821eef6..af0ee632a 100644 --- a/containment/package/contents/ui/abilities/ParabolicEffect.qml +++ b/containment/package/contents/ui/abilities/ParabolicEffect.qml @@ -24,7 +24,7 @@ Ability.ParabolicEffectPrivate { return (maxSize/metrics.iconSize); } factor.maxZoom: Math.max(factor.zoom, animations.requirements.zoomFactor) - factor.marginThicknessZoomInPercentage: 1.0 //100% + factor.marginThicknessZoomInPercentage: settings ? settings.thicknessMarginInfluence : 1.0 //100% restoreZoomIsBlocked: restoreZoomIsBlockedFromApplet || (view && view.contextMenuIsShown) spread: settings ? settings.parabolicSpread : 3