From f9d400fa4abd5cbefb8bbb003d1a0ba6214b7f80 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 6 Mar 2021 11:52:48 +0200 Subject: [PATCH] provide fastLayoutManager save options --- containment/package/contents/ui/main.qml | 6 +-- containment/plugin/layoutmanager.cpp | 50 ++++++++++++++++++++++++ containment/plugin/layoutmanager.h | 2 + 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 7da3a347c..d50eb6bd0 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -844,14 +844,14 @@ Item { endLayout: layoutsContainer.endLayout metrics: _metrics + onLockedZoomAppletsChanged: plasmoid.configuration.lockedZoomApplets = fastLayoutManager.lockedZoomApplets; + onUserBlocksColorizingAppletsChanged: plasmoid.configuration.userBlocksColorizingApplets = fastLayoutManager.userBlocksColorizingApplets; + onAppletOrderChanged: { plasmoid.configuration.appletOrder = fastLayoutManager.appletOrder; root.updateIndexes(); } - onLockedZoomAppletsChanged: plasmoid.configuration.lockedZoomApplets = fastLayoutManager.lockedZoomApplets; - onUserBlocksColorizingAppletsChanged: plasmoid.configuration.userBlocksColorizingApplets = fastLayoutManager.userBlocksColorizingApplets; - onSplitterPositionChanged: { plasmoid.configuration.splitterPosition = fastLayoutManager.splitterPosition; root.updateIndexes(); diff --git a/containment/plugin/layoutmanager.cpp b/containment/plugin/layoutmanager.cpp index 287db4b3e..7f16493b8 100644 --- a/containment/plugin/layoutmanager.cpp +++ b/containment/plugin/layoutmanager.cpp @@ -516,10 +516,60 @@ void LayoutManager::save() setAppletOrder(appletIds.join(";")); + saveOptions(); + qDebug() << "org.kde.latte saving applets:: " << appletOrder() << " :: " << splitterPosition() << " : " << splitterPosition2(); qDebug() << "org.kde.latte saving properties:: " << lockedZoomApplets() << " :: " << userBlocksColorizingApplets(); } +void LayoutManager::saveOptions() +{ + saveOption("lockedZoomApplets"); + saveOption("userBlocksColorizingApplets"); +} + +void LayoutManager::saveOption(const QString &option) +{ + if (!m_startLayout || !m_mainLayout || !m_endLayout) { + return; + } + + QStringList applets; + + const char *optionchars = option.toLatin1().constData(); + + for (int i=0; i<=2; ++i) { + QQuickItem *layout = (i==0 ? m_startLayout : (i==1 ? m_mainLayout : m_endLayout)); + + if (layout->childItems().count() > 0) { + int size = layout->childItems().count(); + for (int j=size-1; j>=0; --j) { + QQuickItem *item = layout->childItems()[j]; + bool issplitter = item->property("isInternalViewSplitter").toBool(); + if (!issplitter) { + bool enabled = item->property(optionchars).toBool(); + if (enabled) { + QVariant appletVariant = item->property("applet"); + if (!appletVariant.isValid()) { + continue; + } + QObject *applet = appletVariant.value(); + uint id = applet->property("id").toUInt(); + + applets << QString::number(id); + } + } + } + } + } + + if (option == "lockedZoomApplets") { + setLockedZoomApplets(applets.join(";")); + } else if (option == "userBlocksColorizingApplets") { + setUserBlocksColorizingApplets(applets.join(";")); + } +} + void LayoutManager::insertBefore(QQuickItem *hoveredItem, QQuickItem *item) { if (!hoveredItem || !item) { diff --git a/containment/plugin/layoutmanager.h b/containment/plugin/layoutmanager.h index e7c476a17..15a651c7b 100644 --- a/containment/plugin/layoutmanager.h +++ b/containment/plugin/layoutmanager.h @@ -120,6 +120,8 @@ private slots: private: void restoreOptions(); void restoreOption(const QString &option); + void saveOptions(); + void saveOption(const QString &option); void setSplitterPosition(const int &position); void setSplitterPosition2(const int &position);