fix restoring splitters on startup

v0.6
Michail Vourlakos 8 years ago
parent 43354c2f46
commit 65b3e313c1

@ -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;

@ -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<totalChildren; ++i){

Loading…
Cancel
Save