mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-13 22:05:48 +00:00
Revert "drop key definition on startup since it blocks several plasmoid"
This reverts commit 4e78e0e1dd
.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user