Commit 6acf1f32 authored by Andras Mantia's avatar Andras Mantia

Store screenMapping info only once

Summary:
Until now every FolderView applet stored exactly the same screenMapping info in the config file. Store it only once
using the config object of the Plasma::Corona

Reviewers: #plasma, mwolff, hein, broulik, mlaurent, mart

Reviewed By: #plasma, mlaurent, mart

Subscribers: mart, mlaurent, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9300
parent d0437195
......@@ -37,10 +37,6 @@
<default></default>
</entry>
<entry name="screenMapping" type="StringList" hidden="true">
<default></default>
</entry>
<entry name="url" type="String">
<label>URL of the file system location being shown.</label>
<default>desktop:/</default>
......
......@@ -188,18 +188,6 @@ Item {
onPositionsChanged: {
folderView.positions = plasmoid.configuration.positions;
}
onScreenMappingChanged: {
Folder.ScreenMapper.screenMapping = plasmoid.configuration.screenMapping;
}
}
Connections {
target: Folder.ScreenMapper
onScreenMappingChanged: {
plasmoid.configuration.screenMapping = Folder.ScreenMapper.screenMapping;
}
}
PlasmaCore.ColorScope {
......@@ -239,7 +227,6 @@ Item {
}
Component.onCompleted: {
Folder.ScreenMapper.screenMapping = plasmoid.configuration.screenMapping;
folderView.sortMode = plasmoid.configuration.sortMode;
folderView.positions = plasmoid.configuration.positions;
}
......
......@@ -24,6 +24,8 @@
#include <QTimer>
#include <Plasma/Corona>
#include <KConfig>
#include <KConfigGroup>
ScreenMapper *ScreenMapper::instance()
{
......@@ -39,6 +41,16 @@ ScreenMapper::ScreenMapper(QObject *parent)
connect(m_screenMappingChangedTimer, &QTimer::timeout,
this, &ScreenMapper::screenMappingChanged);
connect(this, &ScreenMapper::screenMappingChanged, this, [this] {
if (!m_corona)
return;
auto config = m_corona->config();
KConfigGroup group(config, QLatin1String("ScreenMapping"));
group.writeEntry(QLatin1String("screenMapping"), screenMapping());
config->sync();
});
// used to compress screenMappingChanged signals when addMapping is called multiple times,
// eg. from FolderModel::filterAcceptRows. The timer interval is an arbitrary number,
// that doesn't delay too much the signal, but still compresses as much as possible
......@@ -193,6 +205,11 @@ void ScreenMapper::setCorona(Plasma::Corona *corona)
connect(m_corona, &Plasma::Corona::screenAdded, this, [this] (int screenId) {
addScreen(screenId, {});
});
auto config = m_corona->config();
KConfigGroup group(config, QLatin1String("ScreenMapping"));
const QStringList mapping = group.readEntry(QLatin1String("screenMapping"), QStringList{});
setScreenMapping(mapping);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment