Re: plasma data engine / property loop

2017-01-15 Thread Martin Koller
On Sunday 15 January 2017 11:16:22 Kevin Krammer wrote:
> Hi Martin,

Hi Kevin,

>
> On Sunday, 2017-01-15, 00:04:23, Martin Koller wrote:
> > Hi,
> >
> > trying to fix the systemload applet (and new to QML), how can one solve the
> > problem: - a data engine delivers the number of CPU cores
> > - depending on this number, I need to separately "connect" to additional
> > sources in this data engine
> >
> > This creates a property loop.
> > dataSources array depends on cores, but cores is set from dataSources
>
> How is cores set from dataSources?

As shown below via onNewData

> Does the source() function below write to cores?

no, it reads from it: for (var i = 0; i < cores; i++) ...

I'll just attach the real qml file
The message I see is
SystemLoadViewer.qml:123:5: QML : Binding loop detected for property 
"connectedSources"


>
> Cheers,
> Kevin
>
> > E.g. (pseudo code)
> >
> > property int cores: 0
> > dataSources: sources()
> >
> > function sources() { ... create array depending on property "cores", like
> > "cpu/cpu/nice" ... }
> >
> > onNewData: { cores = data.value }
>

--
Best regards/Schöne Grüße

Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail
/\- against proprietary attachments

Geschenkideen, Accessoires, Kulinarisches: www.lillehus.at/*
 * Copyright (C) 2014 Martin Yrjölä 
 * Copyright (C) 2015 Joshua Worth 
 * Copyright (C) 2015 Kåre Särs 
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License or (at your option) version 3 or any later version
 * accepted by the membership of KDE e.V. (or its successor approved
 * by the membership of KDE e.V.), which shall act as a proxy
 * defined in Section 14 of version 3 of the license.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see 
 */

import QtQuick 2.2
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kio 1.0 as Kio
import org.kde.plasma.plasmoid 2.0

Item {
id: main

readonly property double maxCpuLoad: 100.0
readonly property int borderWidth: 1
readonly property int borderRounding: 3
readonly property int headingLevel: 2

property bool setColorsManually: plasmoid.configuration.setColorsManually

property var cpuColors: setColorsManually ? [plasmoid.configuration.cpuSysColor,
 plasmoid.configuration.cpuUserColor,
 plasmoid.configuration.cpuNiceColor,
 plasmoid.configuration.cpuIOWaitColor]
  : [theme.buttonFocusColor,
 theme.highlightColor,
 theme.visitedLinkColor,
 theme.linkColor]

property var memoryColors: setColorsManually ? [plasmoid.configuration.memApplicationColor,
plasmoid.configuration.memBuffersColor,
plasmoid.configuration.memCachedColor]
 : [theme.buttonFocusColor,
theme.visitedLinkColor,
theme.highlightColor]

property var swapColors: setColorsManually ? [plasmoid.configuration.swapUsedColor]
   : [theme.hightlightColor]

// Make labels visible first time so that the
// user knows which monitor is which.
implicitWidth: widestLabelWidth()*1.3 * columnCount()
implicitHeight: implicitWidth / 2

property bool circularMonitorsInUse: plasmoid.configuration.monitorType == 1
property bool compactBarMonitorsInUse: plasmoid.configuration.monitorType == 2
property bool allCPUsShown: plasmoid.configuration.cpuAllActivated

property double barsWidth: compactBarMonitorsInUse ? main.height * 0.35 * columnCount()
   : main.height * 0.5 * columnCount()


// Don't show icon in panel.
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation

// Correct the size when in panel

Re: plasma data engine / property loop

2017-01-15 Thread Martin Koller
On Sunday 15 January 2017 12:18:24 Kevin Krammer wrote:
> Hi Martin,
> 
> On Sunday, 2017-01-15, 11:59:08, Martin Koller wrote:
> > On Sunday 15 January 2017 11:16:22 Kevin Krammer wrote:
> > > Hi Martin,
> > 
> > Hi Kevin,
> > 
> > > On Sunday, 2017-01-15, 00:04:23, Martin Koller wrote:
> > > > Hi,
> > > > 
> > > > trying to fix the systemload applet (and new to QML), how can one solve
> > > > the
> > > > problem: - a data engine delivers the number of CPU cores
> > > > - depending on this number, I need to separately "connect" to additional
> > > > sources in this data engine
> > > > 
> > > > This creates a property loop.
> > > > dataSources array depends on cores, but cores is set from dataSources
> > > 
> > > How is cores set from dataSources?
> > 
> > As shown below via onNewData
> 
> Hmm, ok, so setting connectedSources is triggering the newData signal?
> 
> > > Does the source() function below write to cores?
> > 
> > no, it reads from it: for (var i = 0; i < cores; i++) ...
> > 
> > I'll just attach the real qml file
> > The message I see is
> > SystemLoadViewer.qml:123:5: QML : Binding loop detected for property
> > "connectedSources"
> 
> Does it create any problems during operation?
> That "loop" should end after the first roundtrip as maxCpuIndex won't change 
> anymore.
> 
> If there is a problem or you want to tyr getting rid of the warning, you 
> could 
> try this
> 
> connectedSources: [ cores ]
> onMaxCpuIndexChanged: connectedSources = sources();
> 
> I.e. initially connectedSources is bound to just "system/cores".
> Once the value is retrieved, by onNewData, the change of maxCpuIndex will 
> trigger a one-time setting if connectedSources to the result of sources().
> connectedSource then has a fixed value, not a binding.

yep, thanks. Did it similar to this.
I don't like warnings ...


-- 
Best regards/Schöne Grüße

Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\- against proprietary attachments

Geschenkideen, Accessoires, Kulinarisches: www.lillehus.at

signature.asc
Description: This is a digitally signed message part.


Re: plasma data engine / property loop

2017-01-15 Thread Kevin Krammer
Hi Martin,

On Sunday, 2017-01-15, 11:59:08, Martin Koller wrote:
> On Sunday 15 January 2017 11:16:22 Kevin Krammer wrote:
> > Hi Martin,
> 
> Hi Kevin,
> 
> > On Sunday, 2017-01-15, 00:04:23, Martin Koller wrote:
> > > Hi,
> > > 
> > > trying to fix the systemload applet (and new to QML), how can one solve
> > > the
> > > problem: - a data engine delivers the number of CPU cores
> > > - depending on this number, I need to separately "connect" to additional
> > > sources in this data engine
> > > 
> > > This creates a property loop.
> > > dataSources array depends on cores, but cores is set from dataSources
> > 
> > How is cores set from dataSources?
> 
> As shown below via onNewData

Hmm, ok, so setting connectedSources is triggering the newData signal?

> > Does the source() function below write to cores?
> 
> no, it reads from it: for (var i = 0; i < cores; i++) ...
> 
> I'll just attach the real qml file
> The message I see is
> SystemLoadViewer.qml:123:5: QML : Binding loop detected for property
> "connectedSources"

Does it create any problems during operation?
That "loop" should end after the first roundtrip as maxCpuIndex won't change 
anymore.

If there is a problem or you want to tyr getting rid of the warning, you could 
try this

connectedSources: [ cores ]
onMaxCpuIndexChanged: connectedSources = sources();

I.e. initially connectedSources is bound to just "system/cores".
Once the value is retrieved, by onNewData, the change of maxCpuIndex will 
trigger a one-time setting if connectedSources to the result of sources().
connectedSource then has a fixed value, not a binding.

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring


signature.asc
Description: This is a digitally signed message part.