mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
fix plasma crash with extquotes
rewrite main widget to use signal-slot model
This commit is contained in:
parent
aa15e13713
commit
41deb8ef72
@ -1,3 +1,7 @@
|
||||
Ver.2.3.2:
|
||||
* improve quotes support, e.g. fix plasma crash
|
||||
* rewrite main widget to signal-slot update model
|
||||
|
||||
Ver.2.3.1:
|
||||
- fix bug with no updates from configuration UI
|
||||
- fix invalid vertical tab parsing
|
||||
|
@ -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();
|
||||
|
@ -52,6 +52,9 @@ ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName, const QStringLis
|
||||
values[QString("price")] = 0.0;
|
||||
values[QString("pricechg")] = 0.0;
|
||||
values[QString("percpricechg")] = 0.0;
|
||||
|
||||
manager = new QNetworkAccessManager(this);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +62,9 @@ ExtQuotes::~ExtQuotes()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
|
||||
delete manager;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -235,13 +241,11 @@ void ExtQuotes::readConfiguration()
|
||||
QMap<QString, float> ExtQuotes::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!m_active) return values;
|
||||
if ((!m_active) || (isRunning)) return values;
|
||||
|
||||
if (times == 1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Send request";
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
|
||||
isRunning = true;
|
||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
||||
new QReplyTimeout(reply, 1000);
|
||||
}
|
||||
@ -351,6 +355,8 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
||||
values[QString("pricechg")] = values[QString("price")] == 0 ? 0.0 : value - values[QString("price")];
|
||||
values[QString("percpricechg")] = 100 * values[QString("pricechg")] / values[QString("price")];
|
||||
values[QString("price")] = value;
|
||||
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,6 +96,8 @@ private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
QNetworkAccessManager *manager;
|
||||
bool isRunning = false;
|
||||
Ui::ExtQuotes *ui;
|
||||
QString url();
|
||||
// properties
|
||||
|
Loading…
Reference in New Issue
Block a user