1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-24 18:03:53 +03:00

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
This commit is contained in:
Michail Vourlakos 2018-10-23 00:01:18 +03:00
parent b1ad7f2a18
commit 5bab21d786
3 changed files with 45 additions and 12 deletions

View File

@ -29,7 +29,7 @@ function typeOf(obj, className){
}
function reconsiderAppletIconItem(){
if (communicator.appletIconItem || !applet || container.disableLatteParabolicIconHeuristics)
if (communicator.appletIconItem || !applet || container.disableLatteParabolicIconHeuristics || container.disableLatteIconOverlay)
return;
//! 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() {
if (blacklistedApplets.indexOf(applet.pluginName) >= 0) {
return;
@ -110,14 +137,12 @@ function identifyKickOff() {
for(var i=0; i<level0.length; ++i){
var level1 = level0[i].children;
for(var j=0; j<level1.length; ++j){
if (applet.pluginName === "org.kde.plasma.kickoff") {
if (typeOf(level1[j], "QQuickMouseArea")) {
var level2 = level1[j].children;
for(var k=0; k<level2.length; ++k){
if (typeOf(level2[k], "IconItem")) {
communicator.appletIconItem = level2[k];
return;
}
if (typeOf(level1[j], "QQuickMouseArea")) {
var level2 = level1[j].children;
for(var k=0; k<level2.length; ++k){
if (typeOf(level2[k], "IconItem")) {
communicator.appletIconItem = level2[k];
return;
}
}
}

View File

@ -106,7 +106,6 @@ Item {
property string title: isInternalViewSplitter ? "Now Dock Splitter" : ""
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) ?
(applet.children[0] ? applet.children[0] : null) : null
property Item latteSpacer: applet && (applet.pluginName === "org.kde.latte.spacer") ?

View File

@ -37,7 +37,10 @@ Item{
// -------------------------------------
// NAME: isInLatte
// 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
// NAME: lattePalette
@ -99,6 +102,10 @@ Item{
readonly property bool overlayLatteIconIsActive: canShowOverlaiedLatteIcon
&& !(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 appletImageItem; //first applet's ImageItem to be used by Latte
//! END OF PROPERTIES
@ -136,7 +143,8 @@ Item{
target: container
onAppletChanged: {
if (applet) {
main.reconsiderAppletIconItem();
AppletIdentifier.checkAndUpdateAppletRootItem();
AppletIdentifier.reconsiderAppletIconItem();
overlayInitTimer.start();
}
}
@ -167,6 +175,7 @@ Item{
id: overlayInitTimer
interval: 4000
onTriggered: {
AppletIdentifier.checkAndUpdateAppletRootItem();
AppletIdentifier.reconsiderAppletIconItem();
if (root.debugModeTimers) {