From 65b3e313c1b70f05c4234f2b67e24caf7ef3abc8 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 30 Jan 2017 19:27:24 +0200 Subject: [PATCH] fix restoring splitters on startup --- containment/contents/code/LayoutManager.js | 17 ++++++++++++++--- containment/contents/ui/main.qml | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/containment/contents/code/LayoutManager.js b/containment/contents/code/LayoutManager.js index b35312670..5c9c10172 100644 --- a/containment/contents/code/LayoutManager.js +++ b/containment/contents/code/LayoutManager.js @@ -58,6 +58,7 @@ function restore() { root.addApplet(appletsOrder[i], -1, -1) } + // console.log("splitters restored:"+plasmoid.configuration.splitterPosition+ " - " + plasmoid.configuration.splitterPosition2); //add the splitters in the correct position if they exist if(plasmoid.configuration.splitterPosition !== -1){ root.addInternalViewSplitter(plasmoid.configuration.splitterPosition); @@ -67,12 +68,12 @@ function restore() { root.addInternalViewSplitter(plasmoid.configuration.splitterPosition2); } - inRestore = false; - //rewrite, so if in the orders there were now invalid ids or if some were missing creates a correct list instead save(); restoreLocks(); + inRestore = false; + //update layouts in case there is a splitter in them root.updateLayouts(); } @@ -117,6 +118,8 @@ function save() { if(!splitterExists2 && !inRestore) plasmoid.configuration.splitterPosition2 = -1; + //console.log("splitters saved:"+plasmoid.configuration.splitterPosition+ " - " + plasmoid.configuration.splitterPosition2); + plasmoid.configuration.appletOrder = ids.join(';'); } @@ -210,8 +213,11 @@ function insertAfter(item1, item2) { } function insertAtIndex(item, position) { - if (position < 0 || (position >= layout.children.length && position !== 0)) { + var addToEnd = false; + if (position < 0 || (position > layout.children.length)) { return; + } else if (position === layout.children.length) { + addToEnd = true; } //never ever insert after lastSpacer @@ -223,6 +229,11 @@ function insertAtIndex(item, position) { position = 0; } + if (addToEnd){ + item.parent=layout; + return; + } + if(layout.children.length > 0){ if (layout.children[position] === lastSpacer) { --position; diff --git a/containment/contents/ui/main.qml b/containment/contents/ui/main.qml index 121a93302..3323e5d66 100644 --- a/containment/contents/ui/main.qml +++ b/containment/contents/ui/main.qml @@ -945,6 +945,7 @@ DragDrop.DropArea { function updateLayouts(){ if(!root.editMode){ + // console.log("update layout - internal view splitters count:"+internalViewSplittersCount()); if (internalViewSplittersCount() === 2) { var splitter = -1; var splitter2 = -1; @@ -960,12 +961,14 @@ DragDrop.DropArea { } } + // console.log("update layouts 1:"+splitter + " - "+splitter2); for (var i=0; i<=splitter; ++i){ var item = mainLayout.children[0]; item.parent = startLayout; } splitter2 = splitter2 - splitter - 1; + // console.log("update layouts 2:"+splitter + " - "+splitter2); totalChildren = mainLayout.children.length; for (var i=splitter2+1; i