mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
parent
8c73b2560b
commit
5f4bf9ec29
@ -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
|
||||
|
@ -89,6 +89,22 @@ QString ExtScript::fileName()
|
||||
}
|
||||
|
||||
|
||||
QList<ExtScript::Filter> 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<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;
|
||||
@ -141,6 +187,7 @@ QString ExtScript::strRedirect()
|
||||
case stderr2stdout:
|
||||
value = QString("stderr2stdout");
|
||||
break;
|
||||
case nothing:
|
||||
default:
|
||||
value = QString("nothing");
|
||||
break;
|
||||
@ -158,22 +205,6 @@ QString ExtScript::tag()
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_output;
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -210,12 +241,21 @@ void ExtScript::setExecutable(const QString _executable)
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setHasOutput(const bool state)
|
||||
void ExtScript::setFilters(const QList<ExtScript::Filter> _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("<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>"));
|
||||
|
||||
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)
|
||||
{
|
||||
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<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);
|
||||
|
||||
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();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define EXTSCRIPT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
@ -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<Filter> 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<Filter> 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<Filter> _filters = QList<Filter>());
|
||||
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<Filter> m_filters = QList<Filter>();
|
||||
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();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>304</height>
|
||||
<height>424</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -244,6 +244,75 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_filters">
|
||||
<property name="title">
|
||||
<string>Additional filters</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_colorFilter">
|
||||
<item>
|
||||
<spacer name="spacer_colorFilter">
|
||||
<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_colorFilter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wrap colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_linesFilter">
|
||||
<item>
|
||||
<spacer name="spacer_linesFilter">
|
||||
<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_linesFilter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wrap new lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -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=
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user