Merge pull request #99 from arcan1s/development

Master update
This commit is contained in:
Evgenii Alekseev 2016-07-08 15:11:07 +04:00 committed by GitHub
commit 77675a8e2f
69 changed files with 2741 additions and 364 deletions

View File

@ -54,7 +54,14 @@ for more details. To avoid manual labor there is automatic cmake target named
``` ```
* C-like `NULL`, use `nullptr` instead. * C-like `NULL`, use `nullptr` instead.
* It is highly recommended to avoid implicit casts. * It is highly recommended to avoid implicit casts. Exception `nullptr` casts to
boolean, e.g.:
```
if (nullptr)
qDebug() << "nullptr is true, wtf";
```
* Abstract classes (which have at least one pure virtual method) are allowed. * Abstract classes (which have at least one pure virtual method) are allowed.
* Templates are allowed and recommended. Templates usually should be described * Templates are allowed and recommended. Templates usually should be described
inside header not source code file. inside header not source code file.

View File

@ -34,6 +34,7 @@ option(BUILD_DEB_PACKAGE "Build deb package" OFF)
option(BUILD_RPM_PACKAGE "Build rpm package" OFF) option(BUILD_RPM_PACKAGE "Build rpm package" OFF)
# build details # build details
option(BUILD_FUTURE "Build with the features which will be marked as stable later" OFF) option(BUILD_FUTURE "Build with the features which will be marked as stable later" OFF)
option(BUILD_LOAD "Build with additional load" OFF)
option(BUILD_TESTING "Build with additional test abilities" OFF) option(BUILD_TESTING "Build with additional test abilities" OFF)
# generate changelog # generate changelog

View File

@ -47,6 +47,7 @@ const QStringList getBuildData()
metadata.append(QString(" AWEUAPI: %1").arg(AWEUAPI)); metadata.append(QString(" AWEUAPI: %1").arg(AWEUAPI));
metadata.append(QString(" AWEWAPI: %1").arg(AWEWAPI)); metadata.append(QString(" AWEWAPI: %1").arg(AWEWAPI));
metadata.append(QString(" AWEFAPI: %1").arg(AWEFAPI)); metadata.append(QString(" AWEFAPI: %1").arg(AWEFAPI));
metadata.append(QString(" REQUEST_TIMEOUT: %1").arg(REQUEST_TIMEOUT));
metadata.append(QString(" TIME_KEYS: %1").arg(TIME_KEYS)); metadata.append(QString(" TIME_KEYS: %1").arg(TIME_KEYS));
metadata.append(QString(" STATIC_KEYS: %1").arg(STATIC_KEYS)); metadata.append(QString(" STATIC_KEYS: %1").arg(STATIC_KEYS));
// cmake properties // cmake properties
@ -89,6 +90,7 @@ const QStringList getBuildData()
QString(" CPPCHECK_EXECUTABLE: %1").arg(CPPCHECK_EXECUTABLE)); QString(" CPPCHECK_EXECUTABLE: %1").arg(CPPCHECK_EXECUTABLE));
// additional functions // additional functions
metadata.append(QString(" PROP_FUTURE: %1").arg(PROP_FUTURE)); metadata.append(QString(" PROP_FUTURE: %1").arg(PROP_FUTURE));
metadata.append(QString(" PROP_LOAD: %1").arg(PROP_LOAD));
metadata.append(QString(" PROP_TEST: %1").arg(PROP_TEST)); metadata.append(QString(" PROP_TEST: %1").arg(PROP_TEST));
return metadata; return metadata;

View File

@ -19,6 +19,7 @@
#ifndef AWACTIONS_H #ifndef AWACTIONS_H
#define AWACTIONS_H #define AWACTIONS_H
#include <QMap>
#include <QObject> #include <QObject>

View File

@ -69,7 +69,7 @@ bool AWConfigHelper::dropCache() const
} }
bool AWConfigHelper::exportConfiguration(QObject *nativeConfig, bool AWConfigHelper::exportConfiguration(const QObject *nativeConfig,
const QString fileName) const const QString fileName) const
{ {
qCDebug(LOG_AW) << "Selected filename" << fileName; qCDebug(LOG_AW) << "Selected filename" << fileName;
@ -77,8 +77,8 @@ bool AWConfigHelper::exportConfiguration(QObject *nativeConfig,
QSettings settings(fileName, QSettings::IniFormat); QSettings settings(fileName, QSettings::IniFormat);
// plasmoid configuration // plasmoid configuration
QQmlPropertyMap *configuration const QQmlPropertyMap *configuration
= static_cast<QQmlPropertyMap *>(nativeConfig); = static_cast<const QQmlPropertyMap *>(nativeConfig);
settings.beginGroup(QString("plasmoid")); settings.beginGroup(QString("plasmoid"));
for (auto key : configuration->keys()) { for (auto key : configuration->keys()) {
QVariant value = configuration->value(key); QVariant value = configuration->value(key);

View File

@ -21,6 +21,7 @@
#include <QObject> #include <QObject>
#include <QStandardPaths> #include <QStandardPaths>
#include <QVariant>
class QSettings; class QSettings;
@ -34,7 +35,7 @@ public:
virtual ~AWConfigHelper(); virtual ~AWConfigHelper();
Q_INVOKABLE QString configurationDirectory() const; Q_INVOKABLE QString configurationDirectory() const;
Q_INVOKABLE bool dropCache() const; Q_INVOKABLE bool dropCache() const;
Q_INVOKABLE bool exportConfiguration(QObject *nativeConfig, Q_INVOKABLE bool exportConfiguration(const QObject *nativeConfig,
const QString fileName) const; const QString fileName) const;
Q_INVOKABLE QVariantMap importConfiguration(const QString fileName, Q_INVOKABLE QVariantMap importConfiguration(const QString fileName,
const bool importPlasmoid, const bool importPlasmoid,

View File

@ -42,7 +42,6 @@ void AWDataEngineAggregator::clear()
disconnectSources(); disconnectSources();
m_dataEngines.clear(); m_dataEngines.clear();
delete m_consumer; delete m_consumer;
m_consumer = nullptr;
} }
@ -82,7 +81,7 @@ void AWDataEngineAggregator::dropSource(const QString source)
{ {
qCDebug(LOG_AW) << "Source" << source; qCDebug(LOG_AW) << "Source" << source;
// FIXME there is no possibility to check to which dataengine source // HACK there is no possibility to check to which dataengine source
// connected we will try to disconnect it from systemmonitor and extsysmon // connected we will try to disconnect it from systemmonitor and extsysmon
m_dataEngines[QString("systemmonitor")]->disconnectSource(source, parent()); m_dataEngines[QString("systemmonitor")]->disconnectSource(source, parent());
m_dataEngines[QString("extsysmon")]->disconnectSource(source, parent()); m_dataEngines[QString("extsysmon")]->disconnectSource(source, parent());

View File

@ -26,8 +26,10 @@
#include "awdatetimeformatter.h" #include "awdatetimeformatter.h"
#include "awdebug.h" #include "awdebug.h"
#include "awfloatformatter.h" #include "awfloatformatter.h"
#include "awlistformatter.h"
#include "awnoformatter.h" #include "awnoformatter.h"
#include "awscriptformatter.h" #include "awscriptformatter.h"
#include "awstringformatter.h"
AWFormatterHelper::AWFormatterHelper(QWidget *parent) AWFormatterHelper::AWFormatterHelper(QWidget *parent)
@ -156,10 +158,14 @@ AWFormatterHelper::defineFormatterClass(const QString stringType) const
formatter = AWAbstractFormatter::FormatterClass::DateTime; formatter = AWAbstractFormatter::FormatterClass::DateTime;
else if (stringType == QString("Float")) else if (stringType == QString("Float"))
formatter = AWAbstractFormatter::FormatterClass::Float; formatter = AWAbstractFormatter::FormatterClass::Float;
else if (stringType == QString("List"))
formatter = AWAbstractFormatter::FormatterClass::List;
else if (stringType == QString("NoFormat")) else if (stringType == QString("NoFormat"))
; ;
else if (stringType == QString("Script")) else if (stringType == QString("Script"))
formatter = AWAbstractFormatter::FormatterClass::Script; formatter = AWAbstractFormatter::FormatterClass::Script;
else if (stringType == QString("String"))
formatter = AWAbstractFormatter::FormatterClass::String;
else else
qCWarning(LOG_AW) << "Unknown formatter" << stringType; qCWarning(LOG_AW) << "Unknown formatter" << stringType;
@ -196,10 +202,17 @@ void AWFormatterHelper::initFormatters()
m_formattersClasses[name] m_formattersClasses[name]
= new AWFloatFormatter(this, filePath); = new AWFloatFormatter(this, filePath);
break; break;
case AWAbstractFormatter::FormatterClass::List:
m_formattersClasses[name] = new AWListFormatter(this, filePath);
break;
case AWAbstractFormatter::FormatterClass::Script: case AWAbstractFormatter::FormatterClass::Script:
m_formattersClasses[name] m_formattersClasses[name]
= new AWScriptFormatter(this, filePath); = new AWScriptFormatter(this, filePath);
break; break;
case AWAbstractFormatter::FormatterClass::String:
m_formattersClasses[name]
= new AWStringFormatter(this, filePath);
break;
case AWAbstractFormatter::FormatterClass::NoFormat: case AWAbstractFormatter::FormatterClass::NoFormat:
m_formattersClasses[name] = new AWNoFormatter(this, filePath); m_formattersClasses[name] = new AWNoFormatter(this, filePath);
break; break;
@ -280,7 +293,8 @@ void AWFormatterHelper::doCreateItem()
{ {
QStringList selection = QStringList() QStringList selection = QStringList()
<< QString("NoFormat") << QString("DateTime") << QString("NoFormat") << QString("DateTime")
<< QString("Float") << QString("Script"); << QString("Float") << QString("List")
<< QString("Script") << QString("String");
bool ok; bool ok;
QString select = QInputDialog::getItem( QString select = QInputDialog::getItem(
this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok); this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok);
@ -297,8 +311,12 @@ void AWFormatterHelper::doCreateItem()
return createItem<AWDateTimeFormatter>(); return createItem<AWDateTimeFormatter>();
case AWAbstractFormatter::FormatterClass::Float: case AWAbstractFormatter::FormatterClass::Float:
return createItem<AWFloatFormatter>(); return createItem<AWFloatFormatter>();
case AWAbstractFormatter::FormatterClass::List:
return createItem<AWListFormatter>();
case AWAbstractFormatter::FormatterClass::Script: case AWAbstractFormatter::FormatterClass::Script:
return createItem<AWScriptFormatter>(); return createItem<AWScriptFormatter>();
case AWAbstractFormatter::FormatterClass::String:
return createItem<AWStringFormatter>();
case AWAbstractFormatter::FormatterClass::NoFormat: case AWAbstractFormatter::FormatterClass::NoFormat:
return createItem<AWNoFormatter>(); return createItem<AWNoFormatter>();
} }

View File

@ -38,8 +38,8 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key)
cache.beginGroup(type); cache.beginGroup(type);
QStringList cachedValues; QStringList cachedValues;
for (auto key : cache.allKeys()) for (auto number : cache.allKeys())
cachedValues.append(cache.value(key).toString()); cachedValues.append(cache.value(number).toString());
if (type == QString("hdd")) { if (type == QString("hdd")) {
QStringList allDevices QStringList allDevices
@ -51,6 +51,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key)
if (cachedValues.contains(device)) if (cachedValues.contains(device))
continue; continue;
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type; qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
cachedValues.append(device);
cache.setValue( cache.setValue(
QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')),
device); device);
@ -63,6 +64,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key)
if (cachedValues.contains(device)) if (cachedValues.contains(device))
continue; continue;
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type; qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
cachedValues.append(device);
cache.setValue( cache.setValue(
QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')),
device); device);

View File

@ -189,41 +189,57 @@ QString AWKeyOperations::infoByKey(QString key) const
{ {
qCDebug(LOG_AW) << "Requested key" << key; qCDebug(LOG_AW) << "Requested key" << key;
if (key.startsWith(QString("bar"))) QString stripped = key;
return graphicalItems->itemByTag(key, QString("bar"))->uniq(); stripped.remove(QRegExp(QString("\\d+")));
else if (key.startsWith(QString("custom"))) QString output;
return extScripts->itemByTag(key, QString("custom"))->uniq();
else if (key.contains(QRegExp(QString("^hdd[rw]"))))
return QString("%1").arg(
m_devices[QString("disk")]
[key.remove(QRegExp(QString("hdd[rw]"))).toInt()]);
else if (key.contains(QRegExp(
QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))))
return QString("%1").arg(
m_devices[QString("mount")]
[key
.remove(QRegExp(QString(
"^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))
.toInt()]);
else if (key.startsWith(QString("hddtemp")))
return QString("%1").arg(
m_devices[QString("hdd")][key.remove(QString("hddtemp")).toInt()]);
else if (key.contains(QRegExp(QString("^(down|up)[0-9]"))))
return QString("%1").arg(
m_devices[QString("net")]
[key.remove(QRegExp(QString("^(down|up)"))).toInt()]);
else if (key.startsWith(QString("pkgcount")))
return extUpgrade->itemByTag(key, QString("pkgcount"))->uniq();
else if (key.contains(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))))
return extQuotes->itemByTag(key, QString("ask"))->uniq();
else if (key.contains(QRegExp(
QString("(weather|weatherId|humidity|pressure|temperature)"))))
return extWeather->itemByTag(key, QString("weather"))->uniq();
else if (key.startsWith(QString("temp")))
return QString("%1").arg(
m_devices[QString("temp")][key.remove(QString("temp")).toInt()]);
return QString("(none)"); if (key.startsWith(QString("bar"))) {
AbstractExtItem *item = graphicalItems->itemByTag(key, stripped);
if (item)
output = item->uniq();
} else if (key.startsWith(QString("custom"))) {
AbstractExtItem *item = extScripts->itemByTag(key, stripped);
if (item)
output = item->uniq();
} else if (key.contains(QRegExp(QString("^hdd[rw]")))) {
output = m_devices[QString("disk")]
[key.remove(QRegExp(QString("hdd[rw]"))).toInt()];
} else if (key.contains(QRegExp(
QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))) {
output
= m_devices[QString("mount")]
[key
.remove(QRegExp(QString(
"^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))
.toInt()];
} else if (key.startsWith(QString("hddtemp"))) {
output
= m_devices[QString("hdd")][key.remove(QString("hddtemp")).toInt()];
} else if (key.contains(QRegExp(QString("^(down|up)[0-9]")))) {
output = m_devices[QString("net")]
[key.remove(QRegExp(QString("^(down|up)"))).toInt()];
} else if (key.startsWith(QString("pkgcount"))) {
AbstractExtItem *item = extUpgrade->itemByTag(key, stripped);
if (item)
output = item->uniq();
} else if (key.contains(
QRegExp(QString("(^|perc)(ask|bid|price)(chg|)")))) {
AbstractExtItem *item = extQuotes->itemByTag(key, stripped);
if (item)
output = item->uniq();
} else if (key.contains(QRegExp(QString(
"(weather|weatherId|humidity|pressure|temperature)")))) {
AbstractExtItem *item = extWeather->itemByTag(key, stripped);
if (item)
output = item->uniq();
} else if (key.startsWith(QString("temp"))) {
output
= m_devices[QString("temp")][key.remove(QString("temp")).toInt()];
} else {
output = QString("(none)");
}
return output;
} }
@ -326,6 +342,7 @@ void AWKeyOperations::reinitKeys()
m_pattern = AWPatternFunctions::insertKeyCount(m_pattern, allKeys); m_pattern = AWPatternFunctions::insertKeyCount(m_pattern, allKeys);
m_pattern = AWPatternFunctions::insertKeyNames(m_pattern, allKeys); m_pattern = AWPatternFunctions::insertKeyNames(m_pattern, allKeys);
m_pattern = AWPatternFunctions::insertKeys(m_pattern, allKeys); m_pattern = AWPatternFunctions::insertKeys(m_pattern, allKeys);
m_pattern = AWPatternFunctions::insertMacros(m_pattern);
// wrap templates // wrap templates
m_pattern = AWPatternFunctions::expandTemplates(m_pattern); m_pattern = AWPatternFunctions::expandTemplates(m_pattern);

View File

@ -177,8 +177,10 @@ QString AWKeys::valueByKey(QString key) const
{ {
qCDebug(LOG_AW) << "Requested value for key" << key; qCDebug(LOG_AW) << "Requested value for key" << key;
key.remove(QRegExp(QString("^bar[0-9]{1,}"))); QString trueKey
return aggregator->formatter(values[key], key); = key.startsWith(QString("bar")) ? keyOperator->infoByKey(key) : key;
return aggregator->formatter(values[trueKey], trueKey);
} }
@ -204,10 +206,10 @@ void AWKeys::reinitKeys(const QStringList currentKeys)
qCDebug(LOG_AW) << "Update found keys by using list" << currentKeys; qCDebug(LOG_AW) << "Update found keys by using list" << currentKeys;
// append lists // append lists
m_foundBars m_foundBars = AWPatternFunctions::findKeys(keyOperator->pattern(),
= AWPatternFunctions::findBars(keyOperator->pattern(), currentKeys); currentKeys, true);
m_foundKeys m_foundKeys = AWPatternFunctions::findKeys(keyOperator->pattern(),
= AWPatternFunctions::findKeys(keyOperator->pattern(), currentKeys); currentKeys, false);
m_foundLambdas = AWPatternFunctions::findLambdas(keyOperator->pattern()); m_foundLambdas = AWPatternFunctions::findLambdas(keyOperator->pattern());
// generate list of required keys for bars // generate list of required keys for bars
QStringList barKeys; QStringList barKeys;
@ -215,7 +217,7 @@ void AWKeys::reinitKeys(const QStringList currentKeys)
GraphicalItem *item = keyOperator->giByKey(bar); GraphicalItem *item = keyOperator->giByKey(bar);
if (item->isCustom()) if (item->isCustom())
item->setUsedKeys( item->setUsedKeys(
AWPatternFunctions::findKeys(item->bar(), currentKeys)); AWPatternFunctions::findKeys(item->bar(), currentKeys, false));
else else
item->setUsedKeys(QStringList() << item->bar()); item->setUsedKeys(QStringList() << item->bar());
barKeys.append(item->usedKeys()); barKeys.append(item->usedKeys());

View File

@ -515,7 +515,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source,
} else if (source.startsWith(QString("lmsensors/"))) { } else if (source.startsWith(QString("lmsensors/"))) {
// temperature // temperature
int index = m_devices[QString("temp")].indexOf(source); int index = m_devices[QString("temp")].indexOf(source);
// FIXME on DE initialization there are no units key // HACK on DE initialization there are no units key
if (units.isEmpty()) if (units.isEmpty())
return QStringList() << QString("temp%1").arg(index); return QStringList() << QString("temp%1").arg(index);
if (index > -1) { if (index > -1) {

View File

@ -86,8 +86,9 @@ QString AWPatternFunctions::expandTemplates(QString code)
} }
QVariantList AWPatternFunctions::findFunctionCalls(const QString function, QList<AWPatternFunctions::AWFunction>
const QString code) AWPatternFunctions::findFunctionCalls(const QString function,
const QString code)
{ {
qCDebug(LOG_AW) << "Looking for function" << function << "in" << code; qCDebug(LOG_AW) << "Looking for function" << function << "in" << code;
@ -95,23 +96,23 @@ QVariantList AWPatternFunctions::findFunctionCalls(const QString function,
// $aw_function_name<some args here if any>{{function body}} // $aw_function_name<some args here if any>{{function body}}
// * args should be always comma separated (e.g. commas are not supported // * args should be always comma separated (e.g. commas are not supported
// in this field if they are not screened by $, i.e. '$,' // in this field if they are not screened by $, i.e. '$,'
// * body depends on the function name, double brackets (i.e. {{ or }}) are // * body depends on the function name, double brackets should be screened
// not supported // by using $, e.g. ${
QRegularExpression regex( QRegularExpression regex(
QString("\\$%1\\<(?<args>.*?)\\>\\{\\{(?<body>.*?)\\}\\}") QString("\\$%1\\<(?<args>.*?)\\>\\{\\{(?<body>.*?)\\}\\}")
.arg(function)); .arg(function));
regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
QVariantList foundFunctions; QList<AWPatternFunctions::AWFunction> foundFunctions;
QRegularExpressionMatchIterator it = regex.globalMatch(code); QRegularExpressionMatchIterator it = regex.globalMatch(code);
while (it.hasNext()) { while (it.hasNext()) {
QRegularExpressionMatch match = it.next(); QRegularExpressionMatch match = it.next();
QVariantHash metadata; AWPatternFunctions::AWFunction metadata;
// work with args // work with args
QString argsString = match.captured(QString("args")); QString argsString = match.captured(QString("args"));
if (argsString.isEmpty()) { if (argsString.isEmpty()) {
metadata[QString("args")] = QStringList(); metadata.args = QStringList();
} else { } else {
// replace '$,' to 0x1d // replace '$,' to 0x1d
argsString.replace(QString("$,"), QString(0x1d)); argsString.replace(QString("$,"), QString(0x1d));
@ -119,11 +120,14 @@ QVariantList AWPatternFunctions::findFunctionCalls(const QString function,
std::for_each(args.begin(), args.end(), [](QString &arg) { std::for_each(args.begin(), args.end(), [](QString &arg) {
arg.replace(QString(0x1d), QString(",")); arg.replace(QString(0x1d), QString(","));
}); });
metadata[QString("args")] = args; metadata.args = args;
} }
// other variables // other variables
metadata[QString("body")] = match.captured(QString("body")); metadata.body = match.captured(QString("body"));
metadata[QString("what")] = match.captured(); metadata.what = match.captured();
// replace brackets
metadata.body.replace(QString("${"), QString("{"));
metadata.body.replace(QString("$}"), QString("}"));
foundFunctions.append(metadata); foundFunctions.append(metadata);
} }
@ -136,22 +140,17 @@ QString AWPatternFunctions::insertAllKeys(QString code, const QStringList keys)
qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list" qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list"
<< keys; << keys;
QVariantList found QList<AWPatternFunctions::AWFunction> found
= AWPatternFunctions::findFunctionCalls(QString("aw_all"), code); = AWPatternFunctions::findFunctionCalls(QString("aw_all"), code);
for (auto function : found) { for (auto function : found) {
QVariantHash metadata = function.toHash();
QString separator QString separator
= metadata[QString("args")].toStringList().isEmpty() = function.args.isEmpty() ? QString(",") : function.args.at(0);
? QString(",") QStringList required = keys.filter(QRegExp(function.body));
: metadata[QString("args")].toStringList().at(0);
QStringList required
= keys.filter(QRegExp(metadata[QString("body")].toString()));
std::for_each(required.begin(), required.end(), [](QString &value) { std::for_each(required.begin(), required.end(), [](QString &value) {
value = QString("%1: $%1").arg(value); value = QString("%1: $%1").arg(value);
}); });
code.replace(metadata[QString("what")].toString(), code.replace(function.what, required.join(separator));
required.join(separator));
} }
return code; return code;
@ -163,15 +162,12 @@ QString AWPatternFunctions::insertKeyCount(QString code, const QStringList keys)
qCDebug(LOG_AW) << "Looking for count in code" << code << "using list" qCDebug(LOG_AW) << "Looking for count in code" << code << "using list"
<< keys; << keys;
QVariantList found QList<AWPatternFunctions::AWFunction> found
= AWPatternFunctions::findFunctionCalls(QString("aw_count"), code); = AWPatternFunctions::findFunctionCalls(QString("aw_count"), code);
for (auto function : found) { for (auto function : found) {
QVariantHash metadata = function.toHash(); int count = keys.filter(QRegExp(function.body)).count();
int count = keys.filter(QRegExp(metadata[QString("body")].toString()))
.count();
code.replace(metadata[QString("what")].toString(), code.replace(function.what, QString::number(count));
QString::number(count));
} }
return code; return code;
@ -183,19 +179,14 @@ QString AWPatternFunctions::insertKeyNames(QString code, const QStringList keys)
qCDebug(LOG_AW) << "Looking for key names in code" << code << "using list" qCDebug(LOG_AW) << "Looking for key names in code" << code << "using list"
<< keys; << keys;
QVariantList found QList<AWPatternFunctions::AWFunction> found
= AWPatternFunctions::findFunctionCalls(QString("aw_names"), code); = AWPatternFunctions::findFunctionCalls(QString("aw_names"), code);
for (auto function : found) { for (auto function : found) {
QVariantHash metadata = function.toHash();
QString separator QString separator
= metadata[QString("args")].toStringList().isEmpty() = function.args.isEmpty() ? QString(",") : function.args.at(0);
? QString(",") QStringList required = keys.filter(QRegExp(function.body));
: metadata[QString("args")].toStringList().at(0);
QStringList required
= keys.filter(QRegExp(metadata[QString("body")].toString()));
code.replace(metadata[QString("what")].toString(), code.replace(function.what, required.join(separator));
required.join(separator));
} }
return code; return code;
@ -207,59 +198,80 @@ QString AWPatternFunctions::insertKeys(QString code, const QStringList keys)
qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list" qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list"
<< keys; << keys;
QVariantList found QList<AWPatternFunctions::AWFunction> found
= AWPatternFunctions::findFunctionCalls(QString("aw_keys"), code); = AWPatternFunctions::findFunctionCalls(QString("aw_keys"), code);
for (auto function : found) { for (auto function : found) {
QVariantHash metadata = function.toHash();
QString separator QString separator
= metadata[QString("args")].toStringList().isEmpty() = function.args.isEmpty() ? QString(",") : function.args.at(0);
? QString(",") QStringList required = keys.filter(QRegExp(function.body));
: metadata[QString("args")].toStringList().at(0);
QStringList required
= keys.filter(QRegExp(metadata[QString("body")].toString()));
std::for_each(required.begin(), required.end(), [](QString &value) { std::for_each(required.begin(), required.end(), [](QString &value) {
value = QString("$%1").arg(value); value = QString("$%1").arg(value);
}); });
code.replace(metadata[QString("what")].toString(), code.replace(function.what, required.join(separator));
required.join(separator));
} }
return code; return code;
} }
QStringList AWPatternFunctions::findBars(const QString code, QString AWPatternFunctions::insertMacros(QString code)
const QStringList keys)
{ {
qCDebug(LOG_AW) << "Looking for bars in code" << code << "using list" qCDebug(LOG_AW) << "Looking for macros in code" << code;
<< keys;
QStringList selectedKeys; QList<AWPatternFunctions::AWFunction> found
for (auto key : keys) = AWPatternFunctions::findFunctionCalls(QString("aw_macro"), code);
if ((key.startsWith(QString("bar"))) for (auto macro : found) {
&& (code.contains(QString("$%1").arg(key)))) { // get macro params
qCInfo(LOG_AW) << "Found bar" << key; if (macro.args.isEmpty()) {
selectedKeys.append(key); qCWarning(LOG_AW) << "No macro name found for" << macro.what;
continue;
}
QString name = macro.args.takeFirst();
// find macro usage
QList<AWPatternFunctions::AWFunction> macroUsage
= AWPatternFunctions::findFunctionCalls(
QString("aw_macro_%1").arg(name), code);
for (auto function : macroUsage) {
if (function.args.count() != macro.args.count()) {
qCWarning(LOG_AW) << "Invalid args count found for call"
<< function.what << "with macro"
<< macro.what;
continue;
}
// generate body to replace
QString result = macro.body;
std::for_each(macro.args.cbegin(), macro.args.cend(),
[&result, macro, function](const QString &arg) {
int index = macro.args.indexOf(arg);
result.replace(QString("$%1").arg(arg),
function.args.at(index));
});
// do replace
code.replace(function.what, result);
} }
if (selectedKeys.isEmpty())
qCWarning(LOG_AW) << "No bars found";
return selectedKeys; // remove macro from source pattern
code.remove(macro.what);
}
return code;
} }
QStringList AWPatternFunctions::findKeys(const QString code, QStringList AWPatternFunctions::findKeys(const QString code,
const QStringList keys) const QStringList keys,
const bool isBars)
{ {
qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list" qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list"
<< keys; << keys;
QStringList selectedKeys; QStringList selectedKeys;
for (auto key : keys) for (auto key : keys)
if ((!key.startsWith(QString("bar"))) if ((key.startsWith(QString("bar")) == isBars)
&& (code.contains(QString("$%1").arg(key)))) { && (code.contains(QString("$%1").arg(key)))) {
qCInfo(LOG_AW) << "Found key" << key; qCInfo(LOG_AW) << "Found key" << key << "with bar enabled"
<< isBars;
selectedKeys.append(key); selectedKeys.append(key);
} }
if (selectedKeys.isEmpty()) if (selectedKeys.isEmpty())

View File

@ -27,19 +27,26 @@ class AWKeysAggregator;
namespace AWPatternFunctions namespace AWPatternFunctions
{ {
typedef struct {
QStringList args;
QString body;
QString what;
} AWFunction;
// insert methods // insert methods
QString expandLambdas(QString code, AWKeysAggregator *aggregator, QString expandLambdas(QString code, AWKeysAggregator *aggregator,
const QVariantHash &metadata, const QVariantHash &metadata,
const QStringList &usedKeys); const QStringList &usedKeys);
QString expandTemplates(QString code); QString expandTemplates(QString code);
QVariantList findFunctionCalls(const QString function, const QString code); QList<AWFunction> findFunctionCalls(const QString function, const QString code);
QString insertAllKeys(QString code, const QStringList keys); QString insertAllKeys(QString code, const QStringList keys);
QString insertKeyCount(QString code, const QStringList keys); QString insertKeyCount(QString code, const QStringList keys);
QString insertKeyNames(QString code, const QStringList keys); QString insertKeyNames(QString code, const QStringList keys);
QString insertKeys(QString code, const QStringList keys); QString insertKeys(QString code, const QStringList keys);
QString insertMacros(QString code);
// find methods // find methods
QStringList findBars(const QString code, const QStringList keys); QStringList findKeys(const QString code, const QStringList keys,
QStringList findKeys(const QString code, const QStringList keys); const bool isBars);
QStringList findLambdas(const QString code); QStringList findLambdas(const QString code);
}; };

View File

@ -60,11 +60,11 @@ void AbstractExtItem::bumpApi(const int _newVer)
void AbstractExtItem::copyDefaults(AbstractExtItem *_other) const void AbstractExtItem::copyDefaults(AbstractExtItem *_other) const
{ {
_other->setActive(m_active); _other->setActive(isActive());
_other->setApiVersion(m_apiVersion); _other->setApiVersion(apiVersion());
_other->setComment(m_comment); _other->setComment(comment());
_other->setInterval(m_interval); _other->setInterval(interval());
_other->setName(m_name); _other->setName(name());
} }
@ -129,7 +129,7 @@ QString AbstractExtItem::tag(const QString _type) const
{ {
qCDebug(LOG_LIB) << "Tag type" << _type; qCDebug(LOG_LIB) << "Tag type" << _type;
return QString("%1%2").arg(_type).arg(m_number); return QString("%1%2").arg(_type).arg(number());
} }
@ -182,7 +182,8 @@ void AbstractExtItem::setNumber(int _number)
if (generateNumber) { if (generateNumber) {
_number = []() { _number = []() {
qCWarning(LOG_LIB) << "Number is empty, generate new one"; qCWarning(LOG_LIB) << "Number is empty, generate new one";
qsrand(QTime::currentTime().msec()); // we suppose that currentTIme().msec() is always valid time
qsrand(static_cast<uint>(QTime::currentTime().msec()));
int n = qrand() % 1000; int n = qrand() % 1000;
qCInfo(LOG_LIB) << "Generated number is" << n; qCInfo(LOG_LIB) << "Generated number is" << n;
return n; return n;
@ -200,15 +201,15 @@ void AbstractExtItem::readConfiguration()
QSettings settings(m_fileName, QSettings::IniFormat); QSettings settings(m_fileName, QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setName(settings.value(QString("Name"), m_name).toString()); setName(settings.value(QString("Name"), name()).toString());
setComment(settings.value(QString("Comment"), m_comment).toString()); setComment(settings.value(QString("Comment"), comment()).toString());
setApiVersion( setApiVersion(
settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt()); settings.value(QString("X-AW-ApiVersion"), apiVersion()).toInt());
setActive( setActive(
settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() settings.value(QString("X-AW-Active"), QVariant(isActive())).toString()
== QString("true")); == QString("true"));
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt()); setInterval(settings.value(QString("X-AW-Interval"), interval()).toInt());
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt()); setNumber(settings.value(QString("X-AW-Number"), number()).toInt());
settings.endGroup(); settings.endGroup();
} }
@ -229,12 +230,12 @@ void AbstractExtItem::writeConfiguration() const
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Encoding"), QString("UTF-8")); settings.setValue(QString("Encoding"), QString("UTF-8"));
settings.setValue(QString("Name"), m_name); settings.setValue(QString("Name"), name());
settings.setValue(QString("Comment"), m_comment); settings.setValue(QString("Comment"), comment());
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion); settings.setValue(QString("X-AW-ApiVersion"), apiVersion());
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString()); settings.setValue(QString("X-AW-Active"), QVariant(isActive()).toString());
settings.setValue(QString("X-AW-Interval"), m_interval); settings.setValue(QString("X-AW-Interval"), interval());
settings.setValue(QString("X-AW-Number"), m_number); settings.setValue(QString("X-AW-Number"), number());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();

View File

@ -66,7 +66,7 @@ void AbstractExtItemAggregator::copyItem()
.arg(QStandardPaths::writableLocation( .arg(QStandardPaths::writableLocation(
QStandardPaths::GenericDataLocation)) QStandardPaths::GenericDataLocation))
.arg(m_type); .arg(m_type);
if ((source == nullptr) || (fileName.isEmpty())) { if ((!source) || (fileName.isEmpty())) {
qCWarning(LOG_LIB) << "Nothing to copy"; qCWarning(LOG_LIB) << "Nothing to copy";
return; return;
} }
@ -83,7 +83,7 @@ void AbstractExtItemAggregator::copyItem()
void AbstractExtItemAggregator::deleteItem() void AbstractExtItemAggregator::deleteItem()
{ {
AbstractExtItem *source = itemFromWidget(); AbstractExtItem *source = itemFromWidget();
if (source == nullptr) { if (!source) {
qCWarning(LOG_LIB) << "Nothing to delete"; qCWarning(LOG_LIB) << "Nothing to delete";
return; return;
}; };
@ -98,7 +98,7 @@ void AbstractExtItemAggregator::deleteItem()
void AbstractExtItemAggregator::editItem() void AbstractExtItemAggregator::editItem()
{ {
AbstractExtItem *source = itemFromWidget(); AbstractExtItem *source = itemFromWidget();
if (source == nullptr) { if (!source) {
qCWarning(LOG_LIB) << "Nothing to edit"; qCWarning(LOG_LIB) << "Nothing to edit";
return; return;
}; };
@ -128,7 +128,7 @@ QString AbstractExtItemAggregator::getName()
AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() AbstractExtItem *AbstractExtItemAggregator::itemFromWidget()
{ {
QListWidgetItem *widgetItem = ui->listWidget->currentItem(); QListWidgetItem *widgetItem = ui->listWidget->currentItem();
if (widgetItem == nullptr) if (!widgetItem)
return nullptr; return nullptr;
AbstractExtItem *found = nullptr; AbstractExtItem *found = nullptr;
@ -139,7 +139,7 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget()
found = item; found = item;
break; break;
} }
if (found == nullptr) if (!found)
qCWarning(LOG_LIB) << "Could not find item by name" qCWarning(LOG_LIB) << "Could not find item by name"
<< widgetItem->text(); << widgetItem->text();

View File

@ -40,7 +40,7 @@ void AWAbstractFormatter::copyDefaults(AbstractExtItem *_other) const
{ {
AbstractExtItem::copyDefaults(_other); AbstractExtItem::copyDefaults(_other);
static_cast<AWAbstractFormatter *>(_other)->setType(m_type); static_cast<AWAbstractFormatter *>(_other)->setType(type());
} }
@ -60,9 +60,15 @@ QString AWAbstractFormatter::strType() const
case FormatterClass::Float: case FormatterClass::Float:
value = QString("Float"); value = QString("Float");
break; break;
case FormatterClass::List:
value = QString("List");
break;
case FormatterClass::Script: case FormatterClass::Script:
value = QString("Script"); value = QString("Script");
break; break;
case FormatterClass::String:
value = QString("String");
break;
case FormatterClass::NoFormat: case FormatterClass::NoFormat:
value = QString("NoFormat"); value = QString("NoFormat");
break; break;
@ -86,8 +92,12 @@ void AWAbstractFormatter::setStrType(const QString _type)
m_type = FormatterClass::DateTime; m_type = FormatterClass::DateTime;
else if (_type == QString("Float")) else if (_type == QString("Float"))
m_type = FormatterClass::Float; m_type = FormatterClass::Float;
else if (_type == QString("List"))
m_type = FormatterClass::List;
else if (_type == QString("Script")) else if (_type == QString("Script"))
m_type = FormatterClass::Script; m_type = FormatterClass::Script;
else if (_type == QString("String"))
m_type = FormatterClass::String;
else else
m_type = FormatterClass::NoFormat; m_type = FormatterClass::NoFormat;
} }

View File

@ -28,7 +28,14 @@ class AWAbstractFormatter : public AbstractExtItem
Q_PROPERTY(QString strType READ strType WRITE setStrType) Q_PROPERTY(QString strType READ strType WRITE setStrType)
public: public:
enum class FormatterClass { DateTime, Float, Script, NoFormat }; enum class FormatterClass {
DateTime,
Float,
List,
Script,
String,
NoFormat
};
explicit AWAbstractFormatter(QWidget *parent, explicit AWAbstractFormatter(QWidget *parent,
const QString filePath = QString()); const QString filePath = QString());

View File

@ -94,7 +94,7 @@ void AWDateTimeFormatter::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setFormat(settings.value(QString("X-AW-Format"), m_format).toString()); setFormat(settings.value(QString("X-AW-Format"), format()).toString());
settings.endGroup(); settings.endGroup();
bumpApi(AWEFAPI); bumpApi(AWEFAPI);
@ -108,7 +108,7 @@ int AWDateTimeFormatter::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_typeValue->setText(QString("DateTime")); ui->label_typeValue->setText(QString("DateTime"));
ui->lineEdit_format->setText(m_format); ui->lineEdit_format->setText(format());
int ret = exec(); int ret = exec();
if (ret != 1) if (ret != 1)
@ -131,7 +131,7 @@ void AWDateTimeFormatter::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Format"), m_format); settings.setValue(QString("X-AW-Format"), format());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();

View File

@ -52,8 +52,13 @@ QString AWFloatFormatter::convert(const QVariant &_value) const
{ {
qCDebug(LOG_LIB) << "Convert value" << _value; qCDebug(LOG_LIB) << "Convert value" << _value;
return QString("%1").arg(_value.toDouble() * m_multiplier + m_summand, QString output
m_count, m_format, m_precision, m_fillChar); = QString("%1").arg(_value.toDouble() * multiplier() + summand(),
count(), format(), precision(), fillChar());
if (forceWidth())
output = output.left(count());
return output;
} }
@ -68,6 +73,7 @@ AWFloatFormatter *AWFloatFormatter::copy(const QString _fileName,
item->setCount(count()); item->setCount(count());
item->setFormat(format()); item->setFormat(format());
item->setFillChar(fillChar()); item->setFillChar(fillChar());
item->setForceWidth(forceWidth());
item->setMultiplier(multiplier()); item->setMultiplier(multiplier());
item->setNumber(_number); item->setNumber(_number);
item->setPrecision(precision()); item->setPrecision(precision());
@ -89,6 +95,12 @@ QChar AWFloatFormatter::fillChar() const
} }
bool AWFloatFormatter::forceWidth() const
{
return m_forceWidth;
}
char AWFloatFormatter::format() const char AWFloatFormatter::format() const
{ {
return m_format; return m_format;
@ -129,6 +141,14 @@ void AWFloatFormatter::setFillChar(const QChar _fillChar)
} }
void AWFloatFormatter::setForceWidth(const bool _forceWidth)
{
qCDebug(LOG_LIB) << "Set force strip" << _forceWidth;
m_forceWidth = _forceWidth;
}
void AWFloatFormatter::setFormat(char _format) void AWFloatFormatter::setFormat(char _format)
{ {
qCDebug(LOG_LIB) << "Set format" << _format; qCDebug(LOG_LIB) << "Set format" << _format;
@ -174,18 +194,20 @@ void AWFloatFormatter::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setCount(settings.value(QString("X-AW-Width"), m_count).toInt()); setCount(settings.value(QString("X-AW-Width"), count()).toInt());
setFillChar( setFillChar(
settings.value(QString("X-AW-FillChar"), m_fillChar).toString().at(0)); settings.value(QString("X-AW-FillChar"), fillChar()).toString().at(0));
setFormat(settings.value(QString("X-AW-Format"), QString(m_format)) setForceWidth(
settings.value(QString("X-AW-ForceWidth"), forceWidth()).toBool());
setFormat(settings.value(QString("X-AW-Format"), QString(format()))
.toString() .toString()
.at(0) .at(0)
.toLatin1()); .toLatin1());
setMultiplier( setMultiplier(
settings.value(QString("X-AW-Multiplier"), m_multiplier).toDouble()); settings.value(QString("X-AW-Multiplier"), multiplier()).toDouble());
setPrecision( setPrecision(
settings.value(QString("X-AW-Precision"), m_precision).toInt()); settings.value(QString("X-AW-Precision"), precision()).toInt());
setSummand(settings.value(QString("X-AW-Summand"), m_summand).toDouble()); setSummand(settings.value(QString("X-AW-Summand"), summand()).toDouble());
settings.endGroup(); settings.endGroup();
bumpApi(AWEFAPI); bumpApi(AWEFAPI);
@ -200,12 +222,14 @@ int AWFloatFormatter::showConfiguration(const QVariant args)
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_typeValue->setText(QString("Float")); ui->label_typeValue->setText(QString("Float"));
ui->comboBox_format->setCurrentIndex( ui->comboBox_format->setCurrentIndex(
ui->comboBox_format->findText(QString(m_format))); ui->comboBox_format->findText(QString(format())));
ui->spinBox_precision->setValue(m_precision); ui->spinBox_precision->setValue(precision());
ui->spinBox_width->setValue(m_count); ui->spinBox_width->setValue(count());
ui->lineEdit_fill->setText(QString(m_fillChar)); ui->lineEdit_fill->setText(QString(fillChar()));
ui->doubleSpinBox_multiplier->setValue(m_multiplier); ui->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked
ui->doubleSpinBox_summand->setValue(m_summand); : Qt::Unchecked);
ui->doubleSpinBox_multiplier->setValue(multiplier());
ui->doubleSpinBox_summand->setValue(summand());
int ret = exec(); int ret = exec();
if (ret != 1) if (ret != 1)
@ -217,6 +241,7 @@ int AWFloatFormatter::showConfiguration(const QVariant args)
setPrecision(ui->spinBox_precision->value()); setPrecision(ui->spinBox_precision->value());
setCount(ui->spinBox_width->value()); setCount(ui->spinBox_width->value());
setFillChar(ui->lineEdit_fill->text().at(0)); setFillChar(ui->lineEdit_fill->text().at(0));
setForceWidth(ui->checkBox_forceWidth->checkState() == Qt::Checked);
setMultiplier(ui->doubleSpinBox_multiplier->value()); setMultiplier(ui->doubleSpinBox_multiplier->value());
setSummand(ui->doubleSpinBox_summand->value()); setSummand(ui->doubleSpinBox_summand->value());
@ -233,12 +258,13 @@ void AWFloatFormatter::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Width"), m_count); settings.setValue(QString("X-AW-Width"), count());
settings.setValue(QString("X-AW-FillChar"), m_fillChar); settings.setValue(QString("X-AW-FillChar"), fillChar());
settings.setValue(QString("X-AW-Format"), m_format); settings.setValue(QString("X-AW-Format"), format());
settings.setValue(QString("X-AW-Multiplier"), m_multiplier); settings.setValue(QString("X-AW-ForceWidth"), forceWidth());
settings.setValue(QString("X-AW-Precision"), m_precision); settings.setValue(QString("X-AW-Multiplier"), multiplier());
settings.setValue(QString("X-AW-Summand"), m_summand); settings.setValue(QString("X-AW-Precision"), precision());
settings.setValue(QString("X-AW-Summand"), summand());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -254,6 +280,7 @@ void AWFloatFormatter::translate()
ui->label_precision->setText(i18n("Precision")); ui->label_precision->setText(i18n("Precision"));
ui->label_width->setText(i18n("Width")); ui->label_width->setText(i18n("Width"));
ui->label_fill->setText(i18n("Fill char")); ui->label_fill->setText(i18n("Fill char"));
ui->checkBox_forceWidth->setText(i18n("Force width"));
ui->label_multiplier->setText(i18n("Multiplier")); ui->label_multiplier->setText(i18n("Multiplier"));
ui->label_summand->setText(i18n("Summand")); ui->label_summand->setText(i18n("Summand"));
} }

View File

@ -31,6 +31,7 @@ class AWFloatFormatter : public AWAbstractFormatter
Q_OBJECT Q_OBJECT
Q_PROPERTY(int count READ count WRITE setCount) Q_PROPERTY(int count READ count WRITE setCount)
Q_PROPERTY(QChar fillChar READ fillChar WRITE setFillChar) Q_PROPERTY(QChar fillChar READ fillChar WRITE setFillChar)
Q_PROPERTY(bool forceWidth READ forceWidth WRITE setForceWidth)
Q_PROPERTY(char format READ format WRITE setFormat) Q_PROPERTY(char format READ format WRITE setFormat)
Q_PROPERTY(double multiplier READ multiplier WRITE setMultiplier) Q_PROPERTY(double multiplier READ multiplier WRITE setMultiplier)
Q_PROPERTY(int precision READ precision WRITE setPrecision) Q_PROPERTY(int precision READ precision WRITE setPrecision)
@ -45,12 +46,14 @@ public:
// properties // properties
int count() const; int count() const;
QChar fillChar() const; QChar fillChar() const;
bool forceWidth() const;
char format() const; char format() const;
double multiplier() const; double multiplier() const;
int precision() const; int precision() const;
double summand() const; double summand() const;
void setCount(const int _count); void setCount(const int _count);
void setFillChar(const QChar _fillChar); void setFillChar(const QChar _fillChar);
void setForceWidth(const bool _forceWidth);
void setFormat(char _format); void setFormat(char _format);
void setMultiplier(const double _multiplier); void setMultiplier(const double _multiplier);
void setPrecision(const int _precision); void setPrecision(const int _precision);
@ -67,6 +70,7 @@ private:
// properties // properties
int m_count = 0; int m_count = 0;
QChar m_fillChar = QChar(); QChar m_fillChar = QChar();
bool m_forceWidth = false;
char m_format = 'f'; char m_format = 'f';
double m_multiplier = 1.0; double m_multiplier = 1.0;
int m_precision = -1; int m_precision = -1;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>420</width> <width>420</width>
<height>315</height> <height>362</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -199,6 +199,36 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_forceWIdth">
<item>
<spacer name="horizontalSpacer">
<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_forceWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Force width</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">

View File

@ -0,0 +1,191 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awlistformatter.h"
#include "ui_awlistformatter.h"
#include <KI18n/KLocalizedString>
#include <QSettings>
#include "awdebug.h"
AWListFormatter::AWListFormatter(QWidget *parent, const QString filePath)
: AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWListFormatter)
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
if (!filePath.isEmpty())
readConfiguration();
ui->setupUi(this);
translate();
}
AWListFormatter::~AWListFormatter()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui;
}
QString AWListFormatter::convert(const QVariant &_value) const
{
qCDebug(LOG_LIB) << "Convert value" << _value;
QStringList output = _value.toStringList();
if (isSorted())
output.sort();
return output.filter(m_regex).join(separator());
}
AWListFormatter *AWListFormatter::copy(const QString _fileName,
const int _number)
{
qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number;
AWListFormatter *item
= new AWListFormatter(static_cast<QWidget *>(parent()), _fileName);
AWAbstractFormatter::copyDefaults(item);
item->setFilter(filter());
item->setSeparator(separator());
item->setSorted(isSorted());
item->setNumber(_number);
return item;
}
QString AWListFormatter::filter() const
{
return m_filter;
}
bool AWListFormatter::isSorted() const
{
return m_sorted;
}
QString AWListFormatter::separator() const
{
return m_separator;
}
void AWListFormatter::setFilter(const QString _filter)
{
qCDebug(LOG_LIB) << "Filter" << _filter;
m_filter = _filter;
m_regex = QRegExp(m_filter);
}
void AWListFormatter::setSeparator(const QString _separator)
{
qCDebug(LOG_LIB) << "Separtor" << _separator;
m_separator = _separator;
}
void AWListFormatter::setSorted(const bool _sorted)
{
qCDebug(LOG_LIB) << "Sorting" << _sorted;
m_sorted = _sorted;
}
void AWListFormatter::readConfiguration()
{
AWAbstractFormatter::readConfiguration();
QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setFilter(settings.value(QString("X-AW-Filter"), filter()).toString());
setSeparator(
settings.value(QString("X-AW-Separator"), separator()).toString());
setSorted(settings.value(QString("X-AW-Sort"), isSorted()).toBool());
settings.endGroup();
bumpApi(AWEFAPI);
}
int AWListFormatter::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_typeValue->setText(QString("NoFormat"));
ui->lineEdit_filter->setText(filter());
ui->lineEdit_separator->setText(separator());
ui->checkBox_sorted->setCheckState(isSorted() ? Qt::Checked
: Qt::Unchecked);
int ret = exec();
if (ret != 1)
return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setStrType(ui->label_typeValue->text());
setFilter(ui->lineEdit_filter->text());
setSeparator(ui->lineEdit_separator->text());
setSorted(ui->checkBox_sorted->checkState() == Qt::Checked);
writeConfiguration();
return ret;
}
void AWListFormatter::writeConfiguration() const
{
AWAbstractFormatter::writeConfiguration();
QSettings settings(writtableConfig(), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Filter"), filter());
settings.setValue(QString("X-AW-Separator"), separator());
settings.setValue(QString("X-AW-Sort"), isSorted());
settings.endGroup();
settings.sync();
}
void AWListFormatter::translate()
{
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_type->setText(i18n("Type"));
ui->label_filter->setText(i18n("Filter"));
ui->label_separator->setText(i18n("Separator"));
ui->checkBox_sorted->setText(i18n("Sort"));
}

View File

@ -0,0 +1,66 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWLISTFORMATTER_H
#define AWLISTFORMATTER_H
#include "awabstractformatter.h"
namespace Ui
{
class AWListFormatter;
}
class AWListFormatter : public AWAbstractFormatter
{
Q_OBJECT
Q_PROPERTY(QString filter READ filter WRITE setFilter)
Q_PROPERTY(QString separator READ separator WRITE setSeparator)
Q_PROPERTY(bool sorted READ isSorted WRITE setSorted)
public:
explicit AWListFormatter(QWidget *parent,
const QString filePath = QString());
virtual ~AWListFormatter();
QString convert(const QVariant &_value) const;
AWListFormatter *copy(const QString _fileName, const int _number);
// properties
QString filter() const;
bool isSorted() const;
QString separator() const;
void setFilter(const QString _filter);
void setSeparator(const QString _separator);
void setSorted(const bool _sorted);
public slots:
void readConfiguration();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private:
Ui::AWListFormatter *ui = nullptr;
void translate();
// properties
QString m_filter = QString();
QString m_separator = QString();
bool m_sorted = false;
QRegExp m_regex;
};
#endif /* AWLISTFORMATTER_H */

View File

@ -0,0 +1,220 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AWListFormatter</class>
<widget class="QDialog" name="AWListFormatter">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_name">
<item>
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_name"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_comment">
<item>
<widget class="QLabel" name="label_comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Comment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_comment"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_type">
<item>
<widget class="QLabel" name="label_type">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_typeValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_filter">
<item>
<widget class="QLabel" name="label_filter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Filter</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_filter"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_separator">
<item>
<widget class="QLabel" name="label_separator">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Separator</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_separator"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_sorted">
<item>
<spacer name="horizontalSpacer">
<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_sorted">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Sort</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AWListFormatter</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AWListFormatter</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -146,10 +146,10 @@ void AWScriptFormatter::readConfiguration()
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setAppendCode( setAppendCode(
settings.value(QString("X-AW-AppendCode"), m_appendCode).toBool()); settings.value(QString("X-AW-AppendCode"), appendCode()).toBool());
setCode(settings.value(QString("X-AW-Code"), m_code).toString()); setCode(settings.value(QString("X-AW-Code"), code()).toString());
setHasReturn( setHasReturn(
settings.value(QString("X-AW-HasReturn"), m_hasReturn).toBool()); settings.value(QString("X-AW-HasReturn"), hasReturn()).toBool());
settings.endGroup(); settings.endGroup();
bumpApi(AWEFAPI); bumpApi(AWEFAPI);
@ -163,11 +163,11 @@ int AWScriptFormatter::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_typeValue->setText(QString("Script")); ui->label_typeValue->setText(QString("Script"));
ui->checkBox_appendCode->setCheckState(m_appendCode ? Qt::Checked ui->checkBox_appendCode->setCheckState(appendCode() ? Qt::Checked
: Qt::Unchecked); : Qt::Unchecked);
ui->checkBox_hasReturn->setCheckState(m_hasReturn ? Qt::Checked ui->checkBox_hasReturn->setCheckState(hasReturn() ? Qt::Checked
: Qt::Unchecked); : Qt::Unchecked);
ui->textEdit_code->setPlainText(m_code); ui->textEdit_code->setPlainText(code());
int ret = exec(); int ret = exec();
if (ret != 1) if (ret != 1)
@ -193,9 +193,9 @@ void AWScriptFormatter::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-AppendCode"), m_appendCode); settings.setValue(QString("X-AW-AppendCode"), appendCode());
settings.setValue(QString("X-AW-Code"), m_code); settings.setValue(QString("X-AW-Code"), code());
settings.setValue(QString("X-AW-HasReturn"), m_hasReturn); settings.setValue(QString("X-AW-HasReturn"), hasReturn());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -205,13 +205,13 @@ void AWScriptFormatter::writeConfiguration() const
void AWScriptFormatter::initProgram() void AWScriptFormatter::initProgram()
{ {
// init JS code // init JS code
if (m_appendCode) if (appendCode())
m_program m_program
= QString("(function(value) { %1%2 })") = QString("(function(value) { %1%2 })")
.arg(m_code) .arg(code())
.arg(m_hasReturn ? QString("") : QString("; return output;")); .arg(hasReturn() ? QString("") : QString("; return output;"));
else else
m_program = m_code; m_program = code();
qCInfo(LOG_LIB) << "Create JS engine with code" << m_program; qCInfo(LOG_LIB) << "Create JS engine with code" << m_program;
} }

View File

@ -0,0 +1,192 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awstringformatter.h"
#include "ui_awstringformatter.h"
#include <KI18n/KLocalizedString>
#include <QDir>
#include <QSettings>
#include "awdebug.h"
AWStringFormatter::AWStringFormatter(QWidget *parent, const QString filePath)
: AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWStringFormatter)
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
if (!filePath.isEmpty())
readConfiguration();
ui->setupUi(this);
translate();
}
AWStringFormatter::~AWStringFormatter()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui;
}
QString AWStringFormatter::convert(const QVariant &_value) const
{
qCDebug(LOG_LIB) << "Convert value" << _value;
QString output = QString("%1").arg(_value.toString(), count(), fillChar());
if (forceWidth())
output = output.left(count());
return output;
}
AWStringFormatter *AWStringFormatter::copy(const QString _fileName,
const int _number)
{
qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number;
AWStringFormatter *item
= new AWStringFormatter(static_cast<QWidget *>(parent()), _fileName);
AWAbstractFormatter::copyDefaults(item);
item->setCount(count());
item->setFillChar(fillChar());
item->setForceWidth(forceWidth());
item->setNumber(_number);
return item;
}
int AWStringFormatter::count() const
{
return m_count;
}
QChar AWStringFormatter::fillChar() const
{
return m_fillChar;
}
bool AWStringFormatter::forceWidth() const
{
return m_forceWidth;
}
void AWStringFormatter::setCount(const int _count)
{
qCDebug(LOG_LIB) << "Set width" << _count;
m_count = _count;
}
void AWStringFormatter::setFillChar(const QChar _fillChar)
{
qCDebug(LOG_LIB) << "Set char" << _fillChar;
m_fillChar = _fillChar;
}
void AWStringFormatter::setForceWidth(const bool _forceWidth)
{
qCDebug(LOG_LIB) << "Set force strip" << _forceWidth;
m_forceWidth = _forceWidth;
}
void AWStringFormatter::readConfiguration()
{
AWAbstractFormatter::readConfiguration();
QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setCount(settings.value(QString("X-AW-Width"), count()).toInt());
setFillChar(
settings.value(QString("X-AW-FillChar"), fillChar()).toString().at(0));
setForceWidth(
settings.value(QString("X-AW-ForceWidth"), forceWidth()).toBool());
settings.endGroup();
bumpApi(AWEFAPI);
}
int AWStringFormatter::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_typeValue->setText(QString("String"));
ui->spinBox_width->setValue(count());
ui->lineEdit_fill->setText(QString(fillChar()));
ui->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked
: Qt::Unchecked);
int ret = exec();
if (ret != 1)
return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setStrType(ui->label_typeValue->text());
setCount(ui->spinBox_width->value());
setFillChar(ui->lineEdit_fill->text().at(0));
setForceWidth(ui->checkBox_forceWidth->checkState() == Qt::Checked);
writeConfiguration();
return ret;
}
void AWStringFormatter::writeConfiguration() const
{
AWAbstractFormatter::writeConfiguration();
QSettings settings(writtableConfig(), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Width"), count());
settings.setValue(QString("X-AW-FillChar"), fillChar());
settings.setValue(QString("X-AW-ForceWidth"), forceWidth());
settings.endGroup();
settings.sync();
}
void AWStringFormatter::translate()
{
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_type->setText(i18n("Type"));
ui->label_width->setText(i18n("Width"));
ui->label_fill->setText(i18n("Fill char"));
ui->checkBox_forceWidth->setText(i18n("Force width"));
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWSTRINGFORMATTER_H
#define AWSTRINGFORMATTER_H
#include "awabstractformatter.h"
namespace Ui
{
class AWStringFormatter;
}
class AWStringFormatter : public AWAbstractFormatter
{
Q_OBJECT
Q_PROPERTY(int count READ count WRITE setCount)
Q_PROPERTY(QChar fillChar READ fillChar WRITE setFillChar)
Q_PROPERTY(bool forceWidth READ forceWidth WRITE setForceWidth)
public:
explicit AWStringFormatter(QWidget *parent,
const QString filePath = QString());
virtual ~AWStringFormatter();
QString convert(const QVariant &_value) const;
AWStringFormatter *copy(const QString _fileName, const int _number);
// properties
int count() const;
QChar fillChar() const;
bool forceWidth() const;
void setCount(const int _count);
void setFillChar(const QChar _fillChar);
void setForceWidth(const bool _forceWidth);
public slots:
void readConfiguration();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private:
Ui::AWStringFormatter *ui = nullptr;
void translate();
// properties
int m_count = 0;
QChar m_fillChar = QChar();
bool m_forceWidth = false;
};
#endif /* AWSTRINGFORMATTER_H */

View File

@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AWStringFormatter</class>
<widget class="QDialog" name="AWStringFormatter">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_name">
<item>
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_name"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_comment">
<item>
<widget class="QLabel" name="label_comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Comment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_comment"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_type">
<item>
<widget class="QLabel" name="label_type">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_typeValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_width">
<item>
<widget class="QLabel" name="label_width">
<property name="text">
<string>Width</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_width">
<property name="minimum">
<number>-10000</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fill">
<item>
<widget class="QLabel" name="label_fill">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Fill char</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_fill">
<property name="maxLength">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_forceWIdth">
<item>
<spacer name="horizontalSpacer">
<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_forceWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Force width</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AWStringFormatter</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AWStringFormatter</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -96,7 +96,7 @@ QString ExtQuotes::ticker() const
QString ExtQuotes::uniq() const QString ExtQuotes::uniq() const
{ {
return m_ticker; return ticker();
} }
@ -116,7 +116,7 @@ void ExtQuotes::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString()); setTicker(settings.value(QString("X-AW-Ticker"), ticker()).toString());
settings.endGroup(); settings.endGroup();
// update for current API // update for current API
@ -159,7 +159,7 @@ int ExtQuotes::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number())); ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_ticker->setText(m_ticker); ui->lineEdit_ticker->setText(ticker());
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
: Qt::Unchecked); : Qt::Unchecked);
ui->spinBox_interval->setValue(interval()); ui->spinBox_interval->setValue(interval());
@ -188,7 +188,7 @@ void ExtQuotes::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Ticker"), m_ticker); settings.setValue(QString("X-AW-Ticker"), ticker());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -260,7 +260,7 @@ void ExtQuotes::initUrl()
params.addQueryItem(QString("env"), params.addQueryItem(QString("env"),
QString("store://datatables.org/alltableswithkeys")); QString("store://datatables.org/alltableswithkeys"));
params.addQueryItem(QString("q"), params.addQueryItem(QString("q"),
QString(YAHOO_QUOTES_QUERY).arg(m_ticker)); QString(YAHOO_QUOTES_QUERY).arg(ticker()));
m_url.setQuery(params); m_url.setQuery(params);
} }

View File

@ -104,14 +104,14 @@ ExtScript::Redirect ExtScript::redirect() const
QString ExtScript::uniq() const QString ExtScript::uniq() const
{ {
return m_executable; return executable();
} }
QString ExtScript::strRedirect() const QString ExtScript::strRedirect() const
{ {
QString value; QString value;
switch (m_redirect) { switch (redirect()) {
case Redirect::stdout2stderr: case Redirect::stdout2stderr:
value = QString("stdout2stderr"); value = QString("stdout2stderr");
break; break;
@ -182,7 +182,7 @@ QString ExtScript::applyFilters(QString _value) const
{ {
qCDebug(LOG_LIB) << "Value" << _value; qCDebug(LOG_LIB) << "Value" << _value;
for (auto filt : m_filters) { for (auto filt : filters()) {
qCInfo(LOG_LIB) << "Found filter" << filt; qCInfo(LOG_LIB) << "Found filter" << filt;
QVariantMap filter = jsonFilters[filt].toMap(); QVariantMap filter = jsonFilters[filt].toMap();
if (filter.isEmpty()) { if (filter.isEmpty()) {
@ -203,7 +203,7 @@ void ExtScript::updateFilter(const QString _filter, const bool _add)
qCDebug(LOG_LIB) << "Should be added filters" << _add << "from" << _filter; qCDebug(LOG_LIB) << "Should be added filters" << _add << "from" << _filter;
if (_add) { if (_add) {
if (m_filters.contains(_filter)) if (filters().contains(_filter))
return; return;
m_filters.append(_filter); m_filters.append(_filter);
} else { } else {
@ -219,12 +219,12 @@ void ExtScript::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setExecutable(settings.value(QString("Exec"), m_executable).toString()); setExecutable(settings.value(QString("Exec"), executable()).toString());
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString()); setPrefix(settings.value(QString("X-AW-Prefix"), prefix()).toString());
setStrRedirect( setStrRedirect(
settings.value(QString("X-AW-Redirect"), strRedirect()).toString()); settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
// api == 3 // api == 3
setFilters(settings.value(QString("X-AW-Filters"), m_filters) setFilters(settings.value(QString("X-AW-Filters"), filters())
.toString() .toString()
.split(QChar(','), QString::SkipEmptyParts)); .split(QChar(','), QString::SkipEmptyParts));
settings.endGroup(); settings.endGroup();
@ -270,9 +270,9 @@ QVariantHash ExtScript::run()
if ((times == 1) && (process->state() == QProcess::NotRunning)) { if ((times == 1) && (process->state() == QProcess::NotRunning)) {
QStringList cmdList; QStringList cmdList;
if (!m_prefix.isEmpty()) if (!prefix().isEmpty())
cmdList.append(m_prefix); cmdList.append(prefix());
cmdList.append(m_executable); cmdList.append(executable());
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' ')); qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' '));
process->start(cmdList.join(QChar(' '))); process->start(cmdList.join(QChar(' ')));
} }
@ -293,19 +293,19 @@ int ExtScript::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number())); ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_command->setText(m_executable); ui->lineEdit_command->setText(executable());
ui->lineEdit_prefix->setText(m_prefix); ui->lineEdit_prefix->setText(prefix());
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
: Qt::Unchecked); : Qt::Unchecked);
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect)); ui->comboBox_redirect->setCurrentIndex(static_cast<int>(redirect()));
ui->spinBox_interval->setValue(interval()); ui->spinBox_interval->setValue(interval());
// filters // filters
ui->checkBox_colorFilter->setCheckState( ui->checkBox_colorFilter->setCheckState(
m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked); filters().contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
ui->checkBox_linesFilter->setCheckState( ui->checkBox_linesFilter->setCheckState(
m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked); filters().contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
ui->checkBox_spaceFilter->setCheckState( ui->checkBox_spaceFilter->setCheckState(
m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked); filters().contains(QString("space")) ? Qt::Checked : Qt::Unchecked);
int ret = exec(); int ret = exec();
if (ret != 1) if (ret != 1)
@ -340,10 +340,10 @@ void ExtScript::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Exec"), m_executable); settings.setValue(QString("Exec"), executable());
settings.setValue(QString("X-AW-Prefix"), m_prefix); settings.setValue(QString("X-AW-Prefix"), prefix());
settings.setValue(QString("X-AW-Redirect"), strRedirect()); settings.setValue(QString("X-AW-Redirect"), strRedirect());
settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(','))); settings.setValue(QString("X-AW-Filters"), filters().join(QChar(',')));
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -363,7 +363,7 @@ void ExtScript::updateValue()
qCInfo(LOG_LIB) << "Output" << qoutput; qCInfo(LOG_LIB) << "Output" << qoutput;
QString strValue; QString strValue;
switch (m_redirect) { switch (redirect()) {
case Redirect::stdout2stderr: case Redirect::stdout2stderr:
break; break;
case Redirect::stderr2stdout: case Redirect::stderr2stdout:

View File

@ -93,7 +93,7 @@ int ExtUpgrade::null() const
QString ExtUpgrade::uniq() const QString ExtUpgrade::uniq() const
{ {
return m_executable; return executable();
} }
@ -130,10 +130,10 @@ void ExtUpgrade::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setExecutable(settings.value(QString("Exec"), m_executable).toString()); setExecutable(settings.value(QString("Exec"), executable()).toString());
setNull(settings.value(QString("X-AW-Null"), m_null).toInt()); setNull(settings.value(QString("X-AW-Null"), null()).toInt());
// api == 3 // api == 3
setFilter(settings.value(QString("X-AW-Filter"), m_filter).toString()); setFilter(settings.value(QString("X-AW-Filter"), filter()).toString());
settings.endGroup(); settings.endGroup();
bumpApi(AWEUAPI); bumpApi(AWEUAPI);
@ -146,7 +146,7 @@ QVariantHash ExtUpgrade::run()
return value; return value;
if ((times == 1) && (process->state() == QProcess::NotRunning)) { if ((times == 1) && (process->state() == QProcess::NotRunning)) {
QString cmd = QString("sh -c \"%1\"").arg(m_executable); QString cmd = QString("sh -c \"%1\"").arg(executable());
qCInfo(LOG_LIB) << "Run cmd" << cmd; qCInfo(LOG_LIB) << "Run cmd" << cmd;
process->start(cmd); process->start(cmd);
} }
@ -167,11 +167,11 @@ int ExtUpgrade::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number())); ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_command->setText(m_executable); ui->lineEdit_command->setText(executable());
ui->lineEdit_filter->setText(m_filter); ui->lineEdit_filter->setText(filter());
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
: Qt::Unchecked); : Qt::Unchecked);
ui->spinBox_null->setValue(m_null); ui->spinBox_null->setValue(null());
ui->spinBox_interval->setValue(interval()); ui->spinBox_interval->setValue(interval());
int ret = exec(); int ret = exec();
@ -200,9 +200,9 @@ void ExtUpgrade::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Exec"), m_executable); settings.setValue(QString("Exec"), executable());
settings.setValue(QString("X-AW-Filter"), m_filter); settings.setValue(QString("X-AW-Filter"), filter());
settings.setValue(QString("X-AW-Null"), m_null); settings.setValue(QString("X-AW-Null"), null());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -218,11 +218,11 @@ void ExtUpgrade::updateValue()
->toUnicode(process->readAllStandardOutput()) ->toUnicode(process->readAllStandardOutput())
.trimmed(); .trimmed();
value[tag(QString("pkgcount"))] = [this](QString output) { value[tag(QString("pkgcount"))] = [this](QString output) {
return m_filter.isEmpty() return filter().isEmpty()
? output.split(QChar('\n'), QString::SkipEmptyParts).count() ? output.split(QChar('\n'), QString::SkipEmptyParts).count()
- m_null - null()
: output.split(QChar('\n'), QString::SkipEmptyParts) : output.split(QChar('\n'), QString::SkipEmptyParts)
.filter(QRegExp(m_filter)) .filter(QRegExp(filter()))
.count(); .count();
}(qoutput); }(qoutput);

View File

@ -150,7 +150,7 @@ int ExtWeather::ts() const
QString ExtWeather::uniq() const QString ExtWeather::uniq() const
{ {
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts); return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts());
} }
@ -216,11 +216,11 @@ void ExtWeather::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setCity(settings.value(QString("X-AW-City"), m_city).toString()); setCity(settings.value(QString("X-AW-City"), city()).toString());
setCountry(settings.value(QString("X-AW-Country"), m_country).toString()); setCountry(settings.value(QString("X-AW-Country"), country()).toString());
setTs(settings.value(QString("X-AW-TS"), m_ts).toInt()); setTs(settings.value(QString("X-AW-TS"), ts()).toInt());
// api == 2 // api == 2
setImage(settings.value(QString("X-AW-Image"), QVariant(m_image)).toString() setImage(settings.value(QString("X-AW-Image"), QVariant(image())).toString()
== QString("true")); == QString("true"));
// api == 3 // api == 3
setStrProvider( setStrProvider(
@ -286,11 +286,11 @@ int ExtWeather::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number())); ui->label_numberValue->setText(QString("%1").arg(number()));
ui->comboBox_provider->setCurrentIndex(static_cast<int>(m_provider)); ui->comboBox_provider->setCurrentIndex(static_cast<int>(provider()));
ui->lineEdit_city->setText(m_city); ui->lineEdit_city->setText(city());
ui->lineEdit_country->setText(m_country); ui->lineEdit_country->setText(country());
ui->spinBox_timestamp->setValue(m_ts); ui->spinBox_timestamp->setValue(ts());
ui->checkBox_image->setCheckState(m_image ? Qt::Checked : Qt::Unchecked); ui->checkBox_image->setCheckState(image() ? Qt::Checked : Qt::Unchecked);
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
: Qt::Unchecked); : Qt::Unchecked);
ui->spinBox_interval->setValue(interval()); ui->spinBox_interval->setValue(interval());
@ -323,11 +323,11 @@ void ExtWeather::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-City"), m_city); settings.setValue(QString("X-AW-City"), city());
settings.setValue(QString("X-AW-Country"), m_country); settings.setValue(QString("X-AW-Country"), country());
settings.setValue(QString("X-AW-Image"), m_image); settings.setValue(QString("X-AW-Image"), image());
settings.setValue(QString("X-AW-Provider"), strProvider()); settings.setValue(QString("X-AW-Provider"), strProvider());
settings.setValue(QString("X-AW-TS"), m_ts); settings.setValue(QString("X-AW-TS"), ts());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -373,7 +373,7 @@ void ExtWeather::initProvider()
break; break;
} }
return m_providerObject->initUrl(m_city, m_country, m_ts); return m_providerObject->initUrl(city(), country(), ts());
} }

View File

@ -71,18 +71,18 @@ GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number)
GraphicalItem *item GraphicalItem *item
= new GraphicalItem(static_cast<QWidget *>(parent()), _fileName); = new GraphicalItem(static_cast<QWidget *>(parent()), _fileName);
copyDefaults(item); copyDefaults(item);
item->setActiveColor(m_activeColor); item->setActiveColor(activeColor());
item->setBar(m_bar); item->setBar(bar());
item->setCount(m_count); item->setCount(count());
item->setCustom(m_custom); item->setCustom(isCustom());
item->setDirection(m_direction); item->setDirection(direction());
item->setItemHeight(m_height); item->setItemHeight(itemHeight());
item->setInactiveColor(m_inactiveColor); item->setInactiveColor(inactiveColor());
item->setMaxValue(m_maxValue); item->setMaxValue(maxValue());
item->setMinValue(m_minValue); item->setMinValue(minValue());
item->setNumber(_number); item->setNumber(_number);
item->setType(m_type); item->setType(type());
item->setItemWidth(m_width); item->setItemWidth(itemWidth());
return item; return item;
} }
@ -95,34 +95,34 @@ QString GraphicalItem::image(const QVariant &value)
m_scene->clear(); m_scene->clear();
int scale[2] = {1, 1}; int scale[2] = {1, 1};
float converted float converted
= m_helper->getPercents(value.toFloat(), m_minValue, m_maxValue); = m_helper->getPercents(value.toFloat(), minValue(), maxValue());
// paint // paint
switch (m_type) { switch (m_type) {
case Type::Vertical: case Type::Vertical:
m_helper->paintVertical(converted); m_helper->paintVertical(converted);
// scale // scale
scale[1] = -2 * static_cast<int>(m_direction) + 1; scale[1] = -2 * static_cast<int>(direction()) + 1;
break; break;
case Type::Circle: case Type::Circle:
m_helper->paintCircle(converted); m_helper->paintCircle(converted);
// scale // scale
scale[0] = -2 * static_cast<int>(m_direction) + 1; scale[0] = -2 * static_cast<int>(direction()) + 1;
break; break;
case Type::Graph: case Type::Graph:
m_helper->paintGraph(converted); m_helper->paintGraph(converted);
scale[0] = -2 * static_cast<int>(m_direction) + 1; scale[0] = -2 * static_cast<int>(direction()) + 1;
scale[1] = -1; scale[1] = -1;
break; break;
case Type::Bars: case Type::Bars:
m_helper->paintBars(converted); m_helper->paintBars(converted);
scale[0] = -2 * static_cast<int>(m_direction) + 1; scale[0] = -2 * static_cast<int>(direction()) + 1;
scale[1] = -1; scale[1] = -1;
break; break;
case Type::Horizontal: case Type::Horizontal:
m_helper->paintHorizontal(converted); m_helper->paintHorizontal(converted);
// scale // scale
scale[0] = -2 * static_cast<int>(m_direction) + 1; scale[0] = -2 * static_cast<int>(direction()) + 1;
break; break;
} }
@ -159,8 +159,8 @@ void GraphicalItem::initScene()
// init helper // init helper
m_helper = new GraphicalItemHelper(this, m_scene); m_helper = new GraphicalItemHelper(this, m_scene);
m_helper->setParameters(m_activeColor, m_inactiveColor, m_width, m_height, m_helper->setParameters(activeColor(), inactiveColor(), itemWidth(),
m_count); itemHeight(), count());
} }
@ -227,7 +227,7 @@ GraphicalItem::Type GraphicalItem::type() const
QString GraphicalItem::strType() const QString GraphicalItem::strType() const
{ {
QString value; QString value;
switch (m_type) { switch (type()) {
case Type::Vertical: case Type::Vertical:
value = QString("Vertical"); value = QString("Vertical");
break; break;
@ -258,7 +258,7 @@ GraphicalItem::Direction GraphicalItem::direction() const
QString GraphicalItem::strDirection() const QString GraphicalItem::strDirection() const
{ {
QString value; QString value;
switch (m_direction) { switch (direction()) {
case Direction::RightToLeft: case Direction::RightToLeft:
value = QString("RightToLeft"); value = QString("RightToLeft");
break; break;
@ -279,7 +279,7 @@ QStringList GraphicalItem::usedKeys() const
QString GraphicalItem::uniq() const QString GraphicalItem::uniq() const
{ {
return m_bar; return bar();
} }
@ -411,11 +411,11 @@ void GraphicalItem::setUsedKeys(const QStringList _usedKeys)
// remove dubs // remove dubs
// HACK converting to set may break order // HACK converting to set may break order
m_usedKeys.clear(); usedKeys().clear();
for (auto key : _usedKeys) { for (auto key : _usedKeys) {
if (m_usedKeys.contains(key)) if (usedKeys().contains(key))
continue; continue;
m_usedKeys.append(key); usedKeys().append(key);
} }
} }
@ -427,31 +427,31 @@ void GraphicalItem::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setCount(settings.value(QString("X-AW-Count"), m_count).toInt()); setCount(settings.value(QString("X-AW-Count"), count()).toInt());
setCustom(settings.value(QString("X-AW-Custom"), m_custom).toBool()); setCustom(settings.value(QString("X-AW-Custom"), isCustom()).toBool());
setBar(settings.value(QString("X-AW-Value"), m_bar).toString()); setBar(settings.value(QString("X-AW-Value"), bar()).toString());
setMaxValue(settings.value(QString("X-AW-Max"), m_maxValue).toFloat()); setMaxValue(settings.value(QString("X-AW-Max"), maxValue()).toFloat());
setMinValue(settings.value(QString("X-AW-Min"), m_minValue).toFloat()); setMinValue(settings.value(QString("X-AW-Min"), minValue()).toFloat());
setActiveColor( setActiveColor(
settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString()); settings.value(QString("X-AW-ActiveColor"), activeColor()).toString());
setInactiveColor( setInactiveColor(
settings.value(QString("X-AW-InactiveColor"), m_inactiveColor) settings.value(QString("X-AW-InactiveColor"), inactiveColor())
.toString()); .toString());
setStrType(settings.value(QString("X-AW-Type"), strType()).toString()); setStrType(settings.value(QString("X-AW-Type"), strType()).toString());
setStrDirection( setStrDirection(
settings.value(QString("X-AW-Direction"), strDirection()).toString()); settings.value(QString("X-AW-Direction"), strDirection()).toString());
setItemHeight(settings.value(QString("X-AW-Height"), m_height).toInt()); setItemHeight(settings.value(QString("X-AW-Height"), itemHeight()).toInt());
setItemWidth(settings.value(QString("X-AW-Width"), m_width).toInt()); setItemWidth(settings.value(QString("X-AW-Width"), itemWidth()).toInt());
// api == 5 // api == 5
if (apiVersion() < 5) { if (apiVersion() < 5) {
QString prefix; QString prefix;
prefix = m_activeColor.startsWith(QString("/")) ? QString("file://%1") prefix = activeColor().startsWith(QString("/")) ? QString("file://%1")
: QString("color://%1"); : QString("color://%1");
m_activeColor = prefix.arg(m_activeColor); m_activeColor = prefix.arg(activeColor());
prefix = m_inactiveColor.startsWith(QString("/")) prefix = inactiveColor().startsWith(QString("/"))
? QString("file://%1") ? QString("file://%1")
: QString("color://%1"); : QString("color://%1");
m_inactiveColor = prefix.arg(m_inactiveColor); m_inactiveColor = prefix.arg(inactiveColor());
} }
settings.endGroup(); settings.endGroup();
@ -468,31 +468,31 @@ int GraphicalItem::showConfiguration(const QVariant args)
ui->lineEdit_name->setText(name()); ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment()); ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number())); ui->label_numberValue->setText(QString("%1").arg(number()));
ui->checkBox_custom->setChecked(m_custom); ui->checkBox_custom->setChecked(isCustom());
ui->comboBox_value->addItems(tags); ui->comboBox_value->addItems(tags);
if (m_custom) { if (isCustom()) {
ui->lineEdit_customValue->setText(m_bar); ui->lineEdit_customValue->setText(bar());
} else { } else {
ui->comboBox_value->addItem(m_bar); ui->comboBox_value->addItem(bar());
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1); ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
} }
ui->doubleSpinBox_max->setValue(m_maxValue); ui->doubleSpinBox_max->setValue(maxValue());
ui->doubleSpinBox_min->setValue(m_minValue); ui->doubleSpinBox_min->setValue(minValue());
ui->spinBox_count->setValue(m_count); ui->spinBox_count->setValue(count());
if (m_helper->isColor(m_activeColor)) if (m_helper->isColor(activeColor()))
ui->comboBox_activeImageType->setCurrentIndex(0); ui->comboBox_activeImageType->setCurrentIndex(0);
else else
ui->comboBox_activeImageType->setCurrentIndex(1); ui->comboBox_activeImageType->setCurrentIndex(1);
ui->lineEdit_activeColor->setText(m_activeColor); ui->lineEdit_activeColor->setText(activeColor());
if (m_helper->isColor(m_inactiveColor)) if (m_helper->isColor(inactiveColor()))
ui->comboBox_inactiveImageType->setCurrentIndex(0); ui->comboBox_inactiveImageType->setCurrentIndex(0);
else else
ui->comboBox_inactiveImageType->setCurrentIndex(1); ui->comboBox_inactiveImageType->setCurrentIndex(1);
ui->lineEdit_inactiveColor->setText(m_inactiveColor); ui->lineEdit_inactiveColor->setText(inactiveColor());
ui->comboBox_type->setCurrentIndex(static_cast<int>(m_type)); ui->comboBox_type->setCurrentIndex(static_cast<int>(type()));
ui->comboBox_direction->setCurrentIndex(static_cast<int>(m_direction)); ui->comboBox_direction->setCurrentIndex(static_cast<int>(direction()));
ui->spinBox_height->setValue(m_height); ui->spinBox_height->setValue(itemHeight());
ui->spinBox_width->setValue(m_width); ui->spinBox_width->setValue(itemWidth());
// update UI // update UI
emit(ui->comboBox_type->currentIndexChanged( emit(ui->comboBox_type->currentIndexChanged(
@ -532,17 +532,17 @@ void GraphicalItem::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Value"), m_bar); settings.setValue(QString("X-AW-Value"), bar());
settings.setValue(QString("X-AW-Count"), m_count); settings.setValue(QString("X-AW-Count"), count());
settings.setValue(QString("X-AW-Custom"), m_custom); settings.setValue(QString("X-AW-Custom"), isCustom());
settings.setValue(QString("X-AW-Max"), m_maxValue); settings.setValue(QString("X-AW-Max"), maxValue());
settings.setValue(QString("X-AW-Min"), m_minValue); settings.setValue(QString("X-AW-Min"), minValue());
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor); settings.setValue(QString("X-AW-ActiveColor"), activeColor());
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor); settings.setValue(QString("X-AW-InactiveColor"), inactiveColor());
settings.setValue(QString("X-AW-Type"), strType()); settings.setValue(QString("X-AW-Type"), strType());
settings.setValue(QString("X-AW-Direction"), strDirection()); settings.setValue(QString("X-AW-Direction"), strDirection());
settings.setValue(QString("X-AW-Height"), m_height); settings.setValue(QString("X-AW-Height"), itemHeight());
settings.setValue(QString("X-AW-Width"), m_width); settings.setValue(QString("X-AW-Width"), itemWidth());
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();

View File

@ -148,10 +148,10 @@ void ExtSysMonAggregator::init(const QHash<QString, QString> config)
= new WeatherSource(this, QStringList()); = new WeatherSource(this, QStringList());
for (auto source : weatherItem->sources()) for (auto source : weatherItem->sources())
m_map[source] = weatherItem; m_map[source] = weatherItem;
#ifdef BUILD_TESTING #ifdef BUILD_LOAD
// additional load source // additional load source
AbstractExtSysMonSource *loadItem = new LoadSource(this, QStringList()); AbstractExtSysMonSource *loadItem = new LoadSource(this, QStringList());
for (auto source : loadItem->sources()) for (auto source : loadItem->sources())
m_map[source] = loadItem; m_map[source] = loadItem;
#endif /* BUILD_TESTING */ #endif /* BUILD_LOAD */
} }

View File

@ -345,7 +345,7 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString mpris) const
QString("/org/mpris/MediaPlayer2"), QString(""), QString("Get")); QString("/org/mpris/MediaPlayer2"), QString(""), QString("Get"));
request.setArguments(args); request.setArguments(args);
QDBusMessage response QDBusMessage response
= bus.call(request, QDBus::BlockWithGui, DBUS_CALL_TIMEOUT); = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT);
if ((response.type() != QDBusMessage::ReplyMessage) if ((response.type() != QDBusMessage::ReplyMessage)
|| (response.arguments().isEmpty())) { || (response.arguments().isEmpty())) {
qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); qCWarning(LOG_ESS) << "Error message" << response.errorMessage();

View File

@ -24,10 +24,6 @@
#include "abstractextsysmonsource.h" #include "abstractextsysmonsource.h"
#ifndef DBUS_CALL_TIMEOUT
#define DBUS_CALL_TIMEOUT 3000
#endif /* DBUS_CALL_TIMEOUT */
class QProcess; class QProcess;
class PlayerSource : public AbstractExtSysMonSource class PlayerSource : public AbstractExtSysMonSource

View File

@ -8,6 +8,8 @@ include_directories(
${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/ ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/
${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_MONITORSOURCES}/ ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_MONITORSOURCES}/
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/
${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/
${PROJECT_TRDPARTY_DIR} ${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE} ${Qt_INCLUDE}
${Qt5Test_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS}
@ -19,17 +21,46 @@ set(AWTESTLIBRARY_HEADERS awtestlibrary.h)
set(AWTESTLIBRARY_SOURCES awtestlibrary.cpp) set(AWTESTLIBRARY_SOURCES awtestlibrary.cpp)
add_library(${SUBPROJECT}-awtest STATIC ${AWTESTLIBRARY_SOURCES} ${AWTESTLIBRARY_HEADERS}) add_library(${SUBPROJECT}-awtest STATIC ${AWTESTLIBRARY_SOURCES} ${AWTESTLIBRARY_HEADERS})
target_link_libraries(${SUBPROJECT}-awtest ${Qt_LIBRARIES} ${Qt5Test_LIBRARIES}) target_link_libraries(${SUBPROJECT}-awtest ${Qt_LIBRARIES} ${Qt5Test_LIBRARIES})
set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSOURCES} ${Qt_LIBRARIES} ${Qt5Test_LIBRARIES}) set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSOURCES}
${Qt_LIBRARIES} ${Kf5_LIBRARIES} ${Qt5Test_LIBRARIES})
## modules ## modules
set(TEST_MODULES set(TEST_MODULES
abstractextitem extquotes extscript extupgrade extweather abstractextitem extquotes extscript extupgrade extweather
abstractformatter datetimeformatter floatformatter noformatter scriptformatter abstractformatter datetimeformatter floatformatter listformatter noformatter scriptformatter stringformatter
extitemaggregator extitemaggregator
batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource) batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource
awconfighelper awkeycache awkeys awpatternfunctions awupdatehelper
dpplugin)
foreach (TEST_MODULE ${TEST_MODULES}) foreach (TEST_MODULE ${TEST_MODULES})
set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h)
set(${TEST_MODULE}_SOURCES test${TEST_MODULE}.cpp) set(${TEST_MODULE}_SOURCES test${TEST_MODULE}.cpp)
if (TEST_MODULE MATCHES "awconfighelper")
set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awconfighelper.cpp)
elseif (TEST_MODULE MATCHES "awkeycache")
set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp)
elseif (TEST_MODULE MATCHES "awkeys")
set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awactions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataaggregator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataengineaggregator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeyoperations.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeys.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp
${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp)
elseif (TEST_MODULE MATCHES "awpatternfunctions")
set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp)
elseif (TEST_MODULE MATCHES "awupdatehelper")
set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp)
elseif (TEST_MODULE MATCHES "dpplugin")
set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp
${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp)
endif (TEST_MODULE MATCHES "awconfighelper")
add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES}) add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES})
target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET}) target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET})
add_test(NAME ${TEST_MODULE} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-${TEST_MODULE}) add_test(NAME ${TEST_MODULE} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-${TEST_MODULE})

View File

@ -0,0 +1,82 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testawconfighelper.h"
#include <QtTest>
#include "awconfighelper.h"
#include "awtestlibrary.h"
void TestAWConfigHelper::initTestCase()
{
plugin = new AWConfigHelper(this);
}
void TestAWConfigHelper::cleanupTestCase()
{
delete plugin;
}
void TestAWConfigHelper::test_configurationDirectory()
{
QVERIFY(!plugin->configurationDirectory().isEmpty());
}
void TestAWConfigHelper::test_exportConfiguration()
{
QStringList keys = AWTestLibrary::randomStringList();
for (auto key : keys)
map[key] = AWTestLibrary::randomString();
filename = AWTestLibrary::randomFilenames().first;
QVERIFY(plugin->exportConfiguration(&map, filename));
}
void TestAWConfigHelper::test_importConfiguration()
{
QVariantMap imported
= plugin->importConfiguration(filename, true, true, true);
QVariantMap converted;
for (auto key : map.keys())
converted[key] = map.value(key);
QCOMPARE(imported, converted);
}
void TestAWConfigHelper::test_readDataEngineConfiguration()
{
deConfig = plugin->readDataEngineConfiguration();
QVERIFY(!deConfig.isEmpty());
}
void TestAWConfigHelper::test_writeDataEngineConfiguration()
{
QVERIFY(plugin->writeDataEngineConfiguration(deConfig));
QCOMPARE(plugin->readDataEngineConfiguration(), deConfig);
}
QTEST_MAIN(TestAWConfigHelper);

View File

@ -0,0 +1,52 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTAWCONFIGHELPER_H
#define TESTAWCONFIGHELPER_H
#include <QObject>
#include <QQmlPropertyMap>
class AWConfigHelper;
class QQmlPropertyMap;
class TestAWConfigHelper : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_configurationDirectory();
void test_exportConfiguration();
void test_importConfiguration();
void test_readDataEngineConfiguration();
void test_writeDataEngineConfiguration();
private:
AWConfigHelper *plugin = nullptr;
QString filename;
QQmlPropertyMap map;
QVariantMap deConfig;
};
#endif /* TESTAWCONFIGHELPER_H */

View File

@ -0,0 +1,37 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testawkeycache.h"
#include <QtTest>
#include "awkeycache.h"
#include "awtestlibrary.h"
void TestAWKeyCache::initTestCase()
{
}
void TestAWKeyCache::cleanupTestCase()
{
}
QTEST_MAIN(TestAWKeyCache);

View File

@ -0,0 +1,39 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTAWKEYCACHE_H
#define TESTAWKEYCACHE_H
#include <QObject>
class TestAWKeyCache : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
private:
};
#endif /* TESTAWKEYCACHE_H */

162
sources/test/testawkeys.cpp Normal file
View File

@ -0,0 +1,162 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testawkeys.h"
#include <QtTest>
#include "awkeys.h"
#include "awtestlibrary.h"
void TestAWKeys::initTestCase()
{
plugin = new AWKeys(this);
// tooltip init
QVariantMap tooltipSettings;
tooltipSettings[QString("tooltipNumber")] = 1000;
tooltipSettings[QString("useTooltipBackground")] = true;
tooltipSettings[QString("tooltipBackground")] = QString("#ffffff");
tooltipSettings[QString("cpuTooltip")] = true;
tooltipSettings[QString("cpuclTooltip")] = true;
tooltipSettings[QString("memTooltip")] = true;
tooltipSettings[QString("swapTooltip")] = true;
tooltipSettings[QString("downkbTooltip")] = true;
tooltipSettings[QString("upkbTooltip")] = true;
tooltipSettings[QString("batTooltip")] = true;
tooltipSettings[QString("cpuTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("cpuclTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("memTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("swapTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("downkbTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("upkbTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("batTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("batInTooltipColor")] = QString("#ffffff");
tooltipSettings[QString("acOnline")] = QString("(*)");
tooltipSettings[QString("notify")] = false;
plugin->initDataAggregator(tooltipSettings);
// aggregator init
plugin->setAggregatorProperty("acOffline", QString("( )"));
plugin->setAggregatorProperty("acOnline", QString("(*)"));
plugin->setAggregatorProperty("customTime", QString("$hh"));
plugin->setAggregatorProperty("customUptime", QString("$hh"));
plugin->setAggregatorProperty("tempUnits", QString("Celsius"));
plugin->setAggregatorProperty("translate", false);
plugin->initKeys(pattern, interval, 0, false);
}
void TestAWKeys::cleanupTestCase()
{
delete plugin;
}
void TestAWKeys::test_hddDevices()
{
QVERIFY(!plugin->getHddDevices().isEmpty());
}
void TestAWKeys::test_dictKeys()
{
QStringList keys = plugin->dictKeys();
QVERIFY(!keys.isEmpty());
QStringList sorted = plugin->dictKeys(true);
QVERIFY(!sorted.isEmpty());
QEXPECT_FAIL("", "Sorted and non-sorted lists should differ", Continue);
QCOMPARE(keys, sorted);
pattern = QString("$%1").arg(sorted.join(QString("\n$")));
}
void TestAWKeys::test_pattern()
{
plugin->initKeys(pattern, interval, 0, false);
QSignalSpy spy(plugin, SIGNAL(needTextToBeUpdated(const QString)));
QVERIFY(spy.wait(5 * interval));
QVERIFY(spy.wait(5 * interval));
QString text = spy.takeFirst().at(0).toString();
QEXPECT_FAIL("", "Pattern should be parsed", Continue);
QCOMPARE(text, pattern);
QStringList keys = plugin->dictKeys(true);
for (auto key : keys)
QVERIFY(!text.contains(key));
}
void TestAWKeys::test_tooltip()
{
QSignalSpy spy(plugin, SIGNAL(needToolTipToBeUpdated(const QString)));
QVERIFY(spy.wait(5 * interval));
QString text = spy.takeFirst().at(0).toString();
QVERIFY(text.startsWith(QString("<img")));
}
void TestAWKeys::test_wrapNewLines()
{
QSignalSpy spy(plugin, SIGNAL(needTextToBeUpdated(const QString)));
QVERIFY(spy.wait(5 * interval));
QString text = spy.takeFirst().at(0).toString();
QVERIFY(!text.contains("<br>") && text.contains("\n"));
plugin->setWrapNewLines(true);
QVERIFY(spy.wait(5 * interval));
text = spy.takeFirst().at(0).toString();
QVERIFY(text.contains("<br>") && !text.contains("\n"));
}
void TestAWKeys::test_infoByKey()
{
int notEmpty = 0;
QStringList keys = plugin->dictKeys(true);
for (auto key : keys) {
QString info = plugin->infoByKey(key);
QVERIFY(!info.isEmpty());
// append non-empty field count
if (info != QString("(none)"))
notEmpty++;
}
QVERIFY(notEmpty > 0);
}
void TestAWKeys::test_valueByKey()
{
int notEmpty = 0;
QStringList keys = plugin->dictKeys(true);
for (auto key : keys) {
if (!plugin->valueByKey(key).isEmpty())
notEmpty++;
}
QVERIFY(notEmpty > 0);
}
QTEST_MAIN(TestAWKeys);

51
sources/test/testawkeys.h Normal file
View File

@ -0,0 +1,51 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTAWKEYS_H
#define TESTAWKEYS_H
#include <QObject>
class AWKeys;
class TestAWKeys : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_hddDevices();
void test_dictKeys();
void test_pattern();
void test_tooltip();
void test_wrapNewLines();
void test_infoByKey();
void test_valueByKey();
private:
AWKeys *plugin = nullptr;
QString pattern;
int interval = 1000;
};
#endif /* TESTAWKEYS_H */

View File

@ -0,0 +1,112 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testawpatternfunctions.h"
#include <QtTest>
#include "awpatternfunctions.h"
#include "awtestlibrary.h"
void TestAWPatternFunctions::initTestCase()
{
}
void TestAWPatternFunctions::cleanupTestCase()
{
}
void TestAWPatternFunctions::test_findFunctionCalls()
{
QString name = QString("aw_%1").arg(AWTestLibrary::randomString(10));
QString code = AWTestLibrary::randomString(20);
QStringList args = AWTestLibrary::randomStringList(20);
QString function = QString("$%1<%2>{{%3}}")
.arg(name)
.arg(args.join(QChar(',')))
.arg(code);
QString pattern = AWTestLibrary::randomString() + function
+ AWTestLibrary::randomString();
QList<AWPatternFunctions::AWFunction> found
= AWPatternFunctions::findFunctionCalls(name, pattern);
QCOMPARE(found.count(), 1);
QCOMPARE(found.at(0).args, args);
QCOMPARE(found.at(0).body, code);
QCOMPARE(found.at(0).what, function);
}
void TestAWPatternFunctions::test_findKeys()
{
QStringList keys = AWTestLibrary::randomStringList(20);
QStringList bars = AWTestLibrary::randomStringList(20);
std::for_each(bars.begin(), bars.end(),
[](QString &bar) { bar.prepend(QString("bar")); });
QStringList noise = AWTestLibrary::randomStringList(200);
QStringList allKeys = keys + bars + noise;
QString pattern = QString("$%1 $%2")
.arg(keys.join(QString(" $")))
.arg(bars.join(QString(" $")));
keys.sort();
bars.sort();
QStringList foundKeys
= AWPatternFunctions::findKeys(pattern, allKeys, false);
foundKeys.sort();
QStringList foundBars
= AWPatternFunctions::findKeys(pattern, allKeys, true);
foundBars.sort();
QCOMPARE(foundKeys, keys);
QCOMPARE(foundBars, bars);
}
void TestAWPatternFunctions::test_findLambdas()
{
QStringList lambdas = AWTestLibrary::randomStringList(20);
QString pattern = AWTestLibrary::randomString()
+ QString("${{%1}}").arg(lambdas.join(QString("}}${{")))
+ AWTestLibrary::randomString();
QCOMPARE(AWPatternFunctions::findLambdas(pattern), lambdas);
}
void TestAWPatternFunctions::test_expandTemplates()
{
int firstValue = AWTestLibrary::randomInt();
int secondValue = AWTestLibrary::randomInt();
int result = firstValue + secondValue;
QString code
= QString("$template{{%1+%2}}").arg(firstValue).arg(secondValue);
QString prefix = AWTestLibrary::randomString();
QString pattern = prefix + code;
QCOMPARE(AWPatternFunctions::expandTemplates(pattern),
QString("%1%2").arg(prefix).arg(result));
}
QTEST_MAIN(TestAWPatternFunctions);

View File

@ -0,0 +1,43 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTAWPATTERNFUNCTIONS_H
#define TESTAWPATTERNFUNCTIONS_H
#include <QObject>
class TestAWPatternFunctions : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_findFunctionCalls();
void test_findKeys();
void test_findLambdas();
void test_expandTemplates();
private:
};
#endif /* TESTAWPATTERNFUNCTIONS_H */

View File

@ -0,0 +1,45 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testawupdatehelper.h"
#include <QtTest>
#include "awtestlibrary.h"
#include "awupdatehelper.h"
void TestAWUpdateHelper::initTestCase()
{
plugin = new AWUpdateHelper(this);
}
void TestAWUpdateHelper::cleanupTestCase()
{
delete plugin;
}
void TestAWUpdateHelper::test_checkVersion()
{
QVERIFY(!plugin->checkVersion());
}
QTEST_MAIN(TestAWUpdateHelper);

View File

@ -0,0 +1,43 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTAWUPDATEHELPER_H
#define TESTAWUPDATEHELPER_H
#include <QObject>
class AWUpdateHelper;
class TestAWUpdateHelper : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_checkVersion();
private:
AWUpdateHelper *plugin = nullptr;
};
#endif /* TESTAWUPDATEHELPER_H */

View File

@ -39,11 +39,6 @@ void TestDesktopSource::cleanupTestCase()
void TestDesktopSource::test_sources() void TestDesktopSource::test_sources()
{ {
QCOMPARE(source->sources().count(), 4); QCOMPARE(source->sources().count(), 4);
// FIXME there is segfault here sometimes o_0
// QVERIFY(std::all_of(
// source->sources().cbegin(), source->sources().cend(),
// [](const QString &src) { return
// src.startsWith(QString("desktop/")); }));
} }

View File

@ -0,0 +1,94 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testdpplugin.h"
#include <KWindowSystem>
#include <QtTest>
#include "awtestlibrary.h"
#include "dpadds.h"
void TestDPPlugin::initTestCase()
{
plugin = new DPAdds(this);
}
void TestDPPlugin::cleanupTestCase()
{
delete plugin;
}
void TestDPPlugin::test_desktops()
{
int current = plugin->currentDesktop();
int total = plugin->numberOfDesktops();
QVERIFY(total != 0);
QVERIFY(current < total);
int number;
if (total == 1)
number = current;
else
number = current == (total - 1) ? current - 1 : current + 1;
QSignalSpy spy(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)));
plugin->setCurrentDesktop(number);
QVERIFY(spy.wait(5000));
QCOMPARE(plugin->currentDesktop(), number);
plugin->setCurrentDesktop(current);
QVERIFY(spy.wait(5000));
QCOMPARE(plugin->currentDesktop(), current);
}
void TestDPPlugin::test_dictKeys()
{
QCOMPARE(plugin->dictKeys().count(), 4);
pattern += plugin->dictKeys().join(QString(" $"));
}
void TestDPPlugin::test_parsePattern()
{
QString result = plugin->parsePattern(pattern, plugin->currentDesktop());
QVERIFY(!result.isEmpty());
QVERIFY(result != pattern);
for (auto key : plugin->dictKeys())
QVERIFY(!result.contains(key));
}
void TestDPPlugin::test_tooltipImage()
{
QVariantMap data;
data[QString("tooltipColor")] = QString("#000000");
data[QString("tooltipType")] = QString("windows");
data[QString("tooltipWidth")] = 300;
plugin->setToolTipData(data);
QString image = plugin->toolTipImage(plugin->currentDesktop());
QVERIFY(image.startsWith(QString("<img src=\"")));
QVERIFY(image.endsWith(QString("\"/>")));
}
QTEST_MAIN(TestDPPlugin);

View File

@ -0,0 +1,47 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTDPPLUGIN_H
#define TESTDPPLUGIN_H
#include <QObject>
class DPAdds;
class TestDPPlugin : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_desktops();
void test_dictKeys();
void test_tooltipImage();
void test_parsePattern();
private:
DPAdds *plugin = nullptr;
QString pattern = QString("$");
};
#endif /* TESTDPPLUGIN_H */

View File

@ -49,8 +49,7 @@ void TestAWFloatFormatter::test_count()
QCOMPARE(formatter->count(), count); QCOMPARE(formatter->count(), count);
// test // test
double value = AWTestLibrary::randomDouble(); QString output = formatter->convert(AWTestLibrary::randomDouble());
QString output = formatter->convert(value);
QCOMPARE(output.count(), count); QCOMPARE(output.count(), count);
// reset // reset
@ -67,8 +66,7 @@ void TestAWFloatFormatter::test_fillChar()
formatter->setCount(101); formatter->setCount(101);
// test // test
int value = AWTestLibrary::randomInt(); QString output = formatter->convert(AWTestLibrary::randomInt());
QString output = formatter->convert(value);
QVERIFY(output.startsWith(QChar(c))); QVERIFY(output.startsWith(QChar(c)));
// reset // reset
@ -77,6 +75,24 @@ void TestAWFloatFormatter::test_fillChar()
} }
void TestAWFloatFormatter::test_forceWidth()
{
// assign
int count = AWTestLibrary::randomInt(6);
formatter->setForceWidth(true);
formatter->setCount(count);
QCOMPARE(formatter->forceWidth(), true);
// test
QString output = formatter->convert(AWTestLibrary::randomDouble());
QCOMPARE(output.count(), count);
// reset
formatter->setForceWidth(false);
formatter->setCount(0);
}
void TestAWFloatFormatter::test_format() void TestAWFloatFormatter::test_format()
{ {
// assign // assign
@ -87,8 +103,7 @@ void TestAWFloatFormatter::test_format()
QCOMPARE(formatter->format(), 'e'); QCOMPARE(formatter->format(), 'e');
// test // test
double value = AWTestLibrary::randomDouble(); QString output = formatter->convert(AWTestLibrary::randomDouble());
QString output = formatter->convert(value);
QVERIFY(output.contains('e')); QVERIFY(output.contains('e'));
// reset // reset
@ -104,8 +119,7 @@ void TestAWFloatFormatter::test_precision()
QCOMPARE(formatter->precision(), precision); QCOMPARE(formatter->precision(), precision);
// test // test
double value = AWTestLibrary::randomDouble(); QString output = formatter->convert(AWTestLibrary::randomDouble());
QString output = formatter->convert(value);
output.remove(QString("0.")); output.remove(QString("0."));
QCOMPARE(output.count(), precision); QCOMPARE(output.count(), precision);
@ -157,6 +171,7 @@ void TestAWFloatFormatter::test_copy()
QCOMPARE(newFormatter->count(), formatter->count()); QCOMPARE(newFormatter->count(), formatter->count());
QCOMPARE(newFormatter->fillChar(), formatter->fillChar()); QCOMPARE(newFormatter->fillChar(), formatter->fillChar());
QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth());
QCOMPARE(newFormatter->format(), formatter->format()); QCOMPARE(newFormatter->format(), formatter->format());
QCOMPARE(newFormatter->multiplier(), formatter->multiplier()); QCOMPARE(newFormatter->multiplier(), formatter->multiplier());
QCOMPARE(newFormatter->precision(), formatter->precision()); QCOMPARE(newFormatter->precision(), formatter->precision());
@ -171,6 +186,7 @@ void TestAWFloatFormatter::doRandom()
{ {
formatter->setCount(AWTestLibrary::randomInt()); formatter->setCount(AWTestLibrary::randomInt());
formatter->setFillChar(QChar(AWTestLibrary::randomChar())); formatter->setFillChar(QChar(AWTestLibrary::randomChar()));
formatter->setForceWidth(AWTestLibrary::randomInt() % 2);
formatter->setFormat(AWTestLibrary::randomChar()); formatter->setFormat(AWTestLibrary::randomChar());
formatter->setMultiplier(AWTestLibrary::randomDouble()); formatter->setMultiplier(AWTestLibrary::randomDouble());
formatter->setPrecision(AWTestLibrary::randomInt()); formatter->setPrecision(AWTestLibrary::randomInt());

View File

@ -36,6 +36,7 @@ private slots:
void test_values(); void test_values();
void test_count(); void test_count();
void test_fillChar(); void test_fillChar();
void test_forceWidth();
void test_format(); void test_format();
void test_precision(); void test_precision();
void test_multiplier(); void test_multiplier();

View File

@ -0,0 +1,93 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testlistformatter.h"
#include <QtTest>
#include "awlistformatter.h"
#include "awtestlibrary.h"
void TestAWListFormatter::initTestCase()
{
separator = AWTestLibrary::randomString(10);
formatter = new AWListFormatter(nullptr);
formatter->setSeparator(separator);
}
void TestAWListFormatter::cleanupTestCase()
{
delete formatter;
}
void TestAWListFormatter::test_values()
{
QCOMPARE(formatter->filter(), QString());
QCOMPARE(formatter->separator(), separator);
QCOMPARE(formatter->isSorted(), false);
}
void TestAWListFormatter::test_conversion()
{
QStringList value = AWTestLibrary::randomStringList();
QCOMPARE(formatter->convert(value), value.join(separator));
}
void TestAWListFormatter::test_sorted()
{
formatter->setSorted(true);
QStringList value = AWTestLibrary::randomStringList();
QString received = formatter->convert(value);
value.sort();
QCOMPARE(received, value.join(separator));
}
void TestAWListFormatter::test_filter()
{
QStringList value = AWTestLibrary::randomStringList();
QStringList filters = AWTestLibrary::randomSelect(value);
value.sort();
formatter->setFilter(QString("(^%1$)").arg(filters.join(QString("$|^"))));
QCOMPARE(formatter->convert(value).split(separator).count(),
filters.count());
}
void TestAWListFormatter::test_copy()
{
AWListFormatter *newFormatter = formatter->copy(QString("/dev/null"), 1);
QCOMPARE(newFormatter->number(), 1);
QCOMPARE(newFormatter->filter(), formatter->filter());
QCOMPARE(newFormatter->separator(), formatter->separator());
QCOMPARE(newFormatter->isSorted(), formatter->isSorted());
delete newFormatter;
}
QTEST_MAIN(TestAWListFormatter);

View File

@ -0,0 +1,48 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTLISTFORMATTER_H
#define TESTLISTFORMATTER_H
#include <QObject>
class AWListFormatter;
class TestAWListFormatter : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_values();
void test_conversion();
void test_sorted();
void test_filter();
void test_copy();
private:
AWListFormatter *formatter = nullptr;
QString separator;
};
#endif /* TESTLISTFORMATTER_H */

View File

@ -39,11 +39,6 @@ void TestProcessesSource::cleanupTestCase()
void TestProcessesSource::test_sources() void TestProcessesSource::test_sources()
{ {
QCOMPARE(source->sources().count(), 3); QCOMPARE(source->sources().count(), 3);
// FIXME there is segfault here sometimes o_0
// QVERIFY(std::all_of(
// source->sources().cbegin(), source->sources().cend(),
// [](const QString &src) { return src.startsWith(QString("ps/"));
// }));
} }

View File

@ -0,0 +1,118 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "teststringformatter.h"
#include <QtTest>
#include "awstringformatter.h"
#include "awtestlibrary.h"
void TestAWStringFormatter::initTestCase()
{
formatter = new AWStringFormatter(nullptr);
}
void TestAWStringFormatter::cleanupTestCase()
{
delete formatter;
}
void TestAWStringFormatter::test_values()
{
}
void TestAWStringFormatter::test_count()
{
// assign
int count = 10 + AWTestLibrary::randomInt();
formatter->setCount(count);
QCOMPARE(formatter->count(), count);
// test
QString output = formatter->convert(AWTestLibrary::randomString());
QCOMPARE(output.count(), count);
// reset
formatter->setCount(0);
}
void TestAWStringFormatter::test_fillChar()
{
// assign
char c = AWTestLibrary::randomChar();
formatter->setFillChar(QChar(c));
QCOMPARE(formatter->fillChar(), QChar(c));
formatter->setCount(101);
// test
QString output = formatter->convert(AWTestLibrary::randomString());
QVERIFY(output.startsWith(QChar(c)));
// reset
formatter->setFillChar(QChar());
formatter->setCount(0);
}
void TestAWStringFormatter::test_forceWidth()
{
// assign
int count = AWTestLibrary::randomInt();
formatter->setForceWidth(true);
formatter->setCount(count);
QCOMPARE(formatter->forceWidth(), true);
// test
QString output = formatter->convert(AWTestLibrary::randomString());
QCOMPARE(output.count(), count);
// reset
formatter->setForceWidth(false);
formatter->setCount(0);
}
void TestAWStringFormatter::test_copy()
{
doRandom();
AWStringFormatter *newFormatter = formatter->copy(QString("/dev/null"), 1);
QCOMPARE(newFormatter->count(), formatter->count());
QCOMPARE(newFormatter->fillChar(), formatter->fillChar());
QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth());
QCOMPARE(newFormatter->number(), 1);
delete newFormatter;
}
void TestAWStringFormatter::doRandom()
{
formatter->setCount(AWTestLibrary::randomInt());
formatter->setFillChar(QChar(AWTestLibrary::randomChar()));
formatter->setForceWidth(AWTestLibrary::randomInt() % 2);
}
QTEST_MAIN(TestAWStringFormatter);

View File

@ -0,0 +1,48 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTSTRINGFORMATTER_H
#define TESTSTRINGFORMATTER_H
#include <QObject>
class AWStringFormatter;
class TestAWStringFormatter : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// test
void test_values();
void test_count();
void test_fillChar();
void test_forceWidth();
void test_copy();
private:
void doRandom();
AWStringFormatter *formatter = nullptr;
};
#endif /* TESTSTRINGFORMATTER_H */

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -522,12 +522,24 @@ msgstr ""
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
msgid "Summand" msgid "Summand"
msgstr "" msgstr ""
msgid "Filter"
msgstr ""
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
msgid "Append code" msgid "Append code"
msgstr "" msgstr ""
@ -574,10 +586,10 @@ msgstr ""
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "" msgstr ""
msgid "Filter" msgid "Null"
msgstr "" msgstr ""
msgid "Null" msgid "Provider"
msgstr "" msgstr ""
msgid "City" msgid "City"

View File

@ -6,16 +6,16 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2016-05-16 14:14+0300\n" "PO-Revision-Date: 2016-07-06 19:37+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: English <kde-russian@lists.kde.ru>\n" "Language-Team: English <kde-russian@lists.kde.ru>\n"
"Language: ru\n" "Language: ru\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Lokalize 2.0\n" "X-Generator: Lokalize 2.0\n"
msgid "Widget" msgid "Widget"
@ -527,12 +527,24 @@ msgstr "Width"
msgid "Fill char" msgid "Fill char"
msgstr "Fill char" msgstr "Fill char"
msgid "Force width"
msgstr "Force width"
msgid "Multiplier" msgid "Multiplier"
msgstr "Multiplier" msgstr "Multiplier"
msgid "Summand" msgid "Summand"
msgstr "Summand" msgstr "Summand"
msgid "Filter"
msgstr "Filter"
msgid "Separator"
msgstr "Separator"
msgid "Sort"
msgstr "Sort"
msgid "Append code" msgid "Append code"
msgstr "Append code" msgstr "Append code"
@ -583,12 +595,12 @@ msgstr "Wrap colors"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "Wrap spaces" msgstr "Wrap spaces"
msgid "Filter"
msgstr "Filter"
msgid "Null" msgid "Null"
msgstr "Null" msgstr "Null"
msgid "Provider"
msgstr "Provider"
msgid "City" msgid "City"
msgstr "City" msgstr "City"

View File

@ -9,7 +9,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Awesome widgets\n" "Project-Id-Version: Awesome widgets\n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2016-05-03 06:47+0000\n" "PO-Revision-Date: 2016-05-03 06:47+0000\n"
"Last-Translator: Ernesto Avilés Vázquez <whippiii@gmail.com>\n" "Last-Translator: Ernesto Avilés Vázquez <whippiii@gmail.com>\n"
"Language-Team: Spanish (http://www.transifex.com/arcanis/awesome-widgets/" "Language-Team: Spanish (http://www.transifex.com/arcanis/awesome-widgets/"
@ -534,6 +534,9 @@ msgstr "Ancho"
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -541,6 +544,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "Orden" msgstr "Orden"
msgid "Filter"
msgstr "Filtro"
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "Apariencia" msgstr "Apariencia"
@ -592,12 +604,12 @@ msgstr "Tratamiento de colores"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "Tratamiento de espacios" msgstr "Tratamiento de espacios"
msgid "Filter"
msgstr "Filtro"
msgid "Null" msgid "Null"
msgstr "Líneas en blanco" msgstr "Líneas en blanco"
msgid "Provider"
msgstr ""
msgid "City" msgid "City"
msgstr "Ciudad" msgstr "Ciudad"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2015-07-31 22:16+0300\n" "PO-Revision-Date: 2015-07-31 22:16+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: French <kde-russian@lists.kde.ru>\n" "Language-Team: French <kde-russian@lists.kde.ru>\n"
@ -552,6 +552,9 @@ msgstr ""
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -559,6 +562,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "Commande personnalisée" msgstr "Commande personnalisée"
msgid "Filter"
msgstr ""
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "Apparence" msgstr "Apparence"
@ -611,10 +623,10 @@ msgstr "Couleur de la mémoire d'échange"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "" msgstr ""
msgid "Filter" msgid "Null"
msgstr "" msgstr ""
msgid "Null" msgid "Provider"
msgstr "" msgstr ""
msgid "City" msgid "City"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Awesome widgets\n" "Project-Id-Version: Awesome widgets\n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2015-08-20 22:52+0300\n" "PO-Revision-Date: 2015-08-20 22:52+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Dutch <kde-i18n-nl@kde.org>\n" "Language-Team: Dutch <kde-i18n-nl@kde.org>\n"
@ -554,6 +554,9 @@ msgstr "Breedte"
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -561,6 +564,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "Commentaar" msgstr "Commentaar"
msgid "Filter"
msgstr ""
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "Uiterlijk" msgstr "Uiterlijk"
@ -612,10 +624,10 @@ msgstr "Swap-kleur"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "" msgstr ""
msgid "Filter" msgid "Null"
msgstr "" msgstr ""
msgid "Null" msgid "Provider"
msgstr "" msgstr ""
msgid "City" msgid "City"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -532,6 +532,9 @@ msgstr "Szerokość"
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -539,6 +542,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "Polecenie" msgstr "Polecenie"
msgid "Filter"
msgstr "Filtr"
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "Wygląd" msgstr "Wygląd"
@ -589,12 +601,12 @@ msgstr "Kolory oblewania"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "Oblewanie tekstu" msgstr "Oblewanie tekstu"
msgid "Filter"
msgstr "Filtr"
msgid "Null" msgid "Null"
msgstr "Null" msgstr "Null"
msgid "Provider"
msgstr ""
msgid "City" msgid "City"
msgstr "Miasto" msgstr "Miasto"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2015-07-31 22:21+0300\n" "PO-Revision-Date: 2015-07-31 22:21+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n" "Language-Team: Russian <kde-russian@lists.kde.ru>\n"
@ -548,6 +548,9 @@ msgstr "Largura"
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -555,6 +558,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "Comentário" msgstr "Comentário"
msgid "Filter"
msgstr ""
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "Aparência" msgstr "Aparência"
@ -603,10 +615,10 @@ msgstr "Cor da swap"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "" msgstr ""
msgid "Filter" msgid "Null"
msgstr "" msgstr ""
msgid "Null" msgid "Provider"
msgstr "" msgstr ""
msgid "City" msgid "City"

View File

@ -6,16 +6,16 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2016-05-16 14:15+0300\n" "PO-Revision-Date: 2016-07-06 19:37+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n" "Language-Team: Russian <kde-russian@lists.kde.ru>\n"
"Language: ru\n" "Language: ru\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Lokalize 2.0\n" "X-Generator: Lokalize 2.0\n"
msgid "Widget" msgid "Widget"
@ -527,12 +527,24 @@ msgstr "Ширина"
msgid "Fill char" msgid "Fill char"
msgstr "Заполнение" msgstr "Заполнение"
msgid "Force width"
msgstr "Зафиксировать ширину"
msgid "Multiplier" msgid "Multiplier"
msgstr "Множитель" msgstr "Множитель"
msgid "Summand" msgid "Summand"
msgstr "Слагаемое" msgstr "Слагаемое"
msgid "Filter"
msgstr "Фильтр"
msgid "Separator"
msgstr "Разделитель"
msgid "Sort"
msgstr "Сортировка"
msgid "Append code" msgid "Append code"
msgstr "Дополнить код" msgstr "Дополнить код"
@ -583,12 +595,12 @@ msgstr "Обработать цвета"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "Обработать пробелы" msgstr "Обработать пробелы"
msgid "Filter"
msgstr "Фильтр"
msgid "Null" msgid "Null"
msgstr "Пустые строки" msgstr "Пустые строки"
msgid "Provider"
msgstr "Провайдер"
msgid "City" msgid "City"
msgstr "Город" msgstr "Город"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2016-05-05 17:18+0300\n" "PO-Revision-Date: 2016-05-05 17:18+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Ukrainian <kde-russian@lists.kde.ru>\n" "Language-Team: Ukrainian <kde-russian@lists.kde.ru>\n"
@ -532,6 +532,9 @@ msgstr "Ширина"
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -539,6 +542,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "Команда" msgstr "Команда"
msgid "Filter"
msgstr "Фільтр"
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "Зовнішній вигляд" msgstr "Зовнішній вигляд"
@ -590,12 +602,12 @@ msgstr "Обробити кольори"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "Обробити пробіли" msgstr "Обробити пробіли"
msgid "Filter"
msgstr "Фільтр"
msgid "Null" msgid "Null"
msgstr "Пусті рядки" msgstr "Пусті рядки"
msgid "Provider"
msgstr ""
msgid "City" msgid "City"
msgstr "Місто" msgstr "Місто"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2016-05-16 19:35+0300\n" "POT-Creation-Date: 2016-07-06 19:36+0300\n"
"PO-Revision-Date: 2015-07-31 22:24+0300\n" "PO-Revision-Date: 2015-07-31 22:24+0300\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n" "Language-Team: Russian <kde-russian@lists.kde.ru>\n"
@ -533,6 +533,9 @@ msgstr "宽度"
msgid "Fill char" msgid "Fill char"
msgstr "" msgstr ""
msgid "Force width"
msgstr ""
msgid "Multiplier" msgid "Multiplier"
msgstr "" msgstr ""
@ -540,6 +543,15 @@ msgstr ""
msgid "Summand" msgid "Summand"
msgstr "命令" msgstr "命令"
msgid "Filter"
msgstr "过滤"
msgid "Separator"
msgstr ""
msgid "Sort"
msgstr ""
#, fuzzy #, fuzzy
msgid "Append code" msgid "Append code"
msgstr "外观" msgstr "外观"
@ -591,12 +603,12 @@ msgstr "换行颜色"
msgid "Wrap spaces" msgid "Wrap spaces"
msgstr "换行空格" msgstr "换行空格"
msgid "Filter"
msgstr "过滤"
msgid "Null" msgid "Null"
msgstr "空" msgstr "空"
msgid "Provider"
msgstr ""
msgid "City" msgid "City"
msgstr "城市" msgstr "城市"

View File

@ -37,7 +37,7 @@
// formatter api version // formatter api version
#define AWEFAPI 1 #define AWEFAPI 1
// network requests timeout, ms // network requests timeout, ms
#define REQUEST_TIMEOUT 5000 #define REQUEST_TIMEOUT 3000
// available time keys // available time keys
#define TIME_KEYS \ #define TIME_KEYS \
"dddd,ddd,dd,d,MMMM,MMM,MM,M,yyyy,yy,hh,h,HH,H,mm,m,ss,s,t,ap,a,AP,A" "dddd,ddd,dd,d,MMMM,MMM,MM,M,yyyy,yy,hh,h,HH,H,mm,m,ss,s,t,ap,a,AP,A"
@ -51,6 +51,7 @@
"dalbum,dartist,dtitle,salbum,sartist,stitle,pscount,pstotal,ps,desktop," \ "dalbum,dartist,dtitle,salbum,sartist,stitle,pscount,pstotal,ps,desktop," \
"ndesktop,tdesktops,la15,la5,la1" "ndesktop,tdesktops,la15,la5,la1"
#cmakedefine BUILD_FUTURE #cmakedefine BUILD_FUTURE
#cmakedefine BUILD_LOAD
#cmakedefine BUILD_TESTING #cmakedefine BUILD_TESTING
// links // links
@ -94,6 +95,7 @@
#define CPPCHECK_EXECUTABLE "@CPPCHECK_EXECUTABLE@" #define CPPCHECK_EXECUTABLE "@CPPCHECK_EXECUTABLE@"
// additional functions // additional functions
#define PROP_FUTURE "@BUILD_FUTURE@" #define PROP_FUTURE "@BUILD_FUTURE@"
#define PROP_LOAD "@BUILD_LOAD@"
#define PROP_TEST "@BUILD_TESTING@" #define PROP_TEST "@BUILD_TESTING@"