From 72d2df24c74caa774d31edd6a67c6682a279d861 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 26 Aug 2019 14:15:06 +0200 Subject: [PATCH] correctly restore desktop icons --- .../homescreen2/applicationlistmodel.cpp | 11 +++++++++++ containments/homescreen2/applicationlistmodel.h | 1 + .../package/contents/ui/launcher/Delegate.qml | 16 +++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/containments/homescreen2/applicationlistmodel.cpp b/containments/homescreen2/applicationlistmodel.cpp index b3ef771b..14e64209 100644 --- a/containments/homescreen2/applicationlistmodel.cpp +++ b/containments/homescreen2/applicationlistmodel.cpp @@ -45,6 +45,7 @@ ApplicationListModel::ApplicationListModel(HomeScreen *parent) connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList &)), this, SLOT(sycocaDbChanged(const QStringList &))); m_favorites = m_homeScreen->config().readEntry("Favorites", QStringList()); + m_desktopItems = m_homeScreen->config().readEntry("DesktopItems", QStringList()).toSet(); m_appOrder = m_homeScreen->config().readEntry("AppOrder", QStringList()); int i = 0; for (auto app : m_appOrder) { @@ -150,6 +151,8 @@ void ApplicationListModel::loadApplications() if (m_favorites.contains(data.storageId)) { data.location = Favorites; + } else if (m_desktopItems.contains(data.storageId)) { + data.location = Desktop; } auto it = m_appPositions.constFind(service->storageId()); @@ -245,6 +248,14 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) emit favoriteCountChanged(); } + if (location == Desktop) { + m_desktopItems.insert(data.storageId); + m_homeScreen->config().writeEntry("DesktopItems", m_desktopItems.toList()); + } else if (data.location == Favorites) { + m_desktopItems.remove(data.storageId); + m_homeScreen->config().writeEntry("DesktopItems", m_desktopItems.toList()); + } + data.location = location; emit dataChanged(index(row, 0), index(row, 0)); diff --git a/containments/homescreen2/applicationlistmodel.h b/containments/homescreen2/applicationlistmodel.h index 05bb3986..198008e7 100644 --- a/containments/homescreen2/applicationlistmodel.h +++ b/containments/homescreen2/applicationlistmodel.h @@ -99,6 +99,7 @@ private: HomeScreen *m_homeScreen = nullptr; QStringList m_appOrder; QStringList m_favorites; + QSet m_desktopItems; QHash m_appPositions; }; diff --git a/containments/homescreen2/package/contents/ui/launcher/Delegate.qml b/containments/homescreen2/package/contents/ui/launcher/Delegate.qml index e0f42b94..4ae3e6b0 100644 --- a/containments/homescreen2/package/contents/ui/launcher/Delegate.qml +++ b/containments/homescreen2/package/contents/ui/launcher/Delegate.qml @@ -19,6 +19,7 @@ import QtQuick 2.4 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.3 as Controls +import QtGraphicalEffects 1.6 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore @@ -36,6 +37,9 @@ ContainmentLayoutManager.ItemContainer { property var modelData: typeof model !== "undefined" ? model : null + Layout.minimumWidth: availableCellWidth + units.gridUnit + Layout.minimumHeight: availableCellHeight + units.gridUnit + leftPadding: units.smallSpacing * 2 topPadding: units.smallSpacing * 2 rightPadding: units.smallSpacing * 2 @@ -43,6 +47,7 @@ ContainmentLayoutManager.ItemContainer { opacity: dragging ? 0.4 : 1 + key: model.ApplicationStorageIdRole property real dragCenterX property real dragCenterY @@ -113,7 +118,16 @@ ContainmentLayoutManager.ItemContainer { text: modelData ? modelData.ApplicationNameRole : "" font.pixelSize: theme.defaultFont.pixelSize - color: PlasmaCore.ColorScope.textColor + color: model.ApplicationLocationRole == ApplicationListModel.Desktop ? "white" : PlasmaCore.Theme.textColor + + layer.enabled: model.ApplicationLocationRole == ApplicationListModel.Desktop + layer.effect: DropShadow { + horizontalOffset: 0 + verticalOffset: 2 + radius: 8.0 + samples: 16 + color: Qt.rgba(0, 0, 0, 0.8) + } } } }