From a339f9a7433366cc4d607eceee156a1bad1b2659 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 30 Apr 2016 17:36:01 +0300 Subject: [PATCH 1/9] drop needToBeUpdated call from qml since it is not required --- sources/awesome-widget/package/contents/ui/widget.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/sources/awesome-widget/package/contents/ui/widget.qml b/sources/awesome-widget/package/contents/ui/widget.qml index 8b1d35b..86da37c 100644 --- a/sources/awesome-widget/package/contents/ui/widget.qml +++ b/sources/awesome-widget/package/contents/ui/widget.qml @@ -331,7 +331,6 @@ Item { lock = false awKeys.initKeys(textPattern.text, plasmoid.configuration.interval, plasmoid.configuration.queueLimit, false) - awKeys.needToBeUpdated() } } } From 46db3fee4c26e56dab49a9a89cce01b06fecf6a0 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sun, 1 May 2016 16:23:37 +0300 Subject: [PATCH 2/9] add standalone configuration example (#72) --- .../configs/aw-example-standalonerc | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 sources/awesomewidgets/configs/aw-example-standalonerc diff --git a/sources/awesomewidgets/configs/aw-example-standalonerc b/sources/awesomewidgets/configs/aw-example-standalonerc new file mode 100644 index 0000000..4ca37c7 --- /dev/null +++ b/sources/awesomewidgets/configs/aw-example-standalonerc @@ -0,0 +1,134 @@ +[desktops] +cpu-bar.desktop\Comment=Example cpu bar +cpu-bar.desktop\Encoding=UTF-8 +cpu-bar.desktop\Name=cpu-bar.desktop +cpu-bar.desktop\X-AW-Active=true +cpu-bar.desktop\X-AW-ActiveColor="color://0,0,255,255" +cpu-bar.desktop\X-AW-ApiVersion=5 +cpu-bar.desktop\X-AW-Count=100 +cpu-bar.desktop\X-AW-Custom=false +cpu-bar.desktop\X-AW-Direction=LeftToRight +cpu-bar.desktop\X-AW-Height=10 +cpu-bar.desktop\X-AW-InactiveColor="color://0,0,0,255" +cpu-bar.desktop\X-AW-Interval=1 +cpu-bar.desktop\X-AW-Max=@Variant(\0\0\0\x87\x42\xc8\0\0) +cpu-bar.desktop\X-AW-Min=@Variant(\0\0\0\x87\0\0\0\0) +cpu-bar.desktop\X-AW-Number=7 +cpu-bar.desktop\X-AW-Type=Horizontal +cpu-bar.desktop\X-AW-Value=cpu +cpu-bar.desktop\X-AW-Width=200 +down-graph.desktop\Comment=Example download speed graph +down-graph.desktop\Encoding=UTF-8 +down-graph.desktop\Name=down-graph.desktop +down-graph.desktop\X-AW-Active=true +down-graph.desktop\X-AW-ActiveColor="color://0,170,0,255" +down-graph.desktop\X-AW-ApiVersion=5 +down-graph.desktop\X-AW-Count=100 +down-graph.desktop\X-AW-Custom=true +down-graph.desktop\X-AW-Direction=LeftToRight +down-graph.desktop\X-AW-Height=25 +down-graph.desktop\X-AW-InactiveColor="color://0,0,0,255" +down-graph.desktop\X-AW-Interval=1 +down-graph.desktop\X-AW-Max=100.0 +down-graph.desktop\X-AW-Min=@Variant(\0\0\0\x87\0\0\0\0) +down-graph.desktop\X-AW-Number=8 +down-graph.desktop\X-AW-Type=Bars +down-graph.desktop\X-AW-Value=$downkb +down-graph.desktop\X-AW-Width=300 +ram-bar.desktop\Comment=Example RAM bar +ram-bar.desktop\Encoding=UTF-8 +ram-bar.desktop\Name=ram-bar.desktop +ram-bar.desktop\X-AW-Active=true +ram-bar.desktop\X-AW-ActiveColor="color://0,0,255,255" +ram-bar.desktop\X-AW-ApiVersion=5 +ram-bar.desktop\X-AW-Count=100 +ram-bar.desktop\X-AW-Custom=false +ram-bar.desktop\X-AW-Direction=LeftToRight +ram-bar.desktop\X-AW-Height=10 +ram-bar.desktop\X-AW-InactiveColor="color://0,0,0,255" +ram-bar.desktop\X-AW-Interval=1 +ram-bar.desktop\X-AW-Max=@Variant(\0\0\0\x87\x42\xc8\0\0) +ram-bar.desktop\X-AW-Min=@Variant(\0\0\0\x87\0\0\0\0) +ram-bar.desktop\X-AW-Number=5 +ram-bar.desktop\X-AW-Type=Horizontal +ram-bar.desktop\X-AW-Value=mem +ram-bar.desktop\X-AW-Width=200 +swap-bar.desktop\Comment=Example swap bar +swap-bar.desktop\Encoding=UTF-8 +swap-bar.desktop\Name=swap-bar.desktop +swap-bar.desktop\X-AW-Active=true +swap-bar.desktop\X-AW-ActiveColor="color://0,0,255,255" +swap-bar.desktop\X-AW-ApiVersion=5 +swap-bar.desktop\X-AW-Count=100 +swap-bar.desktop\X-AW-Custom=false +swap-bar.desktop\X-AW-Direction=LeftToRight +swap-bar.desktop\X-AW-Height=10 +swap-bar.desktop\X-AW-InactiveColor="color://0,0,0,255" +swap-bar.desktop\X-AW-Interval=1 +swap-bar.desktop\X-AW-Max=@Variant(\0\0\0\x87\x42\xc8\0\0) +swap-bar.desktop\X-AW-Min=@Variant(\0\0\0\x87\0\0\0\0) +swap-bar.desktop\X-AW-Number=6 +swap-bar.desktop\X-AW-Type=Horizontal +swap-bar.desktop\X-AW-Value=swap +swap-bar.desktop\X-AW-Width=200 +up-graph.desktop\Comment=Example upload speed graph +up-graph.desktop\Encoding=UTF-8 +up-graph.desktop\Name=upload-graph.desktop +up-graph.desktop\X-AW-Active=true +up-graph.desktop\X-AW-ActiveColor="color://0,170,0,255" +up-graph.desktop\X-AW-ApiVersion=5 +up-graph.desktop\X-AW-Count=100 +up-graph.desktop\X-AW-Custom=true +up-graph.desktop\X-AW-Direction=LeftToRight +up-graph.desktop\X-AW-Height=25 +up-graph.desktop\X-AW-InactiveColor="color://0,0,0,255" +up-graph.desktop\X-AW-Interval=1 +up-graph.desktop\X-AW-Max=100.0 +up-graph.desktop\X-AW-Min=@Variant(\0\0\0\x87\0\0\0\0) +up-graph.desktop\X-AW-Number=9 +up-graph.desktop\X-AW-Type=Bars +up-graph.desktop\X-AW-Value=$cpu +up-graph.desktop\X-AW-Width=300 + +[plasmoid] +acOffline=( ) +acOnline=(*) +background=false +batInTooltipColor=#880000 +batTooltip=true +batTooltipColor=#008800 +checkUpdates=true +cpuTooltip=true +cpuTooltipColor=#ff0000 +cpuclTooltip=true +cpuclTooltipColor=#00ff00 +customTime=$hh:$mm +customUptime=$ddd $hhh $mmm +downkbTooltip=true +downkbTooltipColor=#00ffff +fontColor=#ffffff +fontFamily=Terminus +fontSize=12 +fontStyle=normal +fontWeight=normal +height=400 +interval=1000 +memTooltip=true +memTooltipColor=#0000ff +notify=true +optimize=true +queueLimit=0 +swapTooltip=true +swapTooltipColor=#ffff00 +tempUnits=Celsius +text="\n

Uptime: $cuptime
\nRAM:  $mem  $bar5
\nSwap: $swap  $bar6
\nCPU:  $cpu  $bar7
\nCPU Temp: $temp0°C
\nDown: $down$downunits    $downtotal
\n$bar8
\nUp:   $up$upunits    $uptotal
\n$bar9

\n\n" +textAlign=center +tooltipBackground=#ffffff +tooltipNumber=100 +translateStrings=true +upkbTooltipColor=#ff00ff +useTooltipBackground=true +width=300 +wrapNewLines=false +wrapText=false + From 3771ce6ec254db641fb7928bcccd5a9f0354bace Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 3 May 2016 05:04:12 +0300 Subject: [PATCH 3/9] rename forma_t_er to forma_tt_er --- sources/awesome-widget/plugin/awkeys.cpp | 4 +- .../plugin/awkeysaggregator.cpp | 226 ++++++++++-------- .../awesome-widget/plugin/awkeysaggregator.h | 16 +- .../plugin/awpatternfunctions.cpp | 2 +- sources/awesomewidgets/extscript.h | 2 +- sources/awesomewidgets/graphicalitem.h | 2 +- 6 files changed, 139 insertions(+), 113 deletions(-) diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 5667b76..4ae1cb1 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -179,7 +179,7 @@ QString AWKeys::valueByKey(QString key) const qCDebug(LOG_AW) << "Requested value for key" << key; key.remove(QRegExp(QString("^bar[0-9]{1,}"))); - return aggregator->formater(values[key], key); + return aggregator->formatter(values[key], key); } @@ -312,7 +312,7 @@ QString AWKeys::parsePattern(QString pattern) const for (auto key : m_foundKeys) pattern.replace(QString("$%1").arg(key), [this](const QString &tag, const QVariant &value) { - QString strValue = aggregator->formater(value, tag); + QString strValue = aggregator->formatter(value, tag); if ((!tag.startsWith(QString("custom"))) && (!tag.startsWith(QString("weather")))) strValue.replace(QString(" "), QString(" ")); diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 608f417..5b48398 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -24,6 +24,7 @@ #include #include "awdebug.h" +#include "awformatterhelper.h" AWKeysAggregator::AWKeysAggregator(QObject *parent) @@ -31,69 +32,73 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; - // default formaters + // default formatters // memory - m_formater[QString("mem")] = FormaterType::Float; - m_formater[QString("memtotmb")] = FormaterType::MemMBFormat; - m_formater[QString("memtotgb")] = FormaterType::MemGBFormat; + m_formatter[QString("mem")] = FormatterType::Float; + m_formatter[QString("memtotmb")] = FormatterType::MemMBFormat; + m_formatter[QString("memtotgb")] = FormatterType::MemGBFormat; // network - m_formater[QString("down")] = FormaterType::NetSmartFormat; - m_formater[QString("downkb")] = FormaterType::Integer; - m_formater[QString("downunits")] = FormaterType::NetSmartUnits; - m_formater[QString("up")] = FormaterType::NetSmartFormat; - m_formater[QString("upkb")] = FormaterType::Integer; - m_formater[QString("upunits")] = FormaterType::NetSmartUnits; + m_formatter[QString("down")] = FormatterType::NetSmartFormat; + m_formatter[QString("downkb")] = FormatterType::Integer; + m_formatter[QString("downunits")] = FormatterType::NetSmartUnits; + m_formatter[QString("up")] = FormatterType::NetSmartFormat; + m_formatter[QString("upkb")] = FormatterType::Integer; + m_formatter[QString("upunits")] = FormatterType::NetSmartUnits; // swap - m_formater[QString("swap")] = FormaterType::Float; - m_formater[QString("swaptotmb")] = FormaterType::MemMBFormat; - m_formater[QString("swaptotgb")] = FormaterType::MemGBFormat; + m_formatter[QString("swap")] = FormatterType::Float; + m_formatter[QString("swaptotmb")] = FormatterType::MemMBFormat; + m_formatter[QString("swaptotgb")] = FormatterType::MemGBFormat; + + m_customFormatters = new AWFormatterHelper(this); } AWKeysAggregator::~AWKeysAggregator() { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + delete m_customFormatters; } -QString AWKeysAggregator::formater(const QVariant &data, - const QString &key) const +QString AWKeysAggregator::formatter(const QVariant &data, + const QString &key) const { qCDebug(LOG_AW) << "Data" << data << "for key" << key; QString output; QLocale loc = m_translate ? QLocale::system() : QLocale::c(); // case block - switch (m_formater[key]) { - case FormaterType::Float: + switch (m_formatter[key]) { + case FormatterType::Float: output = QString("%1").arg(data.toFloat(), 5, 'f', 1); break; - case FormaterType::FloatTwoSymbols: + case FormatterType::FloatTwoSymbols: output = QString("%1").arg(data.toFloat(), 5, 'f', 2); break; - case FormaterType::Integer: + case FormatterType::Integer: output = QString("%1").arg(data.toFloat(), 4, 'f', 0); break; - case FormaterType::IntegerFive: + case FormatterType::IntegerFive: output = QString("%1").arg(data.toFloat(), 5, 'f', 0); break; - case FormaterType::IntegerThree: + case FormatterType::IntegerThree: output = QString("%1").arg(data.toFloat(), 3, 'f', 0); break; - case FormaterType::List: + case FormatterType::List: output = data.toStringList().join(QChar(',')); break; - case FormaterType::ACFormat: + case FormatterType::ACFormat: output = data.toBool() ? m_acOnline : m_acOffline; break; - case FormaterType::MemGBFormat: + case FormatterType::MemGBFormat: output = QString("%1").arg(data.toFloat() / (1024.0 * 1024.0), 5, 'f', 1); break; - case FormaterType::MemMBFormat: + case FormatterType::MemMBFormat: output = QString("%1").arg(data.toFloat() / 1024.0, 5, 'f', 0); break; - case FormaterType::NetSmartFormat: + case FormatterType::NetSmartFormat: output = [](const float value) { if (value > 1024.0) return QString("%1").arg(value / 1024.0, 4, 'f', 1); @@ -101,41 +106,41 @@ QString AWKeysAggregator::formater(const QVariant &data, return QString("%1").arg(value, 4, 'f', 0); }(data.toFloat()); break; - case FormaterType::NetSmartUnits: + case FormatterType::NetSmartUnits: if (data.toFloat() > 1024.0) output = m_translate ? i18n("MB/s") : QString("MB/s"); else output = m_translate ? i18n("KB/s") : QString("KB/s"); break; - case FormaterType::Quotes: + case FormatterType::Quotes: // first cast output = QString("%1").arg(data.toDouble(), 0, 'f'); output = output.rightJustified(8, QLatin1Char(' '), true); break; - case FormaterType::Temperature: + case FormatterType::Temperature: output = QString("%1").arg(temperature(data.toFloat()), 5, 'f', 1); break; - case FormaterType::Time: + case FormatterType::Time: output = data.toDateTime().toString(); break; - case FormaterType::TimeCustom: + case FormatterType::TimeCustom: output = m_customTime; [&output, loc, this](const QDateTime dt) { for (auto key : timeKeys) output.replace(QString("$%1").arg(key), loc.toString(dt, key)); }(data.toDateTime()); break; - case FormaterType::TimeISO: + case FormatterType::TimeISO: output = data.toDateTime().toString(Qt::ISODate); break; - case FormaterType::TimeLong: + case FormatterType::TimeLong: output = loc.toString(data.toDateTime(), QLocale::LongFormat); break; - case FormaterType::TimeShort: + case FormatterType::TimeShort: output = loc.toString(data.toDateTime(), QLocale::ShortFormat); break; - case FormaterType::Uptime: - case FormaterType::UptimeCustom: + case FormatterType::Uptime: + case FormatterType::UptimeCustom: output = [](QString source, const int uptime) { int seconds = uptime - uptime % 60; @@ -152,13 +157,17 @@ QString AWKeysAggregator::formater(const QVariant &data, QString("%1").arg(minutes, 2, 10, QChar('0'))); source.replace(QString("$m"), QString("%1").arg(minutes)); return source; - }(m_formater[key] == FormaterType::Uptime ? QString("$ddd$hhh$mmm") - : m_customUptime, + }(m_formatter[key] == FormatterType::Uptime + ? QString("$ddd$hhh$mmm") + : m_customUptime, static_cast(data.toFloat())); break; - case FormaterType::NoFormat: + case FormatterType::NoFormat: output = data.toString(); break; + case FormatterType::Custom: + output = m_customFormatters->convert(data, key); + break; } return output; @@ -253,52 +262,52 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (source == QString("battery/ac")) { // AC m_map[source] = QString("ac"); - m_formater[QString("ac")] = FormaterType::ACFormat; + m_formatter[QString("ac")] = FormatterType::ACFormat; } else if (source.startsWith(QString("battery/"))) { // battery stats QString key = source; key.remove(QString("battery/")); m_map[source] = key; - m_formater[key] = FormaterType::IntegerThree; + m_formatter[key] = FormatterType::IntegerThree; } else if (source == QString("cpu/system/TotalLoad")) { // cpu m_map[source] = QString("cpu"); - m_formater[QString("cpu")] = FormaterType::Float; + m_formatter[QString("cpu")] = FormatterType::Float; } else if (source.contains(cpuRegExp)) { // cpus QString key = source; key.remove(QString("cpu/")).remove(QString("/TotalLoad")); m_map[source] = key; - m_formater[key] = FormaterType::Float; + m_formatter[key] = FormatterType::Float; } else if (source == QString("cpu/system/AverageClock")) { // cpucl m_map[source] = QString("cpucl"); - m_formater[QString("cpucl")] = FormaterType::Integer; + m_formatter[QString("cpucl")] = FormatterType::Integer; } else if (source.contains(cpuclRegExp)) { // cpucls QString key = source; key.remove(QString("cpu/cpu")).remove(QString("/clock")); key = QString("cpucl%1").arg(key); m_map[source] = key; - m_formater[key] = FormaterType::Integer; + m_formatter[key] = FormatterType::Integer; } else if (source.startsWith(QString("custom"))) { // custom QString key = source; key.remove(QString("custom/")); m_map[source] = key; - m_formater[key] = FormaterType::NoFormat; + m_formatter[key] = FormatterType::NoFormat; } else if (source == QString("desktop/current/name")) { // current desktop name m_map[source] = QString("desktop"); - m_formater[QString("desktop")] = FormaterType::NoFormat; + m_formatter[QString("desktop")] = FormatterType::NoFormat; } else if (source == QString("desktop/current/number")) { // current desktop number m_map[source] = QString("ndesktop"); - m_formater[QString("ndesktop")] = FormaterType::NoFormat; + m_formatter[QString("ndesktop")] = FormatterType::NoFormat; } else if (source == QString("desktop/total/number")) { // desktop count m_map[source] = QString("tdesktops"); - m_formater[QString("tdesktops")] = FormaterType::NoFormat; + m_formatter[QString("tdesktops")] = FormatterType::NoFormat; } else if (source.contains(hddrRegExp)) { // read speed QString device = source; @@ -307,7 +316,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hddr%1").arg(index); m_map[source] = key; - m_formater[key] = FormaterType::Integer; + m_formatter[key] = FormatterType::Integer; } } else if (source.contains(hddwRegExp)) { // write speed @@ -317,16 +326,16 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hddw%1").arg(index); m_map[source] = key; - m_formater[key] = FormaterType::Integer; + m_formatter[key] = FormatterType::Integer; } } else if (source == QString("gpu/load")) { // gpu load m_map[source] = QString("gpu"); - m_formater[QString("gpu")] = FormaterType::Float; + m_formatter[QString("gpu")] = FormatterType::Float; } else if (source == QString("gpu/temperature")) { // gpu temperature m_map[source] = QString("gputemp"); - m_formater[QString("gputemp")] = FormaterType::Temperature; + m_formatter[QString("gputemp")] = FormatterType::Temperature; } else if (source.contains(mountFillRegExp)) { // fill level QString device = source; @@ -335,12 +344,12 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hdd%1").arg(index); m_map[source] = key; - m_formater[key] = FormaterType::Float; + m_formatter[key] = FormatterType::Float; // additional keys - m_formater[QString("hddtotmb%1").arg(index)] - = FormaterType::MemMBFormat; - m_formater[QString("hddtotgb%1").arg(index)] - = FormaterType::MemGBFormat; + m_formatter[QString("hddtotmb%1").arg(index)] + = FormatterType::MemMBFormat; + m_formatter[QString("hddtotgb%1").arg(index)] + = FormatterType::MemGBFormat; } } else if (source.contains(mountFreeRegExp)) { // free space @@ -351,11 +360,11 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // mb QString key = QString("hddfreemb%1").arg(index); m_map[source] = key; - m_formater[key] = FormaterType::MemMBFormat; + m_formatter[key] = FormatterType::MemMBFormat; // gb key = QString("hddfreegb%1").arg(index); m_map.insertMulti(source, key); - m_formater[key] = FormaterType::MemGBFormat; + m_formatter[key] = FormatterType::MemGBFormat; } } else if (source.contains(mountUsedRegExp)) { // used @@ -366,11 +375,11 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // mb QString key = QString("hddmb%1").arg(index); m_map[source] = key; - m_formater[key] = FormaterType::MemMBFormat; + m_formatter[key] = FormatterType::MemMBFormat; // gb key = QString("hddgb%1").arg(index); m_map.insertMulti(source, key); - m_formater[key] = FormaterType::MemGBFormat; + m_formatter[key] = FormatterType::MemGBFormat; } } else if (source.startsWith(QString("hdd/temperature"))) { // hdd temperature @@ -380,7 +389,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("hddtemp%1").arg(index); m_map[source] = key; - m_formater[key] = FormaterType::Temperature; + m_formatter[key] = FormatterType::Temperature; } } else if (source.startsWith(QString("cpu/system/loadavg"))) { // load average @@ -388,35 +397,35 @@ QStringList AWKeysAggregator::registerSource(const QString &source, time.remove(QString("cpu/system/loadavg")); QString key = QString("la%1").arg(time); m_map[source] = key; - m_formater[key] = FormaterType::FloatTwoSymbols; + m_formatter[key] = FormatterType::FloatTwoSymbols; } else if (source == QString("mem/physical/application")) { // app memory // mb m_map[source] = QString("memmb"); - m_formater[QString("memmb")] = FormaterType::MemMBFormat; + m_formatter[QString("memmb")] = FormatterType::MemMBFormat; // gb m_map.insertMulti(source, QString("memgb")); - m_formater[QString("memgb")] = FormaterType::MemGBFormat; + m_formatter[QString("memgb")] = FormatterType::MemGBFormat; } else if (source == QString("mem/physical/free")) { // free memory // mb m_map[source] = QString("memfreemb"); - m_formater[QString("memfreemb")] = FormaterType::MemMBFormat; + m_formatter[QString("memfreemb")] = FormatterType::MemMBFormat; // gb m_map.insertMulti(source, QString("memfreegb")); - m_formater[QString("memfreegb")] = FormaterType::MemGBFormat; + m_formatter[QString("memfreegb")] = FormatterType::MemGBFormat; } else if (source == QString("mem/physical/used")) { // used memory // mb m_map[source] = QString("memusedmb"); - m_formater[QString("memusedmb")] = FormaterType::MemMBFormat; + m_formatter[QString("memusedmb")] = FormatterType::MemMBFormat; // gb m_map.insertMulti(source, QString("memusedgb")); - m_formater[QString("memusedgb")] = FormaterType::MemGBFormat; + m_formatter[QString("memusedgb")] = FormatterType::MemGBFormat; } else if (source == QString("network/current/name")) { // network device m_map[source] = QString("netdev"); - m_formater[QString("netdev")] = FormaterType::NoFormat; + m_formatter[QString("netdev")] = FormatterType::NoFormat; } else if (source.contains(netRegExp)) { // network speed QString type = source.contains(QString("receiver")) ? QString("down") @@ -427,15 +436,15 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // kb QString key = QString("%1kb%2").arg(type).arg(index); m_map[source] = key; - m_formater[key] = FormaterType::Integer; + m_formatter[key] = FormatterType::Integer; // smart key = QString("%1%2").arg(type).arg(index); m_map.insertMulti(source, key); - m_formater[key] = FormaterType::NetSmartFormat; + m_formatter[key] = FormatterType::NetSmartFormat; // units key = QString("%1units%2").arg(type).arg(index); m_map.insertMulti(source, key); - m_formater[key] = FormaterType::NetSmartUnits; + m_formatter[key] = FormatterType::NetSmartUnits; } } else if (source.contains(netTotalRegExp)) { // network data total @@ -447,58 +456,58 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // kb QString key = QString("%1totalkb%2").arg(type).arg(index); m_map[source] = key; - m_formater[key] = FormaterType::Integer; + m_formatter[key] = FormatterType::Integer; // mb key = QString("%1total%2").arg(type).arg(index); m_map.insertMulti(source, key); - m_formater[key] = FormaterType::MemMBFormat; + m_formatter[key] = FormatterType::MemMBFormat; } } else if (source.startsWith(QString("upgrade"))) { // package manager QString key = source; key.remove(QString("upgrade/")); m_map[source] = key; - m_formater[key] = FormaterType::IntegerThree; + m_formatter[key] = FormatterType::IntegerThree; } else if (source.startsWith(QString("player"))) { // player QString key = source; key.remove(QString("player/")); m_map[source] = key; - m_formater[key] = FormaterType::NoFormat; + m_formatter[key] = FormatterType::NoFormat; } else if (source == QString("ps/running/count")) { // running processes count m_map[source] = QString("pscount"); - m_formater[QString("pscount")] = FormaterType::NoFormat; + m_formatter[QString("pscount")] = FormatterType::NoFormat; } else if (source == QString("ps/running/list")) { // list of running processes m_map[source] = QString("ps"); - m_formater[QString("ps")] = FormaterType::List; + m_formatter[QString("ps")] = FormatterType::List; } else if (source == QString("ps/total/count")) { // total processes count m_map[source] = QString("pstotal"); - m_formater[QString("pstotal")] = FormaterType::NoFormat; + m_formatter[QString("pstotal")] = FormatterType::NoFormat; } else if (source.startsWith(QString("quotes"))) { // quotes QString key = source; key.remove(QString("quotes/")); m_map[source] = key; - m_formater[key] = FormaterType::Quotes; + m_formatter[key] = FormatterType::Quotes; } else if (source == QString("mem/swap/free")) { // free swap // mb m_map[source] = QString("swapfreemb"); - m_formater[QString("swapfreemb")] = FormaterType::MemMBFormat; + m_formatter[QString("swapfreemb")] = FormatterType::MemMBFormat; // gb m_map.insertMulti(source, QString("swapfreegb")); - m_formater[QString("swapfreegb")] = FormaterType::MemGBFormat; + m_formatter[QString("swapfreegb")] = FormatterType::MemGBFormat; } else if (source == QString("mem/swap/used")) { // used swap // mb m_map[source] = QString("swapmb"); - m_formater[QString("swapmb")] = FormaterType::MemMBFormat; + m_formatter[QString("swapmb")] = FormatterType::MemMBFormat; // gb m_map.insertMulti(source, QString("swapgb")); - m_formater[QString("swapgb")] = FormaterType::MemGBFormat; + m_formatter[QString("swapgb")] = FormatterType::MemGBFormat; } else if (source.startsWith(QString("lmsensors/"))) { // temperature int index = m_devices[QString("temp")].indexOf(source); @@ -508,64 +517,77 @@ QStringList AWKeysAggregator::registerSource(const QString &source, if (index > -1) { QString key = QString("temp%1").arg(index); m_map[source] = key; - m_formater[key] = units == QString("°C") ? FormaterType::Temperature - : FormaterType::Integer; + m_formatter[key] = units == QString("°C") + ? FormatterType::Temperature + : FormatterType::Integer; } } else if (source == QString("Local")) { // time m_map[source] = QString("time"); - m_formater[QString("time")] = FormaterType::Time; + m_formatter[QString("time")] = FormatterType::Time; // custom time m_map.insertMulti(source, QString("ctime")); - m_formater[QString("ctime")] = FormaterType::TimeCustom; + m_formatter[QString("ctime")] = FormatterType::TimeCustom; // ISO time m_map.insertMulti(source, QString("isotime")); - m_formater[QString("isotime")] = FormaterType::TimeISO; + m_formatter[QString("isotime")] = FormatterType::TimeISO; // long time m_map.insertMulti(source, QString("longtime")); - m_formater[QString("longtime")] = FormaterType::TimeLong; + m_formatter[QString("longtime")] = FormatterType::TimeLong; // short time m_map.insertMulti(source, QString("shorttime")); - m_formater[QString("shorttime")] = FormaterType::TimeShort; + m_formatter[QString("shorttime")] = FormatterType::TimeShort; } else if (source == QString("system/uptime")) { // uptime m_map[source] = QString("uptime"); - m_formater[QString("uptime")] = FormaterType::Uptime; + m_formatter[QString("uptime")] = FormatterType::Uptime; // custom uptime m_map.insertMulti(source, QString("cuptime")); - m_formater[QString("cuptime")] = FormaterType::UptimeCustom; + m_formatter[QString("cuptime")] = FormatterType::UptimeCustom; } else if (source.startsWith(QString("weather/temperature"))) { // temperature QString key = source; key.remove(QString("weather/")); m_map[source] = key; - m_formater[key] = FormaterType::Temperature; + m_formatter[key] = FormatterType::Temperature; } else if (source.startsWith(QString("weather/"))) { // other weather QString key = source; key.remove(QString("weather/")); m_map[source] = key; - m_formater[key] = FormaterType::NoFormat; + m_formatter[key] = FormatterType::NoFormat; } else if (source.startsWith(QString("load/load"))) { // load source QString key = source; key.remove(QString("load/")); m_map[source] = key; - m_formater[key] = FormaterType::Temperature; + m_formatter[key] = FormatterType::Temperature; + } + + QStringList foundKeys = keysFromSource(source); + + // rewrite formatters for custom ones + QStringList customFormattersKeys = m_customFormatters->definedFormatters(); + qCInfo(LOG_AW) << "Looking for fprmatters" << foundKeys << "in" + << customFormattersKeys; + for (auto key : foundKeys) { + if (!customFormattersKeys.contains(key)) + continue; + m_formatter[key] = FormatterType::Custom; } // drop key from dictionary if no one user requested key required it - QStringList foundKeys = keysFromSource(source); qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << keys; - // this source is required if list is empty (which means skip checking) - // or if key in required key list bool required = keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&keys](const QString &key) { return keys.contains(key); }); - if (!required) + if (!required) { m_map.remove(source); + for (auto key : foundKeys) + m_formatter.remove(key); + } return keysFromSource(source); } diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index a7087c4..1cedf36 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -25,6 +25,8 @@ #include "version.h" +class AWFormatterHelper; + class AWKeysAggregator : public QObject { Q_OBJECT @@ -36,16 +38,17 @@ class AWKeysAggregator : public QObject Q_PROPERTY(QString tempUnits MEMBER m_tempUnits WRITE setTempUnits); Q_PROPERTY(bool translate MEMBER m_translate WRITE setTranslate); - enum class FormaterType { - // general formaters - NoFormat = 0, + enum class FormatterType { + // general formatters + Custom, + NoFormat, Float, FloatTwoSymbols, Integer, IntegerFive, IntegerThree, List, - // unit specific formaters + // unit specific formatters ACFormat, MemGBFormat, MemMBFormat, @@ -66,7 +69,7 @@ public: explicit AWKeysAggregator(QObject *parent = nullptr); virtual ~AWKeysAggregator(); // get methods - QString formater(const QVariant &data, const QString &key) const; + QString formatter(const QVariant &data, const QString &key) const; QStringList keysFromSource(const QString &source) const; // set methods void setAcOffline(const QString inactive); @@ -83,6 +86,7 @@ public slots: private: float temperature(const float temp) const; + AWFormatterHelper *m_customFormatters = nullptr; QStringList timeKeys = QString(TIME_KEYS).split(QChar(',')); // variables QString m_acOffline; @@ -90,7 +94,7 @@ private: QString m_customTime; QString m_customUptime; QHash m_devices; - QHash m_formater; + QHash m_formatter; QHash m_map; QString m_tempUnits; bool m_translate = false; diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index a1843ec..07a0d6c 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -37,7 +37,7 @@ QString AWPatternFunctions::expandLambdas(QString code, // parsed values for (auto lambdaKey : usedKeys) code.replace(QString("$%1").arg(lambdaKey), - aggregator->formater(metadata[lambdaKey], lambdaKey)); + aggregator->formatter(metadata[lambdaKey], lambdaKey)); qCInfo(LOG_AW) << "Expression" << code; QJSValue result = engine.evaluate(code); if (result.isError()) { diff --git a/sources/awesomewidgets/extscript.h b/sources/awesomewidgets/extscript.h index 5d099af..8d1e9b1 100644 --- a/sources/awesomewidgets/extscript.h +++ b/sources/awesomewidgets/extscript.h @@ -37,7 +37,7 @@ class ExtScript : public AbstractExtItem Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect) public: - enum class Redirect { stdout2stderr = 0, nothing, stderr2stdout, swap }; + enum class Redirect { stdout2stderr, nothing, stderr2stdout, swap }; explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(), diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index 18d2630..24af844 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -50,7 +50,7 @@ class GraphicalItem : public AbstractExtItem public: enum class Direction { LeftToRight = 0, RightToLeft = 1 }; - enum class Type { Horizontal = 0, Vertical, Circle, Graph, Bars }; + enum class Type { Horizontal, Vertical, Circle, Graph, Bars }; explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(), From 97f2e783082d50070931c0db8b858598ad4f2235 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Wed, 4 May 2016 12:40:54 +0300 Subject: [PATCH 4/9] add transifex integration * update Spanish translation * rename nl to nl_NL --- .tx/config | 8 ++ sources/translations/es.po | 105 ++++++++--------------- sources/translations/{nl.po => nl_NL.po} | 0 3 files changed, 44 insertions(+), 69 deletions(-) create mode 100644 .tx/config rename sources/translations/{nl.po => nl_NL.po} (100%) diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..5cdfa80 --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.com + +[awesome-widgets.awesome-widgetspot] +source_file = sources/translations/awesome-widgets.pot +source_lang = en +type = PO +file_filter = sources/translations/.po diff --git a/sources/translations/es.po b/sources/translations/es.po index 69729aa..c0686ff 100644 --- a/sources/translations/es.po +++ b/sources/translations/es.po @@ -1,23 +1,22 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: -# Ernesto Avilés Vázquez , 2014-2015 +# Ernesto Avilés Vázquez , 2014-2016 # Evgeniy Alekseev , 2014-2015 msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "POT-Creation-Date: 2016-04-29 12:21+0300\n" -"PO-Revision-Date: 2015-09-26 22:07+0000\n" +"PO-Revision-Date: 2016-05-03 06:47+0000\n" "Last-Translator: Ernesto Avilés Vázquez \n" -"Language-Team: Spanish (http://www.transifex.com/arcanis/awesome-widgets/" -"language/es/)\n" -"Language: es\n" +"Language-Team: Spanish (http://www.transifex.com/arcanis/awesome-widgets/language/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" msgid "Widget" @@ -60,7 +59,7 @@ msgid "Check updates on startup" msgstr "Comprobar actualizaciones al inicio" msgid "Optimize subscription" -msgstr "" +msgstr "Optimizar suscripción" msgid "Widget height, px" msgstr "Alto del widget, px" @@ -114,39 +113,37 @@ msgid "Drop key cache" msgstr "Borrar caché de claves" msgid "Export configuration" -msgstr "" +msgstr "Exportar configuración" msgid "Export" -msgstr "" +msgstr "Exportar" msgid "Success" -msgstr "" +msgstr "Realizado" msgid "Please note that binary files were not copied" -msgstr "" +msgstr "Por favor, note que los archivos binarios no fueron copiados" msgid "Ooops..." -msgstr "" +msgstr "Uy..." msgid "Could not save configuration file" -msgstr "" +msgstr "No se pudo guardar el archivo de configuración" msgid "Import configuration" -msgstr "" +msgstr "Importar configuración" msgid "Import" -msgstr "" +msgstr "Importar" msgid "Import plasmoid settings" -msgstr "" +msgstr "Importar configuraciones de plasmoide" -#, fuzzy msgid "Import extensions" -msgstr "Extensiones" +msgstr "Extensiones a importar" -#, fuzzy msgid "Import additional files" -msgstr "Filtros adicionales" +msgstr "Importar archivos adicionales" msgid "Font" msgstr "Tipo de letra" @@ -277,10 +274,7 @@ msgstr "Comprobar actualizaciones" msgid "" "CPU, CPU clock, memory, swap and network labels support graphical tooltip. " "To enable them just make needed checkbox checked." -msgstr "" -"Las etiquetas para CPU, reloj de CPU, memoria, swap y red soportan ventanas " -"emergentes. Para habilitarlas, simplemente marca las casillas " -"correspondientes." +msgstr "Las etiquetas para CPU, reloj de CPU, memoria, swap y red soportan ventanas emergentes. Para habilitarlas, simplemente marca las casillas correspondientes." msgid "Number of values for tooltips" msgstr "Número de valores para las ventanas emergentes" @@ -334,15 +328,12 @@ msgid "Battery inactive color" msgstr "Color de la batería inactiva" msgid "" -"Detailed information may be found on project homepage" -msgstr "" -"Puedes encontrar información detallada en el sitio del proyecto" +"Detailed information may be found on project homepage" +msgstr "Puedes encontrar información detallada en el sitio del proyecto" -#, fuzzy msgid "Bgcolor" -msgstr "Color de la CPU" +msgstr "Color de fondo" msgid "AC" msgstr "CA" @@ -369,7 +360,7 @@ msgid "Weathers" msgstr "Tiempo" msgid "Functions" -msgstr "" +msgstr "Funciones" msgid "Add" msgstr "Añadir" @@ -423,7 +414,7 @@ msgid "This software uses: %1" msgstr "Este software usa: %1" msgid "Special thanks to %1" -msgstr "" +msgstr "Agradecimientos especiales a %1" msgid "Select font" msgstr "Elegir tipo de letra" @@ -456,7 +447,7 @@ msgid "KB/s" msgstr "KB/s" msgid "Changelog of %1" -msgstr "" +msgstr "Cambios de %1" msgid "You are using the actual version %1" msgstr "Estás usando al versión actual %1" @@ -512,13 +503,9 @@ msgstr "Etiqueta" msgid "" "

Use YAHOO! finance ticker to get quotes for the " "instrument. Refer to http://finance.yahoo.com/

" -msgstr "" -"

Usa el tablero electrónico de YAHOO! para obtener la " -"cotización del medio. Dirígete a http://finance.yahoo." -"com/

" +"text-decoration: underline; " +"color:#0057ae;\">http://finance.yahoo.com/

" +msgstr "

Usa el tablero electrónico de YAHOO! para obtener la cotización del medio. Dirígete a http://finance.yahoo.com/

" msgid "Ticker" msgstr "Tablero" @@ -565,34 +552,29 @@ msgstr "Marca de tiempo" msgid "Use images" msgstr "Usar imágenes" -#, fuzzy msgid "Use custom formula" -msgstr "Formato personalizado de hora" +msgstr "Usar fórmula personalizada" msgid "Value" msgstr "Valor" -#, fuzzy msgid "Max value" -msgstr "Mostrar valor" +msgstr "Valor máximo" -#, fuzzy msgid "Min value" -msgstr "Mostrar valor" +msgstr "Valor mínimo" -#, fuzzy msgid "Active filling type" -msgstr "Activo" +msgstr "Activar tipo de relleno" -#, fuzzy msgid "Inctive filling type" -msgstr "Escritorio inactivo" +msgstr "Inhabilitar tipo de relleno" msgid "Type" msgstr "Tipo" msgid "Points count" -msgstr "" +msgstr "Conteo de puntos" msgid "Direction" msgstr "Dirección" @@ -603,13 +585,11 @@ msgstr "Alto" msgid "Width" msgstr "Ancho" -#, fuzzy msgid "color" -msgstr "Color de la CPU" +msgstr "color" -#, fuzzy msgid "image" -msgstr "Usar imágenes" +msgstr "imagen" msgid "Active desktop" msgstr "Escritorio activo" @@ -651,16 +631,3 @@ msgstr "Tu nombre" msgctxt "EMAIL OF TRANSLATORS" msgid "Your emails" msgstr "Tu correo electrónico" - -#, fuzzy -#~ msgid "Use image for active" -#~ msgstr "Usar imágenes" - -#~ msgid "Active color" -#~ msgstr "Color de activo" - -#~ msgid "Inactive color" -#~ msgstr "Color de inactivo" - -#~ msgid "Add lambda" -#~ msgstr "Añadir lambda" diff --git a/sources/translations/nl.po b/sources/translations/nl_NL.po similarity index 100% rename from sources/translations/nl.po rename to sources/translations/nl_NL.po From 2220ad6bfe92cfa67f128982378f0a5f0480499f Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 5 May 2016 00:11:31 +0300 Subject: [PATCH 5/9] initial creation of custom formatters (#91) --- sources/awdebug.cpp | 1 - sources/awdebug.h | 2 + .../plugin/awabstractformatter.h | 37 ++++ .../plugin/awdatetimeformatter.cpp | 84 +++++++++ .../plugin/awdatetimeformatter.h | 46 +++++ .../plugin/awfloatformatter.cpp | 159 ++++++++++++++++++ .../awesome-widget/plugin/awfloatformatter.h | 64 +++++++ .../plugin/awformatterhelper.cpp | 118 +++++++++++++ .../awesome-widget/plugin/awformatterhelper.h | 49 ++++++ .../awesome-widget/plugin/awnoformatter.cpp | 59 +++++++ sources/awesome-widget/plugin/awnoformatter.h | 41 +++++ sources/cppcheck.cmake | 1 + 12 files changed, 660 insertions(+), 1 deletion(-) create mode 100644 sources/awesome-widget/plugin/awabstractformatter.h create mode 100644 sources/awesome-widget/plugin/awdatetimeformatter.cpp create mode 100644 sources/awesome-widget/plugin/awdatetimeformatter.h create mode 100644 sources/awesome-widget/plugin/awfloatformatter.cpp create mode 100644 sources/awesome-widget/plugin/awfloatformatter.h create mode 100644 sources/awesome-widget/plugin/awformatterhelper.cpp create mode 100644 sources/awesome-widget/plugin/awformatterhelper.h create mode 100644 sources/awesome-widget/plugin/awnoformatter.cpp create mode 100644 sources/awesome-widget/plugin/awnoformatter.h diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index 40a8d5f..d81b355 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -17,7 +17,6 @@ #include "awdebug.h" -#include "version.h" Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", diff --git a/sources/awdebug.h b/sources/awdebug.h index 43944ce..6a3b2dd 100644 --- a/sources/awdebug.h +++ b/sources/awdebug.h @@ -21,6 +21,8 @@ #include +#include "version.h" + #ifndef LOG_FORMAT #define LOG_FORMAT \ "[%{time process}][%{if-debug}DD%{endif}%{if-info}II%{endif}%{if-" \ diff --git a/sources/awesome-widget/plugin/awabstractformatter.h b/sources/awesome-widget/plugin/awabstractformatter.h new file mode 100644 index 0000000..d873ef5 --- /dev/null +++ b/sources/awesome-widget/plugin/awabstractformatter.h @@ -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/ * + ***************************************************************************/ + +#ifndef AWABSTRACTFORMATTER_H +#define AWABSTRACTFORMATTER_H + +#include +#include + + +class AWAbstractFormatter : public QObject +{ +public: + explicit AWAbstractFormatter(QObject *parent, const QString, const QString) + : QObject(parent){}; + explicit AWAbstractFormatter(QObject *parent) + : QObject(parent){}; + virtual ~AWAbstractFormatter(){}; + virtual QString convert(const QVariant &value) const = 0; +}; + + +#endif /* AWABSTRACTFORMATTER_H */ diff --git a/sources/awesome-widget/plugin/awdatetimeformatter.cpp b/sources/awesome-widget/plugin/awdatetimeformatter.cpp new file mode 100644 index 0000000..515dd42 --- /dev/null +++ b/sources/awesome-widget/plugin/awdatetimeformatter.cpp @@ -0,0 +1,84 @@ +/*************************************************************************** + * 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 "awdatetimeformatter.h" + +#include +#include + +#include "awdebug.h" + + +AWDateTimeFormatter::AWDateTimeFormatter(QObject *parent, + const QString filename, + const QString section) + : AWAbstractFormatter(parent, filename, section) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + init(filename, section); +} + + +AWDateTimeFormatter::AWDateTimeFormatter(QObject *parent, const QString format) + : AWAbstractFormatter(parent) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + setFormat(format); +} + + +AWDateTimeFormatter::~AWDateTimeFormatter() +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; +} + + +QString AWDateTimeFormatter::convert(const QVariant &value) const +{ + qCDebug(LOG_AW) << "Convert value" << value; + + return value.toDateTime().toString(m_format); +} + + +QString AWDateTimeFormatter::format() const +{ + return m_format; +} + + +void AWDateTimeFormatter::setFormat(const QString _format) +{ + qCDebug(LOG_AW) << "Set format" << _format; + + m_format = _format; +} + + +void AWDateTimeFormatter::init(const QString filename, const QString section) +{ + qCDebug(LOG_AW) << "Looking for section" << section << "in" << filename; + + QSettings settings(filename, QSettings::IniFormat); + + settings.beginGroup(section); + setFormat(settings.value(QString("Format"), QString()).toString()); + settings.endGroup(); +} diff --git a/sources/awesome-widget/plugin/awdatetimeformatter.h b/sources/awesome-widget/plugin/awdatetimeformatter.h new file mode 100644 index 0000000..df8e9d7 --- /dev/null +++ b/sources/awesome-widget/plugin/awdatetimeformatter.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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 AWDATETIMEFORMATTER_H +#define AWDATETIMEFORMATTER_H + +#include "awabstractformatter.h" + + +class AWDateTimeFormatter : public AWAbstractFormatter +{ + Q_OBJECT + Q_PROPERTY(QString format READ format WRITE setFormat) + +public: + explicit AWDateTimeFormatter(QObject *parent, const QString filename, + const QString section); + explicit AWDateTimeFormatter(QObject *parent, const QString format); + virtual ~AWDateTimeFormatter(); + QString convert(const QVariant &value) const; + // properties + QString format() const; + void setFormat(const QString _format); + +private: + void init(const QString filename, const QString section); + // properties + QString m_format; +}; + + +#endif /* AWDATETIMEFORMATTER_H */ diff --git a/sources/awesome-widget/plugin/awfloatformatter.cpp b/sources/awesome-widget/plugin/awfloatformatter.cpp new file mode 100644 index 0000000..6663e99 --- /dev/null +++ b/sources/awesome-widget/plugin/awfloatformatter.cpp @@ -0,0 +1,159 @@ +/*************************************************************************** + * 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 "awfloatformatter.h" + +#include + +#include "awdebug.h" + + +AWFloatFormatter::AWFloatFormatter(QObject *parent, const QString filename, + const QString section) + : AWAbstractFormatter(parent, filename, section) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + init(filename, section); +} + + +AWFloatFormatter::AWFloatFormatter(QObject *parent, const QChar fillChar, + const char format, const double multiplier, + const int precision, const int width) + : AWAbstractFormatter(parent) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + setFillChar(fillChar); + setFormat(format); + setMultiplier(multiplier); + setPrecision(precision); + setWidth(width); +} + + +AWFloatFormatter::~AWFloatFormatter() +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; +} + + +QString AWFloatFormatter::convert(const QVariant &value) const +{ + qCDebug(LOG_AW) << "Convert value" << value; + + return QString("%1").arg(value.toDouble() * m_multiplier, m_width, m_format, + m_precision, m_fillChar); +} + + +QChar AWFloatFormatter::fillChar() const +{ + return m_fillChar; +} + + +char AWFloatFormatter::format() const +{ + return m_format; +} + + +double AWFloatFormatter::multiplier() const +{ + return m_multiplier; +} + + +int AWFloatFormatter::precision() const +{ + return m_precision; +} + + +int AWFloatFormatter::width() const +{ + return m_width; +} + + +void AWFloatFormatter::setFillChar(const QChar _fillChar) +{ + qCDebug(LOG_AW) << "Set char" << _fillChar; + + m_fillChar = _fillChar; +} + + +void AWFloatFormatter::setFormat(char _format) +{ + qCDebug(LOG_AW) << "Set format" << _format; + // http://doc.qt.io/qt-5/qstring.html#argument-formats + if ((_format != 'e') && (_format != 'E') && (_format != 'f') + && (_format != 'g') && (_format != 'G')) { + qCWarning(LOG_AW) << "Invalid format" << _format; + _format = 'f'; + } + + m_format = _format; +} + + +void AWFloatFormatter::setMultiplier(const double _multiplier) +{ + qCDebug(LOG_AW) << "Set multiplier" << _multiplier; + + m_multiplier = _multiplier; +} + + +void AWFloatFormatter::setPrecision(const int _precision) +{ + qCDebug(LOG_AW) << "Set precision" << _precision; + + m_precision = _precision; +} + + +void AWFloatFormatter::setWidth(const int _width) +{ + qCDebug(LOG_AW) << "Set width" << _width; + + m_width = _width; +} + + +void AWFloatFormatter::init(const QString filename, const QString section) +{ + qCDebug(LOG_AW) << "Looking for section" << section << "in" << filename; + + QSettings settings(filename, QSettings::IniFormat); + + settings.beginGroup(section); + setFillChar( + settings.value(QString("FillChar"), QString()).toString().at(0)); + setFormat(settings.value(QString("Format"), QString("f")) + .toString() + .at(0) + .toLatin1()); + setMultiplier(settings.value(QString("Multiplier"), 1.0).toDouble()); + setPrecision(settings.value(QString("Precision"), -1).toInt()); + setWidth(settings.value(QString("Width"), 0).toInt()); + settings.endGroup(); +} diff --git a/sources/awesome-widget/plugin/awfloatformatter.h b/sources/awesome-widget/plugin/awfloatformatter.h new file mode 100644 index 0000000..1222dd5 --- /dev/null +++ b/sources/awesome-widget/plugin/awfloatformatter.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * 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 AWFLOATFORMATTER_H +#define AWFLOATFORMATTER_H + +#include "awabstractformatter.h" + + +class AWFloatFormatter : public AWAbstractFormatter +{ + Q_OBJECT + Q_PROPERTY(QChar fillChar READ fillChar WRITE setFillChar) + Q_PROPERTY(char format READ format WRITE setFormat) + Q_PROPERTY(double multiplier READ multiplier WRITE setMultiplier) + Q_PROPERTY(int precision READ precision WRITE setPrecision) + Q_PROPERTY(int width READ width WRITE setWidth) + +public: + explicit AWFloatFormatter(QObject *parent, const QString filename, + const QString section); + explicit AWFloatFormatter(QObject *parent, const QChar fillChar, + const char format, const double multiplier, + const int precision, const int width); + virtual ~AWFloatFormatter(); + QString convert(const QVariant &value) const; + // properties + QChar fillChar() const; + char format() const; + double multiplier() const; + int precision() const; + int width() const; + void setFillChar(const QChar _fillChar); + void setFormat(char _format); + void setMultiplier(const double _multiplier); + void setPrecision(const int _precision); + void setWidth(const int _width); + +private: + void init(const QString filename, const QString section); + // properties + QChar m_fillChar; + char m_format; + double m_multiplier; + int m_precision; + int m_width; +}; + + +#endif /* AWFLOATFORMATTER_H */ diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp new file mode 100644 index 0000000..633cfc9 --- /dev/null +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -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 "awformatterhelper.h" + +#include +#include + +#include "awdebug.h" +#include "awdatetimeformatter.h" +#include "awfloatformatter.h" +#include "awnoformatter.h" + + +AWFormatterHelper::AWFormatterHelper(QObject *parent) + : QObject(parent) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + m_genericConfig = QString("%1/awesomewidgets/general.ini") + .arg(QStandardPaths::writableLocation( + QStandardPaths::GenericDataLocation)); +#ifdef BUILD_FUTURE + init(); +#endif /* BUILD_FUTURE */ +} + + +AWFormatterHelper::~AWFormatterHelper() +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + m_formatters.clear(); +} + + +QString AWFormatterHelper::convert(const QVariant &value, + const QString name) const +{ + qCDebug(LOG_AW) << "Convert value" << value << "for" << name; + + return m_formatters.contains(name) ? m_formatters[name]->convert(value) + : value.toString(); +} + + +QStringList AWFormatterHelper::definedFormatters() const +{ + return m_formatters.keys(); +} + + +AWFormatterHelper::FormatterClass +AWFormatterHelper::defineFormatterClass(const QString name) const +{ + qCDebug(LOG_AW) << "Define formatter class for" << name; + + QSettings settings(m_genericConfig, QSettings::IniFormat); + + settings.beginGroup(name); + QString stringType + = settings.value(QString("Type"), QString("NoFormat")).toString(); + settings.endGroup(); + + FormatterClass formatter = FormatterClass::NoFormat; + if (stringType == QString("Float")) + formatter = FormatterClass::Float; + else if (stringType == QString("DateTime")) + formatter = FormatterClass::DateTime; + else + qCWarning(LOG_AW) << "Unknown formatter" << stringType; + + return formatter; +} + + +void AWFormatterHelper::init() +{ + QSettings settings(m_genericConfig, QSettings::IniFormat); + + settings.beginGroup(QString("Formatters")); + QStringList keys = settings.childKeys(); + for (auto key : keys) { + QString name = settings.value(key).toString(); + FormatterClass formatter = defineFormatterClass(name); + qCInfo(LOG_AW) << "Found formatter" << name << "for key" << key + << "defined as" << static_cast(formatter); + + switch (formatter) { + case FormatterClass::Float: + m_formatters[key] + = new AWFloatFormatter(this, m_genericConfig, name); + break; + case FormatterClass::DateTime: + m_formatters[key] + = new AWDateTimeFormatter(this, m_genericConfig, name); + break; + case FormatterClass::NoFormat: + m_formatters[key] = new AWNoFormatter(this, m_genericConfig, name); + break; + } + } + settings.endGroup(); +} diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h new file mode 100644 index 0000000..c4012b6 --- /dev/null +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * 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 AWFORMATTERHELPER_H +#define AWFORMATTERHELPER_H + +#include + +#include "awabstractformatter.h" + + +class AWFormatterHelper : public QObject +{ + Q_OBJECT + +public: + enum class FormatterClass { Float, DateTime, NoFormat }; + + explicit AWFormatterHelper(QObject *parent = nullptr); + virtual ~AWFormatterHelper(); + QString convert(const QVariant &value, const QString name) const; + QStringList definedFormatters() const; + +private: + AWFormatterHelper::FormatterClass + defineFormatterClass(const QString name) const; + void init(); + // properties + QString m_genericConfig; + QHash m_formatters; +}; + + +#endif /* AWFORMATTERHELPER_H */ diff --git a/sources/awesome-widget/plugin/awnoformatter.cpp b/sources/awesome-widget/plugin/awnoformatter.cpp new file mode 100644 index 0000000..f36a2b5 --- /dev/null +++ b/sources/awesome-widget/plugin/awnoformatter.cpp @@ -0,0 +1,59 @@ +/*************************************************************************** + * 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 "awnoformatter.h" + +#include "awdebug.h" + + +AWNoFormatter::AWNoFormatter(QObject *parent, const QString filename, + const QString section) + : AWAbstractFormatter(parent, filename, section) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + init(filename, section); +} + + +AWNoFormatter::AWNoFormatter(QObject *parent) + : AWAbstractFormatter(parent) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; +} + + +AWNoFormatter::~AWNoFormatter() +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; +} + + +QString AWNoFormatter::convert(const QVariant &value) const +{ + qCDebug(LOG_AW) << "Convert value" << value; + + return value.toString(); +} + + +void AWNoFormatter::init(const QString filename, const QString section) +{ + qCDebug(LOG_AW) << "Looking for section" << section << "in" << filename; + // dummy method for future references +} diff --git a/sources/awesome-widget/plugin/awnoformatter.h b/sources/awesome-widget/plugin/awnoformatter.h new file mode 100644 index 0000000..0251b50 --- /dev/null +++ b/sources/awesome-widget/plugin/awnoformatter.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * 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 AWNOFORMATTER_H +#define AWNOFORMATTER_H + +#include "awabstractformatter.h" + + +class AWNoFormatter : public AWAbstractFormatter +{ + Q_OBJECT + +public: + explicit AWNoFormatter(QObject *parent, const QString filename, + const QString section); + explicit AWNoFormatter(QObject *parent); + virtual ~AWNoFormatter(); + QString convert(const QVariant &value) const; + +private: + void init(const QString filename, const QString section); + // properties +}; + + +#endif /* AWNOFORMATTER_H */ diff --git a/sources/cppcheck.cmake b/sources/cppcheck.cmake index 47fd6c8..3a38881 100644 --- a/sources/cppcheck.cmake +++ b/sources/cppcheck.cmake @@ -16,6 +16,7 @@ add_custom_target( COMMAND ${CPPCHECK_EXECUTABLE} --enable=warning,performance,portability,information,missingInclude --std=c++11 + --language=c++ --library=qt.cfg --template="[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)" --verbose From 13f2d560d08b116435efc2519f16659498a815aa Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 6 May 2016 01:22:59 +0300 Subject: [PATCH 6/9] Some more changes * new tag - $tstime * add summand parameter to float formatter * drop version.h includes since it has been moved to awdebug.h (e.g. to introduce BUILD_FUTURE guards easy in the future) --- sources/awesome-widget/plugin/awactions.cpp | 1 - .../plugin/awfloatformatter.cpp | 23 ++++++++++++++++--- .../awesome-widget/plugin/awfloatformatter.h | 7 +++++- .../awesome-widget/plugin/awkeyoperations.cpp | 1 - sources/awesome-widget/plugin/awkeys.cpp | 1 - .../plugin/awkeysaggregator.cpp | 7 ++++++ .../awesome-widget/plugin/awkeysaggregator.h | 1 + .../awesome-widget/plugin/awupdatehelper.cpp | 1 - sources/awesomewidgets/abstractextitem.cpp | 1 - sources/awesomewidgets/extquotes.cpp | 1 - sources/awesomewidgets/extscript.cpp | 1 - sources/awesomewidgets/extupgrade.cpp | 1 - sources/awesomewidgets/extweather.cpp | 1 - sources/awesomewidgets/graphicalitem.cpp | 1 - sources/desktop-panel/plugin/dpadds.cpp | 1 - sources/extsysmon/extsysmon.cpp | 1 - sources/extsysmon/extsysmonaggregator.cpp | 1 - sources/version.h.in | 4 ++-- 18 files changed, 36 insertions(+), 19 deletions(-) diff --git a/sources/awesome-widget/plugin/awactions.cpp b/sources/awesome-widget/plugin/awactions.cpp index d0281ca..31f15bf 100644 --- a/sources/awesome-widget/plugin/awactions.cpp +++ b/sources/awesome-widget/plugin/awactions.cpp @@ -28,7 +28,6 @@ #include "awdebug.h" #include "awupdatehelper.h" -#include "version.h" AWActions::AWActions(QObject *parent) diff --git a/sources/awesome-widget/plugin/awfloatformatter.cpp b/sources/awesome-widget/plugin/awfloatformatter.cpp index 6663e99..7a6fe2c 100644 --- a/sources/awesome-widget/plugin/awfloatformatter.cpp +++ b/sources/awesome-widget/plugin/awfloatformatter.cpp @@ -35,7 +35,8 @@ AWFloatFormatter::AWFloatFormatter(QObject *parent, const QString filename, AWFloatFormatter::AWFloatFormatter(QObject *parent, const QChar fillChar, const char format, const double multiplier, - const int precision, const int width) + const int precision, const double summand, + const int width) : AWAbstractFormatter(parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; @@ -44,6 +45,7 @@ AWFloatFormatter::AWFloatFormatter(QObject *parent, const QChar fillChar, setFormat(format); setMultiplier(multiplier); setPrecision(precision); + setSummand(summand); setWidth(width); } @@ -58,8 +60,8 @@ QString AWFloatFormatter::convert(const QVariant &value) const { qCDebug(LOG_AW) << "Convert value" << value; - return QString("%1").arg(value.toDouble() * m_multiplier, m_width, m_format, - m_precision, m_fillChar); + return QString("%1").arg(value.toDouble() * m_multiplier + m_summand, + m_width, m_format, m_precision, m_fillChar); } @@ -87,6 +89,12 @@ int AWFloatFormatter::precision() const } +double AWFloatFormatter::summand() const +{ + return m_summand; +} + + int AWFloatFormatter::width() const { return m_width; @@ -131,6 +139,14 @@ void AWFloatFormatter::setPrecision(const int _precision) } +void AWFloatFormatter::setSummand(const double _summand) +{ + qCDebug(LOG_AW) << "Set summand" << _summand; + + m_summand = _summand; +} + + void AWFloatFormatter::setWidth(const int _width) { qCDebug(LOG_AW) << "Set width" << _width; @@ -154,6 +170,7 @@ void AWFloatFormatter::init(const QString filename, const QString section) .toLatin1()); setMultiplier(settings.value(QString("Multiplier"), 1.0).toDouble()); setPrecision(settings.value(QString("Precision"), -1).toInt()); + setSummand(settings.value(QString("Summand"), 0.0).toDouble()); setWidth(settings.value(QString("Width"), 0).toInt()); settings.endGroup(); } diff --git a/sources/awesome-widget/plugin/awfloatformatter.h b/sources/awesome-widget/plugin/awfloatformatter.h index 1222dd5..2ee36c8 100644 --- a/sources/awesome-widget/plugin/awfloatformatter.h +++ b/sources/awesome-widget/plugin/awfloatformatter.h @@ -28,6 +28,7 @@ class AWFloatFormatter : public AWAbstractFormatter Q_PROPERTY(char format READ format WRITE setFormat) Q_PROPERTY(double multiplier READ multiplier WRITE setMultiplier) Q_PROPERTY(int precision READ precision WRITE setPrecision) + Q_PROPERTY(double summand READ summand WRITE setSummand) Q_PROPERTY(int width READ width WRITE setWidth) public: @@ -35,7 +36,8 @@ public: const QString section); explicit AWFloatFormatter(QObject *parent, const QChar fillChar, const char format, const double multiplier, - const int precision, const int width); + const int precision, const double summand, + const int width); virtual ~AWFloatFormatter(); QString convert(const QVariant &value) const; // properties @@ -43,11 +45,13 @@ public: char format() const; double multiplier() const; int precision() const; + double summand() const; int width() const; void setFillChar(const QChar _fillChar); void setFormat(char _format); void setMultiplier(const double _multiplier); void setPrecision(const int _precision); + void setSummand(const double _summand); void setWidth(const int _width); private: @@ -57,6 +61,7 @@ private: char m_format; double m_multiplier; int m_precision; + double m_summand; int m_width; }; diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 9441aba..abab46c 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -25,7 +25,6 @@ #include "awdebug.h" #include "awkeycache.h" #include "awpatternfunctions.h" -#include "version.h" // extensions #include "extquotes.h" #include "extscript.h" diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 4ae1cb1..fd1c829 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -31,7 +31,6 @@ #include "awkeysaggregator.h" #include "awpatternfunctions.h" #include "graphicalitem.h" -#include "version.h" AWKeys::AWKeys(QObject *parent) diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 5b48398..0f5f0c0 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -139,6 +139,10 @@ QString AWKeysAggregator::formatter(const QVariant &data, case FormatterType::TimeShort: output = loc.toString(data.toDateTime(), QLocale::ShortFormat); break; + case FormatterType::Timestamp: + output = QString("%1").arg( + data.toDateTime().toMSecsSinceEpoch() / 1000.0, 10, 'f', 0); + break; case FormatterType::Uptime: case FormatterType::UptimeCustom: output = @@ -537,6 +541,9 @@ QStringList AWKeysAggregator::registerSource(const QString &source, // short time m_map.insertMulti(source, QString("shorttime")); m_formatter[QString("shorttime")] = FormatterType::TimeShort; + // timestamp + m_map.insertMulti(source, QString("tstime")); + m_formatter[QString("tstime")] = FormatterType::Timestamp; } else if (source == QString("system/uptime")) { // uptime m_map[source] = QString("uptime"); diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index 1cedf36..81ad9ca 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -61,6 +61,7 @@ class AWKeysAggregator : public QObject TimeISO, TimeLong, TimeShort, + Timestamp, Uptime, UptimeCustom }; diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp index b43001b..9ccd636 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.cpp +++ b/sources/awesome-widget/plugin/awupdatehelper.cpp @@ -29,7 +29,6 @@ #include #include "awdebug.h" -#include "version.h" AWUpdateHelper::AWUpdateHelper(QObject *parent) diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index b66f7ca..fc6abde 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -23,7 +23,6 @@ #include #include "awdebug.h" -#include "version.h" #include "abstractextitemaggregator.h" diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 46a69c6..473b2a1 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -31,7 +31,6 @@ #include #include "awdebug.h" -#include "version.h" ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName, diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index a859d26..a674ff3 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -28,7 +28,6 @@ #include #include "awdebug.h" -#include "version.h" ExtScript::ExtScript(QWidget *parent, const QString scriptName, diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 33d79df..9c23963 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -26,7 +26,6 @@ #include #include "awdebug.h" -#include "version.h" ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName, diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index d348a02..63f8c18 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -32,7 +32,6 @@ #include #include "awdebug.h" -#include "version.h" ExtWeather::ExtWeather(QWidget *parent, const QString weatherName, diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 0caae81..4579a06 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -30,7 +30,6 @@ #include "awdebug.h" #include "graphicalitemhelper.h" -#include "version.h" GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, diff --git a/sources/desktop-panel/plugin/dpadds.cpp b/sources/desktop-panel/plugin/dpadds.cpp index f1e345c..21a551c 100644 --- a/sources/desktop-panel/plugin/dpadds.cpp +++ b/sources/desktop-panel/plugin/dpadds.cpp @@ -34,7 +34,6 @@ #include #include "awdebug.h" -#include "version.h" DPAdds::DPAdds(QObject *parent) diff --git a/sources/extsysmon/extsysmon.cpp b/sources/extsysmon/extsysmon.cpp index 818f9a3..8727df8 100644 --- a/sources/extsysmon/extsysmon.cpp +++ b/sources/extsysmon/extsysmon.cpp @@ -25,7 +25,6 @@ #include "awdebug.h" #include "extsysmonaggregator.h" -#include "version.h" ExtendedSysMon::ExtendedSysMon(QObject *parent, const QVariantList &args) diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index de0419d..e137548 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -31,7 +31,6 @@ #include "sources/quotessource.h" #include "sources/upgradesource.h" #include "sources/weathersource.h" -#include "version.h" ExtSysMonAggregator::ExtSysMonAggregator(QObject *parent, diff --git a/sources/version.h.in b/sources/version.h.in index 10fe51b..9ba98f3 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -40,8 +40,8 @@ "dddd,ddd,dd,d,MMMM,MMM,MM,M,yyyy,yy,hh,h,HH,H,mm,m,ss,s,t,ap,a,AP,A" // static keys #define STATIC_KEYS \ - "time,isotime,shorttime,longtime,ctime,uptime,cuptime,cpucl,cpu,gputemp," \ - "gpu,memmb,memgb,memfreemb,memfreegb,memtotmb,memtotgb,memusedmb," \ + "time,isotime,shorttime,longtime,tstime,ctime,uptime,cuptime,cpucl,cpu," \ + "gputemp,gpu,memmb,memgb,memfreemb,memfreegb,memtotmb,memtotgb,memusedmb," \ "memusedgb,mem,swapmb,swapgb,swapfreemb,swapfreegb,swaptotmb,swaptotgb," \ "swap,downunits,upunits,downkb,downtotalkb,downtotal,down,uptotalkb," \ "uptotal,upkb,up,netdev,ac,bat,album,artist,duration,progress,title," \ From d57e54b714b54fda4c6231901de1fbefbc2fe190 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 7 May 2016 00:10:06 +0300 Subject: [PATCH 7/9] add script formatter --- .../plugin/awformatterhelper.cpp | 17 +- .../awesome-widget/plugin/awformatterhelper.h | 2 +- .../plugin/awscriptformatter.cpp | 151 ++++++++++++++++++ .../awesome-widget/plugin/awscriptformatter.h | 59 +++++++ 4 files changed, 223 insertions(+), 6 deletions(-) create mode 100644 sources/awesome-widget/plugin/awscriptformatter.cpp create mode 100644 sources/awesome-widget/plugin/awscriptformatter.h diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index 633cfc9..aa6cd4f 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -24,6 +24,7 @@ #include "awdatetimeformatter.h" #include "awfloatformatter.h" #include "awnoformatter.h" +#include "awscriptformatter.h" AWFormatterHelper::AWFormatterHelper(QObject *parent) @@ -77,10 +78,12 @@ AWFormatterHelper::defineFormatterClass(const QString name) const settings.endGroup(); FormatterClass formatter = FormatterClass::NoFormat; - if (stringType == QString("Float")) - formatter = FormatterClass::Float; - else if (stringType == QString("DateTime")) + if (stringType == QString("DateTime")) formatter = FormatterClass::DateTime; + else if (stringType == QString("Float")) + formatter = FormatterClass::Float; + else if (stringType == QString("Script")) + formatter = FormatterClass::Script; else qCWarning(LOG_AW) << "Unknown formatter" << stringType; @@ -101,13 +104,17 @@ void AWFormatterHelper::init() << "defined as" << static_cast(formatter); switch (formatter) { + case FormatterClass::DateTime: + m_formatters[key] + = new AWDateTimeFormatter(this, m_genericConfig, name); + break; case FormatterClass::Float: m_formatters[key] = new AWFloatFormatter(this, m_genericConfig, name); break; - case FormatterClass::DateTime: + case FormatterClass::Script: m_formatters[key] - = new AWDateTimeFormatter(this, m_genericConfig, name); + = new AWScriptFormatter(this, m_genericConfig, name); break; case FormatterClass::NoFormat: m_formatters[key] = new AWNoFormatter(this, m_genericConfig, name); diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h index c4012b6..784f5f9 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.h +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -29,7 +29,7 @@ class AWFormatterHelper : public QObject Q_OBJECT public: - enum class FormatterClass { Float, DateTime, NoFormat }; + enum class FormatterClass { DateTime, Float, Script, NoFormat }; explicit AWFormatterHelper(QObject *parent = nullptr); virtual ~AWFormatterHelper(); diff --git a/sources/awesome-widget/plugin/awscriptformatter.cpp b/sources/awesome-widget/plugin/awscriptformatter.cpp new file mode 100644 index 0000000..0f056d2 --- /dev/null +++ b/sources/awesome-widget/plugin/awscriptformatter.cpp @@ -0,0 +1,151 @@ +/*************************************************************************** + * 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 "awscriptformatter.h" + +#include +#include + +#include "awdebug.h" + + +AWScriptFormatter::AWScriptFormatter(QObject *parent, const QString filename, + const QString section) + : AWAbstractFormatter(parent, filename, section) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + init(filename, section); + initProgram(); +} + + +AWScriptFormatter::AWScriptFormatter(QObject *parent, const bool appendCode, + const QString code, const bool hasReturn) + : AWAbstractFormatter(parent) +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + + setAppendCode(appendCode); + setCode(code); + setHasReturn(hasReturn); + initProgram(); +} + + +AWScriptFormatter::~AWScriptFormatter() +{ + qCDebug(LOG_AW) << __PRETTY_FUNCTION__; +} + + +QString AWScriptFormatter::convert(const QVariant &value) const +{ + qCDebug(LOG_AW) << "Convert value" << value; + + // init engine + QJSEngine engine; + QJSValue fn = engine.evaluate(m_program); + QJSValueList args = QJSValueList() << value.toString(); + QJSValue result = fn.call(args); + + if (result.isError()) { + qCWarning(LOG_AW) << "Uncaught exception at line" + << result.property("lineNumber").toInt() << ":" + << result.toString(); + return QString(); + } else { + return result.toString(); + } +} + + +bool AWScriptFormatter::appendCode() const +{ + return m_appendCode; +} + + +QString AWScriptFormatter::code() const +{ + return m_code; +} + + +bool AWScriptFormatter::hasReturn() const +{ + return m_hasReturn; +} + + +QString AWScriptFormatter::program() const +{ + return m_program; +} + + +void AWScriptFormatter::setAppendCode(const bool _appendCode) +{ + qCDebug(LOG_AW) << "Set append code" << _appendCode; + + m_appendCode = _appendCode; +} + + +void AWScriptFormatter::setCode(const QString _code) +{ + qCDebug(LOG_AW) << "Set code" << _code; + + m_code = _code; +} + + +void AWScriptFormatter::setHasReturn(const bool _hasReturn) +{ + qCDebug(LOG_AW) << "Set has return" << _hasReturn; + + m_hasReturn = _hasReturn; +} + + +void AWScriptFormatter::init(const QString filename, const QString section) +{ + qCDebug(LOG_AW) << "Looking for section" << section << "in" << filename; + + QSettings settings(filename, QSettings::IniFormat); + + settings.beginGroup(section); + setAppendCode(settings.value(QString("AppendCode"), true).toBool()); + setCode(settings.value(QString("Code"), QString()).toString()); + setHasReturn(settings.value(QString("HasReturn"), false).toBool()); + settings.endGroup(); +} + + +void AWScriptFormatter::initProgram() +{ + if (m_appendCode) + m_program + = QString("(function(value) { %1%2 })") + .arg(m_code) + .arg(m_hasReturn ? QString("") : QString("; return output;")); + else + m_program = m_code; + + qCInfo(LOG_AW) << "Create JS engine with code" << m_program; +} diff --git a/sources/awesome-widget/plugin/awscriptformatter.h b/sources/awesome-widget/plugin/awscriptformatter.h new file mode 100644 index 0000000..1749e90 --- /dev/null +++ b/sources/awesome-widget/plugin/awscriptformatter.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * 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 AWSCRIPTFORMATTER_H +#define AWSCRIPTFORMATTER_H + +#include "awabstractformatter.h" + + +class AWScriptFormatter : public AWAbstractFormatter +{ + Q_OBJECT + Q_PROPERTY(bool appendCode READ appendCode WRITE setAppendCode) + Q_PROPERTY(QString code READ code WRITE setCode) + Q_PROPERTY(bool hasReturn READ hasReturn WRITE setHasReturn) + Q_PROPERTY(QString program READ program) + +public: + explicit AWScriptFormatter(QObject *parent, const QString filename, + const QString section); + explicit AWScriptFormatter(QObject *parent, const bool appendCode, + const QString code, const bool hasReturn); + virtual ~AWScriptFormatter(); + QString convert(const QVariant &value) const; + // properties + bool appendCode() const; + QString code() const; + bool hasReturn() const; + QString program() const; + void setAppendCode(const bool _appendCode); + void setCode(const QString _code); + void setHasReturn(const bool _hasReturn); + +private: + void init(const QString filename, const QString section); + void initProgram(); + // properties + bool m_appendCode; + QString m_code; + bool m_hasReturn; + QString m_program; +}; + + +#endif /* AWSCRIPTFORMATTER_H */ From 5ad0c533f08469986ffb7ce831e245a4eb0385c6 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sun, 8 May 2016 00:07:44 +0300 Subject: [PATCH 8/9] prerelease updates * update Ukrainian translation * update patches * merge qt5.3-qtconcurrent-and-qlogging-category.patch into qt5.4-replace-qml-dialogs.patch * update cmake files * update README --- README.md | 3 + ...3-qtconcurrent-and-qlogging-category.patch | 45 --------- ...s-qtconcurrent-and-qloggingcategory.patch} | 45 +++++++++ patches/qt5.5-qstringlist-and-qinfo.patch | 2 +- patches/qt5.6-qversionnumber.patch | 13 +-- patches/total-memory-fix.patch | 37 -------- sources/CMakeLists.txt | 2 +- sources/awdebug.cpp | 10 ++ sources/coverity.cmake | 3 +- sources/translations/uk.po | 95 ++++++------------- sources/version.h.in | 6 ++ 11 files changed, 105 insertions(+), 156 deletions(-) delete mode 100644 patches/qt5.3-qtconcurrent-and-qlogging-category.patch rename patches/{qt5.4-replace-qml-dialogs.patch => qt5.4-qml-dialogs-qtconcurrent-and-qloggingcategory.patch} (87%) delete mode 100644 patches/total-memory-fix.patch diff --git a/README.md b/README.md index 63614c6..242ac79 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ awesome-widgets (ex-pytextmonitor) ================================== +[![Build Status](https://travis-ci.org/arcan1s/awesome-widgets.svg?branch=development)](https://travis-ci.org/arcan1s/awesome-widgets) +[![Coverity Scan Build Status](https://scan.coverity.com/projects/8254/badge.svg)](https://scan.coverity.com/projects/awesome-widgets) + Information ----------- diff --git a/patches/qt5.3-qtconcurrent-and-qlogging-category.patch b/patches/qt5.3-qtconcurrent-and-qlogging-category.patch deleted file mode 100644 index a2e8e7f..0000000 --- a/patches/qt5.3-qtconcurrent-and-qlogging-category.patch +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp -index eee61e1..9da8dad 100644 ---- a/sources/awdebug.cpp -+++ b/sources/awdebug.cpp -@@ -20,13 +20,10 @@ - #include "version.h" - - --Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", -- QtMsgType::QtWarningMsg) --Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", -- QtMsgType::QtWarningMsg) --Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon", QtMsgType::QtWarningMsg) --Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", -- QtMsgType::QtWarningMsg) -+Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget") -+Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel") -+Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon") -+Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets") - - - const QStringList getBuildData() -diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp -index e5b9861..eb73073 100644 ---- a/sources/awesome-widget/plugin/awkeys.cpp -+++ b/sources/awesome-widget/plugin/awkeys.cpp -@@ -439,4 +439,4 @@ void AWKeys::dataUpdated(const QString &sourceName, - - // run concurrent data update -- QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sourceName, -+ QtConcurrent::run(this, &AWKeys::setDataBySource, sourceName, - data); -diff --git a/sources/libraries.cmake b/sources/libraries.cmake -index 33192f7..46e2b1e 100644 ---- a/sources/libraries.cmake -+++ b/sources/libraries.cmake -@@ -2,7 +2,7 @@ - find_package(Gettext REQUIRED) - - # main qt libraries --find_package(Qt5 5.4.0 REQUIRED COMPONENTS Core DBus Network Qml Widgets) -+find_package(Qt5 5.3.0 REQUIRED COMPONENTS Core DBus Network Qml Widgets) - add_definitions( - ${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Network_DEFINITIONS} - ${Qt5Qml_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} diff --git a/patches/qt5.4-replace-qml-dialogs.patch b/patches/qt5.4-qml-dialogs-qtconcurrent-and-qloggingcategory.patch similarity index 87% rename from patches/qt5.4-replace-qml-dialogs.patch rename to patches/qt5.4-qml-dialogs-qtconcurrent-and-qloggingcategory.patch index 8bde1d3..2aa624b 100644 --- a/patches/qt5.4-replace-qml-dialogs.patch +++ b/patches/qt5.4-qml-dialogs-qtconcurrent-and-qloggingcategory.patch @@ -352,3 +352,48 @@ index a8300f1..8edc3bd 100644 // values Q_INVOKABLE QString infoByKey(QString key) const; Q_INVOKABLE QString valueByKey(QString key) const; +diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp +index eee61e1..9da8dad 100644 +--- a/sources/awdebug.cpp ++++ b/sources/awdebug.cpp +@@ -20,13 +20,10 @@ + #include "awdebug.h" + + +-Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", +- QtMsgType::QtWarningMsg) +-Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", +- QtMsgType::QtWarningMsg) +-Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon", QtMsgType::QtWarningMsg) +-Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", +- QtMsgType::QtWarningMsg) ++Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget") ++Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel") ++Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon") ++Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets") + + + const QStringList getBuildData() +diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp +index e5b9861..eb73073 100644 +--- a/sources/awesome-widget/plugin/awkeys.cpp ++++ b/sources/awesome-widget/plugin/awkeys.cpp +@@ -439,4 +439,4 @@ void AWKeys::dataUpdated(const QString &sourceName, + { + // run concurrent data update +- QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sourceName, ++ QtConcurrent::run(this, &AWKeys::setDataBySource, sourceName, + data); +diff --git a/sources/libraries.cmake b/sources/libraries.cmake +index 33192f7..46e2b1e 100644 +--- a/sources/libraries.cmake ++++ b/sources/libraries.cmake +@@ -2,7 +2,7 @@ + find_package(Gettext REQUIRED) + + # main qt libraries +-find_package(Qt5 5.4.0 REQUIRED COMPONENTS Core DBus Network Qml Widgets) ++find_package(Qt5 5.3.0 REQUIRED COMPONENTS Core DBus Network Qml Widgets) + add_definitions( + ${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Network_DEFINITIONS} + ${Qt5Qml_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} diff --git a/patches/qt5.5-qstringlist-and-qinfo.patch b/patches/qt5.5-qstringlist-and-qinfo.patch index ff7845b..d293acb 100644 --- a/patches/qt5.5-qstringlist-and-qinfo.patch +++ b/patches/qt5.5-qstringlist-and-qinfo.patch @@ -16,7 +16,7 @@ index 43944ce..c679281 100644 +++ b/sources/awdebug.h @@ -21,9 +21,13 @@ - #include + #include "version.h" +#ifndef qCInfo +#define qCInfo qCDebug diff --git a/patches/qt5.6-qversionnumber.patch b/patches/qt5.6-qversionnumber.patch index 9f622ba..4ca4d9a 100644 --- a/patches/qt5.6-qversionnumber.patch +++ b/patches/qt5.6-qversionnumber.patch @@ -11,7 +11,7 @@ index 3698602..42871c8 100644 m_genericConfig = QString("%1/awesomewidgets/general.ini") .arg(QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation)); -@@ -69,14 +69,14 @@ void AWUpdateHelper::checkUpdates(const bool showAnyway) +@@ -69,15 +69,15 @@ void AWUpdateHelper::checkUpdates(const bool showAnyway) bool AWUpdateHelper::checkVersion() { QSettings settings(m_genericConfig, QSettings::IniFormat); @@ -22,10 +22,11 @@ index 3698602..42871c8 100644 // update version settings.setValue(QString("Version"), QString(VERSION)); settings.sync(); + qCInfo(LOG_AW) << "Found version" << version << "actual one is" + << m_foundVersion; - qCInfo(LOG_AW) << "Found version" << version << "actual one is" << VERSION; -- if (version != QVersionNumber::fromString(VERSION)) { -+ if (version != QString(VERSION)) { +- if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) { ++ if ((version != QString(VERSION)) && (!QString(CHANGELOG).isEmpty())) { genMessageBox(i18n("Changelog of %1", QString(VERSION)), QString(CHANGELOG).replace(QChar('@'), QChar('\n')), QMessageBox::Ok) @@ -65,12 +66,12 @@ index 3698602..42871c8 100644 @@ -128,8 +127,7 @@ void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *button) switch (ret) { - case QMessageBox::Ok: + case QMessageBox::AcceptRole: - QDesktopServices::openUrl(QString(RELEASES) - + m_foundVersion.toString()); + QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion); break; - case QMessageBox::Cancel: + case QMessageBox::RejectRole: default: @@ -157,14 +155,23 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *reply, QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap(); diff --git a/patches/total-memory-fix.patch b/patches/total-memory-fix.patch deleted file mode 100644 index 60f02f1..0000000 --- a/patches/total-memory-fix.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp -index 7a1887b..9f39e2f 100644 ---- a/sources/awesome-widget/plugin/awkeysaggregator.cpp -+++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp -@@ -34,8 +34,8 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) - // default formaters - // memory - m_formater[QString("mem")] = Float; -- m_formater[QString("memtotmb")] = IntegerFive; -- m_formater[QString("memtotgb")] = Float; -+ m_formater[QString("memtotmb")] = MemMBFormat; -+ m_formater[QString("memtotgb")] = MemGBFormat; - // network - m_formater[QString("down")] = NetSmartFormat; - m_formater[QString("downkb")] = Integer; -@@ -45,8 +45,8 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent) - m_formater[QString("upunits")] = NetSmartUnits; - // swap - m_formater[QString("swap")] = Float; -- m_formater[QString("swaptotmb")] = IntegerFive; -- m_formater[QString("swaptotgb")] = Float; -+ m_formater[QString("swaptotmb")] = MemMBFormat; -+ m_formater[QString("swaptotgb")] = MemGBFormat; - } - - -@@ -338,8 +338,8 @@ QStringList AWKeysAggregator::registerSource(const QString &source, - m_map[source] = key; - m_formater[key] = Float; - // additional keys -- m_formater[QString("hddtotmb%1").arg(index)] = IntegerFive; -- m_formater[QString("hddtotgb%1").arg(index)] = Float; -+ m_formater[QString("hddtotmb%1").arg(index)] = MemMBFormat; -+ m_formater[QString("hddtotgb%1").arg(index)] = MemGBFormat; - } - } else if (source.contains(mountFreeRegExp)) { - // free space diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 5540997..0d23497 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -15,7 +15,7 @@ set(PROJECT_CONTACT "esalexeev@gmail.com") set(PROJECT_LICENSE "GPL3") set(PROJECT_VERSION_MAJOR "3") set(PROJECT_VERSION_MINOR "1") -set(PROJECT_VERSION_PATCH "1") +set(PROJECT_VERSION_PATCH "2") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # append git version if any set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "") diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index d81b355..2b9ccc7 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -45,6 +45,7 @@ const QStringList getBuildData() metadata.append(QString(" AWEUAPI: %1").arg(AWEUAPI)); metadata.append(QString(" AWEWAPI: %1").arg(AWEWAPI)); metadata.append(QString(" TIME_KEYS: %1").arg(TIME_KEYS)); + metadata.append(QString(" STATIC_KEYS: %1").arg(STATIC_KEYS)); // cmake properties metadata.append(QString("cmake properties:")); metadata.append(QString(" CMAKE_BUILD_TYPE: %1").arg(CMAKE_BUILD_TYPE)); @@ -67,6 +68,7 @@ const QStringList getBuildData() .arg(CMAKE_SHARED_LINKER_FLAGS)); // components metadata.append(QString("Components data:")); + metadata.append(QString(" BUILD_COVERAGE: %1").arg(BUILD_COVERAGE)); metadata.append(QString(" BUILD_PLASMOIDS: %1").arg(BUILD_PLASMOIDS)); metadata.append( QString(" BUILD_DEB_PACKAGE: %1").arg(BUILD_DEB_PACKAGE)); @@ -74,8 +76,16 @@ const QStringList getBuildData() QString(" BUILD_RPM_PACKAGE: %1").arg(BUILD_RPM_PACKAGE)); metadata.append( QString(" CLANGFORMAT_EXECUTABLE: %1").arg(CLANGFORMAT_EXECUTABLE)); + metadata.append(QString(" COVERITY_COMMENT: %1").arg(COVERITY_COMMENT)); + metadata.append( + QString(" COVERITY_DIRECTORY: %1").arg(COVERITY_DIRECTORY)); + metadata.append(QString(" COVERITY_EMAIL: %1").arg(COVERITY_EMAIL)); + metadata.append( + QString(" COVERITY_EXECUTABLE: %1").arg(COVERITY_EXECUTABLE)); + metadata.append(QString(" COVERITY_URL: %1").arg(COVERITY_URL)); metadata.append( QString(" CPPCHECK_EXECUTABLE: %1").arg(CPPCHECK_EXECUTABLE)); + // additional functions metadata.append(QString(" PROP_FUTURE: %1").arg(PROP_FUTURE)); metadata.append(QString(" PROP_TEST: %1").arg(PROP_TEST)); diff --git a/sources/coverity.cmake b/sources/coverity.cmake index 137060b..517aac8 100644 --- a/sources/coverity.cmake +++ b/sources/coverity.cmake @@ -5,7 +5,6 @@ set(COVERITY_EMAIL "" CACHE STRING "Coverity user email") set(COVERITY_EXECUTABLE "cov-build" CACHE STRING "Path to coverity build tool") set(COVERITY_TOKEN "" CACHE STRING "Coverity token") set(COVERITY_URL "https://scan.coverity.com/builds?project=Awesome+Widgets" CACHE STRING "Coverity project url") -set(CURL_EXECUTABLE "/usr/bin/curl" CACHE STRING "Path to curl executable") add_custom_target( coverity @@ -19,7 +18,7 @@ add_custom_target( add_custom_target( coverity-upload - COMMAND ${CURL_EXECUTABLE} + COMMAND curl --form token=${COVERITY_TOKEN} --form email=${COVERITY_EMAIL} --form file=@${PROJECT_NAME}.zip diff --git a/sources/translations/uk.po b/sources/translations/uk.po index 0a12193..ce87bfe 100644 --- a/sources/translations/uk.po +++ b/sources/translations/uk.po @@ -7,16 +7,16 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" "POT-Creation-Date: 2016-04-29 12:21+0300\n" -"PO-Revision-Date: 2015-09-27 12:37+0300\n" +"PO-Revision-Date: 2016-05-05 17:18+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Ukrainian \n" -"Language: ua\n" +"Language: uk\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -"X-Generator: Lokalize 2.0\n" +"X-Generator: Poedit 1.8.7.1\n" msgid "Widget" msgstr "Віджет" @@ -42,7 +42,6 @@ msgstr "Подяка" msgid "Enable background" msgstr "Включити фон" -#, fuzzy msgid "Translate strings" msgstr "Перекладати рядки" @@ -55,12 +54,11 @@ msgstr "Включити перенос слів" msgid "Enable notifications" msgstr "Включити повідомлення" -#, fuzzy msgid "Check updates on startup" msgstr "Перевіряти оновлення при запуску" msgid "Optimize subscription" -msgstr "" +msgstr "Оптимізувати підписку" msgid "Widget height, px" msgstr "Висота віджету, пікселі" @@ -113,43 +111,38 @@ msgstr "AC відключений" msgid "Drop key cache" msgstr "Скинути кеш ключів" -#, fuzzy msgid "Export configuration" -msgstr "Налаштування" +msgstr "Експорт налаштувань" msgid "Export" -msgstr "" +msgstr "Експорт" msgid "Success" -msgstr "" +msgstr "Успішно" msgid "Please note that binary files were not copied" -msgstr "" +msgstr "Будь ласка, зверніть увагу, що бінарні файли не були скопійовані" msgid "Ooops..." -msgstr "" +msgstr "Ууупс..." -#, fuzzy msgid "Could not save configuration file" -msgstr "Налаштування" +msgstr "Не можу зберегти файл налаштувань" -#, fuzzy msgid "Import configuration" -msgstr "Налаштування" +msgstr "Імпорт налаштувань" msgid "Import" -msgstr "" +msgstr "Імпорт" msgid "Import plasmoid settings" -msgstr "" +msgstr "Імпорт налаштувань плазмоїда" -#, fuzzy msgid "Import extensions" -msgstr "Розширення" +msgstr "Імпорт розширень" -#, fuzzy msgid "Import additional files" -msgstr "Додаткові фільтри" +msgstr "Імпорт додаткових файлів" msgid "Font" msgstr "Шрифт" @@ -190,9 +183,8 @@ msgstr "Оберіть колір" msgid "Select a font" msgstr "Оберіть шрифт" -#, fuzzy msgid "ACPI" -msgstr "Шлях до ACPI" +msgstr "ACPI" msgid "ACPI path" msgstr "Шлях до ACPI" @@ -203,7 +195,6 @@ msgstr "GPU" msgid "GPU device" msgstr "Пристій GPU" -#, fuzzy msgid "HDD temperature" msgstr "Температура HDD" @@ -255,7 +246,6 @@ msgstr "Редагувати команду" msgid "Weather" msgstr "Погода" -#, fuzzy msgid "Edit weather" msgstr "Редагувати погоду" @@ -280,14 +270,13 @@ msgstr "Показати README" msgid "Check updates" msgstr "Шукати оновлення" -#, fuzzy msgid "" "CPU, CPU clock, memory, swap and network labels support graphical tooltip. " "To enable them just make needed checkbox checked." msgstr "" "Поля \"CPU\", \"Частота CPU\", \"Пам’ять\", \"Swap\" та \"Мережа\" " -"підтримують графічні підказки. Щоб їх задіяти, просто зробіть необхідні " -"чекбокси повністю чекнутими." +"підтримують графічні підказки. Щоб їх задіяти, просто виділіть необхідні " +"чекбокси." msgid "Number of values for tooltips" msgstr "Кількість значень для підказки" @@ -295,7 +284,6 @@ msgstr "Кількість значень для підказки" msgid "Background" msgstr "Фон" -#, fuzzy msgid "Background color" msgstr "Колір фону" @@ -305,7 +293,6 @@ msgstr "CPU" msgid "CPU color" msgstr "Колір CPU" -#, fuzzy msgid "CPU clock" msgstr "Частота CPU" @@ -349,9 +336,8 @@ msgstr "" "Детальна інформація може бути знайдена на домашній сторінці проекту" -#, fuzzy msgid "Bgcolor" -msgstr "Колір CPU" +msgstr "Колір фону" msgid "AC" msgstr "Адаптер живлення" @@ -362,27 +348,23 @@ msgstr "Бари" msgid "Desktops" msgstr "Робочі столи" -#, fuzzy msgid "Scripts" msgstr "Скрипти" -#, fuzzy msgid "Time" msgstr "Час" -#, fuzzy msgid "Quotes" msgstr "Котирування" msgid "Upgrades" msgstr "Оновлення" -#, fuzzy msgid "Weathers" msgstr "Погода" msgid "Functions" -msgstr "" +msgstr "Функції" msgid "Add" msgstr "Додати" @@ -436,7 +418,7 @@ msgid "This software uses: %1" msgstr "Ця програма використовує: %1" msgid "Special thanks to %1" -msgstr "" +msgstr "Особлива подяка %1" msgid "Select font" msgstr "Оберіть шрифт" @@ -469,12 +451,11 @@ msgid "KB/s" msgstr "КБ/с" msgid "Changelog of %1" -msgstr "" +msgstr "Список змін %1" msgid "You are using the actual version %1" msgstr "Ви використовуєте актуальну версію %1" -#, fuzzy msgid "No new version found" msgstr "Оновлень не знайдено" @@ -511,7 +492,6 @@ msgstr "Ім’я: %1" msgid "Comment: %1" msgstr "Коментар: %1" -#, fuzzy msgid "Identity: %1" msgstr "Ідентифікатор: %1" @@ -535,19 +515,15 @@ msgstr "" "style=\" text-decoration: underline; color:#0057ae;\">http://finance.yahoo." "com/

" -#, fuzzy msgid "Ticker" -msgstr "Тікер: %1" +msgstr "Тікер" -#, fuzzy msgid "Active" msgstr "Активний" -#, fuzzy msgid "Interval" msgstr "Інтервал" -#, fuzzy msgid "Command" msgstr "Команда" @@ -560,7 +536,6 @@ msgstr "Перенаправлення" msgid "Additional filters" msgstr "Додаткові фільтри" -#, fuzzy msgid "Wrap colors" msgstr "Обробити кольори" @@ -579,41 +554,35 @@ msgstr "Місто" msgid "Country" msgstr "Країна" -#, fuzzy msgid "Timestamp" msgstr "Відмітка часу" msgid "Use images" msgstr "Використовувати зображення" -#, fuzzy msgid "Use custom formula" -msgstr "Свій формат часу" +msgstr "Використовувати свою формулу" msgid "Value" msgstr "Значення" -#, fuzzy msgid "Max value" -msgstr "Показати значення" +msgstr "Максимальне значення" -#, fuzzy msgid "Min value" -msgstr "Показати значення" +msgstr "Мінімальне значення" -#, fuzzy msgid "Active filling type" -msgstr "Активний" +msgstr "Тип активного заповнення" -#, fuzzy msgid "Inctive filling type" -msgstr "Неактивний робочий стіл" +msgstr "Тип неактивного заповнення" msgid "Type" msgstr "Тип" msgid "Points count" -msgstr "" +msgstr "Кількість точок" msgid "Direction" msgstr "Напрямок" @@ -624,13 +593,11 @@ msgstr "Висота" msgid "Width" msgstr "Ширина" -#, fuzzy msgid "color" -msgstr "Колір CPU" +msgstr "колір" -#, fuzzy msgid "image" -msgstr "Використовувати зображення" +msgstr "зображення" msgid "Active desktop" msgstr "Активний робочий стіл" diff --git a/sources/version.h.in b/sources/version.h.in index 9ba98f3..eed78e8 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -78,10 +78,16 @@ #define CMAKE_MODULE_LINKER_FLAGS "@CMAKE_MODULE_LINKER_FLAGS@" #define CMAKE_SHARED_LINKER_FLAGS "@CMAKE_SHARED_LINKER_FLAGS@" // components +#define BUILD_COVERAGE "@BUILD_COVERAGE@" #define BUILD_PLASMOIDS "@BUILD_PLASMOIDS@" #define BUILD_DEB_PACKAGE "@BUILD_DEB_PACKAGE@" #define BUILD_RPM_PACKAGE "@BUILD_RPM_PACKAGE@" #define CLANGFORMAT_EXECUTABLE "@CLANGFORMAT_EXECUTABLE@" +#define COVERITY_COMMENT "@COVERITY_COMMENT@" +#define COVERITY_DIRECTORY "@COVERITY_DIRECTORY@" +#define COVERITY_EMAIL "@COVERITY_EMAIL@" +#define COVERITY_EXECUTABLE "@COVERITY_EXECUTABLE@" +#define COVERITY_URL "@COVERITY_URL@" #define CPPCHECK_EXECUTABLE "@CPPCHECK_EXECUTABLE@" // additional functions #define PROP_FUTURE "@BUILD_FUTURE@" From 4bcdb3a7ff9159e64b54fde8c3d92655281c7b9e Mon Sep 17 00:00:00 2001 From: arcan1s Date: Mon, 9 May 2016 00:12:06 +0300 Subject: [PATCH 9/9] release 3.1.2 --- CHANGELOG | 22 +++++++++++++++++++ packages/PKGBUILD | 4 ++-- .../awesome-widget/package/metadata.desktop | 2 +- .../desktop-panel/package/metadata.desktop | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9a88633..1146b1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,25 @@ +Ver.3.1.2: ++ add standalone widget configuration example ++ new tag tstime ++ new tags uptotal* and downtotal* ++ add background configuration button ++ allow X-AW-Direction property works with graphs and bars (graphical items) ++ add bars support to Graphical Items ++ add integration with transifex ++ add integration with coverity +- drop update source (breaking changes if you are using it as developer) +- fix pen generation from file image (graphical items) +- fix bug with which font html parameters will be pasted even if there cancel clicked +- fix bug with invalid total memory formating +- fix bug in configuration UI with which there is no selected text pasted +- fixes in graphical item configuration UI and behaviour +- fix changelog building +- fix invalid cast (found by coverity) +* change text update mechanism +* grahical item improvements +* code improvements +* translation update + Ver.3.1.1: - fix broken gcc build (#87) * translation update diff --git a/packages/PKGBUILD b/packages/PKGBUILD index 5e797d4..fcd3b80 100644 --- a/packages/PKGBUILD +++ b/packages/PKGBUILD @@ -2,7 +2,7 @@ pkgname=plasma5-applet-awesome-widgets _pkgname=awesome-widgets -pkgver=3.1.1 +pkgver=3.1.2 pkgrel=1 pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)" arch=('i686' 'x86_64') @@ -17,7 +17,7 @@ optdepends=("catalyst: for GPU monitor" makedepends=('cmake' 'extra-cmake-modules' 'python') source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz) install=${pkgname}.install -md5sums=('1a4dc1d912b663dfd24d00712ab68f07') +md5sums=('99514bf6d1a5ca8660dd0210ee58af28') backup=('etc/xdg/plasma-dataengine-extsysmon.conf') prepare() { diff --git a/sources/awesome-widget/package/metadata.desktop b/sources/awesome-widget/package/metadata.desktop index d749b63..f65da37 100644 --- a/sources/awesome-widget/package/metadata.desktop +++ b/sources/awesome-widget/package/metadata.desktop @@ -20,7 +20,7 @@ X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget -X-KDE-PluginInfo-Version=3.1.1 +X-KDE-PluginInfo-Version=3.1.2 X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= diff --git a/sources/desktop-panel/package/metadata.desktop b/sources/desktop-panel/package/metadata.desktop index ce1adc0..93a7731 100644 --- a/sources/desktop-panel/package/metadata.desktop +++ b/sources/desktop-panel/package/metadata.desktop @@ -20,7 +20,7 @@ X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel -X-KDE-PluginInfo-Version=3.1.1 +X-KDE-PluginInfo-Version=3.1.2 X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends=