mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57: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: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||
text.text = AWKeys.parsePattern()
|
||||
tooltip.text = AWKeys.toolTipImage()
|
||||
|
||||
sizeUpdate()
|
||||
@ -211,7 +211,7 @@ Item {
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys()
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
AWKeys.initTooltip(tooltipSettings)
|
||||
AWKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||
AWKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||
|
@ -86,7 +86,7 @@ AWKeys::~AWKeys()
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys()
|
||||
void AWKeys::initKeys(const QString currentPattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -96,8 +96,11 @@ void AWKeys::initKeys()
|
||||
extUpgrade.clear();
|
||||
graphicalItems.clear();
|
||||
keys.clear();
|
||||
foundBars.clear();
|
||||
foundKeys.clear();
|
||||
|
||||
// init
|
||||
pattern = currentPattern;
|
||||
extQuotes = getExtQuotes();
|
||||
extScripts = getExtScripts();
|
||||
extUpgrade = getExtUpgrade();
|
||||
@ -143,19 +146,17 @@ bool AWKeys::isDebugEnabled()
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::parsePattern(const QString currentPattern)
|
||||
QString AWKeys::parsePattern()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (keys.isEmpty()) return currentPattern;
|
||||
if (keys.isEmpty()) return pattern;
|
||||
|
||||
QString parsed = currentPattern;
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<keys.count(); i++) {
|
||||
if (keys[i].startsWith(QString("bar")))
|
||||
parsed.replace(QString("$%1").arg(keys[i]), getItemByTag(keys[i])->image(valueByKey(keys[i]).toFloat()));
|
||||
else
|
||||
parsed.replace(QString("$%1").arg(keys[i]), htmlValue(keys[i]));
|
||||
}
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(foundKeys[i]), htmlValue(foundKeys[i]));
|
||||
for (int i=0; i<foundBars.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(foundBars[i]), getItemByTag(foundBars[i])->image(valueByKey(foundBars[i]).toFloat()));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
// wrap new lines if required
|
||||
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
||||
@ -848,6 +849,8 @@ void AWKeys::reinitKeys()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -51,12 +51,12 @@ public:
|
||||
AWKeys(QObject *parent = nullptr);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys();
|
||||
Q_INVOKABLE void initKeys(const QString currentPattern);
|
||||
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
||||
Q_INVOKABLE void setPopupEnabled(const bool popup = false);
|
||||
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString currentPattern);
|
||||
Q_INVOKABLE QString parsePattern();
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
Q_INVOKABLE QSize toolTipSize();
|
||||
// keys
|
||||
@ -93,6 +93,9 @@ private:
|
||||
QString htmlValue(QString key);
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units);
|
||||
// find methods
|
||||
QStringList findGraphicalItems();
|
||||
QStringList findKeys();
|
||||
// get methods
|
||||
QList<ExtQuotes *> getExtQuotes();
|
||||
QList<ExtScript *> getExtScripts();
|
||||
@ -117,8 +120,10 @@ private:
|
||||
QList<ExtQuotes *> extQuotes;
|
||||
QList<ExtScript *> extScripts;
|
||||
QList<ExtUpgrade *> extUpgrade;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
QString pattern;
|
||||
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