diff --git a/README.md b/README.md index a738441..62138f5 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,7 @@ Instruction Dependencies ------------ -* kdebase-workspace (*if KDE4 is used*) **or** plasma-framework (*if KF5 is used*) -* lm_sensors (*for definition temperature device*) +* plasma-framework Optional dependencies --------------------- @@ -42,7 +41,7 @@ Make dependencies ----------------- * cmake -* automoc4 (*if KDE4 is used*) or extra-cmake-modules (*if KF5 is used*) +* extra-cmake-modules Installation ------------ @@ -72,4 +71,5 @@ Links * [Scripts and bars](http://arcanis.name/en/2014/12/19/aw-v21-bells-and-whistles/) * Plasmoid on [kde-look](http://kde-look.org/content/show.php/Awesome+Widgets?content=157124) * DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773) -* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-awesome-widgets/) package +* Archlinux [AUR](https://aur.archlinux.org/packages/plasma5-applet-awesome-widgets/) package +* [OpenSuse](http://software.opensuse.org/package/awesome-widgets) package diff --git a/sources/extsysmon/extscript.cpp b/sources/extsysmon/extscript.cpp index 6074774..ad03d54 100644 --- a/sources/extsysmon/extscript.cpp +++ b/sources/extsysmon/extscript.cpp @@ -89,6 +89,22 @@ QString ExtScript::fileName() } +QList ExtScript::filters() +{ + if (debug) qDebug() << PDEBUG; + + return m_filters; +} + + +bool ExtScript::hasOutput() +{ + if (debug) qDebug() << PDEBUG; + + return m_output; +} + + int ExtScript::interval() { if (debug) qDebug() << PDEBUG; @@ -97,6 +113,14 @@ int ExtScript::interval() } +bool ExtScript::isActive() +{ + if (debug) qDebug() << PDEBUG; + + return m_active; +} + + QString ExtScript::name() { if (debug) qDebug() << PDEBUG; @@ -129,6 +153,28 @@ ExtScript::Redirect ExtScript::redirect() } +QStringList ExtScript::strFilters() +{ + if (debug) qDebug() << PDEBUG; + + QStringList value; + for (int i=0; i _filters) { if (debug) qDebug() << PDEBUG; - if (debug) qDebug() << PDEBUG << ":" << "State" << state; + if (debug) qDebug() << PDEBUG << ":" << "Filters" << _filters; - m_output = state; + m_filters = _filters; +} + + +void ExtScript::setHasOutput(const bool _state) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "State" << _state; + + m_output = _state; } @@ -271,6 +311,19 @@ 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; @@ -285,6 +338,68 @@ void ExtScript::setStrRedirect(const QString _redirect) } +QString ExtScript::applyColorFilter(QString _value) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Value" << _value; + + // black + _value.replace(QString("\\[\\033[0;30m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;30m\\]"), QString("")); + // red + _value.replace(QString("\\[\\033[0;31m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;31m\\]"), QString("")); + // green + _value.replace(QString("\\[\\033[0;32m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;32m\\]"), QString("")); + // yellow + _value.replace(QString("\\[\\033[0;33m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;33m\\]"), QString("")); + // blue + _value.replace(QString("\\[\\033[0;34m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;34m\\]"), QString("")); + // purple + _value.replace(QString("\\[\\033[0;35m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;35m\\]"), QString("")); + // cyan + _value.replace(QString("\\[\\033[0;36m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;36m\\]"), QString("")); + // white + _value.replace(QString("\\[\\033[0;37m\\]"), QString("")); + _value.replace(QString("\\[\\033[1;37m\\]"), QString("")); + // exit + _value.replace(QString("\\[\\033[0m\\]"), QString("")); + + return _value; +} + + +QString ExtScript::applyNewLineFilter(QString _value) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Value" << _value; + + _value.replace(QString("\n"), QString("
")); + + return _value; +} + + +void ExtScript::updateFilter(const ExtScript::Filter _filter, const bool _add) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Filter" << _filter; + if (debug) qDebug() << PDEBUG << ":" << "Should be added" << _add; + + if (_add) { + if (m_filters.contains(_filter)) return; + m_filters.append(_filter); + } else { + m_filters.removeOne(_filter); + } +} + + void ExtScript::readConfiguration() { if (debug) qDebug() << PDEBUG; @@ -303,6 +418,7 @@ 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()); settings.endGroup(); @@ -351,6 +467,9 @@ int ExtScript::showConfiguration() ui->checkBox_output->setCheckState(m_output ? Qt::Checked : Qt::Unchecked); ui->comboBox_redirect->setCurrentIndex(static_cast(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); int ret = exec(); if (ret != 1) return ret; @@ -364,6 +483,9 @@ int ExtScript::showConfiguration() setHasOutput(ui->checkBox_output->checkState() == Qt::Checked); 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); writeConfiguration(); return ret; @@ -404,6 +526,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.endGroup(); settings.sync(); diff --git a/sources/extsysmon/extscript.h b/sources/extsysmon/extscript.h index 6b1c2b9..3b5eb33 100644 --- a/sources/extsysmon/extscript.h +++ b/sources/extsysmon/extscript.h @@ -19,6 +19,7 @@ #define EXTSCRIPT_H #include +#include #include @@ -29,15 +30,16 @@ namespace Ui { class ExtScript : public QDialog { Q_OBJECT + Q_PROPERTY(bool active READ isActive WRITE setActive) Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion) - Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString comment READ comment WRITE setComment) Q_PROPERTY(QString executable READ executable WRITE setExecutable) - Q_PROPERTY(int number READ number WRITE setNumber) - Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) - Q_PROPERTY(bool active READ isActive WRITE setActive) - Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput) + Q_PROPERTY(QList 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) + Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput) + Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect) public: @@ -46,6 +48,11 @@ 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); @@ -55,27 +62,36 @@ public: QString comment(); QString executable(); QString fileName(); + QList filters(); + bool hasOutput(); int interval(); + bool isActive(); QString name(); int number(); QString prefix(); Redirect redirect(); + // derivatives + QStringList strFilters(); QString strRedirect(); QString tag(); - bool hasOutput(); - bool isActive(); // set methods void setApiVersion(const int _apiVersion = 0); 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 _filters = QList()); 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); public slots: void readConfiguration(); @@ -98,12 +114,14 @@ private: bool m_active = true; QString m_comment = QString("empty"); QString m_executable = QString("/usr/bin/true"); + QList m_filters = QList(); int m_interval = 1; QString m_name = QString("none"); int m_number = -1; bool m_output = true; QString m_prefix = QString(""); Redirect m_redirect = nothing; + // internal properties Q_PID childProcess = 0; int times = 0; QString value = QString(); diff --git a/sources/extsysmon/extscript.ui b/sources/extsysmon/extscript.ui index 46247fd..355f67d 100644 --- a/sources/extsysmon/extscript.ui +++ b/sources/extsysmon/extscript.ui @@ -7,7 +7,7 @@ 0 0 420 - 304 + 424 @@ -244,6 +244,75 @@ + + + + Additional filters + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Wrap colors + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Wrap new lines + + + + + + + + diff --git a/sources/extsysmon/scripts/get-external-ip.desktop b/sources/extsysmon/scripts/get-external-ip.desktop index df9455c..9e4ce46 100644 --- a/sources/extsysmon/scripts/get-external-ip.desktop +++ b/sources/extsysmon/scripts/get-external-ip.desktop @@ -8,5 +8,6 @@ X-AW-Active=true X-AW-Output=true X-AW-Redirect=nothing X-AW-Interval=1 -X-AW-ApiVersion=2 +X-AW-ApiVersion=3 X-AW-Number=0 +X-AW-Filters= diff --git a/sources/version.h.in b/sources/version.h.in index c7909cf..02ddc8a 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -14,7 +14,7 @@ // extquotes api version #define AWEQAPI 1 // extscript api version -#define AWESAPI 2 +#define AWESAPI 3 // extupgrade api version #define AWEUAPI 2