mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
drop key definition on startup since it blocks several plasmoid
instances (refer to #57)
This commit is contained in:
parent
d01fb91e36
commit
4e78e0e1dd
@ -181,7 +181,7 @@ Item {
|
|||||||
onNeedUpdate: {
|
onNeedUpdate: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.log("[main::onNeedUpdate]")
|
||||||
|
|
||||||
text.text = AWKeys.parsePattern()
|
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||||
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(plasmoid.configuration.text)
|
AWKeys.initKeys()
|
||||||
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(const QString currentPattern)
|
void AWKeys::initKeys()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -96,11 +96,8 @@ void AWKeys::initKeys(const QString currentPattern)
|
|||||||
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();
|
||||||
@ -146,17 +143,19 @@ bool AWKeys::isDebugEnabled()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWKeys::parsePattern()
|
QString AWKeys::parsePattern(const QString currentPattern)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (keys.isEmpty()) return pattern;
|
if (keys.isEmpty()) return currentPattern;
|
||||||
|
|
||||||
QString parsed = pattern;
|
QString parsed = currentPattern;
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
for (int i=0; i<foundKeys.count(); i++)
|
for (int i=0; i<keys.count(); i++) {
|
||||||
parsed.replace(QString("$%1").arg(foundKeys[i]), htmlValue(foundKeys[i]));
|
if (keys[i].startsWith(QString("bar")))
|
||||||
for (int i=0; i<foundBars.count(); i++)
|
parsed.replace(QString("$%1").arg(keys[i]), getItemByTag(keys[i])->image(valueByKey(keys[i]).toFloat()));
|
||||||
parsed.replace(QString("$%1").arg(foundBars[i]), getItemByTag(foundBars[i])->image(valueByKey(foundBars[i]).toFloat()));
|
else
|
||||||
|
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>"));
|
||||||
@ -843,8 +842,6 @@ void AWKeys::reinitKeys()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
keys = dictKeys();
|
keys = dictKeys();
|
||||||
foundBars = findGraphicalItems();
|
|
||||||
foundKeys = findKeys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1319,41 +1316,6 @@ 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(const QString currentPattern);
|
Q_INVOKABLE void initKeys();
|
||||||
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();
|
Q_INVOKABLE QString parsePattern(const QString currentPattern);
|
||||||
Q_INVOKABLE QString toolTipImage();
|
Q_INVOKABLE QString toolTipImage();
|
||||||
Q_INVOKABLE QSize toolTipSize();
|
Q_INVOKABLE QSize toolTipSize();
|
||||||
// keys
|
// keys
|
||||||
@ -93,9 +93,6 @@ 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();
|
||||||
@ -120,10 +117,8 @@ 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 diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
QStringList keys, diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user