add function to identify mainitem in applets

--applets can have different main elements based on their
implementation. In such case we use a depth of 2 in order
to search for elements that contain variable isInLatte
pull/3/head
Michail Vourlakos 6 years ago
parent b1ad7f2a18
commit 5bab21d786

@ -29,7 +29,7 @@ function typeOf(obj, className){
} }
function reconsiderAppletIconItem(){ function reconsiderAppletIconItem(){
if (communicator.appletIconItem || !applet || container.disableLatteParabolicIconHeuristics) if (communicator.appletIconItem || !applet || container.disableLatteParabolicIconHeuristics || container.disableLatteIconOverlay)
return; return;
//! searching to find for that applet the first IconItem //! searching to find for that applet the first IconItem
@ -53,6 +53,33 @@ function reconsiderAppletIconItem(){
} }
} }
function checkAndUpdateAppletRootItem() {
if (appletDiscoveredRootItem) {
return;
}
var level0 = applet.children;
for(var i=0; i<level0.length; ++i){
var level1 = level0[i].children;
if (!appletDiscoveredRootItem && level0[i].hasOwnProperty("isInLatte")) {
appletDiscoveredRootItem = level0[i];
}
if (appletDiscoveredRootItem) {
break;
}
for(var j=0; j<level1.length; ++j){
if (!appletDiscoveredRootItem && level1[j].hasOwnProperty("isInLatte")) {
appletDiscoveredRootItem = level1[j];
}
if (appletDiscoveredRootItem) {
break;
}
}
}
}
function identifyGeneric() { function identifyGeneric() {
if (blacklistedApplets.indexOf(applet.pluginName) >= 0) { if (blacklistedApplets.indexOf(applet.pluginName) >= 0) {
return; return;
@ -110,14 +137,12 @@ function identifyKickOff() {
for(var i=0; i<level0.length; ++i){ for(var i=0; i<level0.length; ++i){
var level1 = level0[i].children; var level1 = level0[i].children;
for(var j=0; j<level1.length; ++j){ for(var j=0; j<level1.length; ++j){
if (applet.pluginName === "org.kde.plasma.kickoff") { if (typeOf(level1[j], "QQuickMouseArea")) {
if (typeOf(level1[j], "QQuickMouseArea")) { var level2 = level1[j].children;
var level2 = level1[j].children; for(var k=0; k<level2.length; ++k){
for(var k=0; k<level2.length; ++k){ if (typeOf(level2[k], "IconItem")) {
if (typeOf(level2[k], "IconItem")) { communicator.appletIconItem = level2[k];
communicator.appletIconItem = level2[k]; return;
return;
}
} }
} }
} }

@ -106,7 +106,6 @@ Item {
property string title: isInternalViewSplitter ? "Now Dock Splitter" : "" property string title: isInternalViewSplitter ? "Now Dock Splitter" : ""
property Item applet: null property Item applet: null
property Item appletRootItem: applet && applet.children && applet.children.length>0 ? applet.children[0] : null
property Item latteApplet: applet && (applet.pluginName === root.plasmoidName) ? property Item latteApplet: applet && (applet.pluginName === root.plasmoidName) ?
(applet.children[0] ? applet.children[0] : null) : null (applet.children[0] ? applet.children[0] : null) : null
property Item latteSpacer: applet && (applet.pluginName === "org.kde.latte.spacer") ? property Item latteSpacer: applet && (applet.pluginName === "org.kde.latte.spacer") ?

@ -37,7 +37,10 @@ Item{
// ------------------------------------- // -------------------------------------
// NAME: isInLatte // NAME: isInLatte
// USAGE: property bool isInLatte: false // USAGE: property bool isInLatte: false
// EXPLANATION: Latte sets it to true when this applet is in a Latte containment // EXPLANATION: Latte sets it to true when this applet is in a Latte containment. This parameter
// is very important because it identifies the main element of the applet in which all latte
// parameters need to also placed. Be careful in case you are using CompactRepresentation then
// the main element for which you must place the Latte options is the CompactRepresentation.
property bool appletContainsIsInLatte: appletRootItem && appletRootItem.hasOwnProperty("isInLatte") ? true : false property bool appletContainsIsInLatte: appletRootItem && appletRootItem.hasOwnProperty("isInLatte") ? true : false
// NAME: lattePalette // NAME: lattePalette
@ -99,6 +102,10 @@ Item{
readonly property bool overlayLatteIconIsActive: canShowOverlaiedLatteIcon readonly property bool overlayLatteIconIsActive: canShowOverlaiedLatteIcon
&& !(disableLatteParabolicIconHeuristics || disableLatteIconOverlay) && !(disableLatteParabolicIconHeuristics || disableLatteIconOverlay)
property Item appletRootItem: appletDiscoveredRootItem ? appletDiscoveredRootItem : appletDefaultRootItem
property Item appletDiscoveredRootItem: null
property Item appletDefaultRootItem: applet && applet.children && applet.children.length>0 ? applet.children[0] : null
property Item appletIconItem; //first applet's IconItem to be used by Latte property Item appletIconItem; //first applet's IconItem to be used by Latte
property Item appletImageItem; //first applet's ImageItem to be used by Latte property Item appletImageItem; //first applet's ImageItem to be used by Latte
//! END OF PROPERTIES //! END OF PROPERTIES
@ -136,7 +143,8 @@ Item{
target: container target: container
onAppletChanged: { onAppletChanged: {
if (applet) { if (applet) {
main.reconsiderAppletIconItem(); AppletIdentifier.checkAndUpdateAppletRootItem();
AppletIdentifier.reconsiderAppletIconItem();
overlayInitTimer.start(); overlayInitTimer.start();
} }
} }
@ -167,6 +175,7 @@ Item{
id: overlayInitTimer id: overlayInitTimer
interval: 4000 interval: 4000
onTriggered: { onTriggered: {
AppletIdentifier.checkAndUpdateAppletRootItem();
AppletIdentifier.reconsiderAppletIconItem(); AppletIdentifier.reconsiderAppletIconItem();
if (root.debugModeTimers) { if (root.debugModeTimers) {

Loading…
Cancel
Save