Skip to content

Commit 9ef9be9

Browse files
authored
Merge pull request #11 from alexankitty/enhancements
Desaturate, growth, and animation. Fixes #8
2 parents a598deb + 69ec066 commit 9ef9be9

File tree

3 files changed

+93
-10
lines changed

3 files changed

+93
-10
lines changed

contents/config/main.xml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,26 @@
144144
<label>Sets where the indicator should be. 0 = Top, 1 = Bottom, 2 = Left, 3 = Right</label>
145145
<default>0</default>
146146
</entry>
147-
<entry name="usePlasmaStyle" type="Enum">
148-
<label>Enable both Plasma Style and custom indicators. 0 = Only Custom Indicators, 1 = Both.</label>
149-
<default>0</default>
150-
</entry>
151147
<entry name="indicatorStyle" type="Enum">
152148
<label>Select between 1 of 3 indicator styles. 0 = Metro, 1 = Cliora, 2 = Dots</label>
153149
<default>0</default>
154150
</entry>
151+
<entry name="indicatorLimit" type="Int">
152+
<label>Set the maximum number of running indicators to display.</label>
153+
<default>4</default>
154+
</entry>
155+
<entry name="indicatorDesaturate" type="Bool">
156+
<label>Desaturate the indicator when minimized</label>
157+
<default>false</default>
158+
</entry>
159+
<entry name="indicatorGrow" type="Bool">
160+
<label>Shrink the indicator when minimized</label>
161+
<default>false</default>
162+
</entry>
163+
<entry name="indicatorGrowFactor" type="Int">
164+
<label>Amount to grow the indicator by</label>
165+
<default>100</default>
166+
</entry>
155167
<entry name="indicatorSize" type="Int">
156168
<label>Set the size of the indicator in pixels</label>
157169
<default>4</default>

contents/ui/ConfigIndicators.qml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Kirigami.FormLayout {
1818
property alias cfg_indicatorReverse: indicatorReverse.checked
1919
property alias cfg_indicatorOverride: indicatorOverride.checked
2020
property alias cfg_indicatorStyle: indicatorStyle.currentIndex
21+
property alias cfg_indicatorLimit: indicatorLimit.value
22+
property alias cfg_indicatorDesaturate: indicatorDesaturate.checked
23+
property alias cfg_indicatorGrow: indicatorGrow.checked
24+
property alias cfg_indicatorGrowFactor: indicatorGrowFactor.value
2125
property alias cfg_indicatorSize: indicatorSize.value
2226
property alias cfg_indicatorLength: indicatorLength.value
2327
property alias cfg_indicatorRadius: indicatorRadius.value
@@ -93,6 +97,57 @@ Kirigami.FormLayout {
9397
]
9498
}
9599

100+
SpinBox {
101+
enabled: indicatorsEnabled.currentIndex
102+
id: indicatorLimit
103+
Kirigami.FormData.label: i18n("Indicator Limit:")
104+
from: 1
105+
to: 10
106+
}
107+
108+
CheckBox {
109+
enabled: indicatorsEnabled.currentIndex
110+
id: indicatorDesaturate
111+
Kirigami.FormData.label: i18n("Minimize Options:")
112+
text: i18n("Desaturate")
113+
}
114+
115+
CheckBox {
116+
enabled: indicatorsEnabled.currentIndex
117+
id: indicatorGrow
118+
text: i18n("Shrink when minimized")
119+
}
120+
121+
SpinBox {
122+
id: indicatorGrowFactor
123+
enabled: indicatorsEnabled.currentIndex
124+
visible: indicatorGrow.checked
125+
from: 100
126+
to: 10 * 100
127+
stepSize: 25
128+
Kirigami.FormData.label: i18n("Growth/Shrink factor:")
129+
130+
property int decimals: 2
131+
property real realValue: value / 100
132+
133+
validator: DoubleValidator {
134+
bottom: Math.min(indicatorGrowFactor.from, indicatorGrowFactor.to)
135+
top: Math.max(indicatorGrowFactor.from, indicatorGrowFactor.to)
136+
}
137+
138+
textFromValue: function(value, locale) {
139+
return Number(value / 100).toLocaleString(locale, 'f', indicatorGrowFactor.decimals)
140+
}
141+
142+
valueFromText: function(text, locale) {
143+
return Number.fromLocaleString(locale, text) * 100
144+
}
145+
}
146+
147+
Item {
148+
Kirigami.FormData.isSection: true
149+
}
150+
96151
SpinBox {
97152
enabled: indicatorsEnabled.currentIndex
98153
id: indicatorSize

contents/ui/Task.qml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,20 @@ MouseArea {
412412
}
413413
return Math.min((task.childCount === 0) ? 1 : task.childCount, maxStates);
414414
}
415-
readonly property int maxStates: isMetro ? 2 : 4
415+
readonly property int maxStates: plasmoid.configuration.indicatorLimit
416416

417417
Rectangle{
418418
id: stateRect
419+
Behavior on height { PropertyAnimation {} }
420+
Behavior on width { PropertyAnimation {} }
421+
Behavior on color { PropertyAnimation {} }
422+
Behavior on radius { PropertyAnimation {} }
419423
readonly property color decoColor: frame.dominantColor
420-
readonly property int maxStates: isMetro ? 2 : 4
424+
readonly property int maxStates: plasmoid.configuration.indicatorLimit
421425
readonly property bool isFirst: index === 0
422426
readonly property int adjust: plasmoid.configuration.indicatorShrink
423427
readonly property int indicatorLength: plasmoid.configuration.indicatorLength
424-
readonly property int spacing: PlasmaCore.Units.smallSpacing /2
428+
readonly property int spacing: PlasmaCore.Units.smallSpacing
425429
readonly property bool isVertical: {
426430
if(plasmoid.formFactor === PlasmaCore.Types.Vertical && !plasmoid.configuration.indicatorOverride)
427431
return true;
@@ -441,6 +445,7 @@ MouseArea {
441445
var parentSize = !isVertical ? frame.width : frame.height;
442446
var indicatorComputedSize;
443447
var adjustment = isFirst ? adjust : 0
448+
var parentSpacingAdjust = task.childCount >= 1 && maxStates >= 2 ? spacing * 3 : 0 //Spacing fix for multiple items
444449
if(plasmoid.configuration.indicatorDominantColor){
445450
colorEval = decoColor
446451
}
@@ -451,15 +456,22 @@ MouseArea {
451456
colorEval = plasmoid.configuration.indicatorCustomColor
452457
}
453458
if(isFirst){//compute the size
459+
var growFactor = plasmoid.configuration.indicatorGrowFactor / 100
460+
if(plasmoid.configuration.indicatorGrow && task.state === "minimized") {
461+
var mainSize = indicatorLength * growFactor;
462+
}
463+
else{
464+
var mainSize = (parentSize + parentSpacingAdjust);
465+
}
454466
switch(plasmoid.configuration.indicatorStyle){
455467
case 0:
456-
indicatorComputedSize = parentSize - (Math.min(task.childCount, maxStates) * ((spacing + indicatorLength) / 2) + adjust)
468+
indicatorComputedSize = mainSize - (Math.min(task.childCount, maxStates === 1 ? 0 : maxStates) * (spacing + indicatorLength)) - adjust
457469
break
458470
case 1:
459-
indicatorComputedSize = parentSize - (Math.min(task.childCount, maxStates) * ((spacing + indicatorLength)) + adjust)
471+
indicatorComputedSize = mainSize - (Math.min(task.childCount, maxStates === 1 ? 0 : maxStates) * (spacing + indicatorLength)) - adjust
460472
break
461473
case 2:
462-
indicatorComputedSize = indicatorLength
474+
indicatorComputedSize = plasmoid.configuration.indicatorGrow && task.state !== "minimized" ? indicatorLength * growFactor : indicatorLength
463475
break
464476
default:
465477
break
@@ -476,6 +488,10 @@ MouseArea {
476488
width = plasmoid.configuration.indicatorSize
477489
height = indicatorComputedSize
478490
}
491+
if(plasmoid.configuration.indicatorDesaturate && task.state === "minimized") {
492+
var colorHSL = hexToHSL(colorEval)
493+
colorCalc = Qt.hsla(colorHSL.h, 0.2, 0.6, 1)
494+
}
479495
if(!isFirst && plasmoid.configuration.indicatorStyle === 0) {//Metro specific handling
480496
colorCalc = Qt.darker(colorEval, 1.2)
481497
}

0 commit comments

Comments
 (0)