From 4a0da3f978195fb816291100a06a62a3b9772289 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Wed, 22 Jun 2016 01:04:57 +0300 Subject: [PATCH 01/14] add dpplugin tests --- sources/test/CMakeLists.txt | 12 ++++- sources/test/testdpplugin.cpp | 94 +++++++++++++++++++++++++++++++++++ sources/test/testdpplugin.h | 47 ++++++++++++++++++ 3 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 sources/test/testdpplugin.cpp create mode 100644 sources/test/testdpplugin.h diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index 493b378..ba199a9 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -8,6 +8,8 @@ include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/ ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_MONITORSOURCES}/ + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/ + ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/ ${PROJECT_TRDPARTY_DIR} ${Qt_INCLUDE} ${Qt5Test_INCLUDE_DIRS} @@ -19,17 +21,23 @@ set(AWTESTLIBRARY_HEADERS awtestlibrary.h) set(AWTESTLIBRARY_SOURCES awtestlibrary.cpp) add_library(${SUBPROJECT}-awtest STATIC ${AWTESTLIBRARY_SOURCES} ${AWTESTLIBRARY_HEADERS}) target_link_libraries(${SUBPROJECT}-awtest ${Qt_LIBRARIES} ${Qt5Test_LIBRARIES}) -set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSOURCES} ${Qt_LIBRARIES} ${Qt5Test_LIBRARIES}) +set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSOURCES} + ${Qt_LIBRARIES} ${Kf5_LIBRARIES} ${Qt5Test_LIBRARIES}) ## modules set(TEST_MODULES abstractextitem extquotes extscript extupgrade extweather abstractformatter datetimeformatter floatformatter noformatter scriptformatter extitemaggregator - batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource) + batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource + dpplugin) foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) set(${TEST_MODULE}_SOURCES test${TEST_MODULE}.cpp) + if (TEST_MODULE MATCHES "dpplugin") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp + ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) + endif(TEST_MODULE MATCHES "dpplugin") add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES}) target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET}) add_test(NAME ${TEST_MODULE} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-${TEST_MODULE}) diff --git a/sources/test/testdpplugin.cpp b/sources/test/testdpplugin.cpp new file mode 100644 index 0000000..9a4e166 --- /dev/null +++ b/sources/test/testdpplugin.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testdpplugin.h" + +#include +#include + +#include "awtestlibrary.h" +#include "dpadds.h" + + +void TestDPPlugin::initTestCase() +{ + plugin = new DPAdds(this); +} + + +void TestDPPlugin::cleanupTestCase() +{ + delete plugin; +} + + +void TestDPPlugin::test_desktops() +{ + int current = plugin->currentDesktop(); + int total = plugin->numberOfDesktops(); + QVERIFY(total != 0); + QVERIFY(current < total); + + int number; + if (total == 1) + number = current; + else + number = current == (total - 1) ? current - 1 : current + 1; + QSignalSpy spy(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int))); + plugin->setCurrentDesktop(number); + QVERIFY(spy.wait(5000)); + QCOMPARE(plugin->currentDesktop(), number); + + plugin->setCurrentDesktop(current); + QVERIFY(spy.wait(5000)); + QCOMPARE(plugin->currentDesktop(), current); +} + + +void TestDPPlugin::test_dictKeys() +{ + QCOMPARE(plugin->dictKeys().count(), 4); + pattern += plugin->dictKeys().join(QString(" $")); +} + + +void TestDPPlugin::test_parsePattern() +{ + QString result = plugin->parsePattern(pattern, plugin->currentDesktop()); + QVERIFY(!result.isEmpty()); + QVERIFY(result != pattern); + for (auto key : plugin->dictKeys()) + QVERIFY(!result.contains(key)); +} + + +void TestDPPlugin::test_tooltipImage() +{ + QVariantMap data; + data[QString("tooltipColor")] = QString("#000000"); + data[QString("tooltipType")] = QString("windows"); + data[QString("tooltipWidth")] = 300; + plugin->setToolTipData(data); + + QString image = plugin->toolTipImage(plugin->currentDesktop()); + QVERIFY(image.startsWith(QString(""))); +} + + +QTEST_MAIN(TestDPPlugin); diff --git a/sources/test/testdpplugin.h b/sources/test/testdpplugin.h new file mode 100644 index 0000000..71d89d6 --- /dev/null +++ b/sources/test/testdpplugin.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTDPPLUGIN_H +#define TESTDPPLUGIN_H + +#include + + +class DPAdds; + +class TestDPPlugin : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_desktops(); + void test_dictKeys(); + void test_tooltipImage(); + void test_parsePattern(); + +private: + DPAdds *plugin = nullptr; + QString pattern = QString("$"); +}; + + +#endif /* TESTDPPLUGIN_H */ From f6a6704fd24a5d101fba1ff3904c025e3e8e53ac Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 23 Jun 2016 10:56:55 +0300 Subject: [PATCH 02/14] add test for awupdatehelper and template for awkeycache --- sources/test/CMakeLists.txt | 5 ++++ sources/test/testawkeycache.cpp | 37 ++++++++++++++++++++++++ sources/test/testawkeycache.h | 39 +++++++++++++++++++++++++ sources/test/testawupdatehelper.cpp | 45 +++++++++++++++++++++++++++++ sources/test/testawupdatehelper.h | 43 +++++++++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 sources/test/testawkeycache.cpp create mode 100644 sources/test/testawkeycache.h create mode 100644 sources/test/testawupdatehelper.cpp create mode 100644 sources/test/testawupdatehelper.h diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index ba199a9..e3febbb 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -30,6 +30,7 @@ set(TEST_MODULES abstractformatter datetimeformatter floatformatter noformatter scriptformatter extitemaggregator batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource + awkeycache awupdatehelper dpplugin) foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) @@ -37,6 +38,10 @@ foreach (TEST_MODULE ${TEST_MODULES}) if (TEST_MODULE MATCHES "dpplugin") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) + elseif(TEST_MODULE MATCHES "awkeycache") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp) + elseif(TEST_MODULE MATCHES "awupdatehelper") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp) endif(TEST_MODULE MATCHES "dpplugin") add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES}) target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET}) diff --git a/sources/test/testawkeycache.cpp b/sources/test/testawkeycache.cpp new file mode 100644 index 0000000..08979f6 --- /dev/null +++ b/sources/test/testawkeycache.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testawkeycache.h" + +#include + +#include "awtestlibrary.h" +#include "awkeycache.h" + + +void TestAWKeyCache::initTestCase() +{ +} + + +void TestAWKeyCache::cleanupTestCase() +{ +} + + +QTEST_MAIN(TestAWKeyCache); diff --git a/sources/test/testawkeycache.h b/sources/test/testawkeycache.h new file mode 100644 index 0000000..ec2ca37 --- /dev/null +++ b/sources/test/testawkeycache.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTAWKEYCACHE_H +#define TESTAWKEYCACHE_H + +#include + + +class TestAWKeyCache : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + +private: +}; + + +#endif /* TESTAWKEYCACHE_H */ diff --git a/sources/test/testawupdatehelper.cpp b/sources/test/testawupdatehelper.cpp new file mode 100644 index 0000000..4b96b56 --- /dev/null +++ b/sources/test/testawupdatehelper.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testawupdatehelper.h" + +#include + +#include "awtestlibrary.h" +#include "awupdatehelper.h" + + +void TestAWUpdateHelper::initTestCase() +{ + plugin = new AWUpdateHelper(this); +} + + +void TestAWUpdateHelper::cleanupTestCase() +{ + delete plugin; +} + + +void TestAWUpdateHelper::test_checkVersion() +{ + QVERIFY(!plugin->checkVersion()); +} + + +QTEST_MAIN(TestAWUpdateHelper); diff --git a/sources/test/testawupdatehelper.h b/sources/test/testawupdatehelper.h new file mode 100644 index 0000000..03db776 --- /dev/null +++ b/sources/test/testawupdatehelper.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTAWUPDATEHELPER_H +#define TESTAWUPDATEHELPER_H + +#include + + +class AWUpdateHelper; + +class TestAWUpdateHelper : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_checkVersion(); + +private: + AWUpdateHelper *plugin = nullptr; +}; + + +#endif /* TESTAWUPDATEHELPER_H */ From faf259e339334d3af427287af825abe205e5cf51 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 25 Jun 2016 03:11:21 +0300 Subject: [PATCH 03/14] add tests for pattern functions some simplifications --- sources/awesome-widget/plugin/awkeys.cpp | 10 +- .../plugin/awpatternfunctions.cpp | 93 +++++---------- .../plugin/awpatternfunctions.h | 12 +- sources/test/CMakeLists.txt | 12 +- sources/test/testawkeycache.cpp | 2 +- sources/test/testawpatternfunctions.cpp | 112 ++++++++++++++++++ sources/test/testawpatternfunctions.h | 43 +++++++ 7 files changed, 207 insertions(+), 77 deletions(-) create mode 100644 sources/test/testawpatternfunctions.cpp create mode 100644 sources/test/testawpatternfunctions.h diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index f483209..cfb9c7b 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -204,10 +204,10 @@ void AWKeys::reinitKeys(const QStringList currentKeys) qCDebug(LOG_AW) << "Update found keys by using list" << currentKeys; // append lists - m_foundBars - = AWPatternFunctions::findBars(keyOperator->pattern(), currentKeys); - m_foundKeys - = AWPatternFunctions::findKeys(keyOperator->pattern(), currentKeys); + m_foundBars = AWPatternFunctions::findKeys(keyOperator->pattern(), + currentKeys, true); + m_foundKeys = AWPatternFunctions::findKeys(keyOperator->pattern(), + currentKeys, false); m_foundLambdas = AWPatternFunctions::findLambdas(keyOperator->pattern()); // generate list of required keys for bars QStringList barKeys; @@ -215,7 +215,7 @@ void AWKeys::reinitKeys(const QStringList currentKeys) GraphicalItem *item = keyOperator->giByKey(bar); if (item->isCustom()) item->setUsedKeys( - AWPatternFunctions::findKeys(item->bar(), currentKeys)); + AWPatternFunctions::findKeys(item->bar(), currentKeys, false)); else item->setUsedKeys(QStringList() << item->bar()); barKeys.append(item->usedKeys()); diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index 07a0d6c..1b1950f 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -86,8 +86,9 @@ QString AWPatternFunctions::expandTemplates(QString code) } -QVariantList AWPatternFunctions::findFunctionCalls(const QString function, - const QString code) +QList +AWPatternFunctions::findFunctionCalls(const QString function, + const QString code) { qCDebug(LOG_AW) << "Looking for function" << function << "in" << code; @@ -102,16 +103,16 @@ QVariantList AWPatternFunctions::findFunctionCalls(const QString function, .arg(function)); regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); - QVariantList foundFunctions; + QList foundFunctions; QRegularExpressionMatchIterator it = regex.globalMatch(code); while (it.hasNext()) { QRegularExpressionMatch match = it.next(); - QVariantHash metadata; + AWPatternFunctions::AWFunction metadata; // work with args QString argsString = match.captured(QString("args")); if (argsString.isEmpty()) { - metadata[QString("args")] = QStringList(); + metadata.args = QStringList(); } else { // replace '$,' to 0x1d argsString.replace(QString("$,"), QString(0x1d)); @@ -119,11 +120,11 @@ QVariantList AWPatternFunctions::findFunctionCalls(const QString function, std::for_each(args.begin(), args.end(), [](QString &arg) { arg.replace(QString(0x1d), QString(",")); }); - metadata[QString("args")] = args; + metadata.args = args; } // other variables - metadata[QString("body")] = match.captured(QString("body")); - metadata[QString("what")] = match.captured(); + metadata.body = match.captured(QString("body")); + metadata.what = match.captured(); foundFunctions.append(metadata); } @@ -136,22 +137,17 @@ QString AWPatternFunctions::insertAllKeys(QString code, const QStringList keys) qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list" << keys; - QVariantList found + QList found = AWPatternFunctions::findFunctionCalls(QString("aw_all"), code); for (auto function : found) { - QVariantHash metadata = function.toHash(); QString separator - = metadata[QString("args")].toStringList().isEmpty() - ? QString(",") - : metadata[QString("args")].toStringList().at(0); - QStringList required - = keys.filter(QRegExp(metadata[QString("body")].toString())); + = function.args.isEmpty() ? QString(",") : function.args.at(0); + QStringList required = keys.filter(QRegExp(function.body)); std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("%1: $%1").arg(value); }); - code.replace(metadata[QString("what")].toString(), - required.join(separator)); + code.replace(function.what, required.join(separator)); } return code; @@ -163,15 +159,12 @@ QString AWPatternFunctions::insertKeyCount(QString code, const QStringList keys) qCDebug(LOG_AW) << "Looking for count in code" << code << "using list" << keys; - QVariantList found + QList found = AWPatternFunctions::findFunctionCalls(QString("aw_count"), code); for (auto function : found) { - QVariantHash metadata = function.toHash(); - int count = keys.filter(QRegExp(metadata[QString("body")].toString())) - .count(); + int count = keys.filter(QRegExp(function.body)).count(); - code.replace(metadata[QString("what")].toString(), - QString::number(count)); + code.replace(function.what, QString::number(count)); } return code; @@ -183,19 +176,14 @@ QString AWPatternFunctions::insertKeyNames(QString code, const QStringList keys) qCDebug(LOG_AW) << "Looking for key names in code" << code << "using list" << keys; - QVariantList found + QList found = AWPatternFunctions::findFunctionCalls(QString("aw_names"), code); for (auto function : found) { - QVariantHash metadata = function.toHash(); QString separator - = metadata[QString("args")].toStringList().isEmpty() - ? QString(",") - : metadata[QString("args")].toStringList().at(0); - QStringList required - = keys.filter(QRegExp(metadata[QString("body")].toString())); + = function.args.isEmpty() ? QString(",") : function.args.at(0); + QStringList required = keys.filter(QRegExp(function.body)); - code.replace(metadata[QString("what")].toString(), - required.join(separator)); + code.replace(function.what, required.join(separator)); } return code; @@ -207,59 +195,36 @@ QString AWPatternFunctions::insertKeys(QString code, const QStringList keys) qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list" << keys; - QVariantList found + QList found = AWPatternFunctions::findFunctionCalls(QString("aw_keys"), code); for (auto function : found) { - QVariantHash metadata = function.toHash(); QString separator - = metadata[QString("args")].toStringList().isEmpty() - ? QString(",") - : metadata[QString("args")].toStringList().at(0); - QStringList required - = keys.filter(QRegExp(metadata[QString("body")].toString())); + = function.args.isEmpty() ? QString(",") : function.args.at(0); + QStringList required = keys.filter(QRegExp(function.body)); std::for_each(required.begin(), required.end(), [](QString &value) { value = QString("$%1").arg(value); }); - code.replace(metadata[QString("what")].toString(), - required.join(separator)); + code.replace(function.what, required.join(separator)); } return code; } -QStringList AWPatternFunctions::findBars(const QString code, - const QStringList keys) -{ - qCDebug(LOG_AW) << "Looking for bars in code" << code << "using list" - << keys; - - QStringList selectedKeys; - for (auto key : keys) - if ((key.startsWith(QString("bar"))) - && (code.contains(QString("$%1").arg(key)))) { - qCInfo(LOG_AW) << "Found bar" << key; - selectedKeys.append(key); - } - if (selectedKeys.isEmpty()) - qCWarning(LOG_AW) << "No bars found"; - - return selectedKeys; -} - - QStringList AWPatternFunctions::findKeys(const QString code, - const QStringList keys) + const QStringList keys, + const bool isBars) { qCDebug(LOG_AW) << "Looking for keys in code" << code << "using list" << keys; QStringList selectedKeys; for (auto key : keys) - if ((!key.startsWith(QString("bar"))) + if ((key.startsWith(QString("bar")) == isBars) && (code.contains(QString("$%1").arg(key)))) { - qCInfo(LOG_AW) << "Found key" << key; + qCInfo(LOG_AW) << "Found key" << key << "with bar enabled" + << isBars; selectedKeys.append(key); } if (selectedKeys.isEmpty()) diff --git a/sources/awesome-widget/plugin/awpatternfunctions.h b/sources/awesome-widget/plugin/awpatternfunctions.h index 1c8cc3c..01575dd 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.h +++ b/sources/awesome-widget/plugin/awpatternfunctions.h @@ -27,19 +27,25 @@ class AWKeysAggregator; namespace AWPatternFunctions { +typedef struct { + QStringList args; + QString body; + QString what; +} AWFunction; + // insert methods QString expandLambdas(QString code, AWKeysAggregator *aggregator, const QVariantHash &metadata, const QStringList &usedKeys); QString expandTemplates(QString code); -QVariantList findFunctionCalls(const QString function, const QString code); +QList findFunctionCalls(const QString function, const QString code); QString insertAllKeys(QString code, const QStringList keys); QString insertKeyCount(QString code, const QStringList keys); QString insertKeyNames(QString code, const QStringList keys); QString insertKeys(QString code, const QStringList keys); // find methods -QStringList findBars(const QString code, const QStringList keys); -QStringList findKeys(const QString code, const QStringList keys); +QStringList findKeys(const QString code, const QStringList keys, + const bool isBars); QStringList findLambdas(const QString code); }; diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index e3febbb..79b1006 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -30,7 +30,7 @@ set(TEST_MODULES abstractformatter datetimeformatter floatformatter noformatter scriptformatter extitemaggregator batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource - awkeycache awupdatehelper + awkeycache awpatternfunctions awupdatehelper dpplugin) foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) @@ -38,11 +38,15 @@ foreach (TEST_MODULE ${TEST_MODULES}) if (TEST_MODULE MATCHES "dpplugin") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) - elseif(TEST_MODULE MATCHES "awkeycache") + elseif (TEST_MODULE MATCHES "awkeycache") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp) - elseif(TEST_MODULE MATCHES "awupdatehelper") + elseif (TEST_MODULE MATCHES "awpatternfunctions") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp) + elseif (TEST_MODULE MATCHES "awupdatehelper") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp) - endif(TEST_MODULE MATCHES "dpplugin") + endif (TEST_MODULE MATCHES "dpplugin") add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES}) target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET}) add_test(NAME ${TEST_MODULE} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-${TEST_MODULE}) diff --git a/sources/test/testawkeycache.cpp b/sources/test/testawkeycache.cpp index 08979f6..df8ac05 100644 --- a/sources/test/testawkeycache.cpp +++ b/sources/test/testawkeycache.cpp @@ -20,8 +20,8 @@ #include -#include "awtestlibrary.h" #include "awkeycache.h" +#include "awtestlibrary.h" void TestAWKeyCache::initTestCase() diff --git a/sources/test/testawpatternfunctions.cpp b/sources/test/testawpatternfunctions.cpp new file mode 100644 index 0000000..7e6a0d6 --- /dev/null +++ b/sources/test/testawpatternfunctions.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testawpatternfunctions.h" + +#include + +#include "awpatternfunctions.h" +#include "awtestlibrary.h" + + +void TestAWPatternFunctions::initTestCase() +{ +} + + +void TestAWPatternFunctions::cleanupTestCase() +{ +} + + +void TestAWPatternFunctions::test_findFunctionCalls() +{ + QString name = QString("aw_%1").arg(AWTestLibrary::randomString(10)); + QString code = AWTestLibrary::randomString(20); + QStringList args = AWTestLibrary::randomStringList(20); + QString function = QString("$%1<%2>{{%3}}") + .arg(name) + .arg(args.join(QChar(','))) + .arg(code); + + QString pattern = AWTestLibrary::randomString() + function + + AWTestLibrary::randomString(); + + QList found + = AWPatternFunctions::findFunctionCalls(name, pattern); + QCOMPARE(found.count(), 1); + + QCOMPARE(found.at(0).args, args); + QCOMPARE(found.at(0).body, code); + QCOMPARE(found.at(0).what, function); +} + + +void TestAWPatternFunctions::test_findKeys() +{ + QStringList keys = AWTestLibrary::randomStringList(20); + QStringList bars = AWTestLibrary::randomStringList(20); + std::for_each(bars.begin(), bars.end(), + [](QString &bar) { bar.prepend(QString("bar")); }); + QStringList noise = AWTestLibrary::randomStringList(200); + QStringList allKeys = keys + bars + noise; + QString pattern = QString("$%1 $%2") + .arg(keys.join(QString(" $"))) + .arg(bars.join(QString(" $"))); + + keys.sort(); + bars.sort(); + QStringList foundKeys + = AWPatternFunctions::findKeys(pattern, allKeys, false); + foundKeys.sort(); + QStringList foundBars + = AWPatternFunctions::findKeys(pattern, allKeys, true); + foundBars.sort(); + + QCOMPARE(foundKeys, keys); + QCOMPARE(foundBars, bars); +} + + +void TestAWPatternFunctions::test_findLambdas() +{ + QStringList lambdas = AWTestLibrary::randomStringList(20); + QString pattern = AWTestLibrary::randomString() + + QString("${{%1}}").arg(lambdas.join(QString("}}${{"))) + + AWTestLibrary::randomString(); + + QCOMPARE(AWPatternFunctions::findLambdas(pattern), lambdas); +} + + +void TestAWPatternFunctions::test_expandTemplates() +{ + int firstValue = AWTestLibrary::randomInt(); + int secondValue = AWTestLibrary::randomInt(); + int result = firstValue + secondValue; + QString code + = QString("$template{{%1+%2}}").arg(firstValue).arg(secondValue); + QString prefix = AWTestLibrary::randomString(); + QString pattern = prefix + code; + + QCOMPARE(AWPatternFunctions::expandTemplates(pattern), + QString("%1%2").arg(prefix).arg(result)); +} + + +QTEST_MAIN(TestAWPatternFunctions); diff --git a/sources/test/testawpatternfunctions.h b/sources/test/testawpatternfunctions.h new file mode 100644 index 0000000..d0c09b5 --- /dev/null +++ b/sources/test/testawpatternfunctions.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTAWPATTERNFUNCTIONS_H +#define TESTAWPATTERNFUNCTIONS_H + +#include + + +class TestAWPatternFunctions : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_findFunctionCalls(); + void test_findKeys(); + void test_findLambdas(); + void test_expandTemplates(); + +private: +}; + + +#endif /* TESTAWPATTERNFUNCTIONS_H */ From bf16e72e1e3042bf304cc643383fdffcaa81f2e1 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 26 Jun 2016 01:52:15 +0300 Subject: [PATCH 04/14] add configuration tests --- .../awesome-widget/plugin/awconfighelper.cpp | 6 +- .../awesome-widget/plugin/awconfighelper.h | 3 +- sources/test/CMakeLists.txt | 12 ++-- sources/test/testawconfighelper.cpp | 67 +++++++++++++++++++ sources/test/testawconfighelper.h | 49 ++++++++++++++ 5 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 sources/test/testawconfighelper.cpp create mode 100644 sources/test/testawconfighelper.h diff --git a/sources/awesome-widget/plugin/awconfighelper.cpp b/sources/awesome-widget/plugin/awconfighelper.cpp index 4bb06c7..613a2a1 100644 --- a/sources/awesome-widget/plugin/awconfighelper.cpp +++ b/sources/awesome-widget/plugin/awconfighelper.cpp @@ -69,7 +69,7 @@ bool AWConfigHelper::dropCache() const } -bool AWConfigHelper::exportConfiguration(QObject *nativeConfig, +bool AWConfigHelper::exportConfiguration(const QObject *nativeConfig, const QString fileName) const { qCDebug(LOG_AW) << "Selected filename" << fileName; @@ -77,8 +77,8 @@ bool AWConfigHelper::exportConfiguration(QObject *nativeConfig, QSettings settings(fileName, QSettings::IniFormat); // plasmoid configuration - QQmlPropertyMap *configuration - = static_cast(nativeConfig); + const QQmlPropertyMap *configuration + = static_cast(nativeConfig); settings.beginGroup(QString("plasmoid")); for (auto key : configuration->keys()) { QVariant value = configuration->value(key); diff --git a/sources/awesome-widget/plugin/awconfighelper.h b/sources/awesome-widget/plugin/awconfighelper.h index fdca421..c70373b 100644 --- a/sources/awesome-widget/plugin/awconfighelper.h +++ b/sources/awesome-widget/plugin/awconfighelper.h @@ -21,6 +21,7 @@ #include #include +#include class QSettings; @@ -34,7 +35,7 @@ public: virtual ~AWConfigHelper(); Q_INVOKABLE QString configurationDirectory() const; Q_INVOKABLE bool dropCache() const; - Q_INVOKABLE bool exportConfiguration(QObject *nativeConfig, + Q_INVOKABLE bool exportConfiguration(const QObject *nativeConfig, const QString fileName) const; Q_INVOKABLE QVariantMap importConfiguration(const QString fileName, const bool importPlasmoid, diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index 79b1006..a21acad 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -30,14 +30,13 @@ set(TEST_MODULES abstractformatter datetimeformatter floatformatter noformatter scriptformatter extitemaggregator batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource - awkeycache awpatternfunctions awupdatehelper + awconfighelper awkeycache awpatternfunctions awupdatehelper dpplugin) foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) set(${TEST_MODULE}_SOURCES test${TEST_MODULE}.cpp) - if (TEST_MODULE MATCHES "dpplugin") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp - ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) + if (TEST_MODULE MATCHES "awconfighelper") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awconfighelper.cpp) elseif (TEST_MODULE MATCHES "awkeycache") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp) elseif (TEST_MODULE MATCHES "awpatternfunctions") @@ -46,7 +45,10 @@ foreach (TEST_MODULE ${TEST_MODULES}) ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp) elseif (TEST_MODULE MATCHES "awupdatehelper") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp) - endif (TEST_MODULE MATCHES "dpplugin") + elseif (TEST_MODULE MATCHES "dpplugin") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp + ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) + endif (TEST_MODULE MATCHES "awconfighelper") add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES}) target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET}) add_test(NAME ${TEST_MODULE} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-${TEST_MODULE}) diff --git a/sources/test/testawconfighelper.cpp b/sources/test/testawconfighelper.cpp new file mode 100644 index 0000000..7ccffda --- /dev/null +++ b/sources/test/testawconfighelper.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testawconfighelper.h" + +#include + +#include "awtestlibrary.h" +#include "awconfighelper.h" + + +void TestAWConfigHelper::initTestCase() +{ + plugin = new AWConfigHelper(this); +} + + +void TestAWConfigHelper::cleanupTestCase() +{ + delete plugin; +} + + +void TestAWConfigHelper::test_configurationDirectory() +{ + QVERIFY(!plugin->configurationDirectory().isEmpty()); +} + + +void TestAWConfigHelper::test_exportConfiguration() +{ + QStringList keys = AWTestLibrary::randomStringList(); + for (auto key : keys) + map[key] = AWTestLibrary::randomString(); + filename = AWTestLibrary::randomFilenames().first; + + QVERIFY(plugin->exportConfiguration(&map, filename)); +} + + +void TestAWConfigHelper::test_importConfiguration() +{ + QVariantMap imported = plugin->importConfiguration(filename, true, true, true); + QVariantMap converted; + for (auto key : map.keys()) + converted[key] = map.value(key); + + QCOMPARE(imported, converted); +} + + +QTEST_MAIN(TestAWConfigHelper); diff --git a/sources/test/testawconfighelper.h b/sources/test/testawconfighelper.h new file mode 100644 index 0000000..4f6dfdd --- /dev/null +++ b/sources/test/testawconfighelper.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 TESTAWCONFIGHELPER_H +#define TESTAWCONFIGHELPER_H + +#include +#include + + +class AWConfigHelper; +class QQmlPropertyMap; + +class TestAWConfigHelper : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_configurationDirectory(); + void test_exportConfiguration(); + void test_importConfiguration(); + +private: + AWConfigHelper *plugin = nullptr; + QString filename; + QQmlPropertyMap map; +}; + + +#endif /* TESTAWCONFIGHELPER_H */ From bee8e2f180d9f26f7e8260f7a3dde0016ded81fb Mon Sep 17 00:00:00 2001 From: arcan1s Date: Mon, 27 Jun 2016 16:58:45 +0300 Subject: [PATCH 05/14] add more tests for confighelper --- sources/test/testawconfighelper.cpp | 14 ++++++++++++++ sources/test/testawconfighelper.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/sources/test/testawconfighelper.cpp b/sources/test/testawconfighelper.cpp index 7ccffda..0f7c3a7 100644 --- a/sources/test/testawconfighelper.cpp +++ b/sources/test/testawconfighelper.cpp @@ -64,4 +64,18 @@ void TestAWConfigHelper::test_importConfiguration() } +void TestAWConfigHelper::test_readDataEngineConfiguration() +{ + deConfig = plugin->readDataEngineConfiguration(); + QVERIFY(!deConfig.isEmpty()); +} + + +void TestAWConfigHelper::test_writeDataEngineConfiguration() +{ + QVERIFY(plugin->writeDataEngineConfiguration(deConfig)); + QCOMPARE(plugin->readDataEngineConfiguration(), deConfig); +} + + QTEST_MAIN(TestAWConfigHelper); diff --git a/sources/test/testawconfighelper.h b/sources/test/testawconfighelper.h index 4f6dfdd..8591015 100644 --- a/sources/test/testawconfighelper.h +++ b/sources/test/testawconfighelper.h @@ -38,11 +38,14 @@ private slots: void test_configurationDirectory(); void test_exportConfiguration(); void test_importConfiguration(); + void test_readDataEngineConfiguration(); + void test_writeDataEngineConfiguration(); private: AWConfigHelper *plugin = nullptr; QString filename; QQmlPropertyMap map; + QVariantMap deConfig; }; From 5cd5272f1027262b12646293ed1d913c7a4edd9f Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 28 Jun 2016 11:19:33 +0300 Subject: [PATCH 06/14] add tests for awkeys --- sources/awesome-widget/plugin/awactions.h | 1 + .../awesome-widget/plugin/awkeyoperations.cpp | 18 +- sources/awesome-widget/plugin/awkeys.cpp | 6 +- sources/test/CMakeLists.txt | 14 +- sources/test/testawconfighelper.cpp | 5 +- sources/test/testawkeys.cpp | 161 ++++++++++++++++++ sources/test/testawkeys.h | 51 ++++++ 7 files changed, 245 insertions(+), 11 deletions(-) create mode 100644 sources/test/testawkeys.cpp create mode 100644 sources/test/testawkeys.h diff --git a/sources/awesome-widget/plugin/awactions.h b/sources/awesome-widget/plugin/awactions.h index 2f14650..7185667 100644 --- a/sources/awesome-widget/plugin/awactions.h +++ b/sources/awesome-widget/plugin/awactions.h @@ -19,6 +19,7 @@ #ifndef AWACTIONS_H #define AWACTIONS_H +#include #include diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 1e23e18..811dff0 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -189,10 +189,16 @@ QString AWKeyOperations::infoByKey(QString key) const { qCDebug(LOG_AW) << "Requested key" << key; + QString stripped = key; + stripped.remove(QRegExp(QString("\\d+"))); + + QString output = QString("(none)"); + + // FIXME undefined behaviour if (key.startsWith(QString("bar"))) - return graphicalItems->itemByTag(key, QString("bar"))->uniq(); + return graphicalItems->itemByTag(key, stripped)->uniq(); else if (key.startsWith(QString("custom"))) - return extScripts->itemByTag(key, QString("custom"))->uniq(); + return extScripts->itemByTag(key, stripped)->uniq(); else if (key.contains(QRegExp(QString("^hdd[rw]")))) return QString("%1").arg( m_devices[QString("disk")] @@ -213,17 +219,17 @@ QString AWKeyOperations::infoByKey(QString key) const m_devices[QString("net")] [key.remove(QRegExp(QString("^(down|up)"))).toInt()]); else if (key.startsWith(QString("pkgcount"))) - return extUpgrade->itemByTag(key, QString("pkgcount"))->uniq(); + return extUpgrade->itemByTag(key, stripped)->uniq(); else if (key.contains(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)")))) - return extQuotes->itemByTag(key, QString("ask"))->uniq(); + return extQuotes->itemByTag(key, stripped)->uniq(); else if (key.contains(QRegExp( QString("(weather|weatherId|humidity|pressure|temperature)")))) - return extWeather->itemByTag(key, QString("weather"))->uniq(); + return extWeather->itemByTag(key, stripped)->uniq(); else if (key.startsWith(QString("temp"))) return QString("%1").arg( m_devices[QString("temp")][key.remove(QString("temp")).toInt()]); - return QString("(none)"); + return output; } diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index cfb9c7b..0ccb090 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -177,8 +177,10 @@ QString AWKeys::valueByKey(QString key) const { qCDebug(LOG_AW) << "Requested value for key" << key; - key.remove(QRegExp(QString("^bar[0-9]{1,}"))); - return aggregator->formatter(values[key], key); + QString trueKey + = key.startsWith(QString("bar")) ? keyOperator->infoByKey(key) : key; + + return aggregator->formatter(values[trueKey], trueKey); } diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index a21acad..0197ad9 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -30,7 +30,7 @@ set(TEST_MODULES abstractformatter datetimeformatter floatformatter noformatter scriptformatter extitemaggregator batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource - awconfighelper awkeycache awpatternfunctions awupdatehelper + awconfighelper awkeycache awkeys awpatternfunctions awupdatehelper dpplugin) foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) @@ -39,6 +39,18 @@ foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awconfighelper.cpp) elseif (TEST_MODULE MATCHES "awkeycache") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp) + elseif (TEST_MODULE MATCHES "awkeys") + set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awactions.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataaggregator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataengineaggregator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeyoperations.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeys.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp + ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) elseif (TEST_MODULE MATCHES "awpatternfunctions") set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp diff --git a/sources/test/testawconfighelper.cpp b/sources/test/testawconfighelper.cpp index 0f7c3a7..ac9716e 100644 --- a/sources/test/testawconfighelper.cpp +++ b/sources/test/testawconfighelper.cpp @@ -20,8 +20,8 @@ #include -#include "awtestlibrary.h" #include "awconfighelper.h" +#include "awtestlibrary.h" void TestAWConfigHelper::initTestCase() @@ -55,7 +55,8 @@ void TestAWConfigHelper::test_exportConfiguration() void TestAWConfigHelper::test_importConfiguration() { - QVariantMap imported = plugin->importConfiguration(filename, true, true, true); + QVariantMap imported + = plugin->importConfiguration(filename, true, true, true); QVariantMap converted; for (auto key : map.keys()) converted[key] = map.value(key); diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp new file mode 100644 index 0000000..b20acc6 --- /dev/null +++ b/sources/test/testawkeys.cpp @@ -0,0 +1,161 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testawkeys.h" + +#include + +#include "awkeys.h" +#include "awtestlibrary.h" + + +void TestAWKeys::initTestCase() +{ + plugin = new AWKeys(this); + + // tooltip init + QVariantMap tooltipSettings; + tooltipSettings[QString("tooltipNumber")] = 1000; + tooltipSettings[QString("useTooltipBackground")] = true; + tooltipSettings[QString("tooltipBackground")] = QString("#ffffff"); + tooltipSettings[QString("cpuTooltip")] = true; + tooltipSettings[QString("cpuclTooltip")] = true; + tooltipSettings[QString("memTooltip")] = true; + tooltipSettings[QString("swapTooltip")] = true; + tooltipSettings[QString("downkbTooltip")] = true; + tooltipSettings[QString("upkbTooltip")] = true; + tooltipSettings[QString("batTooltip")] = true; + tooltipSettings[QString("cpuTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("cpuclTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("memTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("swapTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("downkbTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("upkbTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("batTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("batInTooltipColor")] = QString("#ffffff"); + tooltipSettings[QString("acOnline")] = QString("(*)"); + tooltipSettings[QString("notify")] = false; + plugin->initDataAggregator(tooltipSettings); + + // aggregator init + plugin->setAggregatorProperty("acOffline", QString("( )")); + plugin->setAggregatorProperty("acOnline", QString("(*)")); + plugin->setAggregatorProperty("customTime", QString("$hh")); + plugin->setAggregatorProperty("customUptime", QString("$hh")); + plugin->setAggregatorProperty("tempUnits", QString("Celsius")); + plugin->setAggregatorProperty("translate", false); + + plugin->initKeys(pattern, interval, 0, false); +} + + +void TestAWKeys::cleanupTestCase() +{ + delete plugin; +} + + +void TestAWKeys::test_hddDevices() +{ + QVERIFY(!plugin->getHddDevices().isEmpty()); +} + + +void TestAWKeys::test_dictKeys() +{ + QStringList keys = plugin->dictKeys(); + QVERIFY(!keys.isEmpty()); + + QStringList sorted = plugin->dictKeys(true); + QVERIFY(!sorted.isEmpty()); + QEXPECT_FAIL("", "Sorted and non-sorted lists should differ", Continue); + QCOMPARE(keys, sorted); + + pattern = QString("$%1").arg(sorted.join(QString("\n$"))); +} + + +void TestAWKeys::test_pattern() +{ + plugin->initKeys(pattern, interval, 0, false); + QSignalSpy spy(plugin, SIGNAL(needTextToBeUpdated(const QString))); + + QVERIFY(spy.wait(5 * interval)); + QString text = spy.takeFirst().at(0).toString(); + + QEXPECT_FAIL("", "Pattern should be parsed", Continue); + QCOMPARE(text, pattern); + QStringList keys = plugin->dictKeys(true); + for (auto key : keys) + QVERIFY(!text.contains(key)); +} + + +void TestAWKeys::test_tooltip() +{ + QSignalSpy spy(plugin, SIGNAL(needToolTipToBeUpdated(const QString))); + + QVERIFY(spy.wait(5 * interval)); + QString text = spy.takeFirst().at(0).toString(); + QVERIFY(text.startsWith(QString("") && text.contains("\n")); + + plugin->setWrapNewLines(true); + QVERIFY(spy.wait(5 * interval)); + text = spy.takeFirst().at(0).toString(); + QVERIFY(text.contains("
") && !text.contains("\n")); +} + + +void TestAWKeys::test_infoByKey() +{ + int notEmpty = 0; + QStringList keys = plugin->dictKeys(true); + for (auto key : keys) { + QString info = plugin->infoByKey(key); + QVERIFY(!info.isEmpty()); + // append non-empty field count + if (info != QString("(none)")) + notEmpty++; + } + QVERIFY(notEmpty > 0); +} + + +void TestAWKeys::test_valueByKey() +{ + int notEmpty = 0; + QStringList keys = plugin->dictKeys(true); + for (auto key : keys) { + if (!plugin->valueByKey(key).isEmpty()) + notEmpty++; + } + QVERIFY(notEmpty > 0); +} + + +QTEST_MAIN(TestAWKeys); diff --git a/sources/test/testawkeys.h b/sources/test/testawkeys.h new file mode 100644 index 0000000..3c5a2fd --- /dev/null +++ b/sources/test/testawkeys.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTAWKEYS_H +#define TESTAWKEYS_H + +#include + + +class AWKeys; + +class TestAWKeys : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_hddDevices(); + void test_dictKeys(); + void test_pattern(); + void test_tooltip(); + void test_wrapNewLines(); + void test_infoByKey(); + void test_valueByKey(); + +private: + AWKeys *plugin = nullptr; + QString pattern; + int interval = 1000; +}; + + +#endif /* TESTAWKEYS_H */ From 8e8ac2f3c7d54c3e934ed95ab3448bf4aaf295cc Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Thu, 30 Jun 2016 01:59:06 +0300 Subject: [PATCH 07/14] some refactoring * fix undefinded behaviour * drop dbus timout, use generic timeout insead * drop load source to own cmake key * update contributing.md --- CONTRIBUTING.md | 9 +- sources/CMakeLists.txt | 1 + sources/awdebug.cpp | 2 + .../plugin/awdataengineaggregator.cpp | 3 +- sources/awesome-widget/plugin/awkeycache.cpp | 6 +- .../awesome-widget/plugin/awkeyoperations.cpp | 82 +++++++++++-------- .../plugin/awkeysaggregator.cpp | 2 +- .../abstractextitemaggregator.cpp | 10 +-- sources/extsysmon/extsysmonaggregator.cpp | 4 +- sources/extsysmonsources/playersource.cpp | 2 +- sources/extsysmonsources/playersource.h | 4 - sources/test/testawkeys.cpp | 1 + sources/test/testdesktopsource.cpp | 5 -- sources/test/testprocessessource.cpp | 5 -- sources/version.h.in | 4 +- 15 files changed, 75 insertions(+), 65 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c024dd9..a58c2ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,14 @@ for more details. To avoid manual labor there is automatic cmake target named ``` * C-like `NULL`, use `nullptr` instead. -* It is highly recommended to avoid implicit casts. +* It is highly recommended to avoid implicit casts. Exception `nullptr` casts to + boolean, e.g.: + + ``` + if (nullptr) + qDebug() << "nullptr is true, wtf"; + ``` + * Abstract classes (which have at least one pure virtual method) are allowed. * Templates are allowed and recommended. Templates usually should be described inside header not source code file. diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index fa0dc2c..8a415f7 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -34,6 +34,7 @@ option(BUILD_DEB_PACKAGE "Build deb package" OFF) option(BUILD_RPM_PACKAGE "Build rpm package" OFF) # build details option(BUILD_FUTURE "Build with the features which will be marked as stable later" OFF) +option(BUILD_LOAD "Build with additional load" OFF) option(BUILD_TESTING "Build with additional test abilities" OFF) # generate changelog diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index 6397383..09e4ea5 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -47,6 +47,7 @@ const QStringList getBuildData() metadata.append(QString(" AWEUAPI: %1").arg(AWEUAPI)); metadata.append(QString(" AWEWAPI: %1").arg(AWEWAPI)); metadata.append(QString(" AWEFAPI: %1").arg(AWEFAPI)); + metadata.append(QString(" REQUEST_TIMEOUT: %1").arg(REQUEST_TIMEOUT)); metadata.append(QString(" TIME_KEYS: %1").arg(TIME_KEYS)); metadata.append(QString(" STATIC_KEYS: %1").arg(STATIC_KEYS)); // cmake properties @@ -89,6 +90,7 @@ const QStringList getBuildData() QString(" CPPCHECK_EXECUTABLE: %1").arg(CPPCHECK_EXECUTABLE)); // additional functions metadata.append(QString(" PROP_FUTURE: %1").arg(PROP_FUTURE)); + metadata.append(QString(" PROP_LOAD: %1").arg(PROP_LOAD)); metadata.append(QString(" PROP_TEST: %1").arg(PROP_TEST)); return metadata; diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index a8b7d96..9148b73 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -42,7 +42,6 @@ void AWDataEngineAggregator::clear() disconnectSources(); m_dataEngines.clear(); delete m_consumer; - m_consumer = nullptr; } @@ -82,7 +81,7 @@ void AWDataEngineAggregator::dropSource(const QString source) { qCDebug(LOG_AW) << "Source" << source; - // FIXME there is no possibility to check to which dataengine source + // HACK there is no possibility to check to which dataengine source // connected we will try to disconnect it from systemmonitor and extsysmon m_dataEngines[QString("systemmonitor")]->disconnectSource(source, parent()); m_dataEngines[QString("extsysmon")]->disconnectSource(source, parent()); diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp index 11fdcd4..a668908 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -38,8 +38,8 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key) cache.beginGroup(type); QStringList cachedValues; - for (auto key : cache.allKeys()) - cachedValues.append(cache.value(key).toString()); + for (auto number : cache.allKeys()) + cachedValues.append(cache.value(number).toString()); if (type == QString("hdd")) { QStringList allDevices @@ -51,6 +51,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key) if (cachedValues.contains(device)) continue; qCInfo(LOG_AW) << "Found new key" << device << "for type" << type; + cachedValues.append(device); cache.setValue( QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device); @@ -63,6 +64,7 @@ bool AWKeyCache::addKeyToCache(const QString type, const QString key) if (cachedValues.contains(device)) continue; qCInfo(LOG_AW) << "Found new key" << device << "for type" << type; + cachedValues.append(device); cache.setValue( QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device); diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 811dff0..ea14d0c 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -191,43 +191,53 @@ QString AWKeyOperations::infoByKey(QString key) const QString stripped = key; stripped.remove(QRegExp(QString("\\d+"))); + QString output; - QString output = QString("(none)"); - - // FIXME undefined behaviour - if (key.startsWith(QString("bar"))) - return graphicalItems->itemByTag(key, stripped)->uniq(); - else if (key.startsWith(QString("custom"))) - return extScripts->itemByTag(key, stripped)->uniq(); - else if (key.contains(QRegExp(QString("^hdd[rw]")))) - return QString("%1").arg( - m_devices[QString("disk")] - [key.remove(QRegExp(QString("hdd[rw]"))).toInt()]); - else if (key.contains(QRegExp( - QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))) - return QString("%1").arg( - m_devices[QString("mount")] - [key - .remove(QRegExp(QString( - "^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) - .toInt()]); - else if (key.startsWith(QString("hddtemp"))) - return QString("%1").arg( - m_devices[QString("hdd")][key.remove(QString("hddtemp")).toInt()]); - else if (key.contains(QRegExp(QString("^(down|up)[0-9]")))) - return QString("%1").arg( - m_devices[QString("net")] - [key.remove(QRegExp(QString("^(down|up)"))).toInt()]); - else if (key.startsWith(QString("pkgcount"))) - return extUpgrade->itemByTag(key, stripped)->uniq(); - else if (key.contains(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)")))) - return extQuotes->itemByTag(key, stripped)->uniq(); - else if (key.contains(QRegExp( - QString("(weather|weatherId|humidity|pressure|temperature)")))) - return extWeather->itemByTag(key, stripped)->uniq(); - else if (key.startsWith(QString("temp"))) - return QString("%1").arg( - m_devices[QString("temp")][key.remove(QString("temp")).toInt()]); + if (key.startsWith(QString("bar"))) { + AbstractExtItem *item = graphicalItems->itemByTag(key, stripped); + if (item) + output = item->uniq(); + } else if (key.startsWith(QString("custom"))) { + AbstractExtItem *item = extScripts->itemByTag(key, stripped); + if (item) + output = item->uniq(); + } else if (key.contains(QRegExp(QString("^hdd[rw]")))) { + output = m_devices[QString("disk")] + [key.remove(QRegExp(QString("hdd[rw]"))).toInt()]; + } else if (key.contains(QRegExp( + QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)")))) { + output + = m_devices[QString("mount")] + [key + .remove(QRegExp(QString( + "^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) + .toInt()]; + } else if (key.startsWith(QString("hddtemp"))) { + output + = m_devices[QString("hdd")][key.remove(QString("hddtemp")).toInt()]; + } else if (key.contains(QRegExp(QString("^(down|up)[0-9]")))) { + output = m_devices[QString("net")] + [key.remove(QRegExp(QString("^(down|up)"))).toInt()]; + } else if (key.startsWith(QString("pkgcount"))) { + AbstractExtItem *item = extUpgrade->itemByTag(key, stripped); + if (item) + output = item->uniq(); + } else if (key.contains( + QRegExp(QString("(^|perc)(ask|bid|price)(chg|)")))) { + AbstractExtItem *item = extQuotes->itemByTag(key, stripped); + if (item) + output = item->uniq(); + } else if (key.contains(QRegExp(QString( + "(weather|weatherId|humidity|pressure|temperature)")))) { + AbstractExtItem *item = extWeather->itemByTag(key, stripped); + if (item) + output = item->uniq(); + } else if (key.startsWith(QString("temp"))) { + output + = m_devices[QString("temp")][key.remove(QString("temp")).toInt()]; + } else { + output = QString("(none)"); + } return output; } diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 735f716..9fdb952 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -515,7 +515,7 @@ QStringList AWKeysAggregator::registerSource(const QString &source, } else if (source.startsWith(QString("lmsensors/"))) { // temperature int index = m_devices[QString("temp")].indexOf(source); - // FIXME on DE initialization there are no units key + // HACK on DE initialization there are no units key if (units.isEmpty()) return QStringList() << QString("temp%1").arg(index); if (index > -1) { diff --git a/sources/awesomewidgets/abstractextitemaggregator.cpp b/sources/awesomewidgets/abstractextitemaggregator.cpp index 90704cf..cba2f6e 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.cpp +++ b/sources/awesomewidgets/abstractextitemaggregator.cpp @@ -66,7 +66,7 @@ void AbstractExtItemAggregator::copyItem() .arg(QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation)) .arg(m_type); - if ((source == nullptr) || (fileName.isEmpty())) { + if ((!source) || (fileName.isEmpty())) { qCWarning(LOG_LIB) << "Nothing to copy"; return; } @@ -83,7 +83,7 @@ void AbstractExtItemAggregator::copyItem() void AbstractExtItemAggregator::deleteItem() { AbstractExtItem *source = itemFromWidget(); - if (source == nullptr) { + if (!source) { qCWarning(LOG_LIB) << "Nothing to delete"; return; }; @@ -98,7 +98,7 @@ void AbstractExtItemAggregator::deleteItem() void AbstractExtItemAggregator::editItem() { AbstractExtItem *source = itemFromWidget(); - if (source == nullptr) { + if (!source) { qCWarning(LOG_LIB) << "Nothing to edit"; return; }; @@ -128,7 +128,7 @@ QString AbstractExtItemAggregator::getName() AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() { QListWidgetItem *widgetItem = ui->listWidget->currentItem(); - if (widgetItem == nullptr) + if (!widgetItem) return nullptr; AbstractExtItem *found = nullptr; @@ -139,7 +139,7 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() found = item; break; } - if (found == nullptr) + if (!found) qCWarning(LOG_LIB) << "Could not find item by name" << widgetItem->text(); diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index 18a7130..050a748 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -148,10 +148,10 @@ void ExtSysMonAggregator::init(const QHash config) = new WeatherSource(this, QStringList()); for (auto source : weatherItem->sources()) m_map[source] = weatherItem; -#ifdef BUILD_TESTING +#ifdef BUILD_LOAD // additional load source AbstractExtSysMonSource *loadItem = new LoadSource(this, QStringList()); for (auto source : loadItem->sources()) m_map[source] = loadItem; -#endif /* BUILD_TESTING */ +#endif /* BUILD_LOAD */ } diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index a686d8c..e082006 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -345,7 +345,7 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString mpris) const QString("/org/mpris/MediaPlayer2"), QString(""), QString("Get")); request.setArguments(args); QDBusMessage response - = bus.call(request, QDBus::BlockWithGui, DBUS_CALL_TIMEOUT); + = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT); if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) { qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); diff --git a/sources/extsysmonsources/playersource.h b/sources/extsysmonsources/playersource.h index 48fa39b..39d666b 100644 --- a/sources/extsysmonsources/playersource.h +++ b/sources/extsysmonsources/playersource.h @@ -24,10 +24,6 @@ #include "abstractextsysmonsource.h" -#ifndef DBUS_CALL_TIMEOUT -#define DBUS_CALL_TIMEOUT 3000 -#endif /* DBUS_CALL_TIMEOUT */ - class QProcess; class PlayerSource : public AbstractExtSysMonSource diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index b20acc6..84d7beb 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -95,6 +95,7 @@ void TestAWKeys::test_pattern() plugin->initKeys(pattern, interval, 0, false); QSignalSpy spy(plugin, SIGNAL(needTextToBeUpdated(const QString))); + QVERIFY(spy.wait(5 * interval)); QVERIFY(spy.wait(5 * interval)); QString text = spy.takeFirst().at(0).toString(); diff --git a/sources/test/testdesktopsource.cpp b/sources/test/testdesktopsource.cpp index 4096d06..36831e6 100644 --- a/sources/test/testdesktopsource.cpp +++ b/sources/test/testdesktopsource.cpp @@ -39,11 +39,6 @@ void TestDesktopSource::cleanupTestCase() void TestDesktopSource::test_sources() { QCOMPARE(source->sources().count(), 4); - // FIXME there is segfault here sometimes o_0 - // QVERIFY(std::all_of( - // source->sources().cbegin(), source->sources().cend(), - // [](const QString &src) { return - // src.startsWith(QString("desktop/")); })); } diff --git a/sources/test/testprocessessource.cpp b/sources/test/testprocessessource.cpp index 5119418..fef1bf1 100644 --- a/sources/test/testprocessessource.cpp +++ b/sources/test/testprocessessource.cpp @@ -39,11 +39,6 @@ void TestProcessesSource::cleanupTestCase() void TestProcessesSource::test_sources() { QCOMPARE(source->sources().count(), 3); - // FIXME there is segfault here sometimes o_0 - // QVERIFY(std::all_of( - // source->sources().cbegin(), source->sources().cend(), - // [](const QString &src) { return src.startsWith(QString("ps/")); - // })); } diff --git a/sources/version.h.in b/sources/version.h.in index 4c89f7b..518de5a 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -37,7 +37,7 @@ // formatter api version #define AWEFAPI 1 // network requests timeout, ms -#define REQUEST_TIMEOUT 5000 +#define REQUEST_TIMEOUT 3000 // available time keys #define TIME_KEYS \ "dddd,ddd,dd,d,MMMM,MMM,MM,M,yyyy,yy,hh,h,HH,H,mm,m,ss,s,t,ap,a,AP,A" @@ -51,6 +51,7 @@ "dalbum,dartist,dtitle,salbum,sartist,stitle,pscount,pstotal,ps,desktop," \ "ndesktop,tdesktops,la15,la5,la1" #cmakedefine BUILD_FUTURE +#cmakedefine BUILD_LOAD #cmakedefine BUILD_TESTING // links @@ -94,6 +95,7 @@ #define CPPCHECK_EXECUTABLE "@CPPCHECK_EXECUTABLE@" // additional functions #define PROP_FUTURE "@BUILD_FUTURE@" +#define PROP_LOAD "@BUILD_LOAD@" #define PROP_TEST "@BUILD_TESTING@" From 2f88c7ae607e7506c594d7327ce3ffefa19d8136 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Fri, 1 Jul 2016 02:21:48 +0300 Subject: [PATCH 08/14] add macros support Macros should be declared as `aw_macro{{macro body}}` and then they may be used as `aw_name{{}}`. It just puts `macro body` to pattern and replaces arguments to provided ones according to macro call. E.g.: ``` $aw_macro{{phrase}}$aw_test{{}} ``` will transform into ``` hello world ``` --- .../awesome-widget/plugin/awkeyoperations.cpp | 1 + .../plugin/awpatternfunctions.cpp | 42 +++++++++++++++++++ .../plugin/awpatternfunctions.h | 1 + 3 files changed, 44 insertions(+) diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index ea14d0c..3ce11df 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -342,6 +342,7 @@ void AWKeyOperations::reinitKeys() m_pattern = AWPatternFunctions::insertKeyCount(m_pattern, allKeys); m_pattern = AWPatternFunctions::insertKeyNames(m_pattern, allKeys); m_pattern = AWPatternFunctions::insertKeys(m_pattern, allKeys); + m_pattern = AWPatternFunctions::insertMacros(m_pattern); // wrap templates m_pattern = AWPatternFunctions::expandTemplates(m_pattern); diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index 1b1950f..ff40215 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -212,6 +212,48 @@ QString AWPatternFunctions::insertKeys(QString code, const QStringList keys) } +QString AWPatternFunctions::insertMacros(QString code) +{ + qCDebug(LOG_AW) << "Looking for macros in code" << code; + + QList found + = AWPatternFunctions::findFunctionCalls(QString("aw_macro"), code); + for (auto macro : found) { + // get macro params + if (macro.args.isEmpty()) { + qCWarning(LOG_AW) << "No macro name found for" << macro.what; + continue; + } + QString name = macro.args.takeFirst(); + // find macro usage + QList macroUsage + = AWPatternFunctions::findFunctionCalls(QString("aw_%1").arg(name), + code); + for (auto function : macroUsage) { + if (function.args.count() != macro.args.count()) { + qCWarning(LOG_AW) << "Invalid args count found for call" + << function.what << "with macro" + << macro.what; + continue; + } + // generate body to replace + QString result = macro.body; + for (auto arg : macro.args) { + int index = macro.args.indexOf(arg); + result.replace(arg, function.args.at(index)); + } + // do replace + code.replace(function.what, result); + } + + // remove macro from source pattern + code.remove(macro.what); + } + + return code; +} + + QStringList AWPatternFunctions::findKeys(const QString code, const QStringList keys, const bool isBars) diff --git a/sources/awesome-widget/plugin/awpatternfunctions.h b/sources/awesome-widget/plugin/awpatternfunctions.h index 01575dd..b5544b0 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.h +++ b/sources/awesome-widget/plugin/awpatternfunctions.h @@ -43,6 +43,7 @@ QString insertAllKeys(QString code, const QStringList keys); QString insertKeyCount(QString code, const QStringList keys); QString insertKeyNames(QString code, const QStringList keys); QString insertKeys(QString code, const QStringList keys); +QString insertMacros(QString code); // find methods QStringList findKeys(const QString code, const QStringList keys, const bool isBars); From 34979229286513f402e0959dd55e6bf7d3a03899 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 2 Jul 2016 04:07:43 +0300 Subject: [PATCH 09/14] function improvements * use $ for args inside macros * allow to use screened brackets inside functions --- .../plugin/awpatternfunctions.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index ff40215..154a258 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -96,8 +96,8 @@ AWPatternFunctions::findFunctionCalls(const QString function, // $aw_function_name{{function body}} // * args should be always comma separated (e.g. commas are not supported // in this field if they are not screened by $, i.e. '$,' - // * body depends on the function name, double brackets (i.e. {{ or }}) are - // not supported + // * body depends on the function name, double brackets should be screened + // by using $, e.g. ${ QRegularExpression regex( QString("\\$%1\\<(?.*?)\\>\\{\\{(?.*?)\\}\\}") .arg(function)); @@ -125,6 +125,9 @@ AWPatternFunctions::findFunctionCalls(const QString function, // other variables metadata.body = match.captured(QString("body")); metadata.what = match.captured(); + // replace brackets + metadata.body.replace(QString("${"), QString("{")); + metadata.body.replace(QString("$}"), QString("}")); foundFunctions.append(metadata); } @@ -238,10 +241,12 @@ QString AWPatternFunctions::insertMacros(QString code) } // generate body to replace QString result = macro.body; - for (auto arg : macro.args) { - int index = macro.args.indexOf(arg); - result.replace(arg, function.args.at(index)); - } + std::for_each(macro.args.cbegin(), macro.args.cend(), + [&result, macro, function](const QString &arg) { + int index = macro.args.indexOf(arg); + result.replace(QString("$%1").arg(arg), + function.args.at(index)); + }); // do replace code.replace(function.what, result); } From 17a0c61b4ac74298a603a5d7dc418c43819e10f9 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 3 Jul 2016 04:10:04 +0300 Subject: [PATCH 10/14] add list formatter --- .../plugin/awformatterhelper.cpp | 11 +- .../awesomewidgets/awabstractformatter.cpp | 5 + sources/awesomewidgets/awabstractformatter.h | 2 +- sources/awesomewidgets/awlistformatter.cpp | 155 ++++++++++++ sources/awesomewidgets/awlistformatter.h | 64 +++++ sources/awesomewidgets/awlistformatter.ui | 220 ++++++++++++++++++ sources/test/CMakeLists.txt | 2 +- sources/test/testlistformatter.cpp | 93 ++++++++ sources/test/testlistformatter.h | 48 ++++ 9 files changed, 597 insertions(+), 3 deletions(-) create mode 100644 sources/awesomewidgets/awlistformatter.cpp create mode 100644 sources/awesomewidgets/awlistformatter.h create mode 100644 sources/awesomewidgets/awlistformatter.ui create mode 100644 sources/test/testlistformatter.cpp create mode 100644 sources/test/testlistformatter.h diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index 2dc9598..45ac3e0 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -26,6 +26,7 @@ #include "awdatetimeformatter.h" #include "awdebug.h" #include "awfloatformatter.h" +#include "awlistformatter.h" #include "awnoformatter.h" #include "awscriptformatter.h" @@ -160,6 +161,8 @@ AWFormatterHelper::defineFormatterClass(const QString stringType) const ; else if (stringType == QString("Script")) formatter = AWAbstractFormatter::FormatterClass::Script; + else if (stringType == QString("List")) + formatter = AWAbstractFormatter::FormatterClass::List; else qCWarning(LOG_AW) << "Unknown formatter" << stringType; @@ -203,6 +206,9 @@ void AWFormatterHelper::initFormatters() case AWAbstractFormatter::FormatterClass::NoFormat: m_formattersClasses[name] = new AWNoFormatter(this, filePath); break; + case AWAbstractFormatter::FormatterClass::List: + m_formattersClasses[name] = new AWListFormatter(this, filePath); + break; } } } @@ -280,7 +286,8 @@ void AWFormatterHelper::doCreateItem() { QStringList selection = QStringList() << QString("NoFormat") << QString("DateTime") - << QString("Float") << QString("Script"); + << QString("Float") << QString("Script") + << QString("List"); bool ok; QString select = QInputDialog::getItem( this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok); @@ -301,6 +308,8 @@ void AWFormatterHelper::doCreateItem() return createItem(); case AWAbstractFormatter::FormatterClass::NoFormat: return createItem(); + case AWAbstractFormatter::FormatterClass::List: + return createItem(); } } diff --git a/sources/awesomewidgets/awabstractformatter.cpp b/sources/awesomewidgets/awabstractformatter.cpp index 123a245..4d3c58f 100644 --- a/sources/awesomewidgets/awabstractformatter.cpp +++ b/sources/awesomewidgets/awabstractformatter.cpp @@ -66,6 +66,9 @@ QString AWAbstractFormatter::strType() const case FormatterClass::NoFormat: value = QString("NoFormat"); break; + case FormatterClass::List: + value = QString("List"); + break; } return value; @@ -88,6 +91,8 @@ void AWAbstractFormatter::setStrType(const QString _type) m_type = FormatterClass::Float; else if (_type == QString("Script")) m_type = FormatterClass::Script; + else if (_type == QString("List")) + m_type = FormatterClass::List; else m_type = FormatterClass::NoFormat; } diff --git a/sources/awesomewidgets/awabstractformatter.h b/sources/awesomewidgets/awabstractformatter.h index 9bb5315..c62c34c 100644 --- a/sources/awesomewidgets/awabstractformatter.h +++ b/sources/awesomewidgets/awabstractformatter.h @@ -28,7 +28,7 @@ class AWAbstractFormatter : public AbstractExtItem Q_PROPERTY(QString strType READ strType WRITE setStrType) public: - enum class FormatterClass { DateTime, Float, Script, NoFormat }; + enum class FormatterClass { DateTime, Float, Script, NoFormat, List }; explicit AWAbstractFormatter(QWidget *parent, const QString filePath = QString()); diff --git a/sources/awesomewidgets/awlistformatter.cpp b/sources/awesomewidgets/awlistformatter.cpp new file mode 100644 index 0000000..c513598 --- /dev/null +++ b/sources/awesomewidgets/awlistformatter.cpp @@ -0,0 +1,155 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "awlistformatter.h" +#include "ui_awlistformatter.h" + +#include + +#include "awdebug.h" + + +AWListFormatter::AWListFormatter(QWidget *parent, const QString filePath) + : AWAbstractFormatter(parent, filePath) + , ui(new Ui::AWListFormatter) +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; + + if (!filePath.isEmpty()) + readConfiguration(); + ui->setupUi(this); + translate(); +} + + +AWListFormatter::~AWListFormatter() +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; + + delete ui; +} + + +QString AWListFormatter::convert(const QVariant &_value) const +{ + qCDebug(LOG_LIB) << "Convert value" << _value; + + QStringList output = _value.toStringList(); + if (isSorted()) + output.sort(); + + return output.filter(m_regex).join(separator()); +} + + +AWListFormatter *AWListFormatter::copy(const QString _fileName, + const int _number) +{ + qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; + + AWListFormatter *item + = new AWListFormatter(static_cast(parent()), _fileName); + AWAbstractFormatter::copyDefaults(item); + item->setFilter(filter()); + item->setSeparator(separator()); + item->setSorted(isSorted()); + item->setNumber(_number); + + return item; +} + + +QString AWListFormatter::filter() const +{ + return m_filter; +} + + +bool AWListFormatter::isSorted() const +{ + return m_sorted; +} + + +QString AWListFormatter::separator() const +{ + return m_separator; +} + + +void AWListFormatter::setFilter(const QString _filter) +{ + qCDebug(LOG_LIB) << "Filter" << _filter; + + m_filter = _filter; + m_regex = QRegExp(m_filter); +} + + +void AWListFormatter::setSeparator(const QString _separator) +{ + qCDebug(LOG_LIB) << "Separtor" << _separator; + + m_separator = _separator; +} + + +void AWListFormatter::setSorted(const bool _sorted) +{ + qCDebug(LOG_LIB) << "Sorting" << _sorted; + + m_sorted = _sorted; +} + + +int AWListFormatter::showConfiguration(const QVariant args) +{ + Q_UNUSED(args) + + ui->lineEdit_name->setText(name()); + ui->lineEdit_comment->setText(comment()); + ui->label_typeValue->setText(QString("NoFormat")); + ui->lineEdit_filter->setText(filter()); + ui->lineEdit_separator->setText(separator()); + ui->checkBox_sorted->setCheckState(isSorted() ? Qt::Checked + : Qt::Unchecked); + + int ret = exec(); + if (ret != 1) + return ret; + setName(ui->lineEdit_name->text()); + setComment(ui->lineEdit_comment->text()); + setStrType(ui->label_typeValue->text()); + setFilter(ui->lineEdit_filter->text()); + setSeparator(ui->lineEdit_separator->text()); + setSorted(ui->checkBox_sorted->checkState() == Qt::Checked); + + writeConfiguration(); + return ret; +} + + +void AWListFormatter::translate() +{ + ui->label_name->setText(i18n("Name")); + ui->label_comment->setText(i18n("Comment")); + ui->label_type->setText(i18n("Type")); + ui->label_filter->setText(i18n("Filter")); + ui->label_separator->setText(i18n("Separator")); + ui->checkBox_sorted->setText(i18n("Sort")); +} diff --git a/sources/awesomewidgets/awlistformatter.h b/sources/awesomewidgets/awlistformatter.h new file mode 100644 index 0000000..ebc384d --- /dev/null +++ b/sources/awesomewidgets/awlistformatter.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 AWLISTFORMATTER_H +#define AWLISTFORMATTER_H + +#include "awabstractformatter.h" + + +namespace Ui +{ +class AWListFormatter; +} + +class AWListFormatter : public AWAbstractFormatter +{ + Q_OBJECT + Q_PROPERTY(QString filter READ filter WRITE setFilter) + Q_PROPERTY(QString separator READ separator WRITE setSeparator) + Q_PROPERTY(bool sorted READ isSorted WRITE setSorted) + +public: + explicit AWListFormatter(QWidget *parent, + const QString filePath = QString()); + virtual ~AWListFormatter(); + QString convert(const QVariant &_value) const; + AWListFormatter *copy(const QString _fileName, const int _number); + // properties + QString filter() const; + bool isSorted() const; + QString separator() const; + void setFilter(const QString _filter); + void setSeparator(const QString _separator); + void setSorted(const bool _sorted); + +public slots: + int showConfiguration(const QVariant args = QVariant()); + +private: + Ui::AWListFormatter *ui = nullptr; + void translate(); + // properties + QString m_filter = QString(); + QString m_separator = QString(); + bool m_sorted = false; + QRegExp m_regex; +}; + + +#endif /* AWLISTFORMATTER_H */ diff --git a/sources/awesomewidgets/awlistformatter.ui b/sources/awesomewidgets/awlistformatter.ui new file mode 100644 index 0000000..bdebe21 --- /dev/null +++ b/sources/awesomewidgets/awlistformatter.ui @@ -0,0 +1,220 @@ + + + AWListFormatter + + + + 0 + 0 + 420 + 225 + + + + Configuration + + + + + + + + + 0 + 0 + + + + Name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + 0 + 0 + + + + Comment + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Filter + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + 0 + 0 + + + + Separator + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Sort + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AWListFormatter + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AWListFormatter + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index 0197ad9..ed1dd2c 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -27,7 +27,7 @@ set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSO ## modules set(TEST_MODULES abstractextitem extquotes extscript extupgrade extweather - abstractformatter datetimeformatter floatformatter noformatter scriptformatter + abstractformatter datetimeformatter floatformatter listformatter noformatter scriptformatter extitemaggregator batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource awconfighelper awkeycache awkeys awpatternfunctions awupdatehelper diff --git a/sources/test/testlistformatter.cpp b/sources/test/testlistformatter.cpp new file mode 100644 index 0000000..9522dae --- /dev/null +++ b/sources/test/testlistformatter.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "testlistformatter.h" + +#include + +#include "awlistformatter.h" +#include "awtestlibrary.h" + + +void TestAWListFormatter::initTestCase() +{ + separator = AWTestLibrary::randomString(10); + + formatter = new AWListFormatter(nullptr); + formatter->setSeparator(separator); +} + + +void TestAWListFormatter::cleanupTestCase() +{ + delete formatter; +} + + +void TestAWListFormatter::test_values() +{ + QCOMPARE(formatter->filter(), QString()); + QCOMPARE(formatter->separator(), separator); + QCOMPARE(formatter->isSorted(), false); +} + + +void TestAWListFormatter::test_conversion() +{ + QStringList value = AWTestLibrary::randomStringList(); + QCOMPARE(formatter->convert(value), value.join(separator)); +} + + +void TestAWListFormatter::test_sorted() +{ + formatter->setSorted(true); + QStringList value = AWTestLibrary::randomStringList(); + QString received = formatter->convert(value); + + value.sort(); + QCOMPARE(received, value.join(separator)); +} + + +void TestAWListFormatter::test_filter() +{ + QStringList value = AWTestLibrary::randomStringList(); + QStringList filters = AWTestLibrary::randomSelect(value); + value.sort(); + formatter->setFilter(QString("(^%1$)").arg(filters.join(QString("$|^")))); + + QCOMPARE(formatter->convert(value).split(separator).count(), + filters.count()); +} + + +void TestAWListFormatter::test_copy() +{ + AWListFormatter *newFormatter = formatter->copy(QString("/dev/null"), 1); + + QCOMPARE(newFormatter->number(), 1); + QCOMPARE(newFormatter->filter(), formatter->filter()); + QCOMPARE(newFormatter->separator(), formatter->separator()); + QCOMPARE(newFormatter->isSorted(), formatter->isSorted()); + + delete newFormatter; +} + + +QTEST_MAIN(TestAWListFormatter); diff --git a/sources/test/testlistformatter.h b/sources/test/testlistformatter.h new file mode 100644 index 0000000..6f4e16e --- /dev/null +++ b/sources/test/testlistformatter.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTLISTFORMATTER_H +#define TESTLISTFORMATTER_H + +#include + + +class AWListFormatter; + +class TestAWListFormatter : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_values(); + void test_conversion(); + void test_sorted(); + void test_filter(); + void test_copy(); + +private: + AWListFormatter *formatter = nullptr; + QString separator; +}; + + +#endif /* TESTLISTFORMATTER_H */ From baf50855064306109807ad41e717d46697b54e4c Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Mon, 4 Jul 2016 16:24:12 +0300 Subject: [PATCH 11/14] prerelease translation update --- sources/translations/awesome-widgets.pot | 15 ++++++++++++--- sources/translations/en.po | 23 ++++++++++++++++------- sources/translations/es.po | 17 +++++++++++++---- sources/translations/fr.po | 15 ++++++++++++--- sources/translations/nl_NL.po | 15 ++++++++++++--- sources/translations/pl.po | 17 +++++++++++++---- sources/translations/pt_BR.po | 15 ++++++++++++--- sources/translations/ru.po | 23 ++++++++++++++++------- sources/translations/uk.po | 17 +++++++++++++---- sources/translations/zh.po | 17 +++++++++++++---- 10 files changed, 132 insertions(+), 42 deletions(-) diff --git a/sources/translations/awesome-widgets.pot b/sources/translations/awesome-widgets.pot index ca0a5dc..1d4f350 100644 --- a/sources/translations/awesome-widgets.pot +++ b/sources/translations/awesome-widgets.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -528,6 +528,15 @@ msgstr "" msgid "Summand" msgstr "" +msgid "Filter" +msgstr "" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + msgid "Append code" msgstr "" @@ -574,10 +583,10 @@ msgstr "" msgid "Wrap spaces" msgstr "" -msgid "Filter" +msgid "Null" msgstr "" -msgid "Null" +msgid "Provider" msgstr "" msgid "City" diff --git a/sources/translations/en.po b/sources/translations/en.po index 82b3a59..f03eb41 100644 --- a/sources/translations/en.po +++ b/sources/translations/en.po @@ -6,16 +6,16 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" -"PO-Revision-Date: 2016-05-16 14:14+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"PO-Revision-Date: 2016-07-04 16:22+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: English \n" "Language: ru\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" +"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" msgid "Widget" @@ -533,6 +533,15 @@ msgstr "Multiplier" msgid "Summand" msgstr "Summand" +msgid "Filter" +msgstr "Filter" + +msgid "Separator" +msgstr "Separator" + +msgid "Sort" +msgstr "Sort" + msgid "Append code" msgstr "Append code" @@ -583,12 +592,12 @@ msgstr "Wrap colors" msgid "Wrap spaces" msgstr "Wrap spaces" -msgid "Filter" -msgstr "Filter" - msgid "Null" msgstr "Null" +msgid "Provider" +msgstr "Provider" + msgid "City" msgstr "City" diff --git a/sources/translations/es.po b/sources/translations/es.po index af5d59b..9a1e795 100644 --- a/sources/translations/es.po +++ b/sources/translations/es.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\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/" @@ -541,6 +541,15 @@ msgstr "" msgid "Summand" msgstr "Orden" +msgid "Filter" +msgstr "Filtro" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "Apariencia" @@ -592,12 +601,12 @@ msgstr "Tratamiento de colores" msgid "Wrap spaces" msgstr "Tratamiento de espacios" -msgid "Filter" -msgstr "Filtro" - msgid "Null" msgstr "Líneas en blanco" +msgid "Provider" +msgstr "" + msgid "City" msgstr "Ciudad" diff --git a/sources/translations/fr.po b/sources/translations/fr.po index 7635fce..1b30321 100644 --- a/sources/translations/fr.po +++ b/sources/translations/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: 2015-07-31 22:16+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: French \n" @@ -559,6 +559,15 @@ msgstr "" msgid "Summand" msgstr "Commande personnalisée" +msgid "Filter" +msgstr "" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "Apparence" @@ -611,10 +620,10 @@ msgstr "Couleur de la mémoire d'échange" msgid "Wrap spaces" msgstr "" -msgid "Filter" +msgid "Null" msgstr "" -msgid "Null" +msgid "Provider" msgstr "" msgid "City" diff --git a/sources/translations/nl_NL.po b/sources/translations/nl_NL.po index ca5f9ec..8da5b58 100644 --- a/sources/translations/nl_NL.po +++ b/sources/translations/nl_NL.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: 2015-08-20 22:52+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Dutch \n" @@ -561,6 +561,15 @@ msgstr "" msgid "Summand" msgstr "Commentaar" +msgid "Filter" +msgstr "" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "Uiterlijk" @@ -612,10 +621,10 @@ msgstr "Swap-kleur" msgid "Wrap spaces" msgstr "" -msgid "Filter" +msgid "Null" msgstr "" -msgid "Null" +msgid "Provider" msgstr "" msgid "City" diff --git a/sources/translations/pl.po b/sources/translations/pl.po index 8e17d6c..6f0c957 100644 --- a/sources/translations/pl.po +++ b/sources/translations/pl.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -539,6 +539,15 @@ msgstr "" msgid "Summand" msgstr "Polecenie" +msgid "Filter" +msgstr "Filtr" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "Wygląd" @@ -589,12 +598,12 @@ msgstr "Kolory oblewania" msgid "Wrap spaces" msgstr "Oblewanie tekstu" -msgid "Filter" -msgstr "Filtr" - msgid "Null" msgstr "Null" +msgid "Provider" +msgstr "" + msgid "City" msgstr "Miasto" diff --git a/sources/translations/pt_BR.po b/sources/translations/pt_BR.po index e22880f..8724237 100644 --- a/sources/translations/pt_BR.po +++ b/sources/translations/pt_BR.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: 2015-07-31 22:21+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Russian \n" @@ -555,6 +555,15 @@ msgstr "" msgid "Summand" msgstr "Comentário" +msgid "Filter" +msgstr "" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "Aparência" @@ -603,10 +612,10 @@ msgstr "Cor da swap" msgid "Wrap spaces" msgstr "" -msgid "Filter" +msgid "Null" msgstr "" -msgid "Null" +msgid "Provider" msgstr "" msgid "City" diff --git a/sources/translations/ru.po b/sources/translations/ru.po index bf6c14c..5e190ed 100644 --- a/sources/translations/ru.po +++ b/sources/translations/ru.po @@ -6,16 +6,16 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" -"PO-Revision-Date: 2016-05-16 14:15+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"PO-Revision-Date: 2016-07-04 16:22+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Russian \n" "Language: ru\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" +"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" msgid "Widget" @@ -533,6 +533,15 @@ msgstr "Множитель" msgid "Summand" msgstr "Слагаемое" +msgid "Filter" +msgstr "Фильтр" + +msgid "Separator" +msgstr "Разделитель" + +msgid "Sort" +msgstr "Сортировка" + msgid "Append code" msgstr "Дополнить код" @@ -583,12 +592,12 @@ msgstr "Обработать цвета" msgid "Wrap spaces" msgstr "Обработать пробелы" -msgid "Filter" -msgstr "Фильтр" - msgid "Null" msgstr "Пустые строки" +msgid "Provider" +msgstr "Провайдер" + msgid "City" msgstr "Город" diff --git a/sources/translations/uk.po b/sources/translations/uk.po index be53776..a5e42a2 100644 --- a/sources/translations/uk.po +++ b/sources/translations/uk.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: 2016-05-05 17:18+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Ukrainian \n" @@ -539,6 +539,15 @@ msgstr "" msgid "Summand" msgstr "Команда" +msgid "Filter" +msgstr "Фільтр" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "Зовнішній вигляд" @@ -590,12 +599,12 @@ msgstr "Обробити кольори" msgid "Wrap spaces" msgstr "Обробити пробіли" -msgid "Filter" -msgstr "Фільтр" - msgid "Null" msgstr "Пусті рядки" +msgid "Provider" +msgstr "" + msgid "City" msgstr "Місто" diff --git a/sources/translations/zh.po b/sources/translations/zh.po index 894fec4..9a12bdd 100644 --- a/sources/translations/zh.po +++ b/sources/translations/zh.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-05-16 19:35+0300\n" +"POT-Creation-Date: 2016-07-04 16:21+0300\n" "PO-Revision-Date: 2015-07-31 22:24+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Russian \n" @@ -540,6 +540,15 @@ msgstr "" msgid "Summand" msgstr "命令" +msgid "Filter" +msgstr "过滤" + +msgid "Separator" +msgstr "" + +msgid "Sort" +msgstr "" + #, fuzzy msgid "Append code" msgstr "外观" @@ -591,12 +600,12 @@ msgstr "换行颜色" msgid "Wrap spaces" msgstr "换行空格" -msgid "Filter" -msgstr "过滤" - msgid "Null" msgstr "空" +msgid "Provider" +msgstr "" + msgid "City" msgstr "城市" From 085eec7a3d294f5f7816c6ef6dfe2327198d31ce Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Wed, 6 Jul 2016 14:23:01 +0300 Subject: [PATCH 12/14] some fixes inside extensions * do not use private variables if there are special methods * change macro call from `aw_*` to `aw_macro_*` * add forgotten configuration reading/writting for list formatter --- .../plugin/awpatternfunctions.cpp | 4 +- sources/awesomewidgets/abstractextitem.cpp | 39 +++--- .../awesomewidgets/awabstractformatter.cpp | 2 +- .../awesomewidgets/awdatetimeformatter.cpp | 6 +- sources/awesomewidgets/awfloatformatter.cpp | 40 +++--- sources/awesomewidgets/awlistformatter.cpp | 36 +++++ sources/awesomewidgets/awlistformatter.h | 2 + sources/awesomewidgets/awscriptformatter.cpp | 26 ++-- sources/awesomewidgets/extquotes.cpp | 10 +- sources/awesomewidgets/extscript.cpp | 40 +++--- sources/awesomewidgets/extupgrade.cpp | 28 ++-- sources/awesomewidgets/extweather.cpp | 30 ++--- sources/awesomewidgets/graphicalitem.cpp | 124 +++++++++--------- 13 files changed, 213 insertions(+), 174 deletions(-) diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index 154a258..70bd96c 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -230,8 +230,8 @@ QString AWPatternFunctions::insertMacros(QString code) QString name = macro.args.takeFirst(); // find macro usage QList macroUsage - = AWPatternFunctions::findFunctionCalls(QString("aw_%1").arg(name), - code); + = AWPatternFunctions::findFunctionCalls( + QString("aw_macro_%1").arg(name), code); for (auto function : macroUsage) { if (function.args.count() != macro.args.count()) { qCWarning(LOG_AW) << "Invalid args count found for call" diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index cfed6cb..69a3445 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -60,11 +60,11 @@ void AbstractExtItem::bumpApi(const int _newVer) void AbstractExtItem::copyDefaults(AbstractExtItem *_other) const { - _other->setActive(m_active); - _other->setApiVersion(m_apiVersion); - _other->setComment(m_comment); - _other->setInterval(m_interval); - _other->setName(m_name); + _other->setActive(isActive()); + _other->setApiVersion(apiVersion()); + _other->setComment(comment()); + _other->setInterval(interval()); + _other->setName(name()); } @@ -129,7 +129,7 @@ QString AbstractExtItem::tag(const QString _type) const { qCDebug(LOG_LIB) << "Tag type" << _type; - return QString("%1%2").arg(_type).arg(m_number); + return QString("%1%2").arg(_type).arg(number()); } @@ -182,7 +182,8 @@ void AbstractExtItem::setNumber(int _number) if (generateNumber) { _number = []() { qCWarning(LOG_LIB) << "Number is empty, generate new one"; - qsrand(QTime::currentTime().msec()); + // we suppose that currentTIme().msec() is always valid time + qsrand(static_cast(QTime::currentTime().msec())); int n = qrand() % 1000; qCInfo(LOG_LIB) << "Generated number is" << n; return n; @@ -200,15 +201,15 @@ void AbstractExtItem::readConfiguration() QSettings settings(m_fileName, QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setName(settings.value(QString("Name"), m_name).toString()); - setComment(settings.value(QString("Comment"), m_comment).toString()); + setName(settings.value(QString("Name"), name()).toString()); + setComment(settings.value(QString("Comment"), comment()).toString()); setApiVersion( - settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt()); + settings.value(QString("X-AW-ApiVersion"), apiVersion()).toInt()); setActive( - settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() + settings.value(QString("X-AW-Active"), QVariant(isActive())).toString() == QString("true")); - setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt()); - setNumber(settings.value(QString("X-AW-Number"), m_number).toInt()); + setInterval(settings.value(QString("X-AW-Interval"), interval()).toInt()); + setNumber(settings.value(QString("X-AW-Number"), number()).toInt()); settings.endGroup(); } @@ -229,12 +230,12 @@ void AbstractExtItem::writeConfiguration() const settings.beginGroup(QString("Desktop Entry")); settings.setValue(QString("Encoding"), QString("UTF-8")); - settings.setValue(QString("Name"), m_name); - settings.setValue(QString("Comment"), m_comment); - settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion); - settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString()); - settings.setValue(QString("X-AW-Interval"), m_interval); - settings.setValue(QString("X-AW-Number"), m_number); + settings.setValue(QString("Name"), name()); + settings.setValue(QString("Comment"), comment()); + settings.setValue(QString("X-AW-ApiVersion"), apiVersion()); + settings.setValue(QString("X-AW-Active"), QVariant(isActive()).toString()); + settings.setValue(QString("X-AW-Interval"), interval()); + settings.setValue(QString("X-AW-Number"), number()); settings.endGroup(); settings.sync(); diff --git a/sources/awesomewidgets/awabstractformatter.cpp b/sources/awesomewidgets/awabstractformatter.cpp index 4d3c58f..013a3f7 100644 --- a/sources/awesomewidgets/awabstractformatter.cpp +++ b/sources/awesomewidgets/awabstractformatter.cpp @@ -40,7 +40,7 @@ void AWAbstractFormatter::copyDefaults(AbstractExtItem *_other) const { AbstractExtItem::copyDefaults(_other); - static_cast(_other)->setType(m_type); + static_cast(_other)->setType(type()); } diff --git a/sources/awesomewidgets/awdatetimeformatter.cpp b/sources/awesomewidgets/awdatetimeformatter.cpp index dfaa437..65fcffc 100644 --- a/sources/awesomewidgets/awdatetimeformatter.cpp +++ b/sources/awesomewidgets/awdatetimeformatter.cpp @@ -94,7 +94,7 @@ void AWDateTimeFormatter::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setFormat(settings.value(QString("X-AW-Format"), m_format).toString()); + setFormat(settings.value(QString("X-AW-Format"), format()).toString()); settings.endGroup(); bumpApi(AWEFAPI); @@ -108,7 +108,7 @@ int AWDateTimeFormatter::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText(QString("DateTime")); - ui->lineEdit_format->setText(m_format); + ui->lineEdit_format->setText(format()); int ret = exec(); if (ret != 1) @@ -131,7 +131,7 @@ void AWDateTimeFormatter::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Format"), m_format); + settings.setValue(QString("X-AW-Format"), format()); settings.endGroup(); settings.sync(); diff --git a/sources/awesomewidgets/awfloatformatter.cpp b/sources/awesomewidgets/awfloatformatter.cpp index 53a0f5a..c936e86 100644 --- a/sources/awesomewidgets/awfloatformatter.cpp +++ b/sources/awesomewidgets/awfloatformatter.cpp @@ -52,8 +52,8 @@ QString AWFloatFormatter::convert(const QVariant &_value) const { qCDebug(LOG_LIB) << "Convert value" << _value; - return QString("%1").arg(_value.toDouble() * m_multiplier + m_summand, - m_count, m_format, m_precision, m_fillChar); + return QString("%1").arg(_value.toDouble() * multiplier() + summand(), + count(), format(), precision(), fillChar()); } @@ -174,18 +174,18 @@ void AWFloatFormatter::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setCount(settings.value(QString("X-AW-Width"), m_count).toInt()); + setCount(settings.value(QString("X-AW-Width"), count()).toInt()); setFillChar( - settings.value(QString("X-AW-FillChar"), m_fillChar).toString().at(0)); - setFormat(settings.value(QString("X-AW-Format"), QString(m_format)) + settings.value(QString("X-AW-FillChar"), fillChar()).toString().at(0)); + setFormat(settings.value(QString("X-AW-Format"), QString(format())) .toString() .at(0) .toLatin1()); setMultiplier( - settings.value(QString("X-AW-Multiplier"), m_multiplier).toDouble()); + settings.value(QString("X-AW-Multiplier"), multiplier()).toDouble()); setPrecision( - settings.value(QString("X-AW-Precision"), m_precision).toInt()); - setSummand(settings.value(QString("X-AW-Summand"), m_summand).toDouble()); + settings.value(QString("X-AW-Precision"), precision()).toInt()); + setSummand(settings.value(QString("X-AW-Summand"), summand()).toDouble()); settings.endGroup(); bumpApi(AWEFAPI); @@ -200,12 +200,12 @@ int AWFloatFormatter::showConfiguration(const QVariant args) ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText(QString("Float")); ui->comboBox_format->setCurrentIndex( - ui->comboBox_format->findText(QString(m_format))); - ui->spinBox_precision->setValue(m_precision); - ui->spinBox_width->setValue(m_count); - ui->lineEdit_fill->setText(QString(m_fillChar)); - ui->doubleSpinBox_multiplier->setValue(m_multiplier); - ui->doubleSpinBox_summand->setValue(m_summand); + ui->comboBox_format->findText(QString(format()))); + ui->spinBox_precision->setValue(precision()); + ui->spinBox_width->setValue(count()); + ui->lineEdit_fill->setText(QString(fillChar())); + ui->doubleSpinBox_multiplier->setValue(multiplier()); + ui->doubleSpinBox_summand->setValue(summand()); int ret = exec(); if (ret != 1) @@ -233,12 +233,12 @@ void AWFloatFormatter::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Width"), m_count); - settings.setValue(QString("X-AW-FillChar"), m_fillChar); - settings.setValue(QString("X-AW-Format"), m_format); - settings.setValue(QString("X-AW-Multiplier"), m_multiplier); - settings.setValue(QString("X-AW-Precision"), m_precision); - settings.setValue(QString("X-AW-Summand"), m_summand); + settings.setValue(QString("X-AW-Width"), count()); + settings.setValue(QString("X-AW-FillChar"), fillChar()); + settings.setValue(QString("X-AW-Format"), format()); + settings.setValue(QString("X-AW-Multiplier"), multiplier()); + settings.setValue(QString("X-AW-Precision"), precision()); + settings.setValue(QString("X-AW-Summand"), summand()); settings.endGroup(); settings.sync(); diff --git a/sources/awesomewidgets/awlistformatter.cpp b/sources/awesomewidgets/awlistformatter.cpp index c513598..40e2239 100644 --- a/sources/awesomewidgets/awlistformatter.cpp +++ b/sources/awesomewidgets/awlistformatter.cpp @@ -21,6 +21,8 @@ #include +#include + #include "awdebug.h" @@ -117,6 +119,23 @@ void AWListFormatter::setSorted(const bool _sorted) } +void AWListFormatter::readConfiguration() +{ + AWAbstractFormatter::readConfiguration(); + + QSettings settings(fileName(), QSettings::IniFormat); + + settings.beginGroup(QString("Desktop Entry")); + setFilter(settings.value(QString("X-AW-Filter"), filter()).toString()); + setSeparator( + settings.value(QString("X-AW-Separator"), separator()).toString()); + setSorted(settings.value(QString("X-AW-Sort"), isSorted()).toBool()); + settings.endGroup(); + + bumpApi(AWEFAPI); +} + + int AWListFormatter::showConfiguration(const QVariant args) { Q_UNUSED(args) @@ -144,6 +163,23 @@ int AWListFormatter::showConfiguration(const QVariant args) } +void AWListFormatter::writeConfiguration() const +{ + AWAbstractFormatter::writeConfiguration(); + + QSettings settings(writtableConfig(), QSettings::IniFormat); + qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); + + settings.beginGroup(QString("Desktop Entry")); + settings.setValue(QString("X-AW-Filter"), filter()); + settings.setValue(QString("X-AW-Separator"), separator()); + settings.setValue(QString("X-AW-Sort"), isSorted()); + settings.endGroup(); + + settings.sync(); +} + + void AWListFormatter::translate() { ui->label_name->setText(i18n("Name")); diff --git a/sources/awesomewidgets/awlistformatter.h b/sources/awesomewidgets/awlistformatter.h index ebc384d..36438a6 100644 --- a/sources/awesomewidgets/awlistformatter.h +++ b/sources/awesomewidgets/awlistformatter.h @@ -48,7 +48,9 @@ public: void setSorted(const bool _sorted); public slots: + void readConfiguration(); int showConfiguration(const QVariant args = QVariant()); + void writeConfiguration() const; private: Ui::AWListFormatter *ui = nullptr; diff --git a/sources/awesomewidgets/awscriptformatter.cpp b/sources/awesomewidgets/awscriptformatter.cpp index e06ef23..380b9ee 100644 --- a/sources/awesomewidgets/awscriptformatter.cpp +++ b/sources/awesomewidgets/awscriptformatter.cpp @@ -146,10 +146,10 @@ void AWScriptFormatter::readConfiguration() settings.beginGroup(QString("Desktop Entry")); setAppendCode( - settings.value(QString("X-AW-AppendCode"), m_appendCode).toBool()); - setCode(settings.value(QString("X-AW-Code"), m_code).toString()); + settings.value(QString("X-AW-AppendCode"), appendCode()).toBool()); + setCode(settings.value(QString("X-AW-Code"), code()).toString()); setHasReturn( - settings.value(QString("X-AW-HasReturn"), m_hasReturn).toBool()); + settings.value(QString("X-AW-HasReturn"), hasReturn()).toBool()); settings.endGroup(); bumpApi(AWEFAPI); @@ -163,11 +163,11 @@ int AWScriptFormatter::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText(QString("Script")); - ui->checkBox_appendCode->setCheckState(m_appendCode ? Qt::Checked + ui->checkBox_appendCode->setCheckState(appendCode() ? Qt::Checked : Qt::Unchecked); - ui->checkBox_hasReturn->setCheckState(m_hasReturn ? Qt::Checked + ui->checkBox_hasReturn->setCheckState(hasReturn() ? Qt::Checked : Qt::Unchecked); - ui->textEdit_code->setPlainText(m_code); + ui->textEdit_code->setPlainText(code()); int ret = exec(); if (ret != 1) @@ -193,9 +193,9 @@ void AWScriptFormatter::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-AppendCode"), m_appendCode); - settings.setValue(QString("X-AW-Code"), m_code); - settings.setValue(QString("X-AW-HasReturn"), m_hasReturn); + settings.setValue(QString("X-AW-AppendCode"), appendCode()); + settings.setValue(QString("X-AW-Code"), code()); + settings.setValue(QString("X-AW-HasReturn"), hasReturn()); settings.endGroup(); settings.sync(); @@ -205,13 +205,13 @@ void AWScriptFormatter::writeConfiguration() const void AWScriptFormatter::initProgram() { // init JS code - if (m_appendCode) + if (appendCode()) m_program = QString("(function(value) { %1%2 })") - .arg(m_code) - .arg(m_hasReturn ? QString("") : QString("; return output;")); + .arg(code()) + .arg(hasReturn() ? QString("") : QString("; return output;")); else - m_program = m_code; + m_program = code(); qCInfo(LOG_LIB) << "Create JS engine with code" << m_program; } diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 525d45c..830636b 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -96,7 +96,7 @@ QString ExtQuotes::ticker() const QString ExtQuotes::uniq() const { - return m_ticker; + return ticker(); } @@ -116,7 +116,7 @@ void ExtQuotes::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString()); + setTicker(settings.value(QString("X-AW-Ticker"), ticker()).toString()); settings.endGroup(); // update for current API @@ -159,7 +159,7 @@ int ExtQuotes::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->lineEdit_ticker->setText(m_ticker); + ui->lineEdit_ticker->setText(ticker()); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->spinBox_interval->setValue(interval()); @@ -188,7 +188,7 @@ void ExtQuotes::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Ticker"), m_ticker); + settings.setValue(QString("X-AW-Ticker"), ticker()); settings.endGroup(); settings.sync(); @@ -260,7 +260,7 @@ void ExtQuotes::initUrl() params.addQueryItem(QString("env"), QString("store://datatables.org/alltableswithkeys")); params.addQueryItem(QString("q"), - QString(YAHOO_QUOTES_QUERY).arg(m_ticker)); + QString(YAHOO_QUOTES_QUERY).arg(ticker())); m_url.setQuery(params); } diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index fd5179a..b090721 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -104,14 +104,14 @@ ExtScript::Redirect ExtScript::redirect() const QString ExtScript::uniq() const { - return m_executable; + return executable(); } QString ExtScript::strRedirect() const { QString value; - switch (m_redirect) { + switch (redirect()) { case Redirect::stdout2stderr: value = QString("stdout2stderr"); break; @@ -182,7 +182,7 @@ QString ExtScript::applyFilters(QString _value) const { qCDebug(LOG_LIB) << "Value" << _value; - for (auto filt : m_filters) { + for (auto filt : filters()) { qCInfo(LOG_LIB) << "Found filter" << filt; QVariantMap filter = jsonFilters[filt].toMap(); if (filter.isEmpty()) { @@ -203,7 +203,7 @@ void ExtScript::updateFilter(const QString _filter, const bool _add) qCDebug(LOG_LIB) << "Should be added filters" << _add << "from" << _filter; if (_add) { - if (m_filters.contains(_filter)) + if (filters().contains(_filter)) return; m_filters.append(_filter); } else { @@ -219,12 +219,12 @@ void ExtScript::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setExecutable(settings.value(QString("Exec"), m_executable).toString()); - setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString()); + setExecutable(settings.value(QString("Exec"), executable()).toString()); + setPrefix(settings.value(QString("X-AW-Prefix"), prefix()).toString()); setStrRedirect( settings.value(QString("X-AW-Redirect"), strRedirect()).toString()); // api == 3 - setFilters(settings.value(QString("X-AW-Filters"), m_filters) + setFilters(settings.value(QString("X-AW-Filters"), filters()) .toString() .split(QChar(','), QString::SkipEmptyParts)); settings.endGroup(); @@ -270,9 +270,9 @@ QVariantHash ExtScript::run() if ((times == 1) && (process->state() == QProcess::NotRunning)) { QStringList cmdList; - if (!m_prefix.isEmpty()) - cmdList.append(m_prefix); - cmdList.append(m_executable); + if (!prefix().isEmpty()) + cmdList.append(prefix()); + cmdList.append(executable()); qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' ')); process->start(cmdList.join(QChar(' '))); } @@ -293,19 +293,19 @@ int ExtScript::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->lineEdit_command->setText(m_executable); - ui->lineEdit_prefix->setText(m_prefix); + ui->lineEdit_command->setText(executable()); + ui->lineEdit_prefix->setText(prefix()); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); - ui->comboBox_redirect->setCurrentIndex(static_cast(m_redirect)); + ui->comboBox_redirect->setCurrentIndex(static_cast(redirect())); ui->spinBox_interval->setValue(interval()); // filters ui->checkBox_colorFilter->setCheckState( - m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked); + filters().contains(QString("color")) ? Qt::Checked : Qt::Unchecked); ui->checkBox_linesFilter->setCheckState( - m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked); + filters().contains(QString("newline")) ? Qt::Checked : Qt::Unchecked); ui->checkBox_spaceFilter->setCheckState( - m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked); + filters().contains(QString("space")) ? Qt::Checked : Qt::Unchecked); int ret = exec(); if (ret != 1) @@ -340,10 +340,10 @@ void ExtScript::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("Exec"), m_executable); - settings.setValue(QString("X-AW-Prefix"), m_prefix); + settings.setValue(QString("Exec"), executable()); + settings.setValue(QString("X-AW-Prefix"), prefix()); settings.setValue(QString("X-AW-Redirect"), strRedirect()); - settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(','))); + settings.setValue(QString("X-AW-Filters"), filters().join(QChar(','))); settings.endGroup(); settings.sync(); @@ -363,7 +363,7 @@ void ExtScript::updateValue() qCInfo(LOG_LIB) << "Output" << qoutput; QString strValue; - switch (m_redirect) { + switch (redirect()) { case Redirect::stdout2stderr: break; case Redirect::stderr2stdout: diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 951d4d1..f3f8381 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -93,7 +93,7 @@ int ExtUpgrade::null() const QString ExtUpgrade::uniq() const { - return m_executable; + return executable(); } @@ -130,10 +130,10 @@ void ExtUpgrade::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setExecutable(settings.value(QString("Exec"), m_executable).toString()); - setNull(settings.value(QString("X-AW-Null"), m_null).toInt()); + setExecutable(settings.value(QString("Exec"), executable()).toString()); + setNull(settings.value(QString("X-AW-Null"), null()).toInt()); // api == 3 - setFilter(settings.value(QString("X-AW-Filter"), m_filter).toString()); + setFilter(settings.value(QString("X-AW-Filter"), filter()).toString()); settings.endGroup(); bumpApi(AWEUAPI); @@ -146,7 +146,7 @@ QVariantHash ExtUpgrade::run() return value; if ((times == 1) && (process->state() == QProcess::NotRunning)) { - QString cmd = QString("sh -c \"%1\"").arg(m_executable); + QString cmd = QString("sh -c \"%1\"").arg(executable()); qCInfo(LOG_LIB) << "Run cmd" << cmd; process->start(cmd); } @@ -167,11 +167,11 @@ int ExtUpgrade::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->lineEdit_command->setText(m_executable); - ui->lineEdit_filter->setText(m_filter); + ui->lineEdit_command->setText(executable()); + ui->lineEdit_filter->setText(filter()); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); - ui->spinBox_null->setValue(m_null); + ui->spinBox_null->setValue(null()); ui->spinBox_interval->setValue(interval()); int ret = exec(); @@ -200,9 +200,9 @@ void ExtUpgrade::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("Exec"), m_executable); - settings.setValue(QString("X-AW-Filter"), m_filter); - settings.setValue(QString("X-AW-Null"), m_null); + settings.setValue(QString("Exec"), executable()); + settings.setValue(QString("X-AW-Filter"), filter()); + settings.setValue(QString("X-AW-Null"), null()); settings.endGroup(); settings.sync(); @@ -218,11 +218,11 @@ void ExtUpgrade::updateValue() ->toUnicode(process->readAllStandardOutput()) .trimmed(); value[tag(QString("pkgcount"))] = [this](QString output) { - return m_filter.isEmpty() + return filter().isEmpty() ? output.split(QChar('\n'), QString::SkipEmptyParts).count() - - m_null + - null() : output.split(QChar('\n'), QString::SkipEmptyParts) - .filter(QRegExp(m_filter)) + .filter(QRegExp(filter())) .count(); }(qoutput); diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 456d893..d09f3a6 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -150,7 +150,7 @@ int ExtWeather::ts() const QString ExtWeather::uniq() const { - return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts); + return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts()); } @@ -216,11 +216,11 @@ void ExtWeather::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setCity(settings.value(QString("X-AW-City"), m_city).toString()); - setCountry(settings.value(QString("X-AW-Country"), m_country).toString()); - setTs(settings.value(QString("X-AW-TS"), m_ts).toInt()); + setCity(settings.value(QString("X-AW-City"), city()).toString()); + setCountry(settings.value(QString("X-AW-Country"), country()).toString()); + setTs(settings.value(QString("X-AW-TS"), ts()).toInt()); // api == 2 - setImage(settings.value(QString("X-AW-Image"), QVariant(m_image)).toString() + setImage(settings.value(QString("X-AW-Image"), QVariant(image())).toString() == QString("true")); // api == 3 setStrProvider( @@ -286,11 +286,11 @@ int ExtWeather::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->comboBox_provider->setCurrentIndex(static_cast(m_provider)); - ui->lineEdit_city->setText(m_city); - ui->lineEdit_country->setText(m_country); - ui->spinBox_timestamp->setValue(m_ts); - ui->checkBox_image->setCheckState(m_image ? Qt::Checked : Qt::Unchecked); + ui->comboBox_provider->setCurrentIndex(static_cast(provider())); + ui->lineEdit_city->setText(city()); + ui->lineEdit_country->setText(country()); + ui->spinBox_timestamp->setValue(ts()); + ui->checkBox_image->setCheckState(image() ? Qt::Checked : Qt::Unchecked); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->spinBox_interval->setValue(interval()); @@ -323,11 +323,11 @@ void ExtWeather::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-City"), m_city); - settings.setValue(QString("X-AW-Country"), m_country); - settings.setValue(QString("X-AW-Image"), m_image); + settings.setValue(QString("X-AW-City"), city()); + settings.setValue(QString("X-AW-Country"), country()); + settings.setValue(QString("X-AW-Image"), image()); settings.setValue(QString("X-AW-Provider"), strProvider()); - settings.setValue(QString("X-AW-TS"), m_ts); + settings.setValue(QString("X-AW-TS"), ts()); settings.endGroup(); settings.sync(); @@ -373,7 +373,7 @@ void ExtWeather::initProvider() break; } - return m_providerObject->initUrl(m_city, m_country, m_ts); + return m_providerObject->initUrl(city(), country(), ts()); } diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index d236cdc..8a9c32c 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -71,18 +71,18 @@ GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number) GraphicalItem *item = new GraphicalItem(static_cast(parent()), _fileName); copyDefaults(item); - item->setActiveColor(m_activeColor); - item->setBar(m_bar); - item->setCount(m_count); - item->setCustom(m_custom); - item->setDirection(m_direction); - item->setItemHeight(m_height); - item->setInactiveColor(m_inactiveColor); - item->setMaxValue(m_maxValue); - item->setMinValue(m_minValue); + item->setActiveColor(activeColor()); + item->setBar(bar()); + item->setCount(count()); + item->setCustom(isCustom()); + item->setDirection(direction()); + item->setItemHeight(itemHeight()); + item->setInactiveColor(inactiveColor()); + item->setMaxValue(maxValue()); + item->setMinValue(minValue()); item->setNumber(_number); - item->setType(m_type); - item->setItemWidth(m_width); + item->setType(type()); + item->setItemWidth(itemWidth()); return item; } @@ -95,34 +95,34 @@ QString GraphicalItem::image(const QVariant &value) m_scene->clear(); int scale[2] = {1, 1}; float converted - = m_helper->getPercents(value.toFloat(), m_minValue, m_maxValue); + = m_helper->getPercents(value.toFloat(), minValue(), maxValue()); // paint switch (m_type) { case Type::Vertical: m_helper->paintVertical(converted); // scale - scale[1] = -2 * static_cast(m_direction) + 1; + scale[1] = -2 * static_cast(direction()) + 1; break; case Type::Circle: m_helper->paintCircle(converted); // scale - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; break; case Type::Graph: m_helper->paintGraph(converted); - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; scale[1] = -1; break; case Type::Bars: m_helper->paintBars(converted); - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; scale[1] = -1; break; case Type::Horizontal: m_helper->paintHorizontal(converted); // scale - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; break; } @@ -159,8 +159,8 @@ void GraphicalItem::initScene() // init helper m_helper = new GraphicalItemHelper(this, m_scene); - m_helper->setParameters(m_activeColor, m_inactiveColor, m_width, m_height, - m_count); + m_helper->setParameters(activeColor(), inactiveColor(), itemWidth(), + itemHeight(), count()); } @@ -227,7 +227,7 @@ GraphicalItem::Type GraphicalItem::type() const QString GraphicalItem::strType() const { QString value; - switch (m_type) { + switch (type()) { case Type::Vertical: value = QString("Vertical"); break; @@ -258,7 +258,7 @@ GraphicalItem::Direction GraphicalItem::direction() const QString GraphicalItem::strDirection() const { QString value; - switch (m_direction) { + switch (direction()) { case Direction::RightToLeft: value = QString("RightToLeft"); break; @@ -279,7 +279,7 @@ QStringList GraphicalItem::usedKeys() const QString GraphicalItem::uniq() const { - return m_bar; + return bar(); } @@ -411,11 +411,11 @@ void GraphicalItem::setUsedKeys(const QStringList _usedKeys) // remove dubs // HACK converting to set may break order - m_usedKeys.clear(); + usedKeys().clear(); for (auto key : _usedKeys) { - if (m_usedKeys.contains(key)) + if (usedKeys().contains(key)) continue; - m_usedKeys.append(key); + usedKeys().append(key); } } @@ -427,31 +427,31 @@ void GraphicalItem::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setCount(settings.value(QString("X-AW-Count"), m_count).toInt()); - setCustom(settings.value(QString("X-AW-Custom"), m_custom).toBool()); - setBar(settings.value(QString("X-AW-Value"), m_bar).toString()); - setMaxValue(settings.value(QString("X-AW-Max"), m_maxValue).toFloat()); - setMinValue(settings.value(QString("X-AW-Min"), m_minValue).toFloat()); + setCount(settings.value(QString("X-AW-Count"), count()).toInt()); + setCustom(settings.value(QString("X-AW-Custom"), isCustom()).toBool()); + setBar(settings.value(QString("X-AW-Value"), bar()).toString()); + setMaxValue(settings.value(QString("X-AW-Max"), maxValue()).toFloat()); + setMinValue(settings.value(QString("X-AW-Min"), minValue()).toFloat()); setActiveColor( - settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString()); + settings.value(QString("X-AW-ActiveColor"), activeColor()).toString()); setInactiveColor( - settings.value(QString("X-AW-InactiveColor"), m_inactiveColor) + settings.value(QString("X-AW-InactiveColor"), inactiveColor()) .toString()); setStrType(settings.value(QString("X-AW-Type"), strType()).toString()); setStrDirection( settings.value(QString("X-AW-Direction"), strDirection()).toString()); - setItemHeight(settings.value(QString("X-AW-Height"), m_height).toInt()); - setItemWidth(settings.value(QString("X-AW-Width"), m_width).toInt()); + setItemHeight(settings.value(QString("X-AW-Height"), itemHeight()).toInt()); + setItemWidth(settings.value(QString("X-AW-Width"), itemWidth()).toInt()); // api == 5 if (apiVersion() < 5) { QString prefix; - prefix = m_activeColor.startsWith(QString("/")) ? QString("file://%1") + prefix = activeColor().startsWith(QString("/")) ? QString("file://%1") : QString("color://%1"); - m_activeColor = prefix.arg(m_activeColor); - prefix = m_inactiveColor.startsWith(QString("/")) + m_activeColor = prefix.arg(activeColor()); + prefix = inactiveColor().startsWith(QString("/")) ? QString("file://%1") : QString("color://%1"); - m_inactiveColor = prefix.arg(m_inactiveColor); + m_inactiveColor = prefix.arg(inactiveColor()); } settings.endGroup(); @@ -468,31 +468,31 @@ int GraphicalItem::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->checkBox_custom->setChecked(m_custom); + ui->checkBox_custom->setChecked(isCustom()); ui->comboBox_value->addItems(tags); - if (m_custom) { - ui->lineEdit_customValue->setText(m_bar); + if (isCustom()) { + ui->lineEdit_customValue->setText(bar()); } else { - ui->comboBox_value->addItem(m_bar); + ui->comboBox_value->addItem(bar()); ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1); } - ui->doubleSpinBox_max->setValue(m_maxValue); - ui->doubleSpinBox_min->setValue(m_minValue); - ui->spinBox_count->setValue(m_count); - if (m_helper->isColor(m_activeColor)) + ui->doubleSpinBox_max->setValue(maxValue()); + ui->doubleSpinBox_min->setValue(minValue()); + ui->spinBox_count->setValue(count()); + if (m_helper->isColor(activeColor())) ui->comboBox_activeImageType->setCurrentIndex(0); else ui->comboBox_activeImageType->setCurrentIndex(1); - ui->lineEdit_activeColor->setText(m_activeColor); - if (m_helper->isColor(m_inactiveColor)) + ui->lineEdit_activeColor->setText(activeColor()); + if (m_helper->isColor(inactiveColor())) ui->comboBox_inactiveImageType->setCurrentIndex(0); else ui->comboBox_inactiveImageType->setCurrentIndex(1); - ui->lineEdit_inactiveColor->setText(m_inactiveColor); - ui->comboBox_type->setCurrentIndex(static_cast(m_type)); - ui->comboBox_direction->setCurrentIndex(static_cast(m_direction)); - ui->spinBox_height->setValue(m_height); - ui->spinBox_width->setValue(m_width); + ui->lineEdit_inactiveColor->setText(inactiveColor()); + ui->comboBox_type->setCurrentIndex(static_cast(type())); + ui->comboBox_direction->setCurrentIndex(static_cast(direction())); + ui->spinBox_height->setValue(itemHeight()); + ui->spinBox_width->setValue(itemWidth()); // update UI emit(ui->comboBox_type->currentIndexChanged( @@ -532,17 +532,17 @@ void GraphicalItem::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Value"), m_bar); - settings.setValue(QString("X-AW-Count"), m_count); - settings.setValue(QString("X-AW-Custom"), m_custom); - settings.setValue(QString("X-AW-Max"), m_maxValue); - settings.setValue(QString("X-AW-Min"), m_minValue); - settings.setValue(QString("X-AW-ActiveColor"), m_activeColor); - settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor); + settings.setValue(QString("X-AW-Value"), bar()); + settings.setValue(QString("X-AW-Count"), count()); + settings.setValue(QString("X-AW-Custom"), isCustom()); + settings.setValue(QString("X-AW-Max"), maxValue()); + settings.setValue(QString("X-AW-Min"), minValue()); + settings.setValue(QString("X-AW-ActiveColor"), activeColor()); + settings.setValue(QString("X-AW-InactiveColor"), inactiveColor()); settings.setValue(QString("X-AW-Type"), strType()); settings.setValue(QString("X-AW-Direction"), strDirection()); - settings.setValue(QString("X-AW-Height"), m_height); - settings.setValue(QString("X-AW-Width"), m_width); + settings.setValue(QString("X-AW-Height"), itemHeight()); + settings.setValue(QString("X-AW-Width"), itemWidth()); settings.endGroup(); settings.sync(); From 0d4211b2c4bafc033dad40b4100f87237791f2d0 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Thu, 7 Jul 2016 13:36:30 +0300 Subject: [PATCH 13/14] add string formatter --- .../plugin/awformatterhelper.cpp | 31 ++- .../awesomewidgets/awabstractformatter.cpp | 15 +- sources/awesomewidgets/awabstractformatter.h | 9 +- sources/awesomewidgets/awfloatformatter.cpp | 31 ++- sources/awesomewidgets/awfloatformatter.h | 4 + sources/awesomewidgets/awfloatformatter.ui | 32 ++- sources/awesomewidgets/awstringformatter.cpp | 192 +++++++++++++++ sources/awesomewidgets/awstringformatter.h | 65 +++++ sources/awesomewidgets/awstringformatter.ui | 225 ++++++++++++++++++ sources/test/CMakeLists.txt | 2 +- sources/test/testfloatformatter.cpp | 32 ++- sources/test/testfloatformatter.h | 1 + sources/test/teststringformatter.cpp | 118 +++++++++ sources/test/teststringformatter.h | 48 ++++ 14 files changed, 776 insertions(+), 29 deletions(-) create mode 100644 sources/awesomewidgets/awstringformatter.cpp create mode 100644 sources/awesomewidgets/awstringformatter.h create mode 100644 sources/awesomewidgets/awstringformatter.ui create mode 100644 sources/test/teststringformatter.cpp create mode 100644 sources/test/teststringformatter.h diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index 45ac3e0..6a8f7f7 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -29,6 +29,7 @@ #include "awlistformatter.h" #include "awnoformatter.h" #include "awscriptformatter.h" +#include "awstringformatter.h" AWFormatterHelper::AWFormatterHelper(QWidget *parent) @@ -157,12 +158,14 @@ AWFormatterHelper::defineFormatterClass(const QString stringType) const formatter = AWAbstractFormatter::FormatterClass::DateTime; else if (stringType == QString("Float")) formatter = AWAbstractFormatter::FormatterClass::Float; + else if (stringType == QString("List")) + formatter = AWAbstractFormatter::FormatterClass::List; else if (stringType == QString("NoFormat")) ; else if (stringType == QString("Script")) formatter = AWAbstractFormatter::FormatterClass::Script; - else if (stringType == QString("List")) - formatter = AWAbstractFormatter::FormatterClass::List; + else if (stringType == QString("String")) + formatter = AWAbstractFormatter::FormatterClass::String; else qCWarning(LOG_AW) << "Unknown formatter" << stringType; @@ -199,16 +202,20 @@ void AWFormatterHelper::initFormatters() m_formattersClasses[name] = new AWFloatFormatter(this, filePath); break; + case AWAbstractFormatter::FormatterClass::List: + m_formattersClasses[name] = new AWListFormatter(this, filePath); + break; case AWAbstractFormatter::FormatterClass::Script: m_formattersClasses[name] = new AWScriptFormatter(this, filePath); break; + case AWAbstractFormatter::FormatterClass::String: + m_formattersClasses[name] + = new AWStringFormatter(this, filePath); + break; case AWAbstractFormatter::FormatterClass::NoFormat: m_formattersClasses[name] = new AWNoFormatter(this, filePath); break; - case AWAbstractFormatter::FormatterClass::List: - m_formattersClasses[name] = new AWListFormatter(this, filePath); - break; } } } @@ -286,8 +293,8 @@ void AWFormatterHelper::doCreateItem() { QStringList selection = QStringList() << QString("NoFormat") << QString("DateTime") - << QString("Float") << QString("Script") - << QString("List"); + << QString("Float") << QString("List") + << QString("Script") << QString("String"); bool ok; QString select = QInputDialog::getItem( this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok); @@ -304,12 +311,14 @@ void AWFormatterHelper::doCreateItem() return createItem(); case AWAbstractFormatter::FormatterClass::Float: return createItem(); - case AWAbstractFormatter::FormatterClass::Script: - return createItem(); - case AWAbstractFormatter::FormatterClass::NoFormat: - return createItem(); case AWAbstractFormatter::FormatterClass::List: return createItem(); + case AWAbstractFormatter::FormatterClass::Script: + return createItem(); + case AWAbstractFormatter::FormatterClass::String: + return createItem(); + case AWAbstractFormatter::FormatterClass::NoFormat: + return createItem(); } } diff --git a/sources/awesomewidgets/awabstractformatter.cpp b/sources/awesomewidgets/awabstractformatter.cpp index 013a3f7..af9e55e 100644 --- a/sources/awesomewidgets/awabstractformatter.cpp +++ b/sources/awesomewidgets/awabstractformatter.cpp @@ -60,15 +60,18 @@ QString AWAbstractFormatter::strType() const case FormatterClass::Float: value = QString("Float"); break; + case FormatterClass::List: + value = QString("List"); + break; case FormatterClass::Script: value = QString("Script"); break; + case FormatterClass::String: + value = QString("String"); + break; case FormatterClass::NoFormat: value = QString("NoFormat"); break; - case FormatterClass::List: - value = QString("List"); - break; } return value; @@ -89,10 +92,12 @@ void AWAbstractFormatter::setStrType(const QString _type) m_type = FormatterClass::DateTime; else if (_type == QString("Float")) m_type = FormatterClass::Float; - else if (_type == QString("Script")) - m_type = FormatterClass::Script; else if (_type == QString("List")) m_type = FormatterClass::List; + else if (_type == QString("Script")) + m_type = FormatterClass::Script; + else if (_type == QString("String")) + m_type = FormatterClass::String; else m_type = FormatterClass::NoFormat; } diff --git a/sources/awesomewidgets/awabstractformatter.h b/sources/awesomewidgets/awabstractformatter.h index c62c34c..883314d 100644 --- a/sources/awesomewidgets/awabstractformatter.h +++ b/sources/awesomewidgets/awabstractformatter.h @@ -28,7 +28,14 @@ class AWAbstractFormatter : public AbstractExtItem Q_PROPERTY(QString strType READ strType WRITE setStrType) public: - enum class FormatterClass { DateTime, Float, Script, NoFormat, List }; + enum class FormatterClass { + DateTime, + Float, + List, + Script, + String, + NoFormat + }; explicit AWAbstractFormatter(QWidget *parent, const QString filePath = QString()); diff --git a/sources/awesomewidgets/awfloatformatter.cpp b/sources/awesomewidgets/awfloatformatter.cpp index c936e86..b27625c 100644 --- a/sources/awesomewidgets/awfloatformatter.cpp +++ b/sources/awesomewidgets/awfloatformatter.cpp @@ -52,8 +52,13 @@ QString AWFloatFormatter::convert(const QVariant &_value) const { qCDebug(LOG_LIB) << "Convert value" << _value; - return QString("%1").arg(_value.toDouble() * multiplier() + summand(), - count(), format(), precision(), fillChar()); + QString output + = QString("%1").arg(_value.toDouble() * multiplier() + summand(), + count(), format(), precision(), fillChar()); + if (forceWidth()) + output = output.left(count()); + + return output; } @@ -68,6 +73,7 @@ AWFloatFormatter *AWFloatFormatter::copy(const QString _fileName, item->setCount(count()); item->setFormat(format()); item->setFillChar(fillChar()); + item->setForceWidth(forceWidth()); item->setMultiplier(multiplier()); item->setNumber(_number); item->setPrecision(precision()); @@ -89,6 +95,12 @@ QChar AWFloatFormatter::fillChar() const } +bool AWFloatFormatter::forceWidth() const +{ + return m_forceWidth; +} + + char AWFloatFormatter::format() const { return m_format; @@ -129,6 +141,14 @@ void AWFloatFormatter::setFillChar(const QChar _fillChar) } +void AWFloatFormatter::setForceWidth(const bool _forceWidth) +{ + qCDebug(LOG_LIB) << "Set force strip" << _forceWidth; + + m_forceWidth = _forceWidth; +} + + void AWFloatFormatter::setFormat(char _format) { qCDebug(LOG_LIB) << "Set format" << _format; @@ -177,6 +197,8 @@ void AWFloatFormatter::readConfiguration() setCount(settings.value(QString("X-AW-Width"), count()).toInt()); setFillChar( settings.value(QString("X-AW-FillChar"), fillChar()).toString().at(0)); + setForceWidth( + settings.value(QString("X-AW-ForceWidth"), forceWidth()).toBool()); setFormat(settings.value(QString("X-AW-Format"), QString(format())) .toString() .at(0) @@ -204,6 +226,8 @@ int AWFloatFormatter::showConfiguration(const QVariant args) ui->spinBox_precision->setValue(precision()); ui->spinBox_width->setValue(count()); ui->lineEdit_fill->setText(QString(fillChar())); + ui->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked + : Qt::Unchecked); ui->doubleSpinBox_multiplier->setValue(multiplier()); ui->doubleSpinBox_summand->setValue(summand()); @@ -217,6 +241,7 @@ int AWFloatFormatter::showConfiguration(const QVariant args) setPrecision(ui->spinBox_precision->value()); setCount(ui->spinBox_width->value()); setFillChar(ui->lineEdit_fill->text().at(0)); + setForceWidth(ui->checkBox_forceWidth->checkState() == Qt::Checked); setMultiplier(ui->doubleSpinBox_multiplier->value()); setSummand(ui->doubleSpinBox_summand->value()); @@ -236,6 +261,7 @@ void AWFloatFormatter::writeConfiguration() const settings.setValue(QString("X-AW-Width"), count()); settings.setValue(QString("X-AW-FillChar"), fillChar()); settings.setValue(QString("X-AW-Format"), format()); + settings.setValue(QString("X-AW-ForceWidth"), forceWidth()); settings.setValue(QString("X-AW-Multiplier"), multiplier()); settings.setValue(QString("X-AW-Precision"), precision()); settings.setValue(QString("X-AW-Summand"), summand()); @@ -254,6 +280,7 @@ void AWFloatFormatter::translate() ui->label_precision->setText(i18n("Precision")); ui->label_width->setText(i18n("Width")); ui->label_fill->setText(i18n("Fill char")); + ui->checkBox_forceWidth->setText(i18n("Force width")); ui->label_multiplier->setText(i18n("Multiplier")); ui->label_summand->setText(i18n("Summand")); } diff --git a/sources/awesomewidgets/awfloatformatter.h b/sources/awesomewidgets/awfloatformatter.h index 7fcb6ef..7a687c7 100644 --- a/sources/awesomewidgets/awfloatformatter.h +++ b/sources/awesomewidgets/awfloatformatter.h @@ -31,6 +31,7 @@ class AWFloatFormatter : public AWAbstractFormatter Q_OBJECT Q_PROPERTY(int count READ count WRITE setCount) Q_PROPERTY(QChar fillChar READ fillChar WRITE setFillChar) + Q_PROPERTY(bool forceWidth READ forceWidth WRITE setForceWidth) Q_PROPERTY(char format READ format WRITE setFormat) Q_PROPERTY(double multiplier READ multiplier WRITE setMultiplier) Q_PROPERTY(int precision READ precision WRITE setPrecision) @@ -45,12 +46,14 @@ public: // properties int count() const; QChar fillChar() const; + bool forceWidth() const; char format() const; double multiplier() const; int precision() const; double summand() const; void setCount(const int _count); void setFillChar(const QChar _fillChar); + void setForceWidth(const bool _forceWidth); void setFormat(char _format); void setMultiplier(const double _multiplier); void setPrecision(const int _precision); @@ -67,6 +70,7 @@ private: // properties int m_count = 0; QChar m_fillChar = QChar(); + bool m_forceWidth = false; char m_format = 'f'; double m_multiplier = 1.0; int m_precision = -1; diff --git a/sources/awesomewidgets/awfloatformatter.ui b/sources/awesomewidgets/awfloatformatter.ui index 8d6a1e6..e4b7e68 100644 --- a/sources/awesomewidgets/awfloatformatter.ui +++ b/sources/awesomewidgets/awfloatformatter.ui @@ -7,7 +7,7 @@ 0 0 420 - 315 + 362 @@ -199,6 +199,36 @@ + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Force width + + + + + diff --git a/sources/awesomewidgets/awstringformatter.cpp b/sources/awesomewidgets/awstringformatter.cpp new file mode 100644 index 0000000..acff42c --- /dev/null +++ b/sources/awesomewidgets/awstringformatter.cpp @@ -0,0 +1,192 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "awstringformatter.h" +#include "ui_awstringformatter.h" + +#include + +#include +#include + +#include "awdebug.h" + + +AWStringFormatter::AWStringFormatter(QWidget *parent, const QString filePath) + : AWAbstractFormatter(parent, filePath) + , ui(new Ui::AWStringFormatter) +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; + + if (!filePath.isEmpty()) + readConfiguration(); + ui->setupUi(this); + translate(); +} + + +AWStringFormatter::~AWStringFormatter() +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; + + delete ui; +} + + +QString AWStringFormatter::convert(const QVariant &_value) const +{ + qCDebug(LOG_LIB) << "Convert value" << _value; + + QString output = QString("%1").arg(_value.toString(), count(), fillChar()); + if (forceWidth()) + output = output.left(count()); + + return output; +} + + +AWStringFormatter *AWStringFormatter::copy(const QString _fileName, + const int _number) +{ + qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; + + AWStringFormatter *item + = new AWStringFormatter(static_cast(parent()), _fileName); + AWAbstractFormatter::copyDefaults(item); + item->setCount(count()); + item->setFillChar(fillChar()); + item->setForceWidth(forceWidth()); + item->setNumber(_number); + + return item; +} + + +int AWStringFormatter::count() const +{ + return m_count; +} + + +QChar AWStringFormatter::fillChar() const +{ + return m_fillChar; +} + + +bool AWStringFormatter::forceWidth() const +{ + return m_forceWidth; +} + + +void AWStringFormatter::setCount(const int _count) +{ + qCDebug(LOG_LIB) << "Set width" << _count; + + m_count = _count; +} + + +void AWStringFormatter::setFillChar(const QChar _fillChar) +{ + qCDebug(LOG_LIB) << "Set char" << _fillChar; + + m_fillChar = _fillChar; +} + + +void AWStringFormatter::setForceWidth(const bool _forceWidth) +{ + qCDebug(LOG_LIB) << "Set force strip" << _forceWidth; + + m_forceWidth = _forceWidth; +} + + +void AWStringFormatter::readConfiguration() +{ + AWAbstractFormatter::readConfiguration(); + + QSettings settings(fileName(), QSettings::IniFormat); + + settings.beginGroup(QString("Desktop Entry")); + setCount(settings.value(QString("X-AW-Width"), count()).toInt()); + setFillChar( + settings.value(QString("X-AW-FillChar"), fillChar()).toString().at(0)); + setForceWidth( + settings.value(QString("X-AW-ForceWidth"), forceWidth()).toBool()); + settings.endGroup(); + + bumpApi(AWEFAPI); +} + + +int AWStringFormatter::showConfiguration(const QVariant args) +{ + Q_UNUSED(args) + + ui->lineEdit_name->setText(name()); + ui->lineEdit_comment->setText(comment()); + ui->label_typeValue->setText(QString("String")); + ui->spinBox_width->setValue(count()); + ui->lineEdit_fill->setText(QString(fillChar())); + ui->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked + : Qt::Unchecked); + + int ret = exec(); + if (ret != 1) + return ret; + setName(ui->lineEdit_name->text()); + setComment(ui->lineEdit_comment->text()); + setStrType(ui->label_typeValue->text()); + setCount(ui->spinBox_width->value()); + setFillChar(ui->lineEdit_fill->text().at(0)); + setForceWidth(ui->checkBox_forceWidth->checkState() == Qt::Checked); + + writeConfiguration(); + return ret; +} + + +void AWStringFormatter::writeConfiguration() const +{ + AWAbstractFormatter::writeConfiguration(); + + QSettings settings(writtableConfig(), QSettings::IniFormat); + qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); + + settings.beginGroup(QString("Desktop Entry")); + settings.setValue(QString("X-AW-Width"), count()); + settings.setValue(QString("X-AW-FillChar"), fillChar()); + settings.setValue(QString("X-AW-ForceWidth"), forceWidth()); + settings.endGroup(); + + settings.sync(); +} + + +void AWStringFormatter::translate() +{ + ui->label_name->setText(i18n("Name")); + ui->label_comment->setText(i18n("Comment")); + ui->label_type->setText(i18n("Type")); + ui->label_width->setText(i18n("Width")); + ui->label_fill->setText(i18n("Fill char")); + ui->checkBox_forceWidth->setText(i18n("Force width")); +} diff --git a/sources/awesomewidgets/awstringformatter.h b/sources/awesomewidgets/awstringformatter.h new file mode 100644 index 0000000..aff823a --- /dev/null +++ b/sources/awesomewidgets/awstringformatter.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#ifndef AWSTRINGFORMATTER_H +#define AWSTRINGFORMATTER_H + +#include "awabstractformatter.h" + + +namespace Ui +{ +class AWStringFormatter; +} + +class AWStringFormatter : public AWAbstractFormatter +{ + Q_OBJECT + Q_PROPERTY(int count READ count WRITE setCount) + Q_PROPERTY(QChar fillChar READ fillChar WRITE setFillChar) + Q_PROPERTY(bool forceWidth READ forceWidth WRITE setForceWidth) + +public: + explicit AWStringFormatter(QWidget *parent, + const QString filePath = QString()); + virtual ~AWStringFormatter(); + QString convert(const QVariant &_value) const; + AWStringFormatter *copy(const QString _fileName, const int _number); + // properties + int count() const; + QChar fillChar() const; + bool forceWidth() const; + void setCount(const int _count); + void setFillChar(const QChar _fillChar); + void setForceWidth(const bool _forceWidth); + +public slots: + void readConfiguration(); + int showConfiguration(const QVariant args = QVariant()); + void writeConfiguration() const; + +private: + Ui::AWStringFormatter *ui = nullptr; + void translate(); + // properties + int m_count = 0; + QChar m_fillChar = QChar(); + bool m_forceWidth = false; +}; + + +#endif /* AWSTRINGFORMATTER_H */ diff --git a/sources/awesomewidgets/awstringformatter.ui b/sources/awesomewidgets/awstringformatter.ui new file mode 100644 index 0000000..3ae5420 --- /dev/null +++ b/sources/awesomewidgets/awstringformatter.ui @@ -0,0 +1,225 @@ + + + AWStringFormatter + + + + 0 + 0 + 420 + 225 + + + + Configuration + + + + + + + + + 0 + 0 + + + + Name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + 0 + 0 + + + + Comment + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + Width + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + -10000 + + + 10000 + + + + + + + + + + + + 0 + 0 + + + + Fill char + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 1 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Force width + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AWStringFormatter + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AWStringFormatter + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index ed1dd2c..c2821a5 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -27,7 +27,7 @@ set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSO ## modules set(TEST_MODULES abstractextitem extquotes extscript extupgrade extweather - abstractformatter datetimeformatter floatformatter listformatter noformatter scriptformatter + abstractformatter datetimeformatter floatformatter listformatter noformatter scriptformatter stringformatter extitemaggregator batterysource desktopsource gpuloadsource gputempsource hddtempsource networksource playersource processessource awconfighelper awkeycache awkeys awpatternfunctions awupdatehelper diff --git a/sources/test/testfloatformatter.cpp b/sources/test/testfloatformatter.cpp index 46ef23e..dbe75c7 100644 --- a/sources/test/testfloatformatter.cpp +++ b/sources/test/testfloatformatter.cpp @@ -49,8 +49,7 @@ void TestAWFloatFormatter::test_count() QCOMPARE(formatter->count(), count); // test - double value = AWTestLibrary::randomDouble(); - QString output = formatter->convert(value); + QString output = formatter->convert(AWTestLibrary::randomDouble()); QCOMPARE(output.count(), count); // reset @@ -67,8 +66,7 @@ void TestAWFloatFormatter::test_fillChar() formatter->setCount(101); // test - int value = AWTestLibrary::randomInt(); - QString output = formatter->convert(value); + QString output = formatter->convert(AWTestLibrary::randomInt()); QVERIFY(output.startsWith(QChar(c))); // reset @@ -77,6 +75,24 @@ void TestAWFloatFormatter::test_fillChar() } +void TestAWFloatFormatter::test_forceWidth() +{ + // assign + int count = AWTestLibrary::randomInt(6); + formatter->setForceWidth(true); + formatter->setCount(count); + QCOMPARE(formatter->forceWidth(), true); + + // test + QString output = formatter->convert(AWTestLibrary::randomDouble()); + QCOMPARE(output.count(), count); + + // reset + formatter->setForceWidth(false); + formatter->setCount(0); +} + + void TestAWFloatFormatter::test_format() { // assign @@ -87,8 +103,7 @@ void TestAWFloatFormatter::test_format() QCOMPARE(formatter->format(), 'e'); // test - double value = AWTestLibrary::randomDouble(); - QString output = formatter->convert(value); + QString output = formatter->convert(AWTestLibrary::randomDouble()); QVERIFY(output.contains('e')); // reset @@ -104,8 +119,7 @@ void TestAWFloatFormatter::test_precision() QCOMPARE(formatter->precision(), precision); // test - double value = AWTestLibrary::randomDouble(); - QString output = formatter->convert(value); + QString output = formatter->convert(AWTestLibrary::randomDouble()); output.remove(QString("0.")); QCOMPARE(output.count(), precision); @@ -157,6 +171,7 @@ void TestAWFloatFormatter::test_copy() QCOMPARE(newFormatter->count(), formatter->count()); QCOMPARE(newFormatter->fillChar(), formatter->fillChar()); + QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth()); QCOMPARE(newFormatter->format(), formatter->format()); QCOMPARE(newFormatter->multiplier(), formatter->multiplier()); QCOMPARE(newFormatter->precision(), formatter->precision()); @@ -171,6 +186,7 @@ void TestAWFloatFormatter::doRandom() { formatter->setCount(AWTestLibrary::randomInt()); formatter->setFillChar(QChar(AWTestLibrary::randomChar())); + formatter->setForceWidth(AWTestLibrary::randomInt() % 2); formatter->setFormat(AWTestLibrary::randomChar()); formatter->setMultiplier(AWTestLibrary::randomDouble()); formatter->setPrecision(AWTestLibrary::randomInt()); diff --git a/sources/test/testfloatformatter.h b/sources/test/testfloatformatter.h index 77746c9..bdb0e0d 100644 --- a/sources/test/testfloatformatter.h +++ b/sources/test/testfloatformatter.h @@ -36,6 +36,7 @@ private slots: void test_values(); void test_count(); void test_fillChar(); + void test_forceWidth(); void test_format(); void test_precision(); void test_multiplier(); diff --git a/sources/test/teststringformatter.cpp b/sources/test/teststringformatter.cpp new file mode 100644 index 0000000..a7f98b6 --- /dev/null +++ b/sources/test/teststringformatter.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 "teststringformatter.h" + +#include + +#include "awstringformatter.h" +#include "awtestlibrary.h" + + +void TestAWStringFormatter::initTestCase() +{ + formatter = new AWStringFormatter(nullptr); +} + + +void TestAWStringFormatter::cleanupTestCase() +{ + delete formatter; +} + + +void TestAWStringFormatter::test_values() +{ +} + + +void TestAWStringFormatter::test_count() +{ + // assign + int count = 10 + AWTestLibrary::randomInt(); + formatter->setCount(count); + QCOMPARE(formatter->count(), count); + + // test + QString output = formatter->convert(AWTestLibrary::randomString()); + QCOMPARE(output.count(), count); + + // reset + formatter->setCount(0); +} + + +void TestAWStringFormatter::test_fillChar() +{ + // assign + char c = AWTestLibrary::randomChar(); + formatter->setFillChar(QChar(c)); + QCOMPARE(formatter->fillChar(), QChar(c)); + formatter->setCount(101); + + // test + QString output = formatter->convert(AWTestLibrary::randomString()); + QVERIFY(output.startsWith(QChar(c))); + + // reset + formatter->setFillChar(QChar()); + formatter->setCount(0); +} + + +void TestAWStringFormatter::test_forceWidth() +{ + // assign + int count = AWTestLibrary::randomInt(); + formatter->setForceWidth(true); + formatter->setCount(count); + QCOMPARE(formatter->forceWidth(), true); + + // test + QString output = formatter->convert(AWTestLibrary::randomString()); + QCOMPARE(output.count(), count); + + // reset + formatter->setForceWidth(false); + formatter->setCount(0); +} + + +void TestAWStringFormatter::test_copy() +{ + doRandom(); + AWStringFormatter *newFormatter = formatter->copy(QString("/dev/null"), 1); + + QCOMPARE(newFormatter->count(), formatter->count()); + QCOMPARE(newFormatter->fillChar(), formatter->fillChar()); + QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth()); + QCOMPARE(newFormatter->number(), 1); + + delete newFormatter; +} + + +void TestAWStringFormatter::doRandom() +{ + formatter->setCount(AWTestLibrary::randomInt()); + formatter->setFillChar(QChar(AWTestLibrary::randomChar())); + formatter->setForceWidth(AWTestLibrary::randomInt() % 2); +} + + +QTEST_MAIN(TestAWStringFormatter); diff --git a/sources/test/teststringformatter.h b/sources/test/teststringformatter.h new file mode 100644 index 0000000..6ebe95d --- /dev/null +++ b/sources/test/teststringformatter.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef TESTSTRINGFORMATTER_H +#define TESTSTRINGFORMATTER_H + +#include + + +class AWStringFormatter; + +class TestAWStringFormatter : public QObject +{ + Q_OBJECT + +private slots: + // initialization + void initTestCase(); + void cleanupTestCase(); + // test + void test_values(); + void test_count(); + void test_fillChar(); + void test_forceWidth(); + void test_copy(); + +private: + void doRandom(); + AWStringFormatter *formatter = nullptr; +}; + + +#endif /* TESTSTRINGFORMATTER_H */ From 4adf457adabe69bb77e0fa462f1eb35529859695 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Fri, 8 Jul 2016 13:51:29 +0300 Subject: [PATCH 14/14] translation update --- sources/translations/awesome-widgets.pot | 5 ++++- sources/translations/en.po | 7 +++++-- sources/translations/es.po | 5 ++++- sources/translations/fr.po | 5 ++++- sources/translations/nl_NL.po | 5 ++++- sources/translations/pl.po | 5 ++++- sources/translations/pt_BR.po | 5 ++++- sources/translations/ru.po | 7 +++++-- sources/translations/uk.po | 5 ++++- sources/translations/zh.po | 5 ++++- 10 files changed, 42 insertions(+), 12 deletions(-) diff --git a/sources/translations/awesome-widgets.pot b/sources/translations/awesome-widgets.pot index 1d4f350..edd4366 100644 --- a/sources/translations/awesome-widgets.pot +++ b/sources/translations/awesome-widgets.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -522,6 +522,9 @@ msgstr "" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/en.po b/sources/translations/en.po index f03eb41..2fd7652 100644 --- a/sources/translations/en.po +++ b/sources/translations/en.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" -"PO-Revision-Date: 2016-07-04 16:22+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" +"PO-Revision-Date: 2016-07-06 19:37+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: English \n" "Language: ru\n" @@ -527,6 +527,9 @@ msgstr "Width" msgid "Fill char" msgstr "Fill char" +msgid "Force width" +msgstr "Force width" + msgid "Multiplier" msgstr "Multiplier" diff --git a/sources/translations/es.po b/sources/translations/es.po index 9a1e795..dad0291 100644 --- a/sources/translations/es.po +++ b/sources/translations/es.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\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/" @@ -534,6 +534,9 @@ msgstr "Ancho" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/fr.po b/sources/translations/fr.po index 1b30321..3d9e8e6 100644 --- a/sources/translations/fr.po +++ b/sources/translations/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: 2015-07-31 22:16+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: French \n" @@ -552,6 +552,9 @@ msgstr "" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/nl_NL.po b/sources/translations/nl_NL.po index 8da5b58..8bf5a6e 100644 --- a/sources/translations/nl_NL.po +++ b/sources/translations/nl_NL.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: 2015-08-20 22:52+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Dutch \n" @@ -554,6 +554,9 @@ msgstr "Breedte" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/pl.po b/sources/translations/pl.po index 6f0c957..6cfe14a 100644 --- a/sources/translations/pl.po +++ b/sources/translations/pl.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -532,6 +532,9 @@ msgstr "Szerokość" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/pt_BR.po b/sources/translations/pt_BR.po index 8724237..cba4fe7 100644 --- a/sources/translations/pt_BR.po +++ b/sources/translations/pt_BR.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: 2015-07-31 22:21+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Russian \n" @@ -548,6 +548,9 @@ msgstr "Largura" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/ru.po b/sources/translations/ru.po index 5e190ed..2552ccf 100644 --- a/sources/translations/ru.po +++ b/sources/translations/ru.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" -"PO-Revision-Date: 2016-07-04 16:22+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" +"PO-Revision-Date: 2016-07-06 19:37+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Russian \n" "Language: ru\n" @@ -527,6 +527,9 @@ msgstr "Ширина" msgid "Fill char" msgstr "Заполнение" +msgid "Force width" +msgstr "Зафиксировать ширину" + msgid "Multiplier" msgstr "Множитель" diff --git a/sources/translations/uk.po b/sources/translations/uk.po index a5e42a2..92fa462 100644 --- a/sources/translations/uk.po +++ b/sources/translations/uk.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: 2016-05-05 17:18+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Ukrainian \n" @@ -532,6 +532,9 @@ msgstr "Ширина" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr "" diff --git a/sources/translations/zh.po b/sources/translations/zh.po index 9a12bdd..3316d35 100644 --- a/sources/translations/zh.po +++ b/sources/translations/zh.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2016-07-04 16:21+0300\n" +"POT-Creation-Date: 2016-07-06 19:36+0300\n" "PO-Revision-Date: 2015-07-31 22:24+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Russian \n" @@ -533,6 +533,9 @@ msgstr "宽度" msgid "Fill char" msgstr "" +msgid "Force width" +msgstr "" + msgid "Multiplier" msgstr ""