mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-10 04:15:51 +00:00
move dataengine control to plugin part (ref to #66)
This commit is contained in:
@ -118,16 +118,6 @@ Item {
|
||||
QtControls.ComboBox {
|
||||
id: hdd
|
||||
width: parent.width * 3 / 5
|
||||
model: awKeys.getHddDevices(true)
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
||||
if (debug) console.info("Found", model[i], "on", i)
|
||||
hdd.currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,7 +335,16 @@ Item {
|
||||
if (debug) console.debug()
|
||||
|
||||
// init submodule
|
||||
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.queueLimit)
|
||||
awKeys.updateCache()
|
||||
|
||||
// update hdd model
|
||||
hdd.model = awKeys.getHddDevices()
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
||||
if (debug) console.info("Found", model[i], "on", i)
|
||||
hdd.currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
|
@ -63,9 +63,6 @@ Item {
|
||||
"notify": plasmoid.configuration.notify
|
||||
}
|
||||
|
||||
signal connectPlugin
|
||||
signal disconnectPlugin
|
||||
signal dropSource(string sourceName)
|
||||
signal needTextUpdate(string newText)
|
||||
signal needToolTipUpdate(string newText)
|
||||
signal sizeUpdate
|
||||
@ -83,32 +80,6 @@ Item {
|
||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||
Plasmoid.associatedApplication: "ksysguard"
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: systemmonitorDE
|
||||
engine: "systemmonitor"
|
||||
connectedSources: systemmonitorDE.sources
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onSourceAdded: {
|
||||
if (debug) console.debug("Source", source)
|
||||
awKeys.addDevice(source)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "extsysmon"
|
||||
connectedSources: extsysmonDE.sources
|
||||
interval: plasmoid.configuration.interval
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: timeDE
|
||||
engine: "time"
|
||||
connectedSources: ["Local"]
|
||||
interval: 1000
|
||||
}
|
||||
|
||||
|
||||
// ui
|
||||
Text {
|
||||
@ -160,12 +131,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 5 * plasmoid.configuration.interval
|
||||
onTriggered: connectPlugin()
|
||||
}
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
@ -177,42 +142,12 @@ Item {
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
// connect data
|
||||
awKeys.disconnectPlugin.connect(disconnectPlugin)
|
||||
awKeys.dropSourceFromDataengine.connect(dropSource)
|
||||
awKeys.needTextToBeUpdated.connect(needTextUpdate)
|
||||
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
|
||||
connectPlugin()
|
||||
// check updates if required
|
||||
if (plasmoid.configuration.checkUpdates) return awActions.checkUpdates(false)
|
||||
}
|
||||
|
||||
onConnectPlugin: {
|
||||
if (debug) console.debug()
|
||||
|
||||
systemmonitorDE.newData.connect(awKeys.dataUpdateReceived)
|
||||
extsysmonDE.newData.connect(awKeys.dataUpdateReceived)
|
||||
timeDE.newData.connect(awKeys.dataUpdateReceived)
|
||||
|
||||
return awKeys.unlock()
|
||||
}
|
||||
|
||||
onDisconnectPlugin: {
|
||||
if (debug) console.debug()
|
||||
|
||||
systemmonitorDE.newData.disconnect(awKeys.dataUpdateReceived)
|
||||
extsysmonDE.newData.disconnect(awKeys.dataUpdateReceived)
|
||||
timeDE.newData.disconnect(awKeys.dataUpdateReceived)
|
||||
|
||||
return timer.start()
|
||||
}
|
||||
|
||||
onDropSource: {
|
||||
if (debug) console.debug()
|
||||
if (debug) console.debug("Source", sourceName)
|
||||
|
||||
systemmonitorDE.disconnectSource(sourceName)
|
||||
}
|
||||
|
||||
onNeedTextUpdate: {
|
||||
if (debug) console.debug()
|
||||
|
||||
@ -252,7 +187,8 @@ Item {
|
||||
if (debug) console.debug()
|
||||
|
||||
// init submodule
|
||||
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.queueLimit)
|
||||
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.interval,
|
||||
plasmoid.configuration.queueLimit)
|
||||
awKeys.initDataAggregator(tooltipSettings)
|
||||
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||
// configure aggregator
|
||||
|
@ -18,7 +18,6 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Dialogs 1.2 as QtDialogs
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
@ -41,8 +40,8 @@ Item {
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
|
||||
property alias cfg_text: textPattern.text
|
||||
property bool lock: true
|
||||
|
||||
signal dropSource(string sourceName)
|
||||
signal needTextUpdate(string newText)
|
||||
|
||||
|
||||
@ -320,7 +319,9 @@ Item {
|
||||
width: parent.width * 2 / 5
|
||||
text: i18n("Preview")
|
||||
onClicked: {
|
||||
awKeys.initKeys(textPattern.text, plasmoid.configuration.queueLimit)
|
||||
lock = false
|
||||
awKeys.initKeys(textPattern.text, plasmoid.configuration.interval,
|
||||
plasmoid.configuration.queueLimit)
|
||||
awKeys.needToBeUpdated()
|
||||
}
|
||||
}
|
||||
@ -342,67 +343,27 @@ Item {
|
||||
}
|
||||
|
||||
|
||||
// we need to initializate DataEngines here too
|
||||
// because we need to get keys and values
|
||||
PlasmaCore.DataSource {
|
||||
id: systemmonitorDE
|
||||
engine: "systemmonitor"
|
||||
connectedSources: systemmonitorDE.sources
|
||||
interval: 5000
|
||||
onNewData: awKeys.dataUpdateReceived(sourceName, data)
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "extsysmon"
|
||||
connectedSources: extsysmonDE.sources
|
||||
interval: 5000
|
||||
|
||||
onNewData: {
|
||||
// even after a disconnect it is possible that we'll receive an update
|
||||
if (sourceName == "update") return
|
||||
awKeys.dataUpdateReceived(sourceName, data)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: timeDE
|
||||
engine: "time"
|
||||
connectedSources: ["Local"]
|
||||
interval: 5000
|
||||
onNewData: awKeys.dataUpdateReceived(sourceName, data)
|
||||
}
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
|
||||
// drop "update" source which does not required by this page
|
||||
extsysmonDE.disconnectSource("update")
|
||||
awKeys.dropSourceFromDataengine.connect(dropSource)
|
||||
awKeys.needTextToBeUpdated.connect(needTextUpdate)
|
||||
// init submodule
|
||||
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.queueLimit)
|
||||
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.interval,
|
||||
plasmoid.configuration.queueLimit)
|
||||
awKeys.setAggregatorProperty("acOffline", plasmoid.configuration.acOffline)
|
||||
awKeys.setAggregatorProperty("acOnline", plasmoid.configuration.acOnline)
|
||||
awKeys.setAggregatorProperty("customTime", plasmoid.configuration.customTime)
|
||||
awKeys.setAggregatorProperty("customUptime", plasmoid.configuration.customUptime)
|
||||
awKeys.setAggregatorProperty("tempUnits", plasmoid.configuration.tempUnits)
|
||||
awKeys.setAggregatorProperty("translate", plasmoid.configuration.translateStrings)
|
||||
awKeys.unlock()
|
||||
}
|
||||
|
||||
onDropSource: {
|
||||
if (debug) console.debug()
|
||||
if (debug) console.debug("Source", sourceName)
|
||||
|
||||
systemmonitorDE.disconnectSource(sourceName)
|
||||
}
|
||||
|
||||
onNeedTextUpdate: {
|
||||
if (lock) return
|
||||
if (debug) console.debug()
|
||||
|
||||
compiledText.text = newText.replace(/ /g, " ")
|
||||
compiledText.open()
|
||||
lock = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user