improvements for automatic icon size code path

--this patch add two fixes concerning automatic
icon size when contents exceed the view maximum
length.
--A) when the function is called then it also
called one more time after 1sec to confirm that
the icon size found is valid. In the past that
approach was creating an endless loop that should
not be triggered any more
--B) the grow limit was made to be equal with
the shrink limit trying to be more predictive from
the user when the items will grow or shrink. In
the future we must take care of this if the items
grow or shrink endlessly

BUG:411860
FIXED-IN:0.9.3
pull/9/head
Michail Vourlakos 6 years ago
parent 3a2fc4ef2c
commit 182831a808

@ -1377,11 +1377,17 @@ Item {
} }
function updateAutomaticIconSize() { function updateAutomaticIconSize() {
if ( !blockAutomaticUpdateIconSize.running && !visibilityManager.inTempHiding if ( !doubleCallAutomaticUpdateIconSize.running && !visibilityManager.inTempHiding
&& ((visibilityManager.normalState || root.editMode) && ((visibilityManager.normalState || root.editMode)
&& (root.autoDecreaseIconSize || (!root.autoDecreaseIconSize && root.iconSize!=root.maxIconSize))) && (root.autoDecreaseIconSize || (!root.autoDecreaseIconSize && root.iconSize!=root.maxIconSize)))
&& (iconSize===root.maxIconSize || iconSize === automaticIconSizeBasedSize) ) { && (iconSize===root.maxIconSize || iconSize === automaticIconSizeBasedSize) ) {
blockAutomaticUpdateIconSize.start();
//!doubler timer
if (!doubleCallAutomaticUpdateIconSize.secondTimeCallApplied) {
doubleCallAutomaticUpdateIconSize.start();
} else {
doubleCallAutomaticUpdateIconSize.secondTimeCallApplied = false;
}
var layoutLength; var layoutLength;
var maxLength = root.maxLength; var maxLength = root.maxLength;
@ -1397,8 +1403,11 @@ Item {
layoutsContainer.startLayout.width+layoutsContainer.mainLayout.width+layoutsContainer.endLayout.width : layoutsContainer.mainLayout.width layoutsContainer.startLayout.width+layoutsContainer.mainLayout.width+layoutsContainer.endLayout.width : layoutsContainer.mainLayout.width
} }
var toShrinkLimit = maxLength-((root.zoomFactor-1)*(iconSize + thickMargins)); var toShrinkLimit = maxLength-((1+(root.zoomFactor-1))*(iconSize + lengthMargins));
var toGrowLimit = maxLength-1.5*((root.zoomFactor-1)*(iconSize + thickMargins)); var toGrowLimit = maxLength-((1+(root.zoomFactor-1))*(iconSize + lengthMargins));
//console.log("toShrinkLimit: "+ toShrinkLimit);
//console.log("toGrowLimit: "+ toGrowLimit);
var newIconSizeFound = false; var newIconSizeFound = false;
if (layoutLength > toShrinkLimit) { //must shrink if (layoutLength > toShrinkLimit) { //must shrink
@ -1414,7 +1423,7 @@ Item {
automaticIconSizeBasedSize = nextIconSize; automaticIconSizeBasedSize = nextIconSize;
newIconSizeFound = true; newIconSizeFound = true;
console.log("Step 3 - found:"+automaticIconSizeBasedSize); // console.log("Step 3 - found:"+automaticIconSizeBasedSize);
} else if ((layoutLength<toGrowLimit } else if ((layoutLength<toGrowLimit
&& (iconSize === automaticIconSizeBasedSize)) ) { //must grow probably && (iconSize === automaticIconSizeBasedSize)) ) { //must grow probably
// console.log("step4"); // console.log("step4");
@ -1906,13 +1915,19 @@ Item {
} }
} }
// This function is very costly! This timer makes sure that it can be called //! This functions makes sure to call the updateAutomaticIconSize(); function which is costly
// only once every 1sec. //! one more time after its last call to confirm the applied icon size found
Timer{ Timer{
id:blockAutomaticUpdateIconSize id:doubleCallAutomaticUpdateIconSize
interval: 1000 interval: 1000
repeat: false property bool secondTimeCallApplied: false
onTriggered: root.updateAutomaticIconSize();
onTriggered: {
if (!secondTimeCallApplied) {
secondTimeCallApplied = true;
root.updateAutomaticIconSize();
}
}
} }
//! It is used in order to slide-in the latteView on startup //! It is used in order to slide-in the latteView on startup

Loading…
Cancel
Save