mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
improve work with filters for custom scripts
implement new line filters for widget text fix bug with html parsing implement key sorting in combo boxes
This commit is contained in:
parent
5f4bf9ec29
commit
fce098cb5c
@ -1,9 +1,15 @@
|
||||
+ implement fitlers support to ExtScripts (ApiVer = 3) (#53)
|
||||
+ implement ability to wrap `\n` as new lines (#53)
|
||||
+ implement key sorting in comboboxes
|
||||
- fix bug with invalid html parsing
|
||||
* some part of refactoring
|
||||
|
||||
Ver.2.2.2:
|
||||
+ add quotes support (#46)
|
||||
+ add support of properties height and width (#47)
|
||||
+ add transtaltion support to the plugins (#50)
|
||||
+ add support of key caching
|
||||
+ add support of X-AW-Number to ExtScript and ExtUpgrade (ApiVer=2)
|
||||
+ add support of X-AW-Number to ExtScript and ExtUpgrade (ApiVer = 2)
|
||||
+ add reconnection to DataEngine (in some cases some values are not updated)
|
||||
+ add widgets width and height update
|
||||
- fix bug with Ext* items update (#49)
|
||||
|
@ -23,6 +23,9 @@
|
||||
<entry name="notify" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="wrapNewLines" type="bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="background" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -33,6 +33,7 @@ Item {
|
||||
property alias cfg_height: widgetHeight.value
|
||||
property alias cfg_width: widgetWidth.value
|
||||
property alias cfg_notify: notify.checked
|
||||
property alias cfg_wrapNewLines: wrapNewLines.checked
|
||||
property alias cfg_background: background.checked
|
||||
property alias cfg_customTime: customTime.text
|
||||
property alias cfg_customUptime: customUptime.text
|
||||
@ -98,6 +99,20 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Label {
|
||||
height: parent.heigth
|
||||
width: parent.width * 2 / 5
|
||||
}
|
||||
QtControls.CheckBox {
|
||||
id: wrapNewLines
|
||||
width: parent.width * 3 / 5
|
||||
text: i18n("Wrap new lines")
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
@ -273,7 +273,7 @@ Item {
|
||||
if (debug) console.log("[dataengine::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
|
@ -199,7 +199,10 @@ Item {
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
AWKeys.initTooltip(tooltipSettings)
|
||||
AWKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||
AWKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||
|
||||
needUpdate()
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ Item {
|
||||
if (debug) console.log("[widget::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
tags.model = AWKeys.dictKeys()
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
tags.model = AWKeys.dictKeys(true)
|
||||
}
|
||||
}
|
||||
|
@ -130,11 +130,11 @@ QString AWActions::getAboutText(const QString type)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> defaultFont)
|
||||
QVariantMap AWActions::getFont(const QVariantMap defaultFont)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> fontMap;
|
||||
QVariantMap fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
defaultFont[QString("size")].toInt(),
|
||||
400, false, defaultFont[QString("color")].toString());
|
||||
@ -148,14 +148,14 @@ QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> default
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
QVariantMap AWActions::readDataEngineConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
QMap<QString, QVariant> configuration;
|
||||
QVariantMap configuration;
|
||||
|
||||
settings.beginGroup(QString("Configuration"));
|
||||
configuration[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
|
||||
@ -172,7 +172,7 @@ QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
||||
void AWActions::writeDataEngineConfiguration(const QVariantMap configuration)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
|
@ -40,10 +40,10 @@ public:
|
||||
Q_INVOKABLE void showReadme();
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString getAboutText(const QString type = QString("header"));
|
||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont);
|
||||
// dataengine
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
Q_INVOKABLE QVariantMap readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration);
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message,
|
||||
|
@ -86,9 +86,7 @@ AWKeys::~AWKeys()
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString currentPattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup)
|
||||
void AWKeys::initKeys(const QString currentPattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -100,7 +98,6 @@ void AWKeys::initKeys(const QString currentPattern,
|
||||
keys.clear();
|
||||
foundBars.clear();
|
||||
foundKeys.clear();
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
|
||||
// init
|
||||
pattern = currentPattern;
|
||||
@ -113,12 +110,34 @@ void AWKeys::initKeys(const QString currentPattern,
|
||||
addKeyToCache(QString("Network"));
|
||||
loadKeysFromCache();
|
||||
reinitKeys();
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initTooltip(const QVariantMap tooltipParams)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
toolTip = new AWToolTip(this, tooltipParams);
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setPopupEnabled(const bool popup)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
enablePopup = popup;
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setWrapNewLines(const bool wrap)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
wrapNewLines = wrap;
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::isDebugEnabled()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -135,11 +154,12 @@ QString AWKeys::parsePattern()
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(foundKeys[i]), valueByKey(foundKeys[i]));
|
||||
parsed.replace(QString(" "), QString(" "));
|
||||
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>"));
|
||||
|
||||
return parsed;
|
||||
}
|
||||
@ -148,6 +168,7 @@ QString AWKeys::parsePattern()
|
||||
QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QString("");
|
||||
|
||||
if (keys.isEmpty()) return QString();
|
||||
|
||||
@ -163,6 +184,7 @@ QString AWKeys::toolTipImage()
|
||||
QSize AWKeys::toolTipSize()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QSize();
|
||||
|
||||
return toolTip->getSize();
|
||||
}
|
||||
@ -194,7 +216,7 @@ void AWKeys::addDevice(const QString source)
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::dictKeys()
|
||||
QStringList AWKeys::dictKeys(const bool sorted)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -312,6 +334,9 @@ QStringList AWKeys::dictKeys()
|
||||
for (int i=graphicalItemsKeys.count()-1; i>=0; i--)
|
||||
allKeys.append(graphicalItemsKeys[i]);
|
||||
|
||||
// sort if required
|
||||
if (sorted) allKeys.sort();
|
||||
|
||||
return allKeys;
|
||||
}
|
||||
|
||||
@ -329,9 +354,8 @@ QStringList AWKeys::getHddDevices()
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params)
|
||||
bool AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
@ -373,7 +397,9 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
values[QString("ac")] = params[QString("acOffline")].toString();
|
||||
} else {
|
||||
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
|
||||
toolTip->setData(QString("batTooltip"), data[data.keys()[i]].toFloat(), data[QString("ac")].toBool());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("batTooltip"),
|
||||
data[data.keys()[i]].toFloat(),
|
||||
data[QString("ac")].toBool());
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("cpu/system/TotalLoad")) {
|
||||
@ -383,7 +409,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
AWActions::sendNotification(QString("event"), i18n("High CPU load"), enablePopup);
|
||||
// value
|
||||
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
toolTip->setData(QString("cpuTooltip"), data[QString("value")].toFloat());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("cpuTooltip"),
|
||||
data[QString("value")].toFloat());
|
||||
} else if (sourceName.contains(cpuRegExp)) {
|
||||
// cpus
|
||||
QString number = sourceName;
|
||||
@ -392,7 +419,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
} else if (sourceName == QString("cpu/system/AverageClock")) {
|
||||
// cpucl
|
||||
values[QString("cpucl")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
toolTip->setData(QString("cpuclTooltip"), data[QString("value")].toFloat());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("cpuclTooltip"),
|
||||
data[QString("value")].toFloat());
|
||||
} else if (sourceName.contains(cpuclRegExp)) {
|
||||
// cpucls
|
||||
QString number = sourceName;
|
||||
@ -511,7 +539,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
AWActions::sendNotification(QString("event"), i18n("High memory usage"), enablePopup);
|
||||
// value
|
||||
values[QString("mem")] = QString("%1").arg(value, 5, 'f', 1);
|
||||
toolTip->setData(QString("memTooltip"), values[QString("mem")].toFloat());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("memTooltip"),
|
||||
values[QString("mem")].toFloat());
|
||||
} else if (sourceName == QString("netdev")) {
|
||||
// network device
|
||||
// notification
|
||||
@ -533,7 +562,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
}
|
||||
if (device == networkDevice()) {
|
||||
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
toolTip->setData(QString("downTooltip"), data[QString("value")].toFloat());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("downTooltip"),
|
||||
data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName.contains(netTransRegExp)) {
|
||||
// upload speed
|
||||
@ -547,7 +577,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
}
|
||||
if (device == networkDevice()) {
|
||||
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
toolTip->setData(QString("upTooltip"), data[QString("value")].toFloat());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("upTooltip"),
|
||||
data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName == QString("pkg")) {
|
||||
// package manager
|
||||
@ -589,7 +620,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
AWActions::sendNotification(QString("event"), i18n("Swap is used"), enablePopup);
|
||||
// value
|
||||
values[QString("swap")] = QString("%1").arg(value, 5, 'f', 1);
|
||||
toolTip->setData(QString("swapTooltip"), values[QString("swap")].toFloat());
|
||||
if (toolTip != nullptr) toolTip->setData(QString("swapTooltip"),
|
||||
values[QString("swap")].toFloat());
|
||||
} else if (sourceName.contains(tempRegExp)) {
|
||||
// temperature devices
|
||||
if (data[QString("units")].toString() == QString("rpm")) {
|
||||
@ -646,8 +678,8 @@ void AWKeys::graphicalValueByKey()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool ok;
|
||||
QString tag = QInputDialog::getItem(0, i18n("Select tag"),
|
||||
i18n("Tag"), keys, 0, false, &ok);
|
||||
QString tag = QInputDialog::getItem(0, i18n("Select tag"), i18n("Tag"),
|
||||
dictKeys(true), 0, false, &ok);
|
||||
|
||||
if ((!ok) || (tag.isEmpty())) return;
|
||||
QString message = i18n("Tag: %1", tag);
|
||||
@ -1247,7 +1279,7 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
bool AWKeys::checkKeys(const QVariantMap data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
|
||||
@ -1256,6 +1288,18 @@ bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::htmlValue(QString key)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
|
||||
|
||||
QString value = values[key];
|
||||
if (!key.startsWith(QString("custom")))
|
||||
value.replace(QString(" "), QString(" "));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -51,20 +51,20 @@ public:
|
||||
AWKeys(QObject *parent = nullptr);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys(const QString currentPattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup = false);
|
||||
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();
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
Q_INVOKABLE QSize toolTipSize();
|
||||
// keys
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false);
|
||||
Q_INVOKABLE QStringList getHddDevices();
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params);
|
||||
// values
|
||||
Q_INVOKABLE void graphicalValueByKey();
|
||||
Q_INVOKABLE QString infoByKey(QString key);
|
||||
@ -85,7 +85,8 @@ private slots:
|
||||
private:
|
||||
// methods
|
||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||
bool checkKeys(const QMap<QString, QVariant> data);
|
||||
bool checkKeys(const QVariantMap data);
|
||||
QString htmlValue(QString key);
|
||||
QString networkDevice();
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units);
|
||||
@ -111,6 +112,7 @@ private:
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool wrapNewLines = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtQuotes *> extQuotes;
|
||||
QList<ExtScript *> extScripts;
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
AWToolTip::AWToolTip(QObject *parent,
|
||||
QMap<QString, QVariant> settings)
|
||||
AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
|
||||
: QObject(parent),
|
||||
configuration(settings)
|
||||
{
|
||||
|
@ -32,8 +32,7 @@ class AWToolTip : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AWToolTip(QObject *parent = nullptr,
|
||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
||||
AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
||||
~AWToolTip();
|
||||
|
||||
QSize getSize();
|
||||
@ -48,7 +47,7 @@ private:
|
||||
// variables
|
||||
bool debug = false;
|
||||
int counts = 0;
|
||||
QMap<QString, QVariant> configuration;
|
||||
QVariantMap configuration;
|
||||
QMap<QString, float> boundaries;
|
||||
QMap<QString, QList<float>> data;
|
||||
QStringList requiredKeys;
|
||||
|
@ -189,7 +189,6 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop)
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(keys[i]), valueByKey(keys[i], desktop));
|
||||
parsed.replace(QString(" "), QString(" "));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
|
||||
return parsed;
|
||||
@ -221,7 +220,7 @@ void DPAdds::setPanelsToControl(const QString newPanels)
|
||||
}
|
||||
|
||||
|
||||
void DPAdds::setToolTipData(const QMap<QString, QVariant> tooltipData)
|
||||
void DPAdds::setToolTipData(const QVariantMap tooltipData)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << tooltipData;
|
||||
@ -240,9 +239,10 @@ QString DPAdds::valueByKey(const QString key, int desktop)
|
||||
|
||||
QString currentMark = currentDesktop() == desktop ? mark : QString("");
|
||||
if (key == QString("mark"))
|
||||
return QString("%1").arg(currentMark, mark.count(), QLatin1Char(' '));
|
||||
return QString("%1").arg(currentMark, mark.count(), QLatin1Char(' '))
|
||||
.replace(QString(" "), QString(" "));
|
||||
else if (key == QString("name"))
|
||||
return KWindowSystem::desktopName(desktop);
|
||||
return KWindowSystem::desktopName(desktop).replace(QString(" "), QString(" "));
|
||||
else if (key == QString("number"))
|
||||
return QString::number(desktop);
|
||||
else if (key == QString("total"))
|
||||
@ -339,11 +339,11 @@ QString DPAdds::getAboutText(const QString type)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> DPAdds::getFont(const QMap<QString, QVariant> defaultFont)
|
||||
QVariantMap DPAdds::getFont(const QVariantMap defaultFont)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> fontMap;
|
||||
QVariantMap fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
defaultFont[QString("size")].toInt(),
|
||||
400, false, defaultFont[QString("color")].toString());
|
||||
|
@ -55,12 +55,12 @@ public:
|
||||
// values
|
||||
Q_INVOKABLE void setMark(const QString newMark);
|
||||
Q_INVOKABLE void setPanelsToControl(const QString newPanels);
|
||||
Q_INVOKABLE void setToolTipData(const QMap<QString, QVariant> tooltipData);
|
||||
Q_INVOKABLE void setToolTipData(const QVariantMap tooltipData);
|
||||
Q_INVOKABLE QString valueByKey(const QString key, int desktop = -1);
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString editPanelsToContol(const QString current);
|
||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont);
|
||||
|
||||
signals:
|
||||
void desktopChanged();
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextCodec>
|
||||
#include <QTime>
|
||||
|
||||
@ -38,6 +40,7 @@ ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringLis
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
readJsonFilters();
|
||||
// init process
|
||||
process = new QProcess(this);
|
||||
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||
@ -89,7 +92,7 @@ QString ExtScript::fileName()
|
||||
}
|
||||
|
||||
|
||||
QList<ExtScript::Filter> ExtScript::filters()
|
||||
QStringList ExtScript::filters()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -153,28 +156,6 @@ ExtScript::Redirect ExtScript::redirect()
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtScript::strFilters()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList value;
|
||||
for (int i=0; i<m_filters.count(); i++)
|
||||
switch (m_filters[i]) {
|
||||
case wrapAnsiColor:
|
||||
value.append(QString("color"));
|
||||
break;
|
||||
case wrapNewLine:
|
||||
value.append(QString("newline"));
|
||||
break;
|
||||
case none:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::strRedirect()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -241,12 +222,13 @@ void ExtScript::setExecutable(const QString _executable)
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setFilters(const QList<ExtScript::Filter> _filters)
|
||||
void ExtScript::setFilters(const QStringList _filters)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << _filters;
|
||||
|
||||
m_filters = _filters;
|
||||
for (int i=0; i<_filters.count(); i++)
|
||||
updateFilter(_filters[i]);
|
||||
}
|
||||
|
||||
|
||||
@ -311,19 +293,6 @@ void ExtScript::setRedirect(const Redirect _redirect)
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setStrFilters(const QStringList _filters)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << _filters;
|
||||
|
||||
for (int i=0; i<_filters.count(); i++)
|
||||
if (_filters[i] == QString("color"))
|
||||
updateFilter(wrapAnsiColor);
|
||||
else if (_filters[i] == QString("newline"))
|
||||
updateFilter(wrapNewLine);
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setStrRedirect(const QString _redirect)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -338,54 +307,27 @@ void ExtScript::setStrRedirect(const QString _redirect)
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::applyColorFilter(QString _value)
|
||||
QString ExtScript::applyFilters(QString _value)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << _value;
|
||||
|
||||
// black
|
||||
_value.replace(QString("\\[\\033[0;30m\\]"), QString("<span style=\"color:#000000;\">"));
|
||||
_value.replace(QString("\\[\\033[1;30m\\]"), QString("<span style=\"color:#808080;\">"));
|
||||
// red
|
||||
_value.replace(QString("\\[\\033[0;31m\\]"), QString("<span style=\"color:#800000;\">"));
|
||||
_value.replace(QString("\\[\\033[1;31m\\]"), QString("<span style=\"color:#ff0000;\">"));
|
||||
// green
|
||||
_value.replace(QString("\\[\\033[0;32m\\]"), QString("<span style=\"color:#008000;\">"));
|
||||
_value.replace(QString("\\[\\033[1;32m\\]"), QString("<span style=\"color:#00ff00;\">"));
|
||||
// yellow
|
||||
_value.replace(QString("\\[\\033[0;33m\\]"), QString("<span style=\"color:#808000;\">"));
|
||||
_value.replace(QString("\\[\\033[1;33m\\]"), QString("<span style=\"color:#ffff00;\">"));
|
||||
// blue
|
||||
_value.replace(QString("\\[\\033[0;34m\\]"), QString("<span style=\"color:#000080;\">"));
|
||||
_value.replace(QString("\\[\\033[1;34m\\]"), QString("<span style=\"color:#0000ff;\">"));
|
||||
// purple
|
||||
_value.replace(QString("\\[\\033[0;35m\\]"), QString("<span style=\"color:#800080;\">"));
|
||||
_value.replace(QString("\\[\\033[1;35m\\]"), QString("<span style=\"color:#ff00ff;\">"));
|
||||
// cyan
|
||||
_value.replace(QString("\\[\\033[0;36m\\]"), QString("<span style=\"color:#008080;\">"));
|
||||
_value.replace(QString("\\[\\033[1;36m\\]"), QString("<span style=\"color:#00ffff;\">"));
|
||||
// white
|
||||
_value.replace(QString("\\[\\033[0;37m\\]"), QString("<span style=\"color:#c0c0c0;\">"));
|
||||
_value.replace(QString("\\[\\033[1;37m\\]"), QString("<span style=\"color:#ffffff;\">"));
|
||||
// exit
|
||||
_value.replace(QString("\\[\\033[0m\\]"), QString("</span>"));
|
||||
for (int i=0; i<m_filters.count(); i++) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found filter" << m_filters[i];
|
||||
QVariantMap filter = jsonFilters[m_filters[i]].toMap();
|
||||
if (filter.isEmpty()) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find filter in the json";
|
||||
continue;
|
||||
}
|
||||
for (int j=0; j<filter.keys().count(); j++)
|
||||
_value.replace(filter.keys()[j], filter[filter.keys()[j]].toString());
|
||||
}
|
||||
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::applyNewLineFilter(QString _value)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << _value;
|
||||
|
||||
_value.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::updateFilter(const ExtScript::Filter _filter, const bool _add)
|
||||
void ExtScript::updateFilter(const QString _filter, const bool _add)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filter" << _filter;
|
||||
@ -418,9 +360,11 @@ void ExtScript::readConfiguration()
|
||||
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
|
||||
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
setStrFilters(settings.value(QString("X-AW-Filters"), strFilters()).toStringList());
|
||||
// api == 2
|
||||
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||
// api == 3
|
||||
setFilters(settings.value(QString("X-AW-Filters"), m_filters).toString()
|
||||
.split(QChar(','), QString::SkipEmptyParts));
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -435,6 +379,26 @@ void ExtScript::readConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::readJsonFilters()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile jsonFile(fileName);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
QString jsonText = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8());
|
||||
jsonFilters = jsonDoc.toVariant().toMap();
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << jsonFilters;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -468,8 +432,9 @@ int ExtScript::showConfiguration()
|
||||
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
||||
ui->spinBox_interval->setValue(m_interval);
|
||||
// filters
|
||||
ui->checkBox_colorFilter->setCheckState(m_filters.contains(wrapAnsiColor) ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_linesFilter->setCheckState(m_filters.contains(wrapNewLine) ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_colorFilter->setCheckState(m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_linesFilter->setCheckState(m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_spaceFilter->setCheckState(m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
@ -484,8 +449,9 @@ int ExtScript::showConfiguration()
|
||||
setStrRedirect(ui->comboBox_redirect->currentText());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
// filters
|
||||
updateFilter(wrapAnsiColor, ui->checkBox_colorFilter->checkState() == Qt::Checked);
|
||||
updateFilter(wrapNewLine, ui->checkBox_linesFilter->checkState() == Qt::Checked);
|
||||
updateFilter(QString("color"), ui->checkBox_colorFilter->checkState() == Qt::Checked);
|
||||
updateFilter(QString("newline"), ui->checkBox_linesFilter->checkState() == Qt::Checked);
|
||||
updateFilter(QString("space"), ui->checkBox_spaceFilter->checkState() == Qt::Checked);
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
@ -526,7 +492,7 @@ void ExtScript::writeConfiguration()
|
||||
settings.setValue(QString("X-AW-Redirect"), strRedirect());
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.setValue(QString("X-AW-Number"), m_number);
|
||||
settings.setValue(QString("X-AW-Filters"), strFilters());
|
||||
settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(',')));
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
@ -556,4 +522,7 @@ void ExtScript::updateValue()
|
||||
value = qoutput;
|
||||
break;
|
||||
}
|
||||
|
||||
// filters
|
||||
value = applyFilters(value);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class ExtScript : public QDialog
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(QList<Filter> filters READ filters WRITE setFilters)
|
||||
Q_PROPERTY(QStringList filters READ filters WRITE setFilters)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||
@ -48,11 +48,6 @@ public:
|
||||
nothing,
|
||||
stderr2stdout
|
||||
};
|
||||
enum Filter {
|
||||
none = -1,
|
||||
wrapNewLine,
|
||||
wrapAnsiColor
|
||||
};
|
||||
|
||||
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
@ -62,7 +57,7 @@ public:
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
QList<Filter> filters();
|
||||
QStringList filters();
|
||||
bool hasOutput();
|
||||
int interval();
|
||||
bool isActive();
|
||||
@ -71,7 +66,6 @@ public:
|
||||
QString prefix();
|
||||
Redirect redirect();
|
||||
// derivatives
|
||||
QStringList strFilters();
|
||||
QString strRedirect();
|
||||
QString tag();
|
||||
// set methods
|
||||
@ -79,22 +73,21 @@ public:
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setFilters(const QList<Filter> _filters = QList<Filter>());
|
||||
void setFilters(const QStringList _filters = QStringList());
|
||||
void setHasOutput(const bool _state = true);
|
||||
void setInterval(const int _interval = 1);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNumber(int _number = -1);
|
||||
void setPrefix(const QString _prefix = QString(""));
|
||||
void setRedirect(const Redirect _redirect = nothing);
|
||||
void setStrFilters(const QStringList _filters = QStringList());
|
||||
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||
// filters
|
||||
QString applyColorFilter(QString _value);
|
||||
QString applyNewLineFilter(QString _value);
|
||||
void updateFilter(const Filter _filter = none, const bool _add = true);
|
||||
QString applyFilters(QString _value);
|
||||
void updateFilter(const QString _filter, const bool _add = true);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
void readJsonFilters();
|
||||
QString run();
|
||||
int showConfiguration();
|
||||
bool tryDelete();
|
||||
@ -114,7 +107,7 @@ private:
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
QList<Filter> m_filters = QList<Filter>();
|
||||
QStringList m_filters = QStringList();
|
||||
int m_interval = 1;
|
||||
QString m_name = QString("none");
|
||||
int m_number = -1;
|
||||
@ -123,6 +116,7 @@ private:
|
||||
Redirect m_redirect = nothing;
|
||||
// internal properties
|
||||
Q_PID childProcess = 0;
|
||||
QVariantMap jsonFilters = QVariantMap();
|
||||
int times = 0;
|
||||
QString value = QString();
|
||||
};
|
||||
|
@ -310,6 +310,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_spaceFilter">
|
||||
<item>
|
||||
<spacer name="spacer_spaceFilter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_spaceFilter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wrap spaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -303,12 +303,12 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
QVariantMap ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ACPI path" << acpiPath;
|
||||
|
||||
QMap<QString, QVariant> battery;
|
||||
QVariantMap battery;
|
||||
battery[QString("ac")] = false;
|
||||
battery[QString("bat")] = 0;
|
||||
QFile acFile(acpiPath + QString("/AC/online"));
|
||||
@ -344,13 +344,13 @@ QMap<QString, QVariant> ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getCurrentDesktop()
|
||||
QVariantMap ExtendedSysMon::getCurrentDesktop()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
int number = KWindowSystem::currentDesktop();
|
||||
int total = KWindowSystem::numberOfDesktops();
|
||||
QMap<QString, QVariant> currentDesktop;
|
||||
QVariantMap currentDesktop;
|
||||
currentDesktop[QString("currentName")] = KWindowSystem::desktopName(number);
|
||||
currentDesktop[QString("currentNumber")] = number;
|
||||
QStringList list;
|
||||
@ -499,17 +499,15 @@ QString ExtendedSysMon::getNetworkDevice()
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress,
|
||||
const QString mpdPort,
|
||||
QString mpris)
|
||||
QVariantMap ExtendedSysMon::getPlayerInfo(const QString playerName, const QString mpdAddress,
|
||||
const QString mpdPort, QString mpris)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "player" << playerName;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPRIS" << mpris;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
QVariantMap info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = QString("0");
|
||||
@ -530,13 +528,12 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress,
|
||||
const QString mpdPort)
|
||||
QVariantMap ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress, const QString mpdPort)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
QVariantMap info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = QString("0");
|
||||
@ -572,12 +569,12 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddres
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
QVariantMap ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << "MPRIS" << mpris;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
QVariantMap info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = 0;
|
||||
@ -622,7 +619,7 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
QVariantMap ExtendedSysMon::getPsStats()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -641,7 +638,7 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
if (output.contains(QString("running"))) running.append(cmdFile.readAll());
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> psStats;
|
||||
QVariantMap psStats;
|
||||
psStats[QString("pscount")] = running.count();
|
||||
psStats[QString("ps")] = running.join(QString(","));
|
||||
psStats[QString("pstotal")] = directories.count();
|
||||
@ -665,7 +662,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
|
||||
if (source == QString("battery")) {
|
||||
QMap<QString, QVariant> battery = getBattery(configuration[QString("ACPIPATH")]);
|
||||
QVariantMap battery = getBattery(configuration[QString("ACPIPATH")]);
|
||||
setData(source, QString("ac"), battery[QString("ac")].toBool());
|
||||
for (int i=0; i<battery.keys().count(); i++) {
|
||||
if (battery.keys()[i] == QString("ac")) continue;
|
||||
@ -675,7 +672,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
for (int i=0; i<externalScripts.count(); i++)
|
||||
setData(source, externalScripts[i]->tag(), externalScripts[i]->run());
|
||||
} else if (source == QString("desktop")) {
|
||||
QMap<QString, QVariant> desktop = getCurrentDesktop();
|
||||
QVariantMap desktop = getCurrentDesktop();
|
||||
for (int i=0; i<desktop.keys().count(); i++)
|
||||
setData(source, desktop.keys()[i], desktop[desktop.keys()[i]]);
|
||||
} else if (source == QString("gpu")) {
|
||||
@ -697,14 +694,14 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
for (int i=0; i<externalUpgrade.count(); i++)
|
||||
setData(source, externalUpgrade[i]->tag(), externalUpgrade[i]->run());
|
||||
} else if (source == QString("player")) {
|
||||
QMap<QString, QVariant> player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
configuration[QString("MPDPORT")],
|
||||
configuration[QString("MPRIS")]);
|
||||
QVariantMap player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
configuration[QString("MPDPORT")],
|
||||
configuration[QString("MPRIS")]);
|
||||
for (int i=0; i<player.keys().count(); i++)
|
||||
setData(source, player.keys()[i], player[player.keys()[i]]);
|
||||
} else if (source == QString("ps")) {
|
||||
QMap<QString, QVariant> ps = getPsStats();
|
||||
QVariantMap ps = getPsStats();
|
||||
for (int i=0; i<ps.keys().count(); i++)
|
||||
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
||||
} else if (source == QString("quotes")) {
|
||||
|
@ -33,20 +33,20 @@ public:
|
||||
explicit ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
~ExtendedSysMon();
|
||||
// update functions
|
||||
QMap<QString, QVariant> getBattery(const QString acpiPath);
|
||||
QMap<QString, QVariant> getCurrentDesktop();
|
||||
QVariantMap getBattery(const QString acpiPath);
|
||||
QVariantMap getCurrentDesktop();
|
||||
float getGpu(const QString device);
|
||||
float getGpuTemp(const QString device);
|
||||
float getHddTemp(const QString cmd, const QString device);
|
||||
QString getNetworkDevice();
|
||||
QMap<QString, QVariant> getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString(),
|
||||
const QString mpris = QString());
|
||||
QMap<QString, QVariant> getPlayerMpdInfo(const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString());
|
||||
QMap<QString, QVariant> getPlayerMprisInfo(const QString mpris = QString());
|
||||
QMap<QString, QVariant> getPsStats();
|
||||
QVariantMap getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString(),
|
||||
const QString mpris = QString());
|
||||
QVariantMap getPlayerMpdInfo(const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString());
|
||||
QVariantMap getPlayerMprisInfo(const QString mpris = QString());
|
||||
QVariantMap getPsStats();
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &source);
|
||||
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"color": {
|
||||
"\u001b[0;30m": "<span style=\"color:'#000000';\">",
|
||||
"\u001b[1;30m": "<span style=\"color:'#808080';\">",
|
||||
"\u001b[0;31m": "<span style=\"color:'#800000';\">",
|
||||
"\u001b[1;31m": "<span style=\"color:'#ff0000';\">",
|
||||
"\u001b[0;32m": "<span style=\"color:'#008000';\">",
|
||||
"\u001b[1;32m": "<span style=\"color:'#00ff00';\">",
|
||||
"\u001b[0;33m": "<span style=\"color:'#808000';\">",
|
||||
"\u001b[1;33m": "<span style=\"color:'#ffff00';\">",
|
||||
"\u001b[0;34m": "<span style=\"color:'#000080';\">",
|
||||
"\u001b[1;34m": "<span style=\"color:'#0000ff';\">",
|
||||
"\u001b[0;35m": "<span style=\"color:'#800080';\">",
|
||||
"\u001b[1;35m": "<span style=\"color:'#ff00ff';\">",
|
||||
"\u001b[0;36m": "<span style=\"color:'#008080';\">",
|
||||
"\u001b[1;36m": "<span style=\"color:'#00ffff';\">",
|
||||
"\u001b[0;37m": "<span style=\"color:'#c0c0c0';\">",
|
||||
"\u001b[1;37m": "<span style=\"color:'#ffffff';\">",
|
||||
"\u001b[0m": "</span>"
|
||||
},
|
||||
"newline": {
|
||||
"\n": "<br>",
|
||||
"\t": "	"
|
||||
},
|
||||
"space": {
|
||||
" ": " "
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user