mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-24 02:50:35 +03:00
support showing applets numbers with badges
-- this is used mainly from globalshortcuts triggering
This commit is contained in:
parent
db28c6bcaf
commit
103b901125
@ -41,7 +41,7 @@ Item {
|
||||
if(root.latteApplet
|
||||
&& root.latteApplet.parabolicManager.firstRealTaskIndex !== -1
|
||||
&& ((appIndex<root.latteAppletPos && index>=root.latteAppletPos)
|
||||
|| (appIndex>root.latteAppletPos && index<=root.latteAppletPos)) ){
|
||||
|| (appIndex>root.latteAppletPos && index<=root.latteAppletPos)) ){
|
||||
var appStep = Math.abs(root.latteAppletPos-appIndex);
|
||||
var signalStep = Math.abs(index - appIndex);
|
||||
|
||||
@ -55,7 +55,7 @@ Item {
|
||||
if (root.latteApplet.parabolicManager.taskIsSeparator(taskIndex))
|
||||
taskIndex = root.latteApplet.parabolicManager.availableHigherIndex(taskIndex + 1);
|
||||
|
||||
//console.log("normal:" + taskIndex + " step:"+internSepStep + " zoom:"+zScale);
|
||||
//console.log("normal:" + taskIndex + " step:"+internSepStep + " zoom:"+zScale);
|
||||
} else if (appIndex>root.latteAppletPos){
|
||||
if (root.latteApplet.parabolicManager.taskIsSeparator(root.tasksCount-1))
|
||||
internSepStep = Math.abs(root.tasksCount-1 - root.latteApplet.parabolicManager.availableLowerIndex(root.tasksCount-1));
|
||||
@ -64,7 +64,7 @@ Item {
|
||||
if (root.latteApplet.parabolicManager.taskIsSeparator(taskIndex))
|
||||
taskIndex = root.latteApplet.parabolicManager.availableLowerIndex(taskIndex - 1);
|
||||
|
||||
//console.log("reverse:" + taskIndex + " step:"+internSepStep + " zoom:"+zScale);
|
||||
//console.log("reverse:" + taskIndex + " step:"+internSepStep + " zoom:"+zScale);
|
||||
}
|
||||
|
||||
root.latteApplet.updateScale(taskIndex, zScale,zStep);
|
||||
@ -172,7 +172,7 @@ Item {
|
||||
}
|
||||
|
||||
//!when there isnt a single task
|
||||
if (latteApplet && (root.latteApplet.parabolicManager.firstRealTaskIndex !== root.latteApplet.parabolicManager.lastRealTaskIndex)) {
|
||||
if (latteApplet && (root.latteApplet.parabolicManager.firstRealTaskIndex !== root.latteApplet.parabolicManager.lastRealTaskIndex)) {
|
||||
if (gTaskIndex === -1 && lTaskIndex === -1){
|
||||
latteApplet.parabolicManager.clearTasksGreaterThan(0);
|
||||
} else {
|
||||
@ -324,4 +324,74 @@ Item {
|
||||
function isSeparator(index){
|
||||
return (separators.indexOf(index) !== -1)
|
||||
}
|
||||
|
||||
function isHidden(index) {
|
||||
return (hidden.indexOf(index) !== -1)
|
||||
}
|
||||
|
||||
//! the pseudo index applet after we take into account the separators before it, hidden applets,
|
||||
//! spacers etc. for example the third applet if there is a separator before it is 1, it isnt 2
|
||||
function pseudoAppletIndex(realIndex) {
|
||||
//var pseudoIndex = realIndex;
|
||||
|
||||
var counter = 0;
|
||||
var originalAppletFound = false;
|
||||
|
||||
for (var i=0; i<layoutsContainer.startLayout.children.length; ++i){
|
||||
var applet = layoutsContainer.startLayout.children[i];
|
||||
|
||||
if (applet) {
|
||||
if (applet.index < realIndex) {
|
||||
if (applet.isLattePlasmoid) {
|
||||
counter = counter + root.latteApplet.parabolicManager.countRealTasks;
|
||||
} else if (!applet.isSeparator && !applet.isSpacer && !applet.isHidden) {
|
||||
counter = counter + 1;
|
||||
}
|
||||
} else if (applet.index === realIndex) {
|
||||
originalAppletFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!originalAppletFound) {
|
||||
for (var j=0; j<layoutsContainer.mainLayout.children.length; ++j){
|
||||
var applet = layoutsContainer.mainLayout.children[j];
|
||||
|
||||
if (applet) {
|
||||
if (applet.index < realIndex) {
|
||||
if (applet.isLattePlasmoid) {
|
||||
counter = counter + root.latteApplet.parabolicManager.countRealTasks;
|
||||
} else if (!applet.isSeparator && !applet.isSpacer && !applet.isHidden) {
|
||||
counter = counter + 1;
|
||||
}
|
||||
} else if (applet.index === realIndex) {
|
||||
originalAppletFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!originalAppletFound) {
|
||||
for (var k=0; j<layoutsContainer.endLayout.children.length; ++k){
|
||||
var applet = layoutsContainer.endLayout.children[k];
|
||||
|
||||
if (applet) {
|
||||
if (applet.index < realIndex) {
|
||||
if (applet.isLattePlasmoid) {
|
||||
counter = counter + root.latteApplet.parabolicManager.countRealTasks;
|
||||
} else if (!applet.isSeparator && !applet.isSpacer && !applet.isHidden) {
|
||||
counter = counter + 1;
|
||||
}
|
||||
} else if (applet.index === realIndex) {
|
||||
originalAppletFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return counter + 1;
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,10 @@ Item {
|
||||
&& applet.pluginName !== "org.kde.activeWindowControl"
|
||||
property bool isHidden: applet && applet.status === PlasmaCore.Types.HiddenStatus ? true : false
|
||||
property bool isInternalViewSplitter: (internalSplitterId > 0)
|
||||
property bool isLattePlasmoid: latteApplet !== null
|
||||
property bool isZoomed: false
|
||||
property bool isSeparator: applet && applet.pluginName === "audoban.applet.separator"
|
||||
property bool isSpacer: latteSpacer !== null
|
||||
property bool isSystray: applet && (applet.pluginName === "org.kde.plasma.systemtray" || applet.pluginName === "org.nomad.systemtray" )
|
||||
|
||||
property bool firstChildOfStartLayout: (index === layoutsContainer.startLayout.beginIndex)
|
||||
|
@ -559,6 +559,68 @@ Item{
|
||||
}
|
||||
}
|
||||
|
||||
/// START Applets Number
|
||||
Loader{
|
||||
id: appletNumberLoader
|
||||
anchors.fill: container.appletWrapper
|
||||
active: opacityN>0
|
||||
asynchronous: true
|
||||
|
||||
property int fixedIndex:-1
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
fixedIndex = parabolicManager.pseudoAppletIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: fixedIndex = parabolicManager.pseudoAppletIndex(index);
|
||||
|
||||
property real opacityN: root.showAppletsNumbers && !container.isSeparator && !container.isHidden
|
||||
&& !container.isLattePlasmoid && !container.isSpacer && fixedIndex<20 ? 1 : 0
|
||||
|
||||
Behavior on opacityN {
|
||||
NumberAnimation { duration: root.durationTime*2*units.longDuration }
|
||||
}
|
||||
|
||||
sourceComponent: Item{
|
||||
Loader{
|
||||
anchors.fill: appletNumber
|
||||
active: root.enableShadows
|
||||
|
||||
sourceComponent: DropShadow{
|
||||
color: root.appShadowColor
|
||||
fast: true
|
||||
samples: 2 * radius
|
||||
source: appletNumber
|
||||
radius: root.appShadowSize/2
|
||||
verticalOffset: 2
|
||||
}
|
||||
}
|
||||
|
||||
Latte.BadgeText {
|
||||
id: appletNumber
|
||||
anchors.centerIn: parent
|
||||
|
||||
width: 0.4 * (root.iconSize)
|
||||
height: width
|
||||
numberValue: appletNumberLoader.fixedIndex < 10 ? appletNumberLoader.fixedIndex : 0
|
||||
textValue: (keysArrayIndex>=0 && keysArrayIndex<10) ? keysAboveTen[keysArrayIndex] : ''
|
||||
|
||||
showNumber: appletNumberLoader.fixedIndex < 10
|
||||
showText: appletNumberLoader.fixedIndex>=10 && appletNumberLoader.fixedIndex<20
|
||||
|
||||
proportion: 0
|
||||
radiusPerCentage: 50
|
||||
|
||||
property int keysArrayIndex: appletNumberLoader.fixedIndex-10;
|
||||
property var keysAboveTen: ['0', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.']
|
||||
}
|
||||
}
|
||||
}
|
||||
//END of Applets number
|
||||
|
||||
|
||||
BrightnessContrast{
|
||||
id:hoveredImage
|
||||
anchors.fill: _wrapperContainer
|
||||
|
@ -1046,6 +1046,12 @@ DragDrop.DropArea {
|
||||
|
||||
//! this is called from globalshortcuts c++ side
|
||||
function setShowAppletsNumbers(showNumbers){
|
||||
if (latteApplet) {
|
||||
var base = parabolicManager.pseudoAppletIndex(latteAppletPos);
|
||||
latteApplet.setTasksNumbersBase(base - 1);
|
||||
latteApplet.setShowTasksNumbers(showNumbers);
|
||||
}
|
||||
|
||||
showAppletsNumbers = showNumbers;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ Item {
|
||||
|
||||
property int firstRealTaskIndex: -1
|
||||
property int lastRealTaskIndex: -1
|
||||
property int countRealTasks: -1
|
||||
|
||||
//tasks that change state (launcher,startup,window) and
|
||||
//at the next state must look the same
|
||||
@ -118,6 +119,8 @@ Item {
|
||||
|
||||
root.separatorsUpdated();
|
||||
}
|
||||
|
||||
countRealTasks = realTasks();
|
||||
}
|
||||
|
||||
//!this is used in order to update the index when the signal is for applets
|
||||
@ -438,7 +441,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
return pseudoIndex;
|
||||
return pseudoIndex + root.tasksNumbersBase;
|
||||
}
|
||||
|
||||
//! first available task index found after consequent internal separators in the start
|
||||
@ -475,6 +478,24 @@ Item {
|
||||
return root.tasksCount > 0 ? root.tasksCount-1 : -1;
|
||||
}
|
||||
|
||||
//! the real number of tasks if we remove the internal separators
|
||||
function realTasks() {
|
||||
var space = lastRealTaskIndex - firstRealTaskIndex;
|
||||
|
||||
if (space >= 0) {
|
||||
var internseparators = 0;
|
||||
for(var i=firstRealTaskIndex; i<lastRealTaskIndex; ++i) {
|
||||
if (taskIsSeparator(i)) {
|
||||
internseparators = internseparators + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return space + 1 - internseparators;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function freeAvailableSeparatorName() {
|
||||
var available = false;
|
||||
var no = 1;
|
||||
|
@ -68,6 +68,7 @@ Item {
|
||||
property bool isHovered: false
|
||||
property bool showBarLine: plasmoid.configuration.showBarLine
|
||||
property bool showTasksNumbers: false
|
||||
property int tasksNumbersBase: 0
|
||||
property bool useThemePanel: plasmoid.configuration.useThemePanel
|
||||
property bool taskInAnimation: noTasksInAnimation > 0 ? true : false
|
||||
property bool transparentPanel: plasmoid.configuration.transparentPanel
|
||||
@ -1524,8 +1525,15 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
//! show/hide tasks numbered badges e.g. from global shortcuts
|
||||
function setShowTasksNumbers(showNumbers){
|
||||
root.showTasksNumbers = showNumbers;
|
||||
showTasksNumbers = showNumbers;
|
||||
}
|
||||
|
||||
//! setup the tasks first index based on the fact that this is a plasmoid
|
||||
//! and applets could exist before it
|
||||
function setTasksNumbersBase(base){
|
||||
tasksNumbersBase = base;
|
||||
}
|
||||
|
||||
function previewContainsMouse() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user