mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
fix plasma crash with extquotes
rewrite main widget to use signal-slot model
This commit is contained in:
@ -58,6 +58,7 @@ Item {
|
||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
|
||||
}
|
||||
|
||||
signal dropSource(string sourceName)
|
||||
signal needUpdate
|
||||
signal sizeUpdate
|
||||
|
||||
@ -85,7 +86,7 @@ Item {
|
||||
// FIXME: ugly workaround to make some sources working
|
||||
systemmonitorDE.interval = plasmoid.configuration.interval
|
||||
|
||||
if (AWKeys.setDataBySource(sourceName, data, settings)) disconnectSource(sourceName)
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
|
||||
onSourceAdded: {
|
||||
@ -106,7 +107,7 @@ Item {
|
||||
// FIXME: ugly workaround to make some sources working
|
||||
extsysmonDE.interval = plasmoid.configuration.interval
|
||||
|
||||
if (AWKeys.setDataBySource(sourceName, data, settings)) needUpdate()
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +165,16 @@ Item {
|
||||
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
// connect data
|
||||
AWKeys.dropSourceFromDataengine.connect(dropSource)
|
||||
AWKeys.needToBeUpdated.connect(needUpdate)
|
||||
}
|
||||
|
||||
onDropSource: {
|
||||
if (debug) console.log("[main::onDropSource]")
|
||||
if (debug) console.log("[main::onDropSource] : Source " + sourceName)
|
||||
|
||||
systemmonitorDE.disconnectSource(sourceName)
|
||||
}
|
||||
|
||||
onNeedUpdate: {
|
||||
|
@ -355,17 +355,20 @@ QStringList AWKeys::getHddDevices()
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
|
||||
if (sourceName == QString("update")) return true;
|
||||
if (sourceName == QString("update")) {
|
||||
emit(needToBeUpdated());
|
||||
return;
|
||||
}
|
||||
|
||||
// checking
|
||||
if (!checkKeys(data)) return false;
|
||||
if (keys.isEmpty()) return false;
|
||||
if (!checkKeys(data)) return;
|
||||
if (keys.isEmpty()) return;
|
||||
|
||||
// regular expressions
|
||||
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
|
||||
@ -653,11 +656,9 @@ bool AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
|
||||
} else {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source not found";
|
||||
return true;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName << "not found";
|
||||
emit(dropSourceFromDataengine(sourceName));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false);
|
||||
Q_INVOKABLE QStringList getHddDevices();
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params);
|
||||
// values
|
||||
Q_INVOKABLE void graphicalValueByKey();
|
||||
@ -72,6 +72,10 @@ public:
|
||||
// configuration
|
||||
Q_INVOKABLE void editItem(const QString type);
|
||||
|
||||
signals:
|
||||
void dropSourceFromDataengine(const QString source);
|
||||
void needToBeUpdated();
|
||||
|
||||
private slots:
|
||||
void loadKeysFromCache();
|
||||
void reinitKeys();
|
||||
|
Reference in New Issue
Block a user