Commit f5ed6fad authored by Andras Mantia's avatar Andras Mantia
Browse files

Add option to enable shared folderview content per desktop

Summary:
When enabled, it matches the pre 5.12 behavior. There is no GUI for it
yet.

Reviewers: #plasma, hein

Reviewed By: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10408
parent 16979b97
......@@ -266,7 +266,7 @@ void FolderModel::invalidateFilterIfComplete()
void FolderModel::newFileMenuItemCreated(const QUrl &url)
{
if (m_usedByContainment) {
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
m_screenMapper->addMapping(url, m_screen, ScreenMapper::DelayedSignal);
m_dropTargetPositions.insert(url.fileName(), m_menuPosition);
m_menuPosition = {};
......@@ -322,7 +322,7 @@ void FolderModel::setUrl(const QString& url)
emit iconNameChanged();
if (m_usedByContainment) {
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
m_screenMapper->removeScreen(m_screen, oldUrl);
m_screenMapper->addScreen(m_screen, resolvedUrl());
}
......@@ -629,7 +629,7 @@ void FolderModel::setScreen(int screen)
return;
m_screen = screen;
if (m_usedByContainment) {
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
m_screenMapper->addScreen(screen, resolvedUrl());
}
emit screenChanged();
......@@ -1114,7 +1114,7 @@ void FolderModel::drop(QQuickItem *target, QObject* dropEvent, int row)
}
if (m_usedByContainment) {
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
if (isDropBetweenSharedViews(mimeData->urls(), dropTargetFolderUrl)) {
setSortMode(-1);
for (const auto &url : mimeData->urls()) {
......@@ -1164,7 +1164,7 @@ void FolderModel::drop(QQuickItem *target, QObject* dropEvent, int row)
m_dropTargetPositions.insert(targetUrl.fileName(), dropPos);
m_dropTargetPositionsCleanup->start();
if (m_usedByContainment) {
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
// assign a screen for the item before the copy is actually done, so
// filterAcceptsRow doesn't assign the default screen to it
QUrl url = resolvedUrl();
......@@ -1498,7 +1498,7 @@ bool FolderModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen
const KDirModel *dirModel = static_cast<KDirModel*>(sourceModel());
const KFileItem item = dirModel->itemForIndex(dirModel->index(sourceRow, KDirModel::Name, sourceParent));
if (m_usedByContainment) {
if (m_usedByContainment && !m_screenMapper->sharedDesktops()) {
const QUrl url = item.url();
const int screen = m_screenMapper->screenForItem(url);
// don't do anything if the folderview is not associated with a screen
......
......@@ -179,6 +179,19 @@ void ScreenMapper::removeItemFromDisabledScreen(const QUrl &url)
}
}
void ScreenMapper::setSharedDesktop(bool sharedDesktops)
{
if (m_sharedDesktops != sharedDesktops) {
m_sharedDesktops = true;
if (!m_corona)
return;
auto config = m_corona->config();
KConfigGroup group(config, QLatin1String("ScreenMapping"));
group.writeEntry(QLatin1String("sharedDesktops"), m_sharedDesktops);
}
}
#ifdef BUILD_TESTING
void ScreenMapper::cleanup()
{
......@@ -208,6 +221,7 @@ void ScreenMapper::setCorona(Plasma::Corona *corona)
KConfigGroup group(config, QLatin1String("ScreenMapping"));
const QStringList mapping = group.readEntry(QLatin1String("screenMapping"), QStringList{});
setScreenMapping(mapping);
m_sharedDesktops = group.readEntry(QLatin1String("sharedDesktops"), false);
}
}
}
......
......@@ -60,6 +60,9 @@ public:
int firstAvailableScreen(const QUrl &screenUrl) const;
void removeItemFromDisabledScreen(const QUrl &url);
bool sharedDesktops() const { return m_sharedDesktops; }
void setSharedDesktop(bool sharedDesktops);
#ifdef BUILD_TESTING
void cleanup();
#endif
......@@ -80,6 +83,7 @@ private:
QVector<int> m_availableScreens;
Plasma::Corona *m_corona = nullptr;
QTimer *m_screenMappingChangedTimer = nullptr;
bool m_sharedDesktops = false; // all screens share the same desktops, disabling the screen mapping
};
#endif // SCREENMAPPER_H
Supports Markdown
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