fix #217,adaptive applet size based on screen

--the user instead of setting the size in pixels,
can set a per centage value which is calculated
based on the current screen height
pull/1/head
Michail Vourlakos 8 years ago
parent 70e3c2bb7a
commit 909538369f

@ -37,8 +37,8 @@ Image{
property int speed: root.durationTime*4*units.longDuration
property int thickness: visibilityManager.thicknessNormalOriginal + root.editShadow
property int rootThickness: visibilityManager.thicknessZoomOriginal + root.editShadow
property int editLength: root.isHorizontal ? (root.drawShadowsExternal ? root.width - plasmoid.configuration.iconSize/4 : root.maxLength) :
(root.drawShadowsExternal ? root.height - plasmoid.configuration.iconSize/4 : root.maxLength)
property int editLength: root.isHorizontal ? (root.drawShadowsExternal ? root.width - root.maxIconSize/4 : root.maxLength) :
(root.drawShadowsExternal ? root.height - root.maxIconSize/4 : root.maxLength)
property bool animationSent: false
property bool farEdge: (plasmoid.location===PlasmaCore.Types.BottomEdge) || (plasmoid.location===PlasmaCore.Types.RightEdge)

@ -141,7 +141,7 @@ Item{
property int panelSize: automaticPanelSize
property int automaticPanelSize: {
if (root.drawShadowsExternal) {
var iconS = 1.2*plasmoid.configuration.iconSize + 1;
var iconS = 1.2*root.maxIconSize + 1;
root.realPanelThickness = iconS;
return iconS;
} else {

@ -49,18 +49,18 @@ Item{
//it is used in order to not break the calculations for the thickness placement
//especially in automatic icon sizes calculations
property real iconMarginOriginal: 0.12*plasmoid.configuration.iconSize
property int statesLineSizeOriginal: root.latteApplet ? Math.ceil( plasmoid.configuration.iconSize/13 ) : 0
property real iconMarginOriginal: 0.12*root.maxIconSize
property int statesLineSizeOriginal: root.latteApplet ? Math.ceil( root.maxIconSize/13 ) : 0
property int thicknessAutoHidden: 2
property int thicknessMid: root.statesLineSize + (1 + (0.65 * (root.zoomFactor-1)))*(root.iconSize+root.iconMargin) //needed in some animations
property int thicknessNormal: Math.max(root.statesLineSize + root.iconSize + root.iconMargin + 1, root.realPanelSize + root.panelShadow)
property int thicknessZoom: root.statesLineSize + ((root.iconSize+root.iconMargin) * root.zoomFactor) + 2
//it is used to keep thickness solid e.g. when iconSize changes from auto functions
property int thicknessMidOriginal: Math.max(thicknessNormalOriginal, statesLineSizeOriginal + (1 + (0.65 * (root.zoomFactor-1)))*(plasmoid.configuration.iconSize+iconMarginOriginal)) //needed in some animations
property int thicknessMidOriginal: Math.max(thicknessNormalOriginal, statesLineSizeOriginal + (1 + (0.65 * (root.zoomFactor-1)))*(root.maxIconSize+iconMarginOriginal)) //needed in some animations
property int thicknessNormalOriginal: Math.max(thicknessNormalOriginalValue, root.realPanelSize + root.panelShadow)
property int thicknessNormalOriginalValue: statesLineSizeOriginal + plasmoid.configuration.iconSize + iconMarginOriginal + 1
property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((plasmoid.configuration.iconSize+iconMarginOriginal) * root.zoomFactor) + 2,
property int thicknessNormalOriginalValue: statesLineSizeOriginal + root.maxIconSize + iconMarginOriginal + 1
property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((root.maxIconSize+iconMarginOriginal) * root.zoomFactor) + 2,
root.realPanelSize + root.panelShadow)
Binding{

@ -75,10 +75,13 @@ DragDrop.DropArea {
property int animationsNeedThickness: 0 // animations need thickness, e.g. bouncing animation
property int automaticIconSizeBasedSize: -1 //it is not set, this is the defautl
property int iconSize: automaticIconSizeBasedSize > 0 ? Math.min(automaticIconSizeBasedSize, plasmoid.configuration.iconSize) :
plasmoid.configuration.iconSize
property int proportionIconSize: {
//what is the highest icon size based on what icon size is used, screen calculated or user specified
property int maxIconSize: proportionIconSize!==-1 ? proportionIconSize : plasmoid.configuration.iconSize
property int iconSize: automaticIconSizeBasedSize > 0 ? Math.min(automaticIconSizeBasedSize, root.maxIconSize) :
root.maxIconSize
property int proportionIconSize: { //icon size based on screen height
return (plasmoid.configuration.proportionIconSize===-1) ? -1 : Math.round(Screen.height * plasmoid.configuration.proportionIconSize/100/8)*8;
}
@ -512,7 +515,7 @@ DragDrop.DropArea {
}
onIconSizeChanged: {
if (((iconSize === automaticIconSizeBasedSize) || (iconSize === plasmoid.configuration.iconSize)) && automaticSizeAnimation){
if (((iconSize === automaticIconSizeBasedSize) || (iconSize === root.maxIconSize)) && automaticSizeAnimation){
slotAnimationsNeedBothAxis(-1);
automaticSizeAnimation=false;
}
@ -939,7 +942,7 @@ DragDrop.DropArea {
function updateAutomaticIconSize() {
if ((visibilityManager.normalState && !root.editMode)
&& (iconSize===plasmoid.configuration.iconSize || iconSize === automaticIconSizeBasedSize) ) {
&& (iconSize===root.maxIconSize || iconSize === automaticIconSizeBasedSize) ) {
var layoutLength;
var maxLength = root.maxLength;
@ -959,7 +962,7 @@ DragDrop.DropArea {
if (layoutLength > toShrinkLimit) { //must shrink
// console.log("step3");
var nextIconSize = plasmoid.configuration.iconSize;
var nextIconSize = root.maxIconSize;
do {
nextIconSize = nextIconSize - iconStep;
@ -984,10 +987,10 @@ DragDrop.DropArea {
if (nextLength2 < toGrowLimit) {
foundGoodSize = nextIconSize2;
}
} while ( (nextLength2<toGrowLimit) && (nextIconSize2 !== plasmoid.configuration.iconSize ));
} while ( (nextLength2<toGrowLimit) && (nextIconSize2 !== root.maxIconSize ));
if (foundGoodSize > 0) {
if (foundGoodSize === plasmoid.configuration.iconSize) {
if (foundGoodSize === root.maxIconSize) {
automaticIconSizeBasedSize = -1;
} else {
automaticIconSizeBasedSize = foundGoodSize;
@ -1137,7 +1140,7 @@ DragDrop.DropArea {
id: dndSpacer
property int normalSize: root.statesLineSize + root.iconSize + root.iconMargin - 1
//visibilityManager.statesLineSizeOriginal + plasmoid.configuration.iconSize + visibilityManager.iconMarginOriginal - 1
//visibilityManager.statesLineSizeOriginal + root.maxIconSize + visibilityManager.iconMarginOriginal - 1
width: normalSize
height: normalSize

@ -114,7 +114,7 @@ PlasmaComponents.Page {
Layout.fillWidth: true
value: plasmoid.configuration.proportionIconSize
minimumValue: 2.5
maximumValue: 8
maximumValue: 10
stepSize: 0.5
property real realMinimum: minimumValue + 0.5

Loading…
Cancel
Save