correctly restore desktop icons

This commit is contained in:
Marco Martin 2019-08-26 14:15:06 +02:00
parent 62de2cb1be
commit 72d2df24c7
3 changed files with 27 additions and 1 deletions

View file

@ -45,6 +45,7 @@ ApplicationListModel::ApplicationListModel(HomeScreen *parent)
connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList &)), connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList &)),
this, SLOT(sycocaDbChanged(const QStringList &))); this, SLOT(sycocaDbChanged(const QStringList &)));
m_favorites = m_homeScreen->config().readEntry("Favorites", 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()); m_appOrder = m_homeScreen->config().readEntry("AppOrder", QStringList());
int i = 0; int i = 0;
for (auto app : m_appOrder) { for (auto app : m_appOrder) {
@ -150,6 +151,8 @@ void ApplicationListModel::loadApplications()
if (m_favorites.contains(data.storageId)) { if (m_favorites.contains(data.storageId)) {
data.location = Favorites; data.location = Favorites;
} else if (m_desktopItems.contains(data.storageId)) {
data.location = Desktop;
} }
auto it = m_appPositions.constFind(service->storageId()); auto it = m_appPositions.constFind(service->storageId());
@ -245,6 +248,14 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
emit favoriteCountChanged(); 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; data.location = location;
emit dataChanged(index(row, 0), index(row, 0)); emit dataChanged(index(row, 0), index(row, 0));

View file

@ -99,6 +99,7 @@ private:
HomeScreen *m_homeScreen = nullptr; HomeScreen *m_homeScreen = nullptr;
QStringList m_appOrder; QStringList m_appOrder;
QStringList m_favorites; QStringList m_favorites;
QSet<QString> m_desktopItems;
QHash<QString, int> m_appPositions; QHash<QString, int> m_appPositions;
}; };

View file

@ -19,6 +19,7 @@
import QtQuick 2.4 import QtQuick 2.4
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls 2.3 as Controls import QtQuick.Controls 2.3 as Controls
import QtGraphicalEffects 1.6
import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
@ -36,6 +37,9 @@ ContainmentLayoutManager.ItemContainer {
property var modelData: typeof model !== "undefined" ? model : null property var modelData: typeof model !== "undefined" ? model : null
Layout.minimumWidth: availableCellWidth + units.gridUnit
Layout.minimumHeight: availableCellHeight + units.gridUnit
leftPadding: units.smallSpacing * 2 leftPadding: units.smallSpacing * 2
topPadding: units.smallSpacing * 2 topPadding: units.smallSpacing * 2
rightPadding: units.smallSpacing * 2 rightPadding: units.smallSpacing * 2
@ -43,6 +47,7 @@ ContainmentLayoutManager.ItemContainer {
opacity: dragging ? 0.4 : 1 opacity: dragging ? 0.4 : 1
key: model.ApplicationStorageIdRole
property real dragCenterX property real dragCenterX
property real dragCenterY property real dragCenterY
@ -113,7 +118,16 @@ ContainmentLayoutManager.ItemContainer {
text: modelData ? modelData.ApplicationNameRole : "" text: modelData ? modelData.ApplicationNameRole : ""
font.pixelSize: theme.defaultFont.pixelSize 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)
}
} }
} }
} }