protect user from changing to occupied edges

--Views should not move to already occupied screen
edges except in the case these are found in Shared
Layouts
pull/6/head
Michail Vourlakos 6 years ago
parent bb8a946140
commit ae2bc089ff

@ -148,40 +148,31 @@ PlasmaComponents.Page {
Component.onCompleted: screenRow.updateScreens();
//they are used to restore the index when the screen edge
//is occupied
property bool acceptedIndex: true
property int previousIndex: -1
onCurrentIndexChanged: {
//it is used to restore the index when the screen edge
//is occupied
if (!acceptedIndex) {
acceptedIndex = true;
currentIndex = previousIndex;
}
}
onActivated: {
previousIndex = currentIndex;
var succeed = false;
if (index === 0) {
var succeed = latteView.positioner.setCurrentScreen("primary");
succeed = latteView.positioner.setCurrentScreen("primary");
latteView.onPrimary = true;
acceptedIndex = true;
if (succeed) {
latteView.onPrimary = true;
} else if (!latteView.onPrimary){
console.log("the edge is already occupied!!!");
currentIndex = findScreen(latteView.positioner.currentScreenName);
}
} else if (index>0 && (index !== findScreen(latteView.positioner.currentScreenName) || latteView.onPrimary)) {
console.log("current index changed!!! :"+ index);
console.log("screen must be changed...");
var succeed = latteView.positioner.setCurrentScreen(textAt(index));
succeed = latteView.positioner.setCurrentScreen(textAt(index));
if(succeed) {
latteView.onPrimary = false;
} else {
console.log("the edge is already occupied!!!");
acceptedIndex = false;
currentIndex = findScreen(latteView.positioner.currentScreenName);
}
}
}
}
function findScreen(scrName) {

Loading…
Cancel
Save