mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 16:07:19 +00:00
Revert "drop key definition on startup since it blocks several plasmoid"
This reverts commit 4e78e0e1dd
.
This commit is contained in:
parent
467a3bf508
commit
cf5d713d2e
@ -181,7 +181,7 @@ Item {
|
|||||||
onNeedUpdate: {
|
onNeedUpdate: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.log("[main::onNeedUpdate]")
|
||||||
|
|
||||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
text.text = AWKeys.parsePattern()
|
||||||
tooltip.text = AWKeys.toolTipImage()
|
tooltip.text = AWKeys.toolTipImage()
|
||||||
|
|
||||||
sizeUpdate()
|
sizeUpdate()
|
||||||
@ -211,7 +211,7 @@ Item {
|
|||||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
AWKeys.initKeys()
|
AWKeys.initKeys(plasmoid.configuration.text)
|
||||||
AWKeys.initTooltip(tooltipSettings)
|
AWKeys.initTooltip(tooltipSettings)
|
||||||
AWKeys.setPopupEnabled(plasmoid.configuration.notify)
|
AWKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||||
AWKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
AWKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||||
|
@ -86,7 +86,7 @@ AWKeys::~AWKeys()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::initKeys()
|
void AWKeys::initKeys(const QString currentPattern)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -96,8 +96,11 @@ void AWKeys::initKeys()
|
|||||||
extUpgrade.clear();
|
extUpgrade.clear();
|
||||||
graphicalItems.clear();
|
graphicalItems.clear();
|
||||||
keys.clear();
|
keys.clear();
|
||||||
|
foundBars.clear();
|
||||||
|
foundKeys.clear();
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
pattern = currentPattern;
|
||||||
extQuotes = getExtQuotes();
|
extQuotes = getExtQuotes();
|
||||||
extScripts = getExtScripts();
|
extScripts = getExtScripts();
|
||||||
extUpgrade = getExtUpgrade();
|
extUpgrade = getExtUpgrade();
|
||||||
@ -143,19 +146,17 @@ bool AWKeys::isDebugEnabled()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWKeys::parsePattern(const QString currentPattern)
|
QString AWKeys::parsePattern()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (keys.isEmpty()) return currentPattern;
|
if (keys.isEmpty()) return pattern;
|
||||||
|
|
||||||
QString parsed = currentPattern;
|
QString parsed = pattern;
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
for (int i=0; i<keys.count(); i++) {
|
for (int i=0; i<foundKeys.count(); i++)
|
||||||
if (keys[i].startsWith(QString("bar")))
|
parsed.replace(QString("$%1").arg(foundKeys[i]), htmlValue(foundKeys[i]));
|
||||||
parsed.replace(QString("$%1").arg(keys[i]), getItemByTag(keys[i])->image(valueByKey(keys[i]).toFloat()));
|
for (int i=0; i<foundBars.count(); i++)
|
||||||
else
|
parsed.replace(QString("$%1").arg(foundBars[i]), getItemByTag(foundBars[i])->image(valueByKey(foundBars[i]).toFloat()));
|
||||||
parsed.replace(QString("$%1").arg(keys[i]), htmlValue(keys[i]));
|
|
||||||
}
|
|
||||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||||
// wrap new lines if required
|
// wrap new lines if required
|
||||||
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
||||||
@ -848,6 +849,8 @@ void AWKeys::reinitKeys()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
keys = dictKeys();
|
keys = dictKeys();
|
||||||
|
foundBars = findGraphicalItems();
|
||||||
|
foundKeys = findKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1322,6 +1325,41 @@ float AWKeys::temperature(const float temp, const QString units)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWKeys::findGraphicalItems()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList orderedKeys;
|
||||||
|
for (int i=0; i<graphicalItems.count(); i++)
|
||||||
|
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||||
|
orderedKeys.sort();
|
||||||
|
|
||||||
|
QStringList selectedKeys;
|
||||||
|
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||||
|
if (pattern.contains(QString("$%1").arg(orderedKeys[i]))) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys[i];
|
||||||
|
selectedKeys.append(orderedKeys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWKeys::findKeys()
|
||||||
|
{
|
||||||
|
QStringList selectedKeys;
|
||||||
|
for (int i=0; i<keys.count(); i++) {
|
||||||
|
if (keys[i].startsWith(QString("bar"))) continue;
|
||||||
|
if (pattern.contains(QString("$%1").arg(keys[i]))) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
|
||||||
|
selectedKeys.append(keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<ExtQuotes *> AWKeys::getExtQuotes()
|
QList<ExtQuotes *> AWKeys::getExtQuotes()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
@ -51,12 +51,12 @@ public:
|
|||||||
AWKeys(QObject *parent = nullptr);
|
AWKeys(QObject *parent = nullptr);
|
||||||
~AWKeys();
|
~AWKeys();
|
||||||
|
|
||||||
Q_INVOKABLE void initKeys();
|
Q_INVOKABLE void initKeys(const QString currentPattern);
|
||||||
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
||||||
Q_INVOKABLE void setPopupEnabled(const bool popup = false);
|
Q_INVOKABLE void setPopupEnabled(const bool popup = false);
|
||||||
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
|
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE bool isDebugEnabled();
|
||||||
Q_INVOKABLE QString parsePattern(const QString currentPattern);
|
Q_INVOKABLE QString parsePattern();
|
||||||
Q_INVOKABLE QString toolTipImage();
|
Q_INVOKABLE QString toolTipImage();
|
||||||
Q_INVOKABLE QSize toolTipSize();
|
Q_INVOKABLE QSize toolTipSize();
|
||||||
// keys
|
// keys
|
||||||
@ -93,6 +93,9 @@ private:
|
|||||||
QString htmlValue(QString key);
|
QString htmlValue(QString key);
|
||||||
int numberCpus();
|
int numberCpus();
|
||||||
float temperature(const float temp, const QString units);
|
float temperature(const float temp, const QString units);
|
||||||
|
// find methods
|
||||||
|
QStringList findGraphicalItems();
|
||||||
|
QStringList findKeys();
|
||||||
// get methods
|
// get methods
|
||||||
QList<ExtQuotes *> getExtQuotes();
|
QList<ExtQuotes *> getExtQuotes();
|
||||||
QList<ExtScript *> getExtScripts();
|
QList<ExtScript *> getExtScripts();
|
||||||
@ -117,8 +120,10 @@ private:
|
|||||||
QList<ExtQuotes *> extQuotes;
|
QList<ExtQuotes *> extQuotes;
|
||||||
QList<ExtScript *> extScripts;
|
QList<ExtScript *> extScripts;
|
||||||
QList<ExtUpgrade *> extUpgrade;
|
QList<ExtUpgrade *> extUpgrade;
|
||||||
|
QStringList foundBars, foundKeys, keys;
|
||||||
|
QString pattern;
|
||||||
QMap<QString, QString> values;
|
QMap<QString, QString> values;
|
||||||
QStringList keys, diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
QStringList diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user