1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +03:00

update applets windows tracking for AppletsRecords

This commit is contained in:
Michail Vourlakos 2020-04-26 20:52:17 +03:00
parent e4a609f250
commit 92a6319dac
5 changed files with 49 additions and 30 deletions

View File

@ -786,7 +786,7 @@ Window{
}
Text{
text: root.appletsNeedWindowsTracking
text: appletsRecords.windowsTrackingCount
}
Text{

View File

@ -336,7 +336,7 @@ Item{
&& !(latteView.visibility.mode === LatteCore.Types.AlwaysVisible /* Visibility */
|| latteView.visibility.mode === LatteCore.Types.WindowsGoBelow
|| latteView.visibility.mode === LatteCore.Types.AutoHide))
|| root.appletsNeedWindowsTracking > 0 /*Applets Neew Windows Tracking */
|| appletsRecords.windowsTrackingCount > 0 /*Applets Need Windows Tracking */
|| root.dragActiveWindowEnabled /*Dragging Active Window(Empty Areas)*/
|| ((root.backgroundOnlyOnMaximized /*Dynamic Background */
|| plasmoid.configuration.solidBackgroundForMaximized

View File

@ -22,6 +22,7 @@ import QtQuick 2.0
Item {
id: records
property int windowsTrackingCount: 0 //! number of applets requesting windows tracking
property real maxInnerZoomFactor: 1.0 //! maximum inner zoom factor based on all applets
property var applets: []
@ -44,10 +45,14 @@ Item {
if (ind>=0) {
//! remove
applets.splice(ind, 1);
updateInnerZoomFactor();
updateValues();
}
}
function addDefaultRecord(applet) {
applets.push({id: applet, innerZoomFactor: 1.0, windowsTrackingEnabled: false});
}
function setInnerZoomFactor(applet, inner) {
var len = applets.length;
var ind = indexOf(applet);
@ -60,11 +65,35 @@ Item {
}
} else {
//! add
applets.push({id: applet, innerZoomFactor: inner});
addDefaultRecord(applet);
applets[len].innerZoomFactor = inner;
updateInnerZoomFactor();
}
}
function setWindowsTrackingEnabled(applet, value) {
var len = applets.length;
var ind = indexOf(applet);
if (ind>=0) {
//! update
if(applets[ind].windowsTrackingEnabled !== value) {
applets[ind].windowsTrackingEnabled = value;
updateWindowsTrackingCount();
}
} else {
//! add
addDefaultRecord(applet);
applets[len].windowsTrackingEnabled = value;
updateWindowsTrackingCount();
}
}
function updateValues() {
updateInnerZoomFactor();
updateWindowsTrackingCount();
}
function updateInnerZoomFactor() {
var len = applets.length;
var max = 1;
@ -77,4 +106,17 @@ Item {
maxInnerZoomFactor = max;
}
function updateWindowsTrackingCount() {
var len = applets.length;
var cnt = 0;
for (var i=0; i<len; ++i) {
if (applets[i].windowsTrackingEnabled) {
cnt = cnt + 1;
}
}
windowsTrackingCount = cnt;
}
}

View File

@ -55,8 +55,6 @@ Item{
readonly property Item requires: AbilityDefinition.AppletRequirements{}
//! END OF PUBLIC PROPERTIES SET THROUGH LATTEBRIDGE.ACTIONS
property bool windowsTrackingEnabledSent: false
//! BEGIN OF FUNCTIONS
function appletIconItemIsShown() {
return appletIconItem && appletIconItem.visible;
@ -85,13 +83,7 @@ Item{
}
onWindowsTrackingEnabledChanged: {
if (requires.windowsTrackingEnabled && !mainCommunicator.windowsTrackingEnabledSent) {
mainCommunicator.windowsTrackingEnabledSent = true;
root.slotAppletsNeedWindowsTracking(1);
} else if (!requires.windowsTrackingEnabled && mainCommunicator.windowsTrackingEnabledSent) {
mainCommunicator.windowsTrackingEnabledSent = false;
root.slotAppletsNeedWindowsTracking(-1);
}
appletItem.appletsRecords.setWindowsTrackingEnabled(appletItem, requires.windowsTrackingEnabled);
}
}
@ -107,13 +99,6 @@ Item{
}
}
Component.onDestruction: {
if (requires.windowsTrackingEnabled && windowsTrackingEnabledSent) {
windowsTrackingEnabledSent = false;
root.slotAppletsNeedWindowsTracking(-1);
}
}
//! END OF CONNECTIONS
//! BEGIN OF LOADERS

View File

@ -252,8 +252,6 @@ Item {
property alias hoveredIndex: layoutsContainer.hoveredIndex
property alias directRenderDelayerIsRunning: directRenderDelayerForEnteringTimer.running
property int appletsNeedWindowsTracking: 0
readonly property int minAppletLengthInConfigure: 64
readonly property int maxJustifySplitterSize: 96
@ -460,10 +458,12 @@ Item {
property Item latteApplet
readonly property alias animations: _animations
readonly property alias appletsRecords: _appletsRecords
readonly property alias autosize: _autosize
readonly property alias container: _container
readonly property alias indicatorsManager: indicators
readonly property alias parabolicManager: _parabolicManager
readonly property alias maskManager: visibilityManager
readonly property alias layoutsContainerItem: layoutsContainer
@ -1231,14 +1231,6 @@ Item {
return false;
}
function slotAppletsNeedWindowsTracking(step) {
if (step === 0) {
return;
}
appletsNeedWindowsTracking = Math.max(appletsNeedWindowsTracking + step, 0);
}
function slotPreviewsShown(){
if (latteView) {
latteView.extendedInterface.deactivateApplets();