Commit 8f85c465 authored by Bharadwaj Raju's avatar Bharadwaj Raju 📚 Committed by Nate Graham
Browse files

Folder View: save desktop containment icon positions on a per-resolution basis

BUG: 360478
BUG: 354802
FIXED-IN: 5.24.5
(cherry picked from commit 2dca1706)
parent a944f80b
......@@ -30,6 +30,7 @@ FocusScope {
property alias currentIndex: gridView.currentIndex
property alias url: dir.url
property alias status: dir.status
property alias perStripe: positioner.perStripe
property alias positions: positioner.positions
property alias errorString: dir.errorString
property alias dragging: dir.dragging
......@@ -828,20 +829,6 @@ FocusScope {
}
}
onFlowChanged: {
// FIXME TODO: Preserve positions.
if (positioner.enabled) {
positioner.reset();
}
}
onLayoutDirectionChanged: {
// FIXME TODO: Preserve positions.
if (positioner.enabled) {
positioner.reset();
}
}
onCurrentIndexChanged: {
positionViewAtIndex(currentIndex, GridView.Contain);
}
......
......@@ -29,6 +29,8 @@ FocusScope {
property alias overflowing: folderView.overflowing
property alias flow: folderView.flow
property string resolution: Math.round(plasmoid.screenGeometry.width) + "x" + Math.round(plasmoid.screenGeometry.height)
readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
focus: true
......@@ -178,6 +180,26 @@ FocusScope {
}
}
function getPositions() {
try {
var allPositions = JSON.parse(plasmoid.configuration.positions);
} catch (err) {
var allPositions = {};
allPositions[resolution] = plasmoid.configuration.positions;
}
return allPositions[resolution] || "";
}
function savePositions(positions) {
try {
var allPositions = JSON.parse(plasmoid.configuration.positions);
} catch (err) {
var allPositions = {};
}
allPositions[resolution] = positions;
plasmoid.configuration.positions = JSON.stringify(allPositions, Object.keys(allPositions).sort());
}
Connections {
target: plasmoid.configuration
......@@ -211,7 +233,7 @@ FocusScope {
}
function onPositionsChanged() {
folderView.positions = plasmoid.configuration.positions;
folderView.positions = getPositions();
}
}
......@@ -241,12 +263,16 @@ FocusScope {
}
onPositionsChanged: {
plasmoid.configuration.positions = folderView.positions;
savePositions(folderView.positions);
}
onPerStripeChanged: {
folderView.positions = getPositions();
}
Component.onCompleted: {
folderView.sortMode = plasmoid.configuration.sortMode;
folderView.positions = plasmoid.configuration.positions;
folderView.positions = getPositions();
}
}
......
......@@ -854,6 +854,7 @@ void Positioner::applyPositions()
}
if (pos > m_perStripe) {
qDebug() << "Some items did not fit, rearranging";
name = positions.at(offset);
if (!sourceIndices.contains(name)) {
......
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