From ea5d73d8fddd6db2f83515be851ae08dec4bcb1e Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Thu, 24 Aug 2017 01:20:27 +0300 Subject: [PATCH 01/35] add more battery retalted keys --- sources/CMakeLists.txt | 34 +---- sources/compiler.cmake | 29 +++++ sources/extsysmonsources/batterysource.cpp | 143 ++++++++++++++++++--- sources/extsysmonsources/batterysource.h | 4 + 4 files changed, 167 insertions(+), 43 deletions(-) create mode 100644 sources/compiler.cmake diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index f7209f0..80d2ebc 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 2.8.12) # some fucking magic -cmake_policy(SET CMP0003 OLD) -cmake_policy(SET CMP0002 OLD) cmake_policy(SET CMP0011 NEW) cmake_policy(SET CMP0015 NEW) if (POLICY CMP0063) @@ -41,40 +39,23 @@ option(BUILD_TESTING "Build with additional test abilities" OFF) set(PROJECT_CHANGELOG "Changelog" CACHE INTERNAL "") include(changelog.cmake) -# flags -if (CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") - set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") - # avoid newer gcc warnings - add_definitions(-D_DEFAULT_SOURCE) -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -std=c++11") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") - set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") - # linker flags -else () - message(FATAL_ERROR "Unknown compiler") -endif () -if (CMAKE_BUILD_TYPE MATCHES Debug) - set(CMAKE_VERBOSE_MAKEFILE ON) -endif () - -# required by successfully coverity and cppcheck build -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - +# directories set(PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty) set(PROJECT_LIBRARY awesomewidgets) set(PROJECT_MONITORSOURCES extsysmonsources) + +# modules +include(compiler.cmake) include(libraries.cmake) include(clang-format.cmake) include(cppcheck.cmake) include(coverity.cmake) +# pre-configure get_directory_property(CMAKE_DEFINITIONS COMPILE_DEFINITIONS) configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) + +# build components add_subdirectory(awesomewidgets) add_subdirectory(extsysmonsources) add_subdirectory(extsysmon) @@ -90,4 +71,3 @@ if (BUILD_TESTING) endif () include(packages-recipe.cmake) - diff --git a/sources/compiler.cmake b/sources/compiler.cmake new file mode 100644 index 0000000..9e6a05c --- /dev/null +++ b/sources/compiler.cmake @@ -0,0 +1,29 @@ +# flags +if (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "-Wall") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") + set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") + # avoid newer gcc warnings + add_definitions(-D_DEFAULT_SOURCE) +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "-Wall") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") + set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") + # linker flags +else () + message(FATAL_ERROR "Unknown compiler") +endif () + +# some flags +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# verbose output for debug builds +if (CMAKE_BUILD_TYPE MATCHES Debug) + set(CMAKE_VERBOSE_MAKEFILE ON) +endif () + +# required by successfully coverity and cppcheck build +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp index 1219de6..b658e61 100644 --- a/sources/extsysmonsources/batterysource.cpp +++ b/sources/extsysmonsources/batterysource.cpp @@ -31,6 +31,7 @@ BatterySource::BatterySource(QObject *_parent, const QStringList &_args) m_acpiPath = _args.at(0); m_sources = getSources(); + m_timestamp = QDateTime::currentDateTimeUtc(); } @@ -45,14 +46,23 @@ QStringList BatterySource::getSources() QStringList sources; sources.append("battery/ac"); sources.append("battery/bat"); + sources.append("battery/batleft"); + sources.append("battery/batnow"); + sources.append("battery/batrate"); + sources.append("battery/battotal"); m_batteriesCount = QDir(m_acpiPath) .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) .count(); qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount; - for (int i = 0; i < m_batteriesCount; i++) + for (int i = 0; i < m_batteriesCount; i++) { sources.append(QString("battery/bat%1").arg(i)); + sources.append(QString("battery/batleft%1").arg(i)); + sources.append(QString("battery/batnow%1").arg(i)); + sources.append(QString("battery/batrate%1").arg(i)); + sources.append(QString("battery/battotal%1").arg(i)); + } qCInfo(LOG_ESS) << "Sources list" << sources; return sources; @@ -87,7 +97,55 @@ QVariantMap BatterySource::initialData(const QString &_source) const data["name"] = "Average battery usage"; data["type"] = "integer"; data["units"] = "%"; - } else { + } else if (_source == "battery/batleft") { + data["min"] = 0; + data["max"] = 0; + data["name"] = "Battery discharge time"; + data["type"] = "integer"; + data["units"] = "s"; + } else if (_source == "battery/batnow") { + data["min"] = 0; + data["max"] = 0; + data["name"] = "Current battery capacity"; + data["type"] = "integer"; + data["units"] = ""; + } else if (_source == "battery/batrate") { + data["min"] = 0; + data["max"] = 0; + data["name"] = "Average battery discharge rate"; + data["type"] = "float"; + data["units"] = "1/s"; + } else if (_source == "battery/battotal") { + data["min"] = 0; + data["max"] = 0; + data["name"] = "Full battery capacity"; + data["type"] = "integer"; + data["units"] = ""; + } else if (_source == "battery/batleft") { + data["min"] = 0; + data["max"] = 0; + data["name"] = QString("Battery %1 discharge time").arg(index(_source)); + data["type"] = "integer"; + data["units"] = "s"; + } else if (_source.startsWith("battery/batnow")) { + data["min"] = 0; + data["max"] = 0; + data["name"] = QString("Battery %1 capacity").arg(index(_source)); + data["type"] = "integer"; + data["units"] = ""; + } else if (_source.startsWith("battery/battotal")) { + data["min"] = 0; + data["max"] = 0; + data["name"] = QString("Battery %1 full capacity").arg(index(_source)); + data["type"] = "integer"; + data["units"] = ""; + } else if (_source.startsWith("battery/batrate")) { + data["min"] = 0; + data["max"] = 0; + data["name"] = QString("Battery %1 discharge rate").arg(index(_source)); + data["type"] = "float"; + data["units"] = "1/s"; + } else if (_source.startsWith("battery/bat")) { data["min"] = 0; data["max"] = 100; data["name"] = QString("Battery %1 usage").arg(index(_source)); @@ -101,6 +159,9 @@ QVariantMap BatterySource::initialData(const QString &_source) const void BatterySource::run() { + // swap data + m_previousValues.swap(m_values); + // adaptor QFile acFile(QString("%1/AC/online").arg(m_acpiPath)); if (acFile.open(QIODevice::ReadOnly | QIODevice::Text)) @@ -109,28 +170,37 @@ void BatterySource::run() acFile.close(); // batteries - float currentLevel = 0.0; - float fullLevel = 0.0; + float currentLevel = 0.0, fullLevel = 0.0; for (int i = 0; i < m_batteriesCount; i++) { + // current level QFile currentLevelFile( QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i)); + if (currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) + m_values[QString("battery/batnow%1").arg(i)] + = QString(currentLevelFile.readLine()).toInt(); + currentLevelFile.close(); + // total QFile fullLevelFile( QString("%1/BAT%2/energy_full").arg(m_acpiPath).arg(i)); - if ((currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) - && (fullLevelFile.open(QIODevice::ReadOnly | QIODevice::Text))) { - float batCurrent - = QString(currentLevelFile.readLine()).trimmed().toFloat(); - float batFull - = QString(fullLevelFile.readLine()).trimmed().toFloat(); - m_values[QString("battery/bat%1").arg(i)] - = static_cast(100 * batCurrent / batFull); - currentLevel += batCurrent; - fullLevel += batFull; - } - currentLevelFile.close(); + if (fullLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) + m_values[QString("battery/battotal%1").arg(i)] + = QString(fullLevelFile.readLine()).toInt(); fullLevelFile.close(); + + m_values[QString("battery/bat%1").arg(i)] = static_cast( + 100 * m_values[QString("battery/batnow%1").arg(i)].toFloat() + / m_values[QString("battery/battotal%1").arg(i)].toFloat()); + // accumulate + currentLevel += m_values[QString("battery/batnow%1").arg(i)].toFloat(); + fullLevel += m_values[QString("battery/battotal%1").arg(i)].toFloat(); } + + // total + m_values["battery/batnow"] = static_cast(currentLevel); + m_values["battery/battotal"] = static_cast(fullLevel); m_values["battery/bat"] = static_cast(100 * currentLevel / fullLevel); + + calculateRates(); } @@ -138,3 +208,44 @@ QStringList BatterySource::sources() const { return m_sources; } + + +void BatterySource::calculateRates() +{ + // we are using moving average to get good numbers + // check time interval + auto now = QDateTime::currentDateTimeUtc(); + auto interval + = 1000 * (now.toMSecsSinceEpoch() - m_timestamp.toMSecsSinceEpoch()); + m_timestamp.swap(now); + + // check time + if (m_previousValues.empty()) { + qCInfo(LOG_ESS) << "No historical data found for charges, exit"; + return; + } + + // per battery + for (int i = 0; i < m_batteriesCount; i++) { + auto rate + = (m_values[QString("battery/batnow%1").arg(i)].toInt() + - m_previousValues[QString("battery/batnow%1").arg(i)].toInt()) + / interval; + m_values[QString("battery/batrate%1").arg(i)] + = (m_previousValues[QString("battery/batrate%1").arg(i)].toInt() + + rate) + / 2; + m_values[QString("battery/batleft%1").arg(i)] + = m_values[QString("battery/batnow%1").arg(i)].toInt() + / m_values[QString("battery/batrate%1").arg(i)].toInt(); + } + + // total + auto totalRate = (m_values["battery/batnow"].toInt() + - m_previousValues["battery/batnow"].toInt()) + / interval; + m_values["battery/batrate"] + = (totalRate + m_previousValues["battery/batrate"].toInt()) / 2; + m_values["battery/batleft"] = m_values["battery/batnow"].toInt() + / m_values["battery/batrate"].toInt(); +} diff --git a/sources/extsysmonsources/batterysource.h b/sources/extsysmonsources/batterysource.h index c914213..9840193 100644 --- a/sources/extsysmonsources/batterysource.h +++ b/sources/extsysmonsources/batterysource.h @@ -18,6 +18,7 @@ #ifndef BATTERYSOURCE_H #define BATTERYSOURCE_H +#include #include #include "abstractextsysmonsource.h" @@ -37,11 +38,14 @@ public: QStringList sources() const; private: + void calculateRates(); // configuration and values int m_batteriesCount = 0; QString m_acpiPath; QStringList m_sources; + QDateTime m_timestamp; QVariantHash m_values; + QVariantHash m_previousValues; }; From 2d7d4c55a21b3bdc26a68f7bfb5987c265d4c6a8 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Fri, 25 Aug 2017 06:11:18 +0300 Subject: [PATCH 02/35] use MSD for battery calculations, fix segfault --- .../plugin/awdataenginemapper.cpp | 4 +- .../awesome-widget/plugin/awkeyoperations.cpp | 7 +- sources/extsysmonsources/batterysource.cpp | 87 +++++++++++-------- sources/extsysmonsources/batterysource.h | 5 +- sources/version.h.in | 6 +- 5 files changed, 68 insertions(+), 41 deletions(-) diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index afcf602..581d0f0 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -106,7 +106,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, QString key = _source; key.remove("battery/"); m_map[_source] = key; - m_formatter[key] = AWKeysAggregator::FormatterType::IntegerThree; + m_formatter[key] = _source.contains("rate") + ? AWKeysAggregator::FormatterType::Float + : AWKeysAggregator::FormatterType::IntegerThree; } else if (_source == "cpu/system/TotalLoad") { // cpu m_map[_source] = "cpu"; diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 7f992da..7f6cb1a 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -136,8 +136,13 @@ QStringList AWKeyOperations::dictKeys() const = QDir("/sys/class/power_supply") .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - for (int i = 0; i < allBatteryDevices.count(); i++) + for (int i = 0; i < allBatteryDevices.count(); i++) { allKeys.append(QString("bat%1").arg(i)); + allKeys.append(QString("batleft%1").arg(i)); + allKeys.append(QString("batnow%1").arg(i)); + allKeys.append(QString("batrate%1").arg(i)); + allKeys.append(QString("battotal%1").arg(i)); + } // package manager for (auto &item : m_extUpgrade->activeItems()) allKeys.append(item->tag("pkgcount")); diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp index b658e61..810ce9c 100644 --- a/sources/extsysmonsources/batterysource.cpp +++ b/sources/extsysmonsources/batterysource.cpp @@ -20,6 +20,8 @@ #include +#include + #include "awdebug.h" @@ -31,7 +33,6 @@ BatterySource::BatterySource(QObject *_parent, const QStringList &_args) m_acpiPath = _args.at(0); m_sources = getSources(); - m_timestamp = QDateTime::currentDateTimeUtc(); } @@ -50,12 +51,14 @@ QStringList BatterySource::getSources() sources.append("battery/batnow"); sources.append("battery/batrate"); sources.append("battery/battotal"); + m_batteriesCount = QDir(m_acpiPath) .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) .count(); qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount; + for (int i = 0; i < m_batteriesCount; i++) { sources.append(QString("battery/bat%1").arg(i)); sources.append(QString("battery/batleft%1").arg(i)); @@ -159,9 +162,6 @@ QVariantMap BatterySource::initialData(const QString &_source) const void BatterySource::run() { - // swap data - m_previousValues.swap(m_values); - // adaptor QFile acFile(QString("%1/AC/online").arg(m_acpiPath)); if (acFile.open(QIODevice::ReadOnly | QIODevice::Text)) @@ -175,9 +175,11 @@ void BatterySource::run() // current level QFile currentLevelFile( QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i)); - if (currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) - m_values[QString("battery/batnow%1").arg(i)] - = QString(currentLevelFile.readLine()).toInt(); + if (currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + auto value = QString(currentLevelFile.readLine()).toInt(); + m_trend[i + 1].append(value); + m_values[QString("battery/batnow%1").arg(i)] = value; + } currentLevelFile.close(); // total QFile fullLevelFile( @@ -196,6 +198,7 @@ void BatterySource::run() } // total + m_trend[0].append(static_cast(currentLevel)); m_values["battery/batnow"] = static_cast(currentLevel); m_values["battery/battotal"] = static_cast(fullLevel); m_values["battery/bat"] = static_cast(100 * currentLevel / fullLevel); @@ -210,42 +213,56 @@ QStringList BatterySource::sources() const } +double BatterySource::approximate(const QList &_trend) +{ + qCDebug(LOG_ESS) << "Approximate by MSD" << _trend; + + auto count = _trend.count(); + + auto sumxy = 0; + for (int i = 0; i < count; i++) + sumxy += _trend.at(i) * (i + 1); + + auto sumx = count * (count + 1) / 2; + auto sumy = std::accumulate(_trend.cbegin(), _trend.cend(), 0); + auto sumx2 = count * (count + 1) * (2 * count + 1) / 6; + + return (count * sumxy - sumx * sumy) / (count * sumx2 - std::pow(sumx, 2)); +} + + void BatterySource::calculateRates() { - // we are using moving average to get good numbers - // check time interval - auto now = QDateTime::currentDateTimeUtc(); - auto interval - = 1000 * (now.toMSecsSinceEpoch() - m_timestamp.toMSecsSinceEpoch()); - m_timestamp.swap(now); - - // check time - if (m_previousValues.empty()) { - qCInfo(LOG_ESS) << "No historical data found for charges, exit"; + // check if it is first run + if (!m_timestamp.isValid()) { + m_timestamp = QDateTime::currentDateTimeUtc(); return; } - // per battery + // check time interval + auto now = QDateTime::currentDateTimeUtc(); + auto interval + = (now.toMSecsSinceEpoch() - m_timestamp.toMSecsSinceEpoch()) / 1000.0f; + m_timestamp.swap(now); + for (int i = 0; i < m_batteriesCount; i++) { - auto rate - = (m_values[QString("battery/batnow%1").arg(i)].toInt() - - m_previousValues[QString("battery/batnow%1").arg(i)].toInt()) - / interval; - m_values[QString("battery/batrate%1").arg(i)] - = (m_previousValues[QString("battery/batrate%1").arg(i)].toInt() - + rate) - / 2; + auto approx = approximate(m_trend[i + 1]); + m_values[QString("battery/batrate%1").arg(i)] = approx / interval; m_values[QString("battery/batleft%1").arg(i)] - = m_values[QString("battery/batnow%1").arg(i)].toInt() - / m_values[QString("battery/batrate%1").arg(i)].toInt(); + = interval * m_values[QString("battery/batnow%1").arg(i)].toFloat() + / approx; } // total - auto totalRate = (m_values["battery/batnow"].toInt() - - m_previousValues["battery/batnow"].toInt()) - / interval; - m_values["battery/batrate"] - = (totalRate + m_previousValues["battery/batrate"].toInt()) / 2; - m_values["battery/batleft"] = m_values["battery/batnow"].toInt() - / m_values["battery/batrate"].toInt(); + auto approx = approximate(m_trend[0]); + m_values["battery/batrate"] = approx / interval; + m_values["battery/batleft"] + = interval * m_values["battery/batnow"].toFloat() / approx; + + // old data cleanup + for (auto &trend : m_trend.keys()) { + if (m_trend[trend].count() <= TREND_LIMIT) + continue; + m_trend[trend].removeFirst(); + } } diff --git a/sources/extsysmonsources/batterysource.h b/sources/extsysmonsources/batterysource.h index 9840193..11763f3 100644 --- a/sources/extsysmonsources/batterysource.h +++ b/sources/extsysmonsources/batterysource.h @@ -29,6 +29,8 @@ class BatterySource : public AbstractExtSysMonSource Q_OBJECT public: + const int TREND_LIMIT = 20; + explicit BatterySource(QObject *_parent, const QStringList &_args); virtual ~BatterySource(); QStringList getSources(); @@ -38,14 +40,15 @@ public: QStringList sources() const; private: + double approximate(const QList &_trend); void calculateRates(); // configuration and values int m_batteriesCount = 0; QString m_acpiPath; QStringList m_sources; QDateTime m_timestamp; + QHash> m_trend; QVariantHash m_values; - QVariantHash m_previousValues; }; diff --git a/sources/version.h.in b/sources/version.h.in index 56d4ec4..ad4b040 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -59,9 +59,9 @@ const char STATIC_KEYS[] "gputemp,gpu,memmb,memgb,memfreemb,memfreegb,memtotmb,memtotgb,memusedmb," "memusedgb,mem,swapmb,swapgb,swapfreemb,swapfreegb,swaptotmb,swaptotgb," "swap,downunits,upunits,downkb,downtotkb,downtot,down,uptotkb,uptot,upkb," - "up,netdev,ac,bat,album,artist,duration,progress,title,dalbum,dartist," - "dtitle,salbum,sartist,stitle,pscount,pstot,ps,desktop,ndesktop," - "tdesktops,la15,la5,la1"; + "up,netdev,ac,bat,batleft,batnow,batrate,battotal,album,artist,duration," + "progress,title,dalbum,dartist,dtitle,salbum,sartist,stitle,pscount,pstot" + ",ps,desktop,ndesktop,tdesktops,la15,la5,la1"; #cmakedefine BUILD_FUTURE #cmakedefine BUILD_LOAD #cmakedefine BUILD_TESTING From 5886dcc50b1060a6b2c180a4698b807646f194c1 Mon Sep 17 00:00:00 2001 From: "Ibnu D. Aji" Date: Sat, 2 Dec 2017 01:21:36 +0700 Subject: [PATCH 03/35] Finished ID translation. --- .vscode/temp.sql | 0 sources/translations/id_ID.po | 786 ++++++++++++++++++++++++++++++++++ 2 files changed, 786 insertions(+) create mode 100644 .vscode/temp.sql create mode 100644 sources/translations/id_ID.po diff --git a/.vscode/temp.sql b/.vscode/temp.sql new file mode 100644 index 0000000..e69de29 diff --git a/sources/translations/id_ID.po b/sources/translations/id_ID.po new file mode 100644 index 0000000..0aafca0 --- /dev/null +++ b/sources/translations/id_ID.po @@ -0,0 +1,786 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Translators: +# Ibnu Daru Aji , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Awesome widgets\n" +"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" +"POT-Creation-Date: 2017-07-13 17:39+0300\n" +"PO-Revision-Date: 2016-07-09 08:47+0000\n" +"Last-Translator: Heimen Stoffels \n" +"Language-Team: Bahasa (Bahasa Indonesia) (http://www.transifex.com/arcanis/awesome-" +"widgets/language/id_ID/)\n" +"Language: id_ID\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Version %1 (build date %2)" +msgstr "Versi %1 (tanggal bangun %2)" + +msgid "A set of minimalistic plasmoid widgets" +msgstr "Seperangkat widget plasmoid minimalis" + +msgid "Links:" +msgstr "Tautan:" + +msgid "Homepage" +msgstr "Laman web" + +msgid "Repository" +msgstr "Lumbung" + +msgid "Bugtracker" +msgstr "Bugtracker" + +msgid "Translation issue" +msgstr "Masalah terjemahan" + +msgid "AUR packages" +msgstr "Paket AUR" + +msgid "openSUSE packages" +msgstr "paket openSUSE" + +msgid "This software is licensed under %1" +msgstr "Perangkat lunak ini berlisensi %1" + +#, fuzzy +msgid "Translators:" +msgstr "Penerjemah: %1" + +#, fuzzy +msgid "This software uses:" +msgstr "Perangkat lunak ini menggunakan: %1" + +#, fuzzy +msgid "Special thanks to:" +msgstr "Terima kasih banyak kepada: %1" + +msgid "Widget" +msgstr "Widget" + +msgid "Advanced" +msgstr "Tingkat Lanjut" + +msgid "Tooltip" +msgstr "Tooltip" + +msgid "Appearance" +msgstr "Penampilan" + +msgid "DataEngine" +msgstr "DataEngine" + +msgid "About" +msgstr "Tentang" + +msgid "Enable background" +msgstr "Aktifkan latar belakang" + +msgid "Translate strings" +msgstr "Terjemahkan string" + +msgid "Wrap new lines" +msgstr "Tekuk baris baru" + +msgid "Enable word wrap" +msgstr "Aktifkan penekuk baris" + +msgid "Enable notifications" +msgstr "Aktifkan pemberitahuan" + +msgid "Check updates on startup" +msgstr "Periksa pemutakhiran saat mulai" + +msgid "Optimize subscription" +msgstr "Optimasi langganan" + +msgid "Widget height, px" +msgstr "Tinggi widget, px" + +msgid "Widget width, px" +msgstr "Lebar widget, px" + +msgid "Time interval" +msgstr "Jeda waktu" + +msgid "Messages queue limit" +msgstr "Batas antrian pesan" + +msgid "Celsius" +msgstr "Celsius" + +msgid "Fahrenheit" +msgstr "Fahrenheit" + +msgid "Kelvin" +msgstr "Kelvin" + +msgid "Reaumur" +msgstr "Reaumur" + +msgid "cm^-1" +msgstr "cm^-1" + +msgid "kJ/mol" +msgstr "kJ/mol" + +msgid "kcal/mol" +msgstr "kcal/mol" + +msgid "Temperature units" +msgstr "Unit temperatur" + +msgid "Custom time format" +msgstr "Format waktu lain" + +msgid "Custom uptime format" +msgstr "Format waktu nyala lain" + +msgid "AC online tag" +msgstr "Label AC daring" + +msgid "AC offline tag" +msgstr "Label AC luring" + +#, fuzzy +msgid "Actions" +msgstr "Aksi" + +msgid "Drop key cache" +msgstr "Hapus tembolok kunci" + +msgid "Export configuration" +msgstr "Ekspor konfigurasi" + +msgid "Import configuration" +msgstr "Impor konfigurasi" + +msgid "Telemetry" +msgstr "Telemetri" + +msgid "Enable remote telemetry" +msgstr "Aktifkan telemetri remote" + +#, fuzzy +msgid "History count" +msgstr "Jumlah riwayat" + +msgid "Telemetry ID" +msgstr "ID Telemetri" + +msgid "Font" +msgstr "Fonta" + +msgid "Font size" +msgstr "Ukuran fonta" + +msgid "Font weight" +msgstr "Bobot fonta" + +msgid "Font style" +msgstr "Gaya fonta" + +msgid "Font color" +msgstr "Warna fonta" + +msgid "Style" +msgstr "Gaya" + +#, fuzzy +msgid "Style color" +msgstr "Warna gaya" + +msgid "ACPI" +msgstr "ACPI" + +msgid "ACPI path" +msgstr "ACPI-path" + +msgid "GPU" +msgstr "GPU" + +msgid "GPU device" +msgstr "Divais GPU" + +msgid "HDD temperature" +msgstr "Temperatur HDD" + +msgid "HDD" +msgstr "HDD" + +msgid "hddtemp cmd" +msgstr "hddtemp cmd" + +msgid "Player" +msgstr "Pemutar musik" + +msgid "Player data symbols" +msgstr "Data simbol pemutar musik" + +msgid "Music player" +msgstr "Pemutar musik" + +msgid "MPRIS player name" +msgstr "MPRIS nama pemain" + +msgid "MPD address" +msgstr "Alamat MPD" + +msgid "MPD port" +msgstr "Port MPD" + +msgid "Extensions" +msgstr "Ekstensi" + +msgid "Custom scripts" +msgstr "Skrip lain" + +#, fuzzy +msgid "Network requests" +msgstr "Jaringan" + +msgid "Package manager" +msgstr "Manajer paket" + +msgid "Quotes monitor" +msgstr "Monitor kutipan" + +msgid "Weather" +msgstr "Cuaca" + +msgid "Select tag" +msgstr "Pilih penanda" + +msgid "Tag: %1" +msgstr "Penanda: %1" + +msgid "Value: %1" +msgstr "Nilai: %1" + +msgid "Info: %1" +msgstr "Informasi: %1" + +msgid "Request key" +msgstr "Kunci permintaan" + +msgid "Show README" +msgstr "Perlihatkan README" + +msgid "Check updates" +msgstr "Periksa pemutakhiran" + +msgid "Report bug" +msgstr "Laporkan kutu" + +msgid "" +"CPU, CPU clock, memory, swap and network labels support graphical tooltip. " +"To enable them just make needed checkbox checked." +msgstr "" +"Label CPU, frekuensi CPU, memori, swap, dan jaringan mendukung tooltip grafik" +"Untuk mengaktifkanya, cukup tandai kotak centang." + +msgid "Number of values for tooltips" +msgstr "Jumlah nilai untuk tooltip" + +msgid "Background" +msgstr "Latar belakang" + +msgid "Background color" +msgstr "Warna latar belakang" + +msgid "CPU" +msgstr "CPU" + +msgid "CPU color" +msgstr "Warna CPU" + +msgid "CPU clock" +msgstr "Frekuensi CPU" + +msgid "CPU clock color" +msgstr "Warna CPU frekuensi" + +msgid "Memory" +msgstr "Memori" + +msgid "Memory color" +msgstr "Warna memori" + +msgid "Swap" +msgstr "SWAP" + +msgid "Swap color" +msgstr "Warna swap" + +msgid "Network" +msgstr "Jaringan" + +msgid "Download speed color" +msgstr "Warna kecepatan unduh" + +msgid "Upload speed color" +msgstr "Warna kecepatan unggah" + +msgid "Battery" +msgstr "Batere" + +msgid "Battery active color" +msgstr "Warna batere aktif" + +msgid "Battery inactive color" +msgstr "Warna batere non-aktif" + +msgid "Edit" +msgstr "Sunting" + +msgid "Run %1" +msgstr "Jalankan %1" + +msgid "Not supported" +msgstr "Tidak didukung" + +msgid "You are using mammoth's Qt version, try to update it first" +msgstr "Anda menggunakan Qt versi mammoth, silakan coba untuk memperbarui" + +msgid "Select font" +msgstr "Pilih fonta" + +msgid "Issue created" +msgstr "Isu terbuat" + +msgid "Issue %1 has been created" +msgstr "Isu %1 sudah terbuat" + +msgid "AC online" +msgstr "AC daring" + +msgid "AC offline" +msgstr "AC luring" + +msgid "High CPU load" +msgstr "Tinggi beban CPU" + +msgid "High memory usage" +msgstr "Tinggi beban memori" + +msgid "Swap is used" +msgstr "Swap digunakan" + +msgid "High GPU load" +msgstr "Tinggi beban GPU" + +msgid "Network device has been changed to %1" +msgstr "Divais jaringan telah berganti ke %1" + +msgid "Select type" +msgstr "Pilih tipe" + +msgid "Type:" +msgstr "Tipe:" + +msgid "MB/s" +msgstr "MB/dtk" + +msgid "KB/s" +msgstr "KB/dtk" + +msgid "Changelog of %1" +msgstr "Riwayat ubah dari %1" + +msgid "You are using the actual version %1" +msgstr "Anda menggunakan versi aktual %1" + +msgid "No new version found" +msgstr "Tidak ada versi baru yang ditemukan" + +msgid "Current version : %1" +msgstr "Versi saat ini: %1" + +msgid "New version : %1" +msgstr "Versi baru: %1" + +msgid "Click \"Ok\" to download" +msgstr "Klik \"OK\" untuk mengunduh" + +msgid "There are updates" +msgstr "Ada pemutakhiran" + +msgid "Copy" +msgstr "Salin" + +msgid "Create" +msgstr "Buat" + +msgid "Remove" +msgstr "Hapus" + +msgid "Enter file name" +msgstr "Masukkan nama berkas" + +msgid "File name" +msgstr "Nama berkas" + +msgid "Name: %1" +msgstr "Nama: %1" + +msgid "Comment: %1" +msgstr "Komentar: %1" + +msgid "Identity: %1" +msgstr "Identitas: %1" + +msgid "Name" +msgstr "Nama" + +msgid "Comment" +msgstr "Komentar" + +msgid "Type" +msgstr "Tipe" + +msgid "Format" +msgstr "Format" + +msgid "Precision" +msgstr "Presisi" + +msgid "Width" +msgstr "Lebar" + +msgid "Fill char" +msgstr "Masukan karakter" + +msgid "Force width" +msgstr "Paksa lebar" + +msgid "Multiplier" +msgstr "Pengali" + +msgid "Summand" +msgstr "Penjumlah" + +msgid "Path" +msgstr "" + +msgid "Filter" +msgstr "Filter" + +msgid "Separator" +msgstr "Pemisah" + +msgid "Sort" +msgstr "Urutkan" + +msgid "Append code" +msgstr "Tambahkan kode" + +msgid "Has return" +msgstr "Menghasilkan" + +msgid "Code" +msgstr "Kode" + +msgid "Tag" +msgstr "Tag" + +msgid "URL" +msgstr "Pranala" + +msgid "Active" +msgstr "Aktif" + +msgid "Schedule" +msgstr "Jadwal" + +msgid "Socket" +msgstr "Soket" + +msgid "Interval" +msgstr "Jeda" + +msgid "" +"

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

" +msgstr "" + +msgid "Ticker" +msgstr "Ticker" + +msgid "Command" +msgstr "Perintah" + +msgid "Prefix" +msgstr "Awalan" + +msgid "Redirect" +msgstr "Pengalihan" + +msgid "Additional filters" +msgstr "Filter tambahan" + +msgid "Wrap colors" +msgstr "Tekuk warna" + +msgid "Wrap spaces" +msgstr "Tekuk spasi" + +msgid "Null" +msgstr "Nil" + +msgid "Provider" +msgstr "Penyedia" + +msgid "City" +msgstr "Kota" + +msgid "Country" +msgstr "Negara" + +msgid "Timestamp" +msgstr "Tanggal" + +msgid "Use images" +msgstr "Gunakan gambar" + +#, fuzzy +msgid "Select color" +msgstr "Pilih warna" + +#, fuzzy +msgid "Select path" +msgstr "Pilih path" + +msgid "Images (*.png *.bpm *.jpg);;All files (*.*)" +msgstr "" + +msgid "Use custom formula" +msgstr "Gunakan rumus lain" + +msgid "Value" +msgstr "Nilai" + +msgid "Max value" +msgstr "Nilai maksimal" + +msgid "Min value" +msgstr "Nilai minimal" + +msgid "Active filling type" +msgstr "Tipe pengisi aktif" + +msgid "Inctive filling type" +msgstr "Tipe pengisi non-aktif" + +msgid "Points count" +msgstr "Jumlah poin" + +msgid "Direction" +msgstr "Arah" + +msgid "Height" +msgstr "Tinggi" + +msgid "color" +msgstr "Warna" + +msgid "image" +msgstr "gambar" + +msgid "Active desktop" +msgstr "Desktop aktif" + +msgid "Inactive desktop" +msgstr "Desktop inaktif" + +msgid "Vertical layout" +msgstr "Tata letak vertikal" + +msgid "Mark" +msgstr "Tanda" + +msgid "contours" +msgstr "kontur" + +msgid "windows" +msgstr "jendela" + +msgid "clean desktop" +msgstr "bersihkan desktop" + +msgid "names" +msgstr "nama" + +msgid "none" +msgstr "kosong" + +msgid "Tooltip type" +msgstr "Tipe tooltip" + +msgid "Tooltip width" +msgstr "Lebar tooltip" + +msgid "Edit bars" +msgstr "Sunting palang" + +msgid "Formatters" +msgstr "Pemformat" + +msgid "User keys" +msgstr "Kunci pungguna" + +msgid "Preview" +msgstr "Pratayang" + +msgid "" +"Detailed information may be found on project homepage" +msgstr "" +"Informasi mendetail dapat dilihat pada laman situs" + +msgid "Add" +msgstr "Tambah" + +msgid "Show value" +msgstr "Tunjukkan nilai" + +msgid "Acknowledgment" +msgstr "Pengakuan" + +msgid "Report a bug" +msgstr "Laporkan kutu" + +msgid "Report subject" +msgstr "Subjek laporan" + +#, fuzzy +msgid "Description" +msgstr "Deskripsi" + +msgid "Steps to reproduce" +msgstr "Langkah reproduksi" + +msgid "Expected result" +msgstr "Hasil yang diharapkan" + +msgid "Logs" +msgstr "Catatan" + +#, fuzzy +msgid "Use command" +msgstr "Gunakan perintah" + +msgid "Load log file" +msgstr "Baca berkas catatan" + +msgid "Open log file" +msgstr "Buka berkas catatan" + +msgid "Select a color" +msgstr "Pilih warna" + +msgid "Export" +msgstr "Ekspor" + +msgid "Success" +msgstr "Sukses" + +msgid "Please note that binary files were not copied" +msgstr "Harap perhatikan bahwa berkas biner tidak disalin" + +msgid "Ooops..." +msgstr "Waduh cok!" + +msgid "Could not save configuration file" +msgstr "Tidak dapat menyimpan berkas konfigurasi" + +msgid "Select a font" +msgstr "Pilih fonta" + +msgid "AC" +msgstr "AC" + +msgid "Bars" +msgstr "Palang" + +msgid "Desktops" +msgstr "Desktop" + +#, fuzzy +msgid "Network request" +msgstr "Jaringan" + +msgid "Scripts" +msgstr "Skrip" + +msgid "Time" +msgstr "Waktu" + +msgid "Quotes" +msgstr "Kutipan" + +msgid "Upgrades" +msgstr "Pemutakhiran" + +msgid "Weathers" +msgstr "Cuaca" + +msgid "Functions" +msgstr "Fungsi" + +msgid "User defined" +msgstr "Pilihan pengguna" + +msgid "All" +msgstr "Semua" + +msgid "normal" +msgstr "normal" + +msgid "italic" +msgstr "miring" + +msgid "light" +msgstr "ringan" + +msgid "demi bold" +msgstr "semi tebal" + +msgid "bold" +msgstr "tebal" + +msgid "black" +msgstr "hitam" + +#, fuzzy +msgid "outline" +msgstr "AC online" + +msgid "raised" +msgstr "timbul" + +msgid "sunken" +msgstr "tenggelam" + +msgid "Bgcolor" +msgstr "Warna latar belakang" + +msgid "Import" +msgstr "Impor" + +msgid "Import plasmoid settings" +msgstr "Impor pengaturan plasmoid" + +msgid "Import extensions" +msgstr "Impor ekstensi" + +msgid "Import additional files" +msgstr "Impor bekas tambahan" From e5a9e9943854cd1b40a8b430e8869aaebe0fb345 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Fri, 15 Dec 2017 02:01:34 +0300 Subject: [PATCH 04/35] Replace yahoo finance to stooq (#131) Old code is dropped to separated provider --- sources/.clang-format | 2 +- sources/CMakeLists.txt | 3 + sources/awdebug.cpp | 95 +++++--------- .../plugin/awabstractpairconfig.cpp | 27 ++-- .../plugin/awabstractpairconfig.h | 3 +- .../plugin/awabstractpairhelper.cpp | 26 ++-- .../plugin/awabstractpairhelper.h | 6 +- .../plugin/awabstractselector.cpp | 22 ++-- .../plugin/awabstractselector.h | 3 +- sources/awesome-widget/plugin/awactions.cpp | 24 ++-- sources/awesome-widget/plugin/awactions.h | 3 +- .../awesome-widget/plugin/awbugreporter.cpp | 33 ++--- sources/awesome-widget/plugin/awbugreporter.h | 6 +- .../awesome-widget/plugin/awconfighelper.cpp | 87 +++++-------- .../awesome-widget/plugin/awconfighelper.h | 19 ++- .../plugin/awcustomkeysconfig.cpp | 3 +- .../plugin/awdataaggregator.cpp | 77 +++++------- .../awesome-widget/plugin/awdataaggregator.h | 9 +- .../plugin/awdataengineaggregator.cpp | 42 +++---- .../plugin/awdataenginemapper.cpp | 42 +++---- .../plugin/awdataenginemapper.h | 3 +- .../awesome-widget/plugin/awdbusadaptor.cpp | 20 ++- sources/awesome-widget/plugin/awdbusadaptor.h | 3 +- .../plugin/awformatterhelper.cpp | 46 +++---- .../awesome-widget/plugin/awformatterhelper.h | 6 +- sources/awesome-widget/plugin/awkeycache.cpp | 53 +++----- sources/awesome-widget/plugin/awkeycache.h | 3 +- .../awesome-widget/plugin/awkeyoperations.cpp | 28 ++--- sources/awesome-widget/plugin/awkeys.cpp | 103 ++++++--------- sources/awesome-widget/plugin/awkeys.h | 12 +- .../plugin/awkeysaggregator.cpp | 25 ++-- .../awesome-widget/plugin/awkeysaggregator.h | 3 +- .../plugin/awpatternfunctions.cpp | 79 +++++------- .../plugin/awpatternfunctions.h | 9 +- .../plugin/awtelemetryhandler.cpp | 35 ++---- .../plugin/awtelemetryhandler.h | 9 +- .../awesome-widget/plugin/awupdatehelper.cpp | 58 ++++----- sources/awesomewidgets/abstractextitem.cpp | 18 +-- sources/awesomewidgets/abstractextitem.h | 6 +- .../abstractextitemaggregator.cpp | 38 +++--- .../abstractextitemaggregator.h | 8 +- .../awesomewidgets/abstractquotesprovider.h | 45 +++++++ .../awesomewidgets/abstractweatherprovider.h | 20 ++- .../awesomewidgets/awabstractformatter.cpp | 6 +- sources/awesomewidgets/awabstractformatter.h | 13 +- .../awesomewidgets/awdatetimeformatter.cpp | 12 +- sources/awesomewidgets/awdatetimeformatter.h | 6 +- sources/awesomewidgets/awfloatformatter.cpp | 26 ++-- sources/awesomewidgets/awfloatformatter.h | 3 +- sources/awesomewidgets/awjsonformatter.cpp | 22 ++-- sources/awesomewidgets/awjsonformatter.h | 6 +- sources/awesomewidgets/awlistformatter.cpp | 9 +- sources/awesomewidgets/awlistformatter.h | 3 +- sources/awesomewidgets/awnoformatter.cpp | 3 +- sources/awesomewidgets/awnoformatter.h | 3 +- sources/awesomewidgets/awscriptformatter.cpp | 17 +-- sources/awesomewidgets/awscriptformatter.h | 3 +- sources/awesomewidgets/awstringformatter.cpp | 9 +- sources/awesomewidgets/awstringformatter.h | 3 +- sources/awesomewidgets/extitemaggregator.h | 7 +- sources/awesomewidgets/extnetworkrequest.cpp | 13 +- sources/awesomewidgets/extnetworkrequest.h | 3 +- sources/awesomewidgets/extquotes.cpp | 89 ++++--------- sources/awesomewidgets/extquotes.h | 12 +- sources/awesomewidgets/extquotes.ui | 2 +- sources/awesomewidgets/extscript.cpp | 62 ++++------ sources/awesomewidgets/extscript.h | 10 +- sources/awesomewidgets/extupgrade.cpp | 18 +-- sources/awesomewidgets/extupgrade.h | 3 +- sources/awesomewidgets/extweather.cpp | 26 ++-- sources/awesomewidgets/extweather.h | 5 +- sources/awesomewidgets/graphicalitem.cpp | 64 ++++------ sources/awesomewidgets/graphicalitem.h | 11 +- .../awesomewidgets/graphicalitemhelper.cpp | 48 +++---- sources/awesomewidgets/graphicalitemhelper.h | 7 +- sources/awesomewidgets/owmweatherprovider.cpp | 27 ++-- sources/awesomewidgets/owmweatherprovider.h | 2 +- sources/awesomewidgets/qcronscheduler.cpp | 16 +-- sources/awesomewidgets/qcronscheduler.h | 3 +- sources/awesomewidgets/quotes/aapl.desktop | 2 +- sources/awesomewidgets/quotes/eurrub.desktop | 4 +- sources/awesomewidgets/quotes/eurusd.desktop | 4 +- sources/awesomewidgets/quotes/goog.desktop | 2 +- sources/awesomewidgets/quotes/msft.desktop | 2 +- sources/awesomewidgets/quotes/rts.desktop | 6 +- sources/awesomewidgets/quotes/snp.desktop | 11 -- sources/awesomewidgets/quotes/usdrub.desktop | 4 +- sources/awesomewidgets/quotes/vix.desktop | 11 -- .../awesomewidgets/stooqquotesprovider.cpp | 88 +++++++++++++ sources/awesomewidgets/stooqquotesprovider.h | 42 +++++++ .../awesomewidgets/yahooquotesprovider.cpp | 88 +++++++++++++ sources/awesomewidgets/yahooquotesprovider.h | 43 +++++++ .../awesomewidgets/yahooweatherprovider.cpp | 47 +++---- sources/awesomewidgets/yahooweatherprovider.h | 5 +- sources/desktop-panel/plugin/dpadds.cpp | 75 +++++------ sources/desktop-panel/plugin/dpadds.h | 12 +- sources/extsysmon/extsysmon.cpp | 25 ++-- sources/extsysmon/extsysmon.h | 3 +- sources/extsysmon/extsysmonaggregator.cpp | 33 ++--- sources/extsysmon/extsysmonaggregator.h | 3 +- sources/extsysmonsources/batterysource.cpp | 27 ++-- sources/extsysmonsources/customsource.cpp | 10 +- sources/extsysmonsources/gpuloadsource.cpp | 25 ++-- sources/extsysmonsources/gputempsource.cpp | 19 ++- sources/extsysmonsources/hddtempsource.cpp | 27 ++-- sources/extsysmonsources/networksource.cpp | 6 +- sources/extsysmonsources/playersource.cpp | 117 ++++++------------ sources/extsysmonsources/playersource.h | 3 +- sources/extsysmonsources/processessource.cpp | 4 +- sources/extsysmonsources/quotessource.cpp | 78 ++++-------- sources/extsysmonsources/requestsource.cpp | 7 +- sources/extsysmonsources/upgradesource.cpp | 10 +- sources/extsysmonsources/weathersource.cpp | 15 ++- sources/qml/General.qml | 2 +- sources/test/awtestlibrary.cpp | 10 +- sources/test/testabstractformatter.cpp | 4 +- sources/test/testawbugreporter.cpp | 8 +- sources/test/testawconfighelper.cpp | 3 +- sources/test/testawkeycache.cpp | 4 +- sources/test/testawkeys.cpp | 7 +- sources/test/testawpatternfunctions.cpp | 31 ++--- sources/test/testbatterysource.cpp | 16 ++- sources/test/testdatetimeformatter.cpp | 3 +- sources/test/testextquotes.cpp | 8 +- sources/test/testextquotes.h | 8 +- sources/test/testextupgrade.cpp | 6 +- sources/test/testextweather.cpp | 18 ++- sources/test/testfloatformatter.cpp | 10 +- sources/test/testhddtempsource.cpp | 14 +-- sources/test/testlistformatter.cpp | 3 +- sources/test/testnoformatter.cpp | 4 +- sources/test/testplayersource.cpp | 25 ++-- sources/test/teststringformatter.cpp | 4 +- sources/version.h.in | 30 ++--- 134 files changed, 1213 insertions(+), 1597 deletions(-) create mode 100644 sources/awesomewidgets/abstractquotesprovider.h delete mode 100644 sources/awesomewidgets/quotes/snp.desktop delete mode 100644 sources/awesomewidgets/quotes/vix.desktop create mode 100644 sources/awesomewidgets/stooqquotesprovider.cpp create mode 100644 sources/awesomewidgets/stooqquotesprovider.h create mode 100644 sources/awesomewidgets/yahooquotesprovider.cpp create mode 100644 sources/awesomewidgets/yahooquotesprovider.h diff --git a/sources/.clang-format b/sources/.clang-format index b4b4e86..a3de373 100644 --- a/sources/.clang-format +++ b/sources/.clang-format @@ -21,7 +21,7 @@ BreakBeforeBinaryOperators: All BreakBeforeBraces: Linux BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: true -ColumnLimit: 80 +ColumnLimit: 100 CommentPragmas: '^ IWYU pragma:' ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 80d2ebc..d5b6fe4 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -6,6 +6,9 @@ cmake_policy(SET CMP0015 NEW) if (POLICY CMP0063) cmake_policy(SET CMP0063 OLD) endif () +if (POLICY CMP0071) + cmake_policy(SET CMP0071 NEW) +endif () project(awesomewidgets) set(PROJECT_AUTHOR "Evgeniy Alekseev") diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index 84c14ba..852b18d 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -21,16 +21,12 @@ #include "awdebug.h" -Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", - QtMsgType::QtWarningMsg) +Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", QtMsgType::QtWarningMsg) Q_LOGGING_CATEGORY(LOG_DBUS, "org.kde.plasma.awdbus", QtMsgType::QtWarningMsg) -Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", - QtMsgType::QtWarningMsg) +Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", QtMsgType::QtWarningMsg) Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon", QtMsgType::QtWarningMsg) -Q_LOGGING_CATEGORY(LOG_ESS, "org.kde.plasma.extsysmonsources", - QtMsgType::QtWarningMsg) -Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", - QtMsgType::QtWarningMsg) +Q_LOGGING_CATEGORY(LOG_ESS, "org.kde.plasma.extsysmonsources", QtMsgType::QtWarningMsg) +Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", QtMsgType::QtWarningMsg) QString AWDebug::getAboutText(const QString &_type) @@ -46,15 +42,9 @@ QString AWDebug::getAboutText(const QString &_type) text = i18n("A set of minimalistic plasmoid widgets"); } else if (_type == "links") { text = i18n("Links:") + "
    " - + QString("
  • %2
  • ") - .arg(HOMEPAGE) - .arg(i18n("Homepage")) - + QString("
  • %2
  • ") - .arg(REPOSITORY) - .arg(i18n("Repository")) - + QString("
  • %2
  • ") - .arg(BUGTRACKER) - .arg(i18n("Bugtracker")) + + QString("
  • %2
  • ").arg(HOMEPAGE).arg(i18n("Homepage")) + + QString("
  • %2
  • ").arg(REPOSITORY).arg(i18n("Repository")) + + QString("
  • %2
  • ").arg(BUGTRACKER).arg(i18n("Bugtracker")) + QString("
  • %2
  • ") .arg(TRANSLATION) .arg(i18n("Translation issue")) @@ -70,28 +60,22 @@ QString AWDebug::getAboutText(const QString &_type) .arg(DATE) .arg(EMAIL) .arg(AUTHOR) - + i18n("This software is licensed under %1", LICENSE) - + ""; + + i18n("This software is licensed under %1", LICENSE) + ""; } else if (_type == "translators") { QStringList translatorList = QString(TRANSLATORS).split(','); for (auto &translator : translatorList) translator = QString("
  • %1
  • ").arg(translator); - text - = i18n("Translators:") + "
      " + translatorList.join("") + "
    "; + text = i18n("Translators:") + "
      " + translatorList.join("") + "
    "; } else if (_type == "3rdparty") { - QStringList trdPartyList - = QString(TRDPARTY_LICENSE).split(';', QString::SkipEmptyParts); + QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(';', QString::SkipEmptyParts); for (int i = 0; i < trdPartyList.count(); i++) - trdPartyList[i] - = QString("
  • %1 (%2 license)
  • ") - .arg(trdPartyList.at(i).split(',')[0]) - .arg(trdPartyList.at(i).split(',')[1]) - .arg(trdPartyList.at(i).split(',')[2]); - text = i18n("This software uses:") + "
      " + trdPartyList.join("") - + "
    "; + trdPartyList[i] = QString("
  • %1 (%2 license)
  • ") + .arg(trdPartyList.at(i).split(',')[0]) + .arg(trdPartyList.at(i).split(',')[1]) + .arg(trdPartyList.at(i).split(',')[2]); + text = i18n("This software uses:") + "
      " + trdPartyList.join("") + "
    "; } else if (_type == "thanks") { - QStringList thanks - = QString(SPECIAL_THANKS).split(';', QString::SkipEmptyParts); + QStringList thanks = QString(SPECIAL_THANKS).split(';', QString::SkipEmptyParts); for (int i = 0; i < thanks.count(); i++) thanks[i] = QString("
  • %1
  • ") .arg(thanks.at(i).split(',')[0]) @@ -117,10 +101,8 @@ QStringList AWDebug::getBuildData() metadata.append(QString(" AW_GRAPHITEM_API: %1").arg(AW_GRAPHITEM_API)); metadata.append(QString(" AW_EXTQUOTES_API: %1").arg(AW_EXTQUOTES_API)); metadata.append(QString(" AW_EXTSCRIPT_API: %1").arg(AW_EXTSCRIPT_API)); - metadata.append( - QString(" AW_EXTUPGRADE_API: %1").arg(AW_EXTUPGRADE_API)); - metadata.append( - QString(" AW_EXTWEATHER_API: %1").arg(AW_EXTWEATHER_API)); + metadata.append(QString(" AW_EXTUPGRADE_API: %1").arg(AW_EXTUPGRADE_API)); + metadata.append(QString(" AW_EXTWEATHER_API: %1").arg(AW_EXTWEATHER_API)); metadata.append(QString(" AW_FORMATTER_API: %1").arg(AW_FORMATTER_API)); metadata.append(QString(" REQUEST_TIMEOUT: %1").arg(REQUEST_TIMEOUT)); metadata.append(QString(" TIME_KEYS: %1").arg(TIME_KEYS)); @@ -128,41 +110,28 @@ QStringList AWDebug::getBuildData() // cmake properties metadata.append("cmake properties:"); metadata.append(QString(" CMAKE_BUILD_TYPE: %1").arg(CMAKE_BUILD_TYPE)); - metadata.append( - QString(" CMAKE_CXX_COMPILER: %1").arg(CMAKE_CXX_COMPILER)); + metadata.append(QString(" CMAKE_CXX_COMPILER: %1").arg(CMAKE_CXX_COMPILER)); metadata.append(QString(" CMAKE_CXX_FLAGS: %1").arg(CMAKE_CXX_FLAGS)); + metadata.append(QString(" CMAKE_CXX_FLAGS_DEBUG: %1").arg(CMAKE_CXX_FLAGS_DEBUG)); + metadata.append(QString(" CMAKE_CXX_FLAGS_RELEASE: %1").arg(CMAKE_CXX_FLAGS_RELEASE)); metadata.append( - QString(" CMAKE_CXX_FLAGS_DEBUG: %1").arg(CMAKE_CXX_FLAGS_DEBUG)); - metadata.append(QString(" CMAKE_CXX_FLAGS_RELEASE: %1") - .arg(CMAKE_CXX_FLAGS_RELEASE)); - metadata.append(QString(" CMAKE_CXX_FLAGS_OPTIMIZATION: %1") - .arg(CMAKE_CXX_FLAGS_OPTIMIZATION)); - metadata.append( - QString(" CMAKE_DEFINITIONS: %1").arg(CMAKE_DEFINITIONS)); - metadata.append( - QString(" CMAKE_INSTALL_PREFIX: %1").arg(CMAKE_INSTALL_PREFIX)); - metadata.append(QString(" CMAKE_MODULE_LINKER_FLAGS: %1") - .arg(CMAKE_MODULE_LINKER_FLAGS)); - metadata.append(QString(" CMAKE_SHARED_LINKER_FLAGS: %1") - .arg(CMAKE_SHARED_LINKER_FLAGS)); + QString(" CMAKE_CXX_FLAGS_OPTIMIZATION: %1").arg(CMAKE_CXX_FLAGS_OPTIMIZATION)); + metadata.append(QString(" CMAKE_DEFINITIONS: %1").arg(CMAKE_DEFINITIONS)); + metadata.append(QString(" CMAKE_INSTALL_PREFIX: %1").arg(CMAKE_INSTALL_PREFIX)); + metadata.append(QString(" CMAKE_MODULE_LINKER_FLAGS: %1").arg(CMAKE_MODULE_LINKER_FLAGS)); + metadata.append(QString(" CMAKE_SHARED_LINKER_FLAGS: %1").arg(CMAKE_SHARED_LINKER_FLAGS)); // components metadata.append("Components data:"); metadata.append(QString(" BUILD_PLASMOIDS: %1").arg(BUILD_PLASMOIDS)); - metadata.append( - QString(" BUILD_DEB_PACKAGE: %1").arg(BUILD_DEB_PACKAGE)); - metadata.append( - QString(" BUILD_RPM_PACKAGE: %1").arg(BUILD_RPM_PACKAGE)); - metadata.append( - QString(" CLANGFORMAT_EXECUTABLE: %1").arg(CLANGFORMAT_EXECUTABLE)); + metadata.append(QString(" BUILD_DEB_PACKAGE: %1").arg(BUILD_DEB_PACKAGE)); + metadata.append(QString(" BUILD_RPM_PACKAGE: %1").arg(BUILD_RPM_PACKAGE)); + metadata.append(QString(" CLANGFORMAT_EXECUTABLE: %1").arg(CLANGFORMAT_EXECUTABLE)); metadata.append(QString(" COVERITY_COMMENT: %1").arg(COVERITY_COMMENT)); - metadata.append( - QString(" COVERITY_DIRECTORY: %1").arg(COVERITY_DIRECTORY)); + metadata.append(QString(" COVERITY_DIRECTORY: %1").arg(COVERITY_DIRECTORY)); metadata.append(QString(" COVERITY_EMAIL: %1").arg(COVERITY_EMAIL)); - metadata.append( - QString(" COVERITY_EXECUTABLE: %1").arg(COVERITY_EXECUTABLE)); + metadata.append(QString(" COVERITY_EXECUTABLE: %1").arg(COVERITY_EXECUTABLE)); metadata.append(QString(" COVERITY_URL: %1").arg(COVERITY_URL)); - metadata.append( - QString(" CPPCHECK_EXECUTABLE: %1").arg(CPPCHECK_EXECUTABLE)); + metadata.append(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)); diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.cpp b/sources/awesome-widget/plugin/awabstractpairconfig.cpp index aaab069..2b378cf 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.cpp +++ b/sources/awesome-widget/plugin/awabstractpairconfig.cpp @@ -26,8 +26,7 @@ #include "awdebug.h" -AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, - const bool _hasEdit, +AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit, const QStringList &_keys) : QDialog(_parent) , ui(new Ui::AWAbstractPairConfig) @@ -43,8 +42,7 @@ AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, // edit feature if (m_hasEdit) { - m_editButton = ui->buttonBox->addButton(i18n("Edit"), - QDialogButtonBox::ActionRole); + m_editButton = ui->buttonBox->addButton(i18n("Edit"), QDialogButtonBox::ActionRole); connect(m_editButton, SIGNAL(clicked(bool)), this, SLOT(edit())); } } @@ -86,10 +84,8 @@ void AWAbstractPairConfig::edit() void AWAbstractPairConfig::updateUi() { - QPair current - = static_cast(sender())->current(); - int index - = m_selectors.indexOf(static_cast(sender())); + QPair current = static_cast(sender())->current(); + int index = m_selectors.indexOf(static_cast(sender())); if ((current.first.isEmpty()) && (current.second.isEmpty())) { // remove current selector if it is empty and does not last @@ -108,15 +104,13 @@ void AWAbstractPairConfig::updateUi() } -void AWAbstractPairConfig::addSelector(const QStringList &_keys, - const QStringList &_values, +void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringList &_values, const QPair &_current) { qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values << "and current ones" << _current; - AWAbstractSelector *selector - = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable); + AWAbstractSelector *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable); selector->init(_keys, _values, _current); ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, selector); connect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi())); @@ -127,8 +121,7 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, void AWAbstractPairConfig::clearSelectors() { for (auto &selector : m_selectors) { - disconnect(selector, SIGNAL(selectionChanged()), this, - SLOT(updateUi())); + disconnect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi())); ui->verticalLayout->removeWidget(selector); selector->deleteLater(); } @@ -167,8 +160,7 @@ QPair AWAbstractPairConfig::initKeys() const left.append(m_helper->leftKeys().isEmpty() ? m_keys : m_helper->leftKeys()); left.sort(); QStringList right = {""}; - right.append(m_helper->rightKeys().isEmpty() ? m_keys - : m_helper->rightKeys()); + right.append(m_helper->rightKeys().isEmpty() ? m_keys : m_helper->rightKeys()); right.sort(); return QPair(left, right); @@ -182,8 +174,7 @@ void AWAbstractPairConfig::updateDialog() auto keys = initKeys(); for (auto &key : m_helper->keys()) - addSelector(keys.first, keys.second, - QPair(key, m_helper->pairs()[key])); + addSelector(keys.first, keys.second, QPair(key, m_helper->pairs()[key])); // empty one addSelector(keys.first, keys.second, QPair()); } diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.h b/sources/awesome-widget/plugin/awabstractpairconfig.h index df1fd40..2834ee6 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.h +++ b/sources/awesome-widget/plugin/awabstractpairconfig.h @@ -35,8 +35,7 @@ class AWAbstractPairConfig : public QDialog Q_OBJECT public: - explicit AWAbstractPairConfig(QWidget *_parent = nullptr, - const bool _hasEdit = false, + explicit AWAbstractPairConfig(QWidget *_parent = nullptr, const bool _hasEdit = false, const QStringList &_keys = QStringList()); virtual ~AWAbstractPairConfig(); template void initHelper() diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.cpp b/sources/awesome-widget/plugin/awabstractpairhelper.cpp index 5f37995..aac202e 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.cpp +++ b/sources/awesome-widget/plugin/awabstractpairhelper.cpp @@ -23,8 +23,7 @@ #include "awdebug.h" -AWAbstractPairHelper::AWAbstractPairHelper(const QString &_filePath, - const QString &_section) +AWAbstractPairHelper::AWAbstractPairHelper(const QString &_filePath, const QString &_section) : m_filePath(_filePath) , m_section(_section) { @@ -62,8 +61,8 @@ void AWAbstractPairHelper::initItems() { m_pairs.clear(); - QStringList configs = QStandardPaths::locateAll( - QStandardPaths::GenericDataLocation, m_filePath); + QStringList configs + = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_filePath); for (auto &fileName : configs) { QSettings settings(fileName, QSettings::IniFormat); @@ -86,15 +85,14 @@ void AWAbstractPairHelper::initItems() } -bool AWAbstractPairHelper::writeItems( - const QHash &_configuration) const +bool AWAbstractPairHelper::writeItems(const QHash &_configuration) const { qCDebug(LOG_AW) << "Write configuration" << _configuration; - QString fileName = QString("%1/%2") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)) - .arg(m_filePath); + QString fileName + = QString("%1/%2") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)) + .arg(m_filePath); QSettings settings(fileName, QSettings::IniFormat); qCInfo(LOG_AW) << "Configuration file" << fileName; @@ -113,10 +111,10 @@ bool AWAbstractPairHelper::removeUnusedKeys(const QStringList &_keys) const { qCDebug(LOG_AW) << "Remove keys" << _keys; - QString fileName = QString("%1/%2") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)) - .arg(m_filePath); + QString fileName + = QString("%1/%2") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)) + .arg(m_filePath); QSettings settings(fileName, QSettings::IniFormat); qCInfo(LOG_AW) << "Configuration file" << fileName; diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.h b/sources/awesome-widget/plugin/awabstractpairhelper.h index b1d5c33..c1eac82 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.h +++ b/sources/awesome-widget/plugin/awabstractpairhelper.h @@ -25,16 +25,14 @@ class AWAbstractPairHelper { public: - explicit AWAbstractPairHelper(const QString &_filePath = "", - const QString &_section = ""); + explicit AWAbstractPairHelper(const QString &_filePath = "", const QString &_section = ""); virtual ~AWAbstractPairHelper(); QStringList keys() const; QHash pairs() const; QStringList values() const; // read-write methods virtual void initItems(); - virtual bool - writeItems(const QHash &_configuration) const; + virtual bool writeItems(const QHash &_configuration) const; virtual bool removeUnusedKeys(const QStringList &_keys) const; // configuration related virtual void editPairs() = 0; diff --git a/sources/awesome-widget/plugin/awabstractselector.cpp b/sources/awesome-widget/plugin/awabstractselector.cpp index 4dc3bfd..aaa816c 100644 --- a/sources/awesome-widget/plugin/awabstractselector.cpp +++ b/sources/awesome-widget/plugin/awabstractselector.cpp @@ -21,8 +21,7 @@ #include "awdebug.h" -AWAbstractSelector::AWAbstractSelector(QWidget *_parent, - const QPair &_editable) +AWAbstractSelector::AWAbstractSelector(QWidget *_parent, const QPair &_editable) : QWidget(_parent) , ui(new Ui::AWAbstractSelector) { @@ -32,10 +31,8 @@ AWAbstractSelector::AWAbstractSelector(QWidget *_parent, ui->comboBox_key->setEditable(_editable.first); ui->comboBox_value->setEditable(_editable.second); - connect(ui->comboBox_key, SIGNAL(currentIndexChanged(int)), this, - SIGNAL(selectionChanged())); - connect(ui->comboBox_value, SIGNAL(currentIndexChanged(int)), this, - SIGNAL(selectionChanged())); + connect(ui->comboBox_key, SIGNAL(currentIndexChanged(int)), this, SIGNAL(selectionChanged())); + connect(ui->comboBox_value, SIGNAL(currentIndexChanged(int)), this, SIGNAL(selectionChanged())); } @@ -56,18 +53,15 @@ QPair AWAbstractSelector::current() const } -void AWAbstractSelector::init(const QStringList &_keys, - const QStringList &_values, +void AWAbstractSelector::init(const QStringList &_keys, const QStringList &_values, const QPair &_current) { - if ((!_keys.contains(_current.first)) - || (!_values.contains(_current.second))) { - qCWarning(LOG_AW) << "Invalid current value" << _current - << "not found in default ones"; + if ((!_keys.contains(_current.first)) || (!_values.contains(_current.second))) { + qCWarning(LOG_AW) << "Invalid current value" << _current << "not found in default ones"; return; } - qCDebug(LOG_AW) << "Init selector with keys" << _keys << "and values" - << _values << "and current ones are" << _current; + qCDebug(LOG_AW) << "Init selector with keys" << _keys << "and values" << _values + << "and current ones are" << _current; // set data ui->comboBox_key->clear(); diff --git a/sources/awesome-widget/plugin/awabstractselector.h b/sources/awesome-widget/plugin/awabstractselector.h index ef85ab8..ef586ec 100644 --- a/sources/awesome-widget/plugin/awabstractselector.h +++ b/sources/awesome-widget/plugin/awabstractselector.h @@ -33,8 +33,7 @@ class AWAbstractSelector : public QWidget public: explicit AWAbstractSelector(QWidget *_parent = nullptr, - const QPair &_editable - = {false, false}); + const QPair &_editable = {false, false}); virtual ~AWAbstractSelector(); QPair current() const; void init(const QStringList &_keys, const QStringList &_values, diff --git a/sources/awesome-widget/plugin/awactions.cpp b/sources/awesome-widget/plugin/awactions.cpp index 5ba0d69..4935099 100644 --- a/sources/awesome-widget/plugin/awactions.cpp +++ b/sources/awesome-widget/plugin/awactions.cpp @@ -61,8 +61,7 @@ QString AWActions::getFileContent(const QString &_path) const QFile inputFile(_path); if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - qCWarning(LOG_AW) << "Could not open file as text" - << inputFile.fileName(); + qCWarning(LOG_AW) << "Could not open file as text" << inputFile.fileName(); return ""; } @@ -102,8 +101,7 @@ void AWActions::showLegacyInfo() const msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->setWindowTitle(i18n("Not supported")); - msgBox->setText( - i18n("You are using mammoth's Qt version, try to update it first")); + msgBox->setText(i18n("You are using mammoth's Qt version, try to update it first")); msgBox->setStandardButtons(QMessageBox::Ok); msgBox->setIcon(QMessageBox::Information); @@ -126,11 +124,9 @@ QVariantMap AWActions::getFont(const QVariantMap &_defaultFont) const QVariantMap fontMap; int ret = 0; - CFont defaultCFont - = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), - 400, false, _defaultFont["color"].toString()); - CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, - false, &ret); + CFont defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, + false, _defaultFont["color"].toString()); + CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret); fontMap["applied"] = ret; fontMap["color"] = font.color().name(); @@ -142,13 +138,11 @@ QVariantMap AWActions::getFont(const QVariantMap &_defaultFont) const // to avoid additional object definition this method is static -void AWActions::sendNotification(const QString &_eventId, - const QString &_message) +void AWActions::sendNotification(const QString &_eventId, const QString &_message) { qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message; - KNotification *notification = KNotification::event( - _eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message); - notification->setComponentName( - "plasma-applet-org.kde.plasma.awesome-widget"); + KNotification *notification + = KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message); + notification->setComponentName("plasma-applet-org.kde.plasma.awesome-widget"); } diff --git a/sources/awesome-widget/plugin/awactions.h b/sources/awesome-widget/plugin/awactions.h index 9b8937b..a70d7b5 100644 --- a/sources/awesome-widget/plugin/awactions.h +++ b/sources/awesome-widget/plugin/awactions.h @@ -43,8 +43,7 @@ public: Q_INVOKABLE QVariantMap getFont(const QVariantMap &_defaultFont) const; public slots: - Q_INVOKABLE static void sendNotification(const QString &_eventId, - const QString &_message); + Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message); private: AWUpdateHelper *m_updateHelper = nullptr; diff --git a/sources/awesome-widget/plugin/awbugreporter.cpp b/sources/awesome-widget/plugin/awbugreporter.cpp index edc78ed..a2410db 100644 --- a/sources/awesome-widget/plugin/awbugreporter.cpp +++ b/sources/awesome-widget/plugin/awbugreporter.cpp @@ -49,22 +49,18 @@ void AWBugReporter::doConnect() } -QString AWBugReporter::generateText(const QString &_description, - const QString &_reproduce, - const QString &_expected, - const QString &_logs) const +QString AWBugReporter::generateText(const QString &_description, const QString &_reproduce, + const QString &_expected, const QString &_logs) const { // do not log _logs here, it may have quite large size - qCDebug(LOG_AW) << "Generate text with description" << _description - << "steps" << _reproduce << "and expected result" - << _expected; + qCDebug(LOG_AW) << "Generate text with description" << _description << "steps" << _reproduce + << "and expected result" << _expected; QString output; output += QString("**Description**\n\n%1\n\n").arg(_description); output += QString("**Step to _reproduce**\n\n%1\n\n").arg(_reproduce); output += QString("**Expected result**\n\n%1\n\n").arg(_expected); - output += QString("**Version**\n\n%1\n\n") - .arg(AWDebug::getBuildData().join(QString("\n"))); + output += QString("**Version**\n\n%1\n\n").arg(AWDebug::getBuildData().join(QString("\n"))); // append _logs output += QString("**Logs**\n\n%1").arg(_logs); @@ -74,8 +70,7 @@ QString AWBugReporter::generateText(const QString &_description, void AWBugReporter::sendBugReport(const QString &_title, const QString &_body) { - qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" - << _body; + qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" << _body; QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr); connect(manager, SIGNAL(finished(QNetworkReply *)), this, @@ -90,10 +85,8 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body) payload["body"] = _body; payload["labels"] = QStringList() << "from application"; // convert to QByteArray to send request - QByteArray data - = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact); - qCInfo(LOG_AW) << "Send request with _body" << data.data() << "and size" - << data.size(); + QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact); + qCInfo(LOG_AW) << "Send request with _body" << data.data() << "and size" << data.size(); manager->post(request, data); } @@ -102,8 +95,8 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body) void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply) { if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() - << "with message" << _reply->errorString(); + qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" + << _reply->errorString(); return emit(replyReceived(0, "")); } @@ -126,8 +119,7 @@ void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply) void AWBugReporter::showInformation(const int _number, const QString &_url) { - qCDebug(LOG_AW) << "Created issue with number" << _number << "and url" - << _url; + qCDebug(LOG_AW) << "Created issue with number" << _number << "and url" << _url; // cache url first m_lastBugUrl = _url; @@ -146,8 +138,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url) void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button) { - QMessageBox::ButtonRole ret - = static_cast(sender())->buttonRole(_button); + QMessageBox::ButtonRole ret = static_cast(sender())->buttonRole(_button); qCInfo(LOG_AW) << "User select" << ret; switch (ret) { diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index e7bae5b..88aed69 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -33,10 +33,8 @@ public: explicit AWBugReporter(QObject *_parent = nullptr); virtual ~AWBugReporter(); Q_INVOKABLE void doConnect(); - Q_INVOKABLE QString generateText(const QString &_description, - const QString &_reproduce, - const QString &_expected, - const QString &_logs) const; + Q_INVOKABLE QString generateText(const QString &_description, const QString &_reproduce, + const QString &_expected, const QString &_logs) const; Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body); signals: diff --git a/sources/awesome-widget/plugin/awconfighelper.cpp b/sources/awesome-widget/plugin/awconfighelper.cpp index c2ccb57..edffc40 100644 --- a/sources/awesome-widget/plugin/awconfighelper.cpp +++ b/sources/awesome-widget/plugin/awconfighelper.cpp @@ -34,8 +34,7 @@ AWConfigHelper::AWConfigHelper(QObject *_parent) qCDebug(LOG_AW) << __PRETTY_FUNCTION__; m_baseDir = QString("%1/awesomewidgets") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); } @@ -48,14 +47,13 @@ AWConfigHelper::~AWConfigHelper() QString AWConfigHelper::configurationDirectory() const { // get readable directory - QString localDir = QString("%1/awesomewidgets/configs") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + QString localDir + = QString("%1/awesomewidgets/configs") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); // create directory and copy files from default settings QDir localDirectory; - if ((!localDirectory.exists(localDir)) - && (localDirectory.mkpath(localDir))) { + if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir))) { qCInfo(LOG_AW) << "Created directory" << localDir; copyConfigs(localDir); } @@ -66,23 +64,21 @@ QString AWConfigHelper::configurationDirectory() const bool AWConfigHelper::dropCache() const { - QString fileName = QString("%1/awesomewidgets.ndx") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericCacheLocation)); + QString fileName + = QString("%1/awesomewidgets.ndx") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); return QFile(fileName).remove(); } -bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, - const QString &_fileName) const +bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const { qCDebug(LOG_AW) << "Selected filename" << _fileName; QSettings settings(_fileName, QSettings::IniFormat); // plasmoid configuration - const QQmlPropertyMap *configuration - = static_cast(_nativeConfig); + const QQmlPropertyMap *configuration = static_cast(_nativeConfig); settings.beginGroup("plasmoid"); for (auto &key : configuration->keys()) { QVariant value = configuration->value(key); @@ -94,9 +90,8 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, // extensions for (auto &item : m_dirs) { - QStringList items - = QDir(QString("%1/%2").arg(m_baseDir).arg(item)) - .entryList(QStringList() << "*.desktop", QDir::Files); + QStringList items = QDir(QString("%1/%2").arg(m_baseDir).arg(item)) + .entryList(QStringList() << "*.desktop", QDir::Files); settings.beginGroup(item); for (auto &it : items) copyExtensions(it, item, settings, false); @@ -107,18 +102,15 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, settings.beginGroup("json"); // script filters readFile(settings, "filters", - QString("%1/scripts/awesomewidgets-extscripts-filters.json") - .arg(m_baseDir)); + QString("%1/scripts/awesomewidgets-extscripts-filters.json").arg(m_baseDir)); // weather icon settings readFile(settings, "weathers", - QString("%1/weather/awesomewidgets-extweather-ids.json") - .arg(m_baseDir)); + QString("%1/weather/awesomewidgets-extweather-ids.json").arg(m_baseDir)); settings.endGroup(); settings.beginGroup("ini"); // formatter settings - readFile(settings, "formatters", - QString("%1/formatters/formatters.ini").arg(m_baseDir)); + readFile(settings, "formatters", QString("%1/formatters/formatters.ini").arg(m_baseDir)); // custom keys settings readFile(settings, "custom", QString("%1/custom.ini").arg(m_baseDir)); settings.endGroup(); @@ -155,18 +147,15 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName, settings.beginGroup("json"); // script filters writeFile(settings, "filters", - QString("%1/scripts/awesomewidgets-extscripts-filters.json") - .arg(m_baseDir)); + QString("%1/scripts/awesomewidgets-extscripts-filters.json").arg(m_baseDir)); // weather icon settings writeFile(settings, "weathers", - QString("%1/weather/awesomewidgets-extweather-ids.json") - .arg(m_baseDir)); + QString("%1/weather/awesomewidgets-extweather-ids.json").arg(m_baseDir)); settings.endGroup(); settings.beginGroup("ini"); // formatter settings - writeFile(settings, "formatters", - QString("%1/formatters/formatters.ini").arg(m_baseDir)); + writeFile(settings, "formatters", QString("%1/formatters/formatters.ini").arg(m_baseDir)); // custom keys settings writeFile(settings, "custom", QString("%1/custom.ini").arg(m_baseDir)); settings.endGroup(); @@ -186,19 +175,17 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName, QVariantMap AWConfigHelper::readDataEngineConfiguration() const { - QString fileName = QStandardPaths::locate( - QStandardPaths::ConfigLocation, "plasma-dataengine-extsysmon.conf"); + QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, + "plasma-dataengine-extsysmon.conf"); qCInfo(LOG_AW) << "Configuration file" << fileName; QSettings settings(fileName, QSettings::IniFormat); QVariantMap configuration; settings.beginGroup("Configuration"); - configuration["ACPIPATH"] - = settings.value("ACPIPATH", "/sys/class/power_supply/"); + configuration["ACPIPATH"] = settings.value("ACPIPATH", "/sys/class/power_supply/"); configuration["GPUDEV"] = settings.value("GPUDEV", "auto"); configuration["HDDDEV"] = settings.value("HDDDEV", "all"); - configuration["HDDTEMPCMD"] - = settings.value("HDDTEMPCMD", "sudo smartctl -a"); + configuration["HDDTEMPCMD"] = settings.value("HDDTEMPCMD", "sudo smartctl -a"); configuration["MPDADDRESS"] = settings.value("MPDADDRESS", "localhost"); configuration["MPDPORT"] = settings.value("MPDPORT", "6600"); configuration["MPRIS"] = settings.value("MPRIS", "auto"); @@ -212,14 +199,12 @@ QVariantMap AWConfigHelper::readDataEngineConfiguration() const } -bool AWConfigHelper::writeDataEngineConfiguration( - const QVariantMap &_configuration) const +bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configuration) const { qCDebug(LOG_AW) << "Configuration" << _configuration; QString fileName = QString("%1/plasma-dataengine-extsysmon.conf") - .arg(QStandardPaths::writableLocation( - QStandardPaths::ConfigLocation)); + .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); QSettings settings(fileName, QSettings::IniFormat); qCInfo(LOG_AW) << "Configuration file" << settings.fileName(); @@ -245,35 +230,31 @@ void AWConfigHelper::copyConfigs(const QString &_localDir) const { qCDebug(LOG_AW) << "Local directory" << _localDir; - QStringList dirs = QStandardPaths::locateAll( - QStandardPaths::GenericDataLocation, "awesomewidgets/configs", - QStandardPaths::LocateDirectory); + QStringList dirs + = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "awesomewidgets/configs", + QStandardPaths::LocateDirectory); for (auto &dir : dirs) { if (dir == _localDir) continue; QStringList files = QDir(dir).entryList(QDir::Files); for (auto &source : files) { QString destination = QString("%1/%2").arg(_localDir).arg(source); - bool status = QFile::copy(QString("%1/%2").arg(dir).arg(source), - destination); - qCInfo(LOG_AW) << "File" << source << "has been copied to" - << destination << "with status" << status; + bool status = QFile::copy(QString("%1/%2").arg(dir).arg(source), destination); + qCInfo(LOG_AW) << "File" << source << "has been copied to" << destination + << "with status" << status; } } } void AWConfigHelper::copyExtensions(const QString &_item, const QString &_type, - QSettings &_settings, - const bool _inverse) const + QSettings &_settings, const bool _inverse) const { - qCDebug(LOG_AW) << "Extension" << _item << "has type" << _type - << "inverse copying" << _inverse; + qCDebug(LOG_AW) << "Extension" << _item << "has type" << _type << "inverse copying" << _inverse; _settings.beginGroup(_item); - QSettings itemSettings( - QString("%1/%2/%3").arg(m_baseDir).arg(_type).arg(_item), - QSettings::IniFormat); + QSettings itemSettings(QString("%1/%2/%3").arg(m_baseDir).arg(_type).arg(_item), + QSettings::IniFormat); itemSettings.beginGroup("Desktop Entry"); if (_inverse) copySettings(_settings, itemSettings); diff --git a/sources/awesome-widget/plugin/awconfighelper.h b/sources/awesome-widget/plugin/awconfighelper.h index 1997129..e008a64 100644 --- a/sources/awesome-widget/plugin/awconfighelper.h +++ b/sources/awesome-widget/plugin/awconfighelper.h @@ -34,31 +34,26 @@ public: virtual ~AWConfigHelper(); Q_INVOKABLE QString configurationDirectory() const; Q_INVOKABLE bool dropCache() const; - Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, - const QString &_fileName) const; + Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const; Q_INVOKABLE QVariantMap importConfiguration(const QString &_fileName, const bool _importPlasmoid, const bool _importExtensions, const bool _importAdds) const; // dataengine Q_INVOKABLE QVariantMap readDataEngineConfiguration() const; - Q_INVOKABLE bool - writeDataEngineConfiguration(const QVariantMap &_configuration) const; + Q_INVOKABLE bool writeDataEngineConfiguration(const QVariantMap &_configuration) const; private: // methods void copyConfigs(const QString &_localDir) const; - void copyExtensions(const QString &_item, const QString &_type, - QSettings &_settings, const bool _inverse) const; + void copyExtensions(const QString &_item, const QString &_type, QSettings &_settings, + const bool _inverse) const; void copySettings(QSettings &_from, QSettings &_to) const; - void readFile(QSettings &_settings, const QString &_key, - const QString &_fileName) const; - void writeFile(QSettings &_settings, const QString &_key, - const QString &_fileName) const; + void readFile(QSettings &_settings, const QString &_key, const QString &_fileName) const; + void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName) const; // properties QString m_baseDir; - QStringList m_dirs - = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"}; + QStringList m_dirs = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"}; }; diff --git a/sources/awesome-widget/plugin/awcustomkeysconfig.cpp b/sources/awesome-widget/plugin/awcustomkeysconfig.cpp index 5409151..5435b86 100644 --- a/sources/awesome-widget/plugin/awcustomkeysconfig.cpp +++ b/sources/awesome-widget/plugin/awcustomkeysconfig.cpp @@ -21,8 +21,7 @@ #include "awdebug.h" -AWCustomKeysConfig::AWCustomKeysConfig(QWidget *_parent, - const QStringList &_keys) +AWCustomKeysConfig::AWCustomKeysConfig(QWidget *_parent, const QStringList &_keys) : AWAbstractPairConfig(_parent, false, _keys) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; diff --git a/sources/awesome-widget/plugin/awdataaggregator.cpp b/sources/awesome-widget/plugin/awdataaggregator.cpp index b7f239b..48e9e1e 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataaggregator.cpp @@ -60,10 +60,9 @@ QString AWDataAggregator::htmlImage(const QPixmap &_source) const QBuffer buffer(&byteArray); _source.save(&buffer, "PNG"); - return byteArray.isEmpty() - ? "" - : QString("") - .arg(QString(byteArray.toBase64())); + return byteArray.isEmpty() ? "" + : QString("") + .arg(QString(byteArray.toBase64())); } @@ -125,8 +124,7 @@ QPixmap AWDataAggregator::tooltipImage() shift -= 100.0; // apply pen color if (key != "batTooltip") - pen.setColor(QColor( - m_configuration[QString("%1Color").arg(key)].toString())); + pen.setColor(QColor(m_configuration[QString("%1Color").arg(key)].toString())); // paint data inside frame for (int j = 0; j < m_values[key].count() - 1; j++) { // some magic here @@ -136,11 +134,9 @@ QPixmap AWDataAggregator::tooltipImage() float y2 = -std::fabs(m_values[key].at(j + 1)) * normY + 5.0f; if (key == "batTooltip") { if (m_values[key].at(j + 1) > 0) - pen.setColor( - QColor(m_configuration["batTooltipColor"].toString())); + pen.setColor(QColor(m_configuration["batTooltipColor"].toString())); else - pen.setColor(QColor( - m_configuration["batInTooltipColor"].toString())); + pen.setColor(QColor(m_configuration["batInTooltipColor"].toString())); } m_toolTipScene->addLine(x1, y1, x2, y2, pen); } @@ -163,33 +159,27 @@ void AWDataAggregator::dataUpdate(const QVariantHash &_values) void AWDataAggregator::checkValue(const QString &_source, const float _value, const float _extremum) const { - qCDebug(LOG_AW) << "Notification source" << _source << "with value" - << _value << "called with extremum" << _extremum; + qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value + << "called with extremum" << _extremum; if (_value >= 0.0) { - if ((m_enablePopup) && (_value > _extremum) - && (m_values[_source].last() < _extremum)) - return AWActions::sendNotification( - "event", notificationText(_source, _value)); + if ((m_enablePopup) && (_value > _extremum) && (m_values[_source].last() < _extremum)) + return AWActions::sendNotification("event", notificationText(_source, _value)); } else { - if ((m_enablePopup) && (_value < _extremum) - && (m_values[_source].last() > _extremum)) - return AWActions::sendNotification( - "event", notificationText(_source, _value)); + if ((m_enablePopup) && (_value < _extremum) && (m_values[_source].last() > _extremum)) + return AWActions::sendNotification("event", notificationText(_source, _value)); } } -void AWDataAggregator::checkValue(const QString &_source, - const QString &_current, +void AWDataAggregator::checkValue(const QString &_source, const QString &_current, const QString &_received) const { - qCDebug(LOG_AW) << "Notification source" << _source << "with current value" - << _current << "and received one" << _received; + qCDebug(LOG_AW) << "Notification source" << _source << "with current value" << _current + << "and received one" << _received; if ((m_enablePopup) && (_current != _received) && (!_received.isEmpty())) - return AWActions::sendNotification( - "event", notificationText(_source, _received)); + return AWActions::sendNotification("event", notificationText(_source, _received)); } @@ -205,11 +195,9 @@ void AWDataAggregator::initScene() } -QString AWDataAggregator::notificationText(const QString &_source, - const float _value) const +QString AWDataAggregator::notificationText(const QString &_source, const float _value) const { - qCDebug(LOG_AW) << "Notification source" << _source << "with value" - << _value; + qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value; QString output; if (_source == "batTooltip") @@ -227,11 +215,9 @@ QString AWDataAggregator::notificationText(const QString &_source, } -QString AWDataAggregator::notificationText(const QString &_source, - const QString &_value) const +QString AWDataAggregator::notificationText(const QString &_source, const QString &_value) const { - qCDebug(LOG_AW) << "Notification source" << _source << "with value" - << _value; + qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value; QString output; if (_source == "netdev") @@ -245,8 +231,8 @@ void AWDataAggregator::setData(const QVariantHash &_values) { // do not log these arguments // battery update requires info is AC online or not - setData(_values["ac"].toString() == m_configuration["acOnline"], - "batTooltip", _values["bat"].toFloat()); + setData(_values["ac"].toString() == m_configuration["acOnline"], "batTooltip", + _values["bat"].toFloat()); // usual case setData("cpuTooltip", _values["cpu"].toFloat(), 90.0); setData("cpuclTooltip", _values["cpucl"].toFloat()); @@ -267,16 +253,13 @@ void AWDataAggregator::setData(const QVariantHash &_values) } -void AWDataAggregator::setData(const QString &_source, float _value, - const float _extremum) +void AWDataAggregator::setData(const QString &_source, float _value, const float _extremum) { - qCDebug(LOG_AW) << "Source" << _source << "to value" << _value - << "with extremum" << _extremum; + qCDebug(LOG_AW) << "Source" << _source << "to value" << _value << "with extremum" << _extremum; if (m_values[_source].count() == 0) m_values[_source].append(0.0); - else if (m_values[_source].count() - > m_configuration["tooltipNumber"].toInt()) + else if (m_values[_source].count() > m_configuration["tooltipNumber"].toInt()) m_values[_source].removeFirst(); if (std::isnan(_value)) _value = 0.0; @@ -286,8 +269,7 @@ void AWDataAggregator::setData(const QString &_source, float _value, m_values[_source].append(_value); if (_source == "downkbTooltip") { - QList netValues - = m_values["downkbTooltip"] + m_values["upkbTooltip"]; + QList netValues = m_values["downkbTooltip"] + m_values["upkbTooltip"]; // to avoid inf value of normY netValues << 1.0; m_boundaries["downkbTooltip"] @@ -297,11 +279,10 @@ void AWDataAggregator::setData(const QString &_source, float _value, } -void AWDataAggregator::setData(const bool _dontInvert, const QString &_source, - float _value) +void AWDataAggregator::setData(const bool _dontInvert, const QString &_source, float _value) { - qCDebug(LOG_AW) << "Do not invert" << _dontInvert << "value" << _value - << "for source" << _source; + qCDebug(LOG_AW) << "Do not invert" << _dontInvert << "value" << _value << "for source" + << _source; // invert values for different battery colours _value = _dontInvert ? _value : -_value; diff --git a/sources/awesome-widget/plugin/awdataaggregator.h b/sources/awesome-widget/plugin/awdataaggregator.h index b554477..d0769dd 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.h +++ b/sources/awesome-widget/plugin/awdataaggregator.h @@ -49,18 +49,15 @@ private: // ui QGraphicsScene *m_toolTipScene = nullptr; QGraphicsView *m_toolTipView = nullptr; - void checkValue(const QString &_source, const float _value, - const float _extremum) const; + void checkValue(const QString &_source, const float _value, const float _extremum) const; void checkValue(const QString &_source, const QString &_current, const QString &_received) const; void initScene(); QString notificationText(const QString &_source, const float _value) const; - QString notificationText(const QString &_source, - const QString &_value) const; + QString notificationText(const QString &_source, const QString &_value) const; // main method void setData(const QVariantHash &_values); - void setData(const QString &_source, float _value, - const float _extremum = -1.0f); + void setData(const QString &_source, float _value, const float _extremum = -1.0f); // different signature for battery device void setData(const bool _dontInvert, const QString &_source, float _value); // variables diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index 6ca46ef..e6d2c1c 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -34,13 +34,12 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent) m_dataEngines["time"] = m_consumer->dataEngine("time"); // additional method required by systemmonitor structure - m_newSourceConnection = connect( - m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, - [this](const QString source) { - emit(deviceAdded(source)); - m_dataEngines["systemmonitor"]->connectSource(source, parent(), - 1000); - }); + m_newSourceConnection + = connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, + [this](const QString source) { + emit(deviceAdded(source)); + m_dataEngines["systemmonitor"]->connectSource(source, parent(), 1000); + }); // required to define Qt::QueuedConnection for signal-slot connection qRegisterMetaType("Plasma::DataEngine::Data"); @@ -74,13 +73,12 @@ void AWDataEngineAggregator::reconnectSources(const int _interval) m_dataEngines["extsysmon"]->connectAllSources(parent(), _interval); m_dataEngines["time"]->connectSource("Local", parent(), 1000); - m_newSourceConnection = connect( - m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, - [this, _interval](const QString source) { - emit(deviceAdded(source)); - m_dataEngines["systemmonitor"]->connectSource(source, parent(), - _interval); - }); + m_newSourceConnection + = connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, + [this, _interval](const QString source) { + emit(deviceAdded(source)); + m_dataEngines["systemmonitor"]->connectSource(source, parent(), _interval); + }); #ifdef BUILD_FUTURE createQueuedConnection(); @@ -105,24 +103,18 @@ void AWDataEngineAggregator::createQueuedConnection() // for more details refer to plasma-framework source code for (auto &dataEngine : m_dataEngines.keys()) { // different source set for different engines - QStringList sources = dataEngine == "time" - ? QStringList() << "Local" - : m_dataEngines[dataEngine]->sources(); + QStringList sources = dataEngine == "time" ? QStringList() << "Local" + : m_dataEngines[dataEngine]->sources(); // reconnect sources for (auto &source : sources) { Plasma::DataContainer *container = m_dataEngines[dataEngine]->containerForSource(source); // disconnect old connections first - disconnect(container, - SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), - parent(), + disconnect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(), SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); // and now reconnect with Qt::QueuedConnection type - connect(container, - SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), - parent(), - SLOT(dataUpdated(QString, Plasma::DataEngine::Data)), - Qt::QueuedConnection); + connect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(), + SLOT(dataUpdated(QString, Plasma::DataEngine::Data)), Qt::QueuedConnection); } } } diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index 581d0f0..fa7f004 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -23,8 +23,7 @@ #include "awformatterhelper.h" -AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, - AWFormatterHelper *_custom) +AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_custom) : QObject(_parent) , m_customFormatters(_custom) { @@ -59,8 +58,7 @@ AWDataEngineMapper::~AWDataEngineMapper() } -AWKeysAggregator::FormatterType -AWDataEngineMapper::formatter(const QString &_key) const +AWKeysAggregator::FormatterType AWDataEngineMapper::formatter(const QString &_key) const { qCDebug(LOG_AW) << "Get formatter for key" << _key; @@ -78,8 +76,7 @@ QStringList AWDataEngineMapper::keysFromSource(const QString &_source) const // HACK units required to define should the value be calculated as temperature // or fan data -QStringList AWDataEngineMapper::registerSource(const QString &_source, - const QString &_units, +QStringList AWDataEngineMapper::registerSource(const QString &_source, const QString &_units, const QStringList &_keys) { qCDebug(LOG_AW) << "Source" << _source << "with units" << _units; @@ -92,10 +89,8 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, QRegExp mountFillRegExp = QRegExp("partitions/.*/filllevel"); QRegExp mountFreeRegExp = QRegExp("partitions/.*/freespace"); QRegExp mountUsedRegExp = QRegExp("partitions/.*/usedspace"); - QRegExp netRegExp - = QRegExp("network/interfaces/.*/(receiver|transmitter)/data$"); - QRegExp netTotalRegExp - = QRegExp("network/interfaces/.*/(receiver|transmitter)/dataTotal$"); + QRegExp netRegExp = QRegExp("network/interfaces/.*/(receiver|transmitter)/data$"); + QRegExp netTotalRegExp = QRegExp("network/interfaces/.*/(receiver|transmitter)/dataTotal$"); if (_source == "battery/ac") { // AC @@ -106,9 +101,8 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, QString key = _source; key.remove("battery/"); m_map[_source] = key; - m_formatter[key] = _source.contains("rate") - ? AWKeysAggregator::FormatterType::Float - : AWKeysAggregator::FormatterType::IntegerThree; + m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float + : AWKeysAggregator::FormatterType::IntegerThree; } else if (_source == "cpu/system/TotalLoad") { // cpu m_map[_source] = "cpu"; @@ -338,12 +332,10 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, // free swap // mb m_map[_source] = "swapfreemb"; - m_formatter["swapfreemb"] - = AWKeysAggregator::FormatterType::MemMBFormat; + m_formatter["swapfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat; // gb m_map.insertMulti(_source, "swapfreegb"); - m_formatter["swapfreegb"] - = AWKeysAggregator::FormatterType::MemGBFormat; + m_formatter["swapfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat; } else if (_source == "mem/swap/used") { // used swap // mb @@ -361,9 +353,8 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, if (index > -1) { QString key = QString("temp%1").arg(index); m_map[_source] = key; - m_formatter[key] - = _units == "°C" ? AWKeysAggregator::FormatterType::Temperature - : AWKeysAggregator::FormatterType::Integer; + m_formatter[key] = _units == "°C" ? AWKeysAggregator::FormatterType::Temperature + : AWKeysAggregator::FormatterType::Integer; } } else if (_source == "Local") { // time @@ -417,8 +408,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, QStringList customFormattersKeys; if (m_customFormatters) customFormattersKeys = m_customFormatters->definedFormatters(); - qCInfo(LOG_AW) << "Looking for formatters" << foundKeys << "in" - << customFormattersKeys; + qCInfo(LOG_AW) << "Looking for formatters" << foundKeys << "in" << customFormattersKeys; for (auto &key : foundKeys) { if (!customFormattersKeys.contains(key)) continue; @@ -427,11 +417,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, // drop key from dictionary if no one user requested key required it qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys; - bool required - = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), - [&_keys](const QString &key) { - return _keys.contains(key); - }); + bool required = _keys.isEmpty() + || std::any_of(foundKeys.cbegin(), foundKeys.cend(), + [&_keys](const QString &key) { return _keys.contains(key); }); if (!required) { m_map.remove(_source); for (auto &key : foundKeys) diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index e070f23..9f00e75 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -32,8 +32,7 @@ class AWDataEngineMapper : public QObject Q_OBJECT public: - explicit AWDataEngineMapper(QObject *_parent = nullptr, - AWFormatterHelper *_custom = nullptr); + explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr); virtual ~AWDataEngineMapper(); // get methods AWKeysAggregator::FormatterType formatter(const QString &_key) const; diff --git a/sources/awesome-widget/plugin/awdbusadaptor.cpp b/sources/awesome-widget/plugin/awdbusadaptor.cpp index db6b545..10a7906 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.cpp +++ b/sources/awesome-widget/plugin/awdbusadaptor.cpp @@ -40,8 +40,8 @@ AWDBusAdaptor::~AWDBusAdaptor() QStringList AWDBusAdaptor::ActiveServices() const { - QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call( - QDBus::BlockWithGui, "ListNames"); + QDBusMessage listServices + = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, "ListNames"); if (listServices.arguments().isEmpty()) { qCWarning(LOG_DBUS) << "Could not find any DBus service"; return {}; @@ -86,8 +86,8 @@ void AWDBusAdaptor::SetLogLevel(const QString &what, const int level) qCDebug(LOG_DBUS) << "Set log level" << level << "for" << what; if (level >= m_logLevels.count()) { - qCDebug(LOG_DBUS) << "Invalid logging level" << level - << "should be less than" << m_logLevels.count(); + qCDebug(LOG_DBUS) << "Invalid logging level" << level << "should be less than" + << m_logLevels.count(); return; } @@ -96,19 +96,15 @@ void AWDBusAdaptor::SetLogLevel(const QString &what, const int level) } -void AWDBusAdaptor::SetLogLevel(const QString &what, const QString &level, - const bool enabled) +void AWDBusAdaptor::SetLogLevel(const QString &what, const QString &level, const bool enabled) { - qCDebug(LOG_DBUS) << "Set log level" << level << "enabled" << enabled - << "for" << what; + qCDebug(LOG_DBUS) << "Set log level" << level << "enabled" << enabled << "for" << what; if (!m_logLevels.contains(level)) { - qCDebug(LOG_DBUS) << "Invalid logging level" << level << "should be in" - << m_logLevels; + qCDebug(LOG_DBUS) << "Invalid logging level" << level << "should be in" << m_logLevels; return; } QString state = enabled ? "true" : "false"; - QLoggingCategory::setFilterRules( - QString("%1.%2=%3").arg(what).arg(level).arg(state)); + QLoggingCategory::setFilterRules(QString("%1.%2=%3").arg(what).arg(level).arg(state)); } diff --git a/sources/awesome-widget/plugin/awdbusadaptor.h b/sources/awesome-widget/plugin/awdbusadaptor.h index f73110f..a790c2d 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.h +++ b/sources/awesome-widget/plugin/awdbusadaptor.h @@ -44,8 +44,7 @@ public slots: qlonglong WhoAmI() const; // set methods void SetLogLevel(const QString &what, const int level); - void SetLogLevel(const QString &what, const QString &level, - const bool enabled); + void SetLogLevel(const QString &what, const QString &level, const bool enabled); private: AWKeys *m_plugin = nullptr; diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index f06e39a..d00d844 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -35,8 +35,7 @@ AWFormatterHelper::AWFormatterHelper(QWidget *_parent) : AbstractExtItemAggregator(_parent, "formatters") - , AWAbstractPairHelper("awesomewidgets/formatters/formatters.ini", - "Formatters") + , AWAbstractPairHelper("awesomewidgets/formatters/formatters.ini", "Formatters") { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; @@ -63,8 +62,7 @@ void AWFormatterHelper::initItems() for (auto &key : pairs().keys()) { auto name = pairs()[key]; if (!m_formattersClasses.contains(name)) { - qCWarning(LOG_AW) - << "Invalid formatter" << name << "found in" << key; + qCWarning(LOG_AW) << "Invalid formatter" << name << "found in" << key; continue; } @@ -73,13 +71,11 @@ void AWFormatterHelper::initItems() } -QString AWFormatterHelper::convert(const QVariant &_value, - const QString &_name) const +QString AWFormatterHelper::convert(const QVariant &_value, const QString &_name) const { qCDebug(LOG_AW) << "Convert value" << _value << "for" << _name; - return m_formatters.contains(_name) ? m_formatters[_name]->convert(_value) - : _value.toString(); + return m_formatters.contains(_name) ? m_formatters[_name]->convert(_value) : _value.toString(); } @@ -130,8 +126,7 @@ AWFormatterHelper::defineFormatterClass(const QString &_stringType) const { qCDebug(LOG_AW) << "Define formatter class for" << _stringType; - AWAbstractFormatter::FormatterClass formatter - = AWAbstractFormatter::FormatterClass::NoFormat; + AWAbstractFormatter::FormatterClass formatter = AWAbstractFormatter::FormatterClass::NoFormat; if (_stringType == "DateTime") formatter = AWAbstractFormatter::FormatterClass::DateTime; else if (_stringType == "Float") @@ -177,32 +172,25 @@ void AWFormatterHelper::initFormatters() auto metadata = readMetadata(filePath); switch (metadata.second) { case AWAbstractFormatter::FormatterClass::DateTime: - m_formattersClasses[metadata.first] - = new AWDateTimeFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWDateTimeFormatter(this, filePath); break; case AWAbstractFormatter::FormatterClass::Float: - m_formattersClasses[metadata.first] - = new AWFloatFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWFloatFormatter(this, filePath); break; case AWAbstractFormatter::FormatterClass::List: - m_formattersClasses[metadata.first] - = new AWListFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWListFormatter(this, filePath); break; case AWAbstractFormatter::FormatterClass::Script: - m_formattersClasses[metadata.first] - = new AWScriptFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWScriptFormatter(this, filePath); break; case AWAbstractFormatter::FormatterClass::String: - m_formattersClasses[metadata.first] - = new AWStringFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWStringFormatter(this, filePath); break; case AWAbstractFormatter::FormatterClass::Json: - m_formattersClasses[metadata.first] - = new AWJsonFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWJsonFormatter(this, filePath); break; case AWAbstractFormatter::FormatterClass::NoFormat: - m_formattersClasses[metadata.first] - = new AWNoFormatter(this, filePath); + m_formattersClasses[metadata.first] = new AWNoFormatter(this, filePath); break; } } @@ -228,19 +216,17 @@ AWFormatterHelper::readMetadata(const QString &_filePath) const void AWFormatterHelper::doCreateItem() { - QStringList selection - = {"NoFormat", "DateTime", "Float", "List", "Script", "String", "Json"}; + QStringList selection = {"NoFormat", "DateTime", "Float", "List", "Script", "String", "Json"}; bool ok; - QString select = QInputDialog::getItem( - this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok); + QString select + = QInputDialog::getItem(this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok); if (!ok) { qCWarning(LOG_AW) << "No type selected"; return; } qCInfo(LOG_AW) << "Selected type" << select; - AWAbstractFormatter::FormatterClass formatter - = defineFormatterClass(select); + AWAbstractFormatter::FormatterClass formatter = defineFormatterClass(select); switch (formatter) { case AWAbstractFormatter::FormatterClass::DateTime: return createItem(); diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h index e8b4950..a1cfd71 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.h +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -24,8 +24,7 @@ #include "awabstractpairhelper.h" -class AWFormatterHelper : public AbstractExtItemAggregator, - public AWAbstractPairHelper +class AWFormatterHelper : public AbstractExtItemAggregator, public AWAbstractPairHelper { Q_OBJECT @@ -48,8 +47,7 @@ public slots: private: // methods - AWAbstractFormatter::FormatterClass - defineFormatterClass(const QString &_stringType) const; + AWAbstractFormatter::FormatterClass defineFormatterClass(const QString &_stringType) const; void initFormatters(); QPair readMetadata(const QString &_filePath) const; diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp index e6a9f91..eac2749 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -29,9 +29,9 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key) { qCDebug(LOG_AW) << "Key" << _key << "with type" << _type; - QString fileName = QString("%1/awesomewidgets.ndx") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericCacheLocation)); + QString fileName + = QString("%1/awesomewidgets.ndx") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); qCInfo(LOG_AW) << "Cache file" << fileName; QSettings cache(fileName, QSettings::IniFormat); @@ -41,8 +41,7 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key) cachedValues.append(cache.value(number).toString()); if (_type == "hdd") { - QStringList allDevices - = QDir("/dev").entryList(QDir::System, QDir::Name); + QStringList allDevices = QDir("/dev").entryList(QDir::System, QDir::Name); QStringList devices = allDevices.filter(QRegExp("^[hms]d[a-z]$")); for (auto &dev : devices) { QString device = QString("/dev/%1").arg(dev); @@ -50,30 +49,23 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key) 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); + cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device); } } else if (_type == "net") { - QList rawInterfaceList - = QNetworkInterface::allInterfaces(); + QList rawInterfaceList = QNetworkInterface::allInterfaces(); for (auto &interface : rawInterfaceList) { QString device = interface.name(); 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); + cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device); } } else { if (cachedValues.contains(_key)) return false; qCInfo(LOG_AW) << "Found new key" << _key << "for type" << _type; - cache.setValue( - QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), - _key); + cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), _key); } cache.endGroup(); @@ -82,14 +74,12 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key) } -QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, - const QStringList &_bars, - const QVariantMap &_tooltip, - const QStringList &_userKeys, +QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringList &_bars, + const QVariantMap &_tooltip, const QStringList &_userKeys, const QStringList &_allKeys) { - qCDebug(LOG_AW) << "Looking for required keys in" << _keys << _bars - << "using tooltip settings" << _tooltip; + qCDebug(LOG_AW) << "Looking for required keys in" << _keys << _bars << "using tooltip settings" + << _tooltip; // initial copy QSet used = QSet::fromList(_keys); @@ -110,8 +100,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, continue; key.remove("hddtotmb"); int index = key.toInt(); - used << QString("hddfreemb%1").arg(index) - << QString("hddmb%1").arg(index); + used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index); } // hddtotgb* for (auto &key : _allKeys.filter(QRegExp("^hddtotgb"))) { @@ -119,8 +108,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, continue; key.remove("hddtotgb"); int index = key.toInt(); - used << QString("hddfreegb%1").arg(index) - << QString("hddgb%1").arg(index); + used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index); } // mem if (used.contains("mem")) @@ -147,13 +135,12 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, used << "swapgb" << "swapfreegb"; // network keys - QStringList netKeys({"up", "upkb", "uptot", "uptotkb", "upunits", "down", - "downkb", "downtot", "downtotkb", "downunits"}); + QStringList netKeys({"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", + "downtotkb", "downunits"}); for (auto &key : netKeys) { if (!used.contains(key)) continue; - QStringList filt - = _allKeys.filter(QRegExp(QString("^%1[0-9]{1,}").arg(key))); + QStringList filt = _allKeys.filter(QRegExp(QString("^%1[0-9]{1,}").arg(key))); for (auto &filtered : filt) used << filtered; } @@ -173,9 +160,9 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, QHash AWKeyCache::loadKeysFromCache() { - QString fileName = QString("%1/awesomewidgets.ndx") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericCacheLocation)); + QString fileName + = QString("%1/awesomewidgets.ndx") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); qCInfo(LOG_AW) << "Cache file" << fileName; QSettings cache(fileName, QSettings::IniFormat); diff --git a/sources/awesome-widget/plugin/awkeycache.h b/sources/awesome-widget/plugin/awkeycache.h index c9fb3bf..0317cc2 100644 --- a/sources/awesome-widget/plugin/awkeycache.h +++ b/sources/awesome-widget/plugin/awkeycache.h @@ -28,8 +28,7 @@ namespace AWKeyCache { bool addKeyToCache(const QString &_type, const QString &_key = ""); QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars, - const QVariantMap &_tooltip, - const QStringList &_userKeys, + const QVariantMap &_tooltip, const QStringList &_userKeys, const QStringList &_allKeys); QHash loadKeysFromCache(); }; diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index 7f6cb1a..f3e3a5c 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -41,10 +41,8 @@ AWKeyOperations::AWKeyOperations(QObject *_parent) qCDebug(LOG_AW) << __PRETTY_FUNCTION__; m_customKeys = new AWCustomKeysHelper(this); - m_graphicalItems - = new ExtItemAggregator(nullptr, "desktops"); - m_extNetRequest - = new ExtItemAggregator(nullptr, "requests"); + m_graphicalItems = new ExtItemAggregator(nullptr, "desktops"); + m_extNetRequest = new ExtItemAggregator(nullptr, "requests"); m_extQuotes = new ExtItemAggregator(nullptr, "quotes"); m_extScripts = new ExtItemAggregator(nullptr, "scripts"); m_extUpgrade = new ExtItemAggregator(nullptr, "upgrade"); @@ -134,8 +132,7 @@ QStringList AWKeyOperations::dictKeys() const // battery QStringList allBatteryDevices = QDir("/sys/class/power_supply") - .entryList(QStringList({"BAT*"}), - QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); for (int i = 0; i < allBatteryDevices.count(); i++) { allKeys.append(QString("bat%1").arg(i)); allKeys.append(QString("batleft%1").arg(i)); @@ -148,15 +145,12 @@ QStringList AWKeyOperations::dictKeys() const allKeys.append(item->tag("pkgcount")); // quotes for (auto &item : m_extQuotes->activeItems()) { - allKeys.append(item->tag("ask")); - allKeys.append(item->tag("askchg")); - allKeys.append(item->tag("percaskchg")); - allKeys.append(item->tag("bid")); - allKeys.append(item->tag("bidchg")); - allKeys.append(item->tag("percbidchg")); allKeys.append(item->tag("price")); allKeys.append(item->tag("pricechg")); allKeys.append(item->tag("percpricechg")); + allKeys.append(item->tag("volume")); + allKeys.append(item->tag("volumechg")); + allKeys.append(item->tag("percvolumechg")); } // custom for (auto &item : m_extScripts->activeItems()) @@ -228,8 +222,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const QString index = _key; index.remove(QRegExp("hdd[rw]")); output = m_devices["disk"][index.toInt()]; - } else if (_key.contains( - QRegExp("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) { + } else if (_key.contains(QRegExp("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) { QString index = _key; index.remove(QRegExp("^hdd(|mb|gb|freemb|freegb|totmb|totgb)")); output = m_devices["mount"][index.toInt()]; @@ -249,8 +242,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const AbstractExtItem *item = m_extQuotes->itemByTag(_key, stripped); if (item) output = item->uniq(); - } else if (_key.contains(QRegExp( - "(weather|weatherId|humidity|pressure|temperature)"))) { + } else if (_key.contains(QRegExp("(weather|weatherId|humidity|pressure|temperature)"))) { AbstractExtItem *item = m_extWeather->itemByTag(_key, stripped); if (item) output = item->uniq(); @@ -289,8 +281,8 @@ void AWKeyOperations::editItem(const QString &_type) qCDebug(LOG_AW) << "Item type" << _type; if (_type == "graphicalitem") { - QStringList keys = dictKeys().filter( - QRegExp("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")); + QStringList keys + = dictKeys().filter(QRegExp("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")); keys.sort(); m_graphicalItems->setConfigArgs(keys); return m_graphicalItems->editItems(); diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 9c8a8c7..208d392 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -62,11 +62,11 @@ AWKeys::AWKeys(QObject *_parent) // transfer signal from AWDataAggregator object to QML ui connect(m_dataAggregator, SIGNAL(toolTipPainted(const QString &)), this, SIGNAL(needToolTipToBeUpdated(const QString &))); - connect(this, SIGNAL(dropSourceFromDataengine(const QString &)), - m_dataEngineAggregator, SLOT(dropSource(const QString &))); + connect(this, SIGNAL(dropSourceFromDataengine(const QString &)), m_dataEngineAggregator, + SLOT(dropSource(const QString &))); // transfer signal from dataengine to update source list - connect(m_dataEngineAggregator, SIGNAL(deviceAdded(const QString &)), - m_keyOperator, SLOT(addDevice(const QString &))); + connect(m_dataEngineAggregator, SIGNAL(deviceAdded(const QString &)), m_keyOperator, + SLOT(addDevice(const QString &))); } @@ -91,17 +91,15 @@ void AWKeys::initDataAggregator(const QVariantMap &_tooltipParams) } -void AWKeys::initKeys(const QString &_currentPattern, const int _interval, - const int _limit, const bool _optimize) +void AWKeys::initKeys(const QString &_currentPattern, const int _interval, const int _limit, + const bool _optimize) { - qCDebug(LOG_AW) << "Pattern" << _currentPattern << "with interval" - << _interval << "and queue limit" << _limit - << "with optimization" << _optimize; + qCDebug(LOG_AW) << "Pattern" << _currentPattern << "with interval" << _interval + << "and queue limit" << _limit << "with optimization" << _optimize; // init m_optimize = _optimize; - m_threadPool->setMaxThreadCount(_limit == 0 ? QThread::idealThreadCount() - : _limit); + m_threadPool->setMaxThreadCount(_limit == 0 ? QThread::idealThreadCount() : _limit); // child objects m_aggregator->initFormatters(); m_keyOperator->setPattern(_currentPattern); @@ -138,8 +136,7 @@ void AWKeys::updateCache() QStringList AWKeys::dictKeys(const bool _sorted, const QString &_regexp) const { - qCDebug(LOG_AW) << "Should be sorted" << _sorted << "and filter applied" - << _regexp; + qCDebug(LOG_AW) << "Should be sorted" << _sorted << "and filter applied" << _regexp; // check if functions asked if (_regexp == "functions") @@ -190,8 +187,7 @@ QString AWKeys::valueByKey(const QString &_key) const { qCDebug(LOG_AW) << "Requested value for key" << _key; - QString trueKey - = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key; + QString trueKey = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key; return m_aggregator->formatter(m_values[trueKey], trueKey); } @@ -205,12 +201,10 @@ void AWKeys::editItem(const QString &_type) } -void AWKeys::dataUpdated(const QString &_sourceName, - const Plasma::DataEngine::Data &_data) +void AWKeys::dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data) { // run concurrent data update - QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, _sourceName, - _data); + QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, _sourceName, _data); } @@ -219,28 +213,24 @@ void AWKeys::reinitKeys(const QStringList &_currentKeys) qCDebug(LOG_AW) << "Update found keys by using list" << _currentKeys; // append lists - m_foundBars = AWPatternFunctions::findKeys(m_keyOperator->pattern(), - _currentKeys, true); - m_foundKeys = AWPatternFunctions::findKeys(m_keyOperator->pattern(), - _currentKeys, false); + m_foundBars = AWPatternFunctions::findKeys(m_keyOperator->pattern(), _currentKeys, true); + m_foundKeys = AWPatternFunctions::findKeys(m_keyOperator->pattern(), _currentKeys, false); m_foundLambdas = AWPatternFunctions::findLambdas(m_keyOperator->pattern()); // generate list of required keys for bars QStringList barKeys; for (auto &bar : m_foundBars) { GraphicalItem *item = m_keyOperator->giByKey(bar); if (item->isCustom()) - item->setUsedKeys( - AWPatternFunctions::findKeys(item->bar(), _currentKeys, false)); + item->setUsedKeys(AWPatternFunctions::findKeys(item->bar(), _currentKeys, false)); else item->setUsedKeys(QStringList() << item->bar()); barKeys.append(item->usedKeys()); } // get required keys - m_requiredKeys = m_optimize - ? AWKeyCache::getRequiredKeys( - m_foundKeys, barKeys, m_tooltipParams, - m_keyOperator->requiredUserKeys(), _currentKeys) - : QStringList(); + m_requiredKeys + = m_optimize ? AWKeyCache::getRequiredKeys(m_foundKeys, barKeys, m_tooltipParams, + m_keyOperator->requiredUserKeys(), _currentKeys) + : QStringList(); // set key data to m_aggregator m_aggregator->setDevices(m_keyOperator->devices()); @@ -278,17 +268,13 @@ void AWKeys::calculateValues() } // memtot* - m_values["memtotmb"] - = m_values["memusedmb"].toInt() + m_values["memfreemb"].toInt(); - m_values["memtotgb"] - = m_values["memusedgb"].toFloat() + m_values["memfreegb"].toFloat(); + m_values["memtotmb"] = m_values["memusedmb"].toInt() + m_values["memfreemb"].toInt(); + m_values["memtotgb"] = m_values["memusedgb"].toFloat() + m_values["memfreegb"].toFloat(); // mem - m_values["mem"] - = 100.0f * m_values["memmb"].toFloat() / m_values["memtotmb"].toFloat(); + m_values["mem"] = 100.0f * m_values["memmb"].toFloat() / m_values["memtotmb"].toFloat(); // up, down, upkb, downkb, upunits, downunits - int netIndex - = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString()); + int netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString()); m_values["down"] = m_values[QString("down%1").arg(netIndex)]; m_values["downkb"] = m_values[QString("downkb%1").arg(netIndex)]; m_values["downtot"] = m_values[QString("downtot%1").arg(netIndex)]; @@ -301,13 +287,10 @@ void AWKeys::calculateValues() m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)]; // swaptot* - m_values["swaptotmb"] - = m_values["swapmb"].toInt() + m_values["swapfreemb"].toInt(); - m_values["swaptotgb"] - = m_values["swapgb"].toFloat() + m_values["swapfreegb"].toFloat(); + m_values["swaptotmb"] = m_values["swapmb"].toInt() + m_values["swapfreemb"].toInt(); + m_values["swaptotgb"] = m_values["swapgb"].toFloat() + m_values["swapfreegb"].toFloat(); // swap - m_values["swap"] = 100.0f * m_values["swapmb"].toFloat() - / m_values["swaptotmb"].toFloat(); + m_values["swap"] = 100.0f * m_values["swapmb"].toFloat() / m_values["swaptotmb"].toFloat(); // user defined keys for (auto &key : m_keyOperator->userKeys()) @@ -315,8 +298,7 @@ void AWKeys::calculateValues() // lambdas for (auto &key : m_foundLambdas) - m_values[key] = AWPatternFunctions::expandLambdas( - key, m_aggregator, m_values, m_foundKeys); + m_values[key] = AWPatternFunctions::expandLambdas(key, m_aggregator, m_values, m_foundKeys); } @@ -329,8 +311,7 @@ void AWKeys::createDBusInterface() QDBusConnection instanceBus = QDBusConnection::sessionBus(); // HACK we are going to use different services because it binds to // application - if (instanceBus.registerService( - QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id))) { + if (instanceBus.registerService(QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id))) { if (!instanceBus.registerObject(AWDBUS_PATH, new AWDBusAdaptor(this), QDBusConnection::ExportAllContents)) qCWarning(LOG_AW) << "Could not register DBus object, last error" @@ -359,17 +340,15 @@ QString AWKeys::parsePattern(QString _pattern) const // main keys for (auto &key : m_foundKeys) - _pattern.replace(QString("$%1").arg(key), - m_aggregator->formatter(m_values[key], key)); + _pattern.replace(QString("$%1").arg(key), m_aggregator->formatter(m_values[key], key)); // bars for (auto &bar : m_foundBars) { GraphicalItem *item = m_keyOperator->giByKey(bar); - QString image - = item->isCustom() - ? item->image(AWPatternFunctions::expandLambdas( - item->bar(), m_aggregator, m_values, item->usedKeys())) - : item->image(m_values[item->bar()]); + QString image = item->isCustom() + ? item->image(AWPatternFunctions::expandLambdas( + item->bar(), m_aggregator, m_values, item->usedKeys())) + : item->image(m_values[item->bar()]); _pattern.replace(QString("$%1").arg(bar), image); } @@ -382,16 +361,14 @@ QString AWKeys::parsePattern(QString _pattern) const } -void AWKeys::setDataBySource(const QString &_sourceName, - const QVariantMap &_data) +void AWKeys::setDataBySource(const QString &_sourceName, const QVariantMap &_data) { qCDebug(LOG_AW) << "Source" << _sourceName << "with data" << _data; // first list init QStringList tags = m_aggregator->keysFromSource(_sourceName); if (tags.isEmpty()) - tags = m_aggregator->registerSource( - _sourceName, _data["units"].toString(), m_requiredKeys); + tags = m_aggregator->registerSource(_sourceName, _data["units"].toString(), m_requiredKeys); // update data or drop source if there are no matches and exit if (tags.isEmpty()) { @@ -401,10 +378,8 @@ void AWKeys::setDataBySource(const QString &_sourceName, m_mutex.lock(); // HACK workaround for time values which are stored in the different path - std::for_each(tags.cbegin(), tags.cend(), - [this, &_data, &_sourceName](const QString &tag) { - m_values[tag] = _sourceName == "Local" ? _data["DateTime"] - : _data["value"]; - }); + std::for_each(tags.cbegin(), tags.cend(), [this, &_data, &_sourceName](const QString &tag) { + m_values[tag] = _sourceName == "Local" ? _data["DateTime"] : _data["value"]; + }); m_mutex.unlock(); } diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index 0c49b8c..a1864ee 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -40,18 +40,15 @@ public: explicit AWKeys(QObject *_parent = nullptr); virtual ~AWKeys(); Q_INVOKABLE void initDataAggregator(const QVariantMap &_tooltipParams); - Q_INVOKABLE void initKeys(const QString &_currentPattern, - const int _interval, const int _limit, + Q_INVOKABLE void initKeys(const QString &_currentPattern, const int _interval, const int _limit, const bool _optimize); - Q_INVOKABLE void setAggregatorProperty(const QString &_key, - const QVariant &_value); + Q_INVOKABLE void setAggregatorProperty(const QString &_key, const QVariant &_value); Q_INVOKABLE void setWrapNewLines(const bool _wrap); // additional method to force load keys from Qml UI. Used in some // configuration pages Q_INVOKABLE void updateCache(); // keys - Q_INVOKABLE QStringList dictKeys(const bool _sorted = false, - const QString &_regexp = "") const; + Q_INVOKABLE QStringList dictKeys(const bool _sorted = false, const QString &_regexp = "") const; Q_INVOKABLE QVariantList getHddDevices() const; // values Q_INVOKABLE QString infoByKey(const QString &_key) const; @@ -60,8 +57,7 @@ public: Q_INVOKABLE void editItem(const QString &_type); public slots: - void dataUpdated(const QString &_sourceName, - const Plasma::DataEngine::Data &_data); + void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data); // dummy method required by DataEngine connections void modelChanged(QString, QAbstractItemModel *){}; diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index b099019..47632cb 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -55,8 +55,7 @@ void AWKeysAggregator::initFormatters() } -QString AWKeysAggregator::formatter(const QVariant &_data, - const QString &_key) const +QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key) const { qCDebug(LOG_AW) << "Data" << _data << "for key" << _key; @@ -86,8 +85,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, output = _data.toBool() ? m_acOnline : m_acOffline; break; case FormatterType::MemGBFormat: - output - = QString("%1").arg(_data.toFloat() / (1024.0 * 1024.0), 5, 'f', 1); + output = QString("%1").arg(_data.toFloat() / (1024.0 * 1024.0), 5, 'f', 1); break; case FormatterType::MemMBFormat: output = QString("%1").arg(_data.toFloat() / 1024.0, 5, 'f', 0); @@ -134,8 +132,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, output = loc.toString(_data.toDateTime(), QLocale::ShortFormat); break; case FormatterType::Timestamp: - output = QString("%1").arg( - _data.toDateTime().toMSecsSinceEpoch() / 1000.0, 10, 'f', 0); + output = QString("%1").arg(_data.toDateTime().toMSecsSinceEpoch() / 1000.0, 10, 'f', 0); break; case FormatterType::Uptime: case FormatterType::UptimeCustom: @@ -145,19 +142,14 @@ QString AWKeysAggregator::formatter(const QVariant &_data, int minutes = seconds / 60 % 60; int hours = ((seconds / 60) - minutes) / 60 % 24; int days = (((seconds / 60) - minutes) / 60 - hours) / 24; - source.replace("$dd", - QString("%1").arg(days, 3, 10, QChar('0'))); + source.replace("$dd", QString("%1").arg(days, 3, 10, QChar('0'))); source.replace("$d", QString("%1").arg(days)); - source.replace("$hh", - QString("%1").arg(hours, 2, 10, QChar('0'))); + source.replace("$hh", QString("%1").arg(hours, 2, 10, QChar('0'))); source.replace("$h", QString("%1").arg(hours)); - source.replace("$mm", - QString("%1").arg(minutes, 2, 10, QChar('0'))); + source.replace("$mm", QString("%1").arg(minutes, 2, 10, QChar('0'))); source.replace("$m", QString("%1").arg(minutes)); return source; - }(m_mapper->formatter(_key) == FormatterType::Uptime - ? "$ddd$hhh$mmm" - : m_customUptime, + }(m_mapper->formatter(_key) == FormatterType::Uptime ? "$ddd$hhh$mmm" : m_customUptime, static_cast(_data.toFloat())); break; case FormatterType::NoFormat: @@ -241,8 +233,7 @@ void AWKeysAggregator::setTranslate(const bool _translate) } -QStringList AWKeysAggregator::registerSource(const QString &_source, - const QString &_units, +QStringList AWKeysAggregator::registerSource(const QString &_source, const QString &_units, const QStringList &_keys) { qCDebug(LOG_AW) << "Source" << _source << "with units" << _units; diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index d6d5d1a..8f99846 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -32,8 +32,7 @@ class AWKeysAggregator : public QObject Q_PROPERTY(QString acOffline MEMBER m_acOffline WRITE setAcOffline); Q_PROPERTY(QString acOnline MEMBER m_acOnline WRITE setAcOnline); Q_PROPERTY(QString customTime MEMBER m_customTime WRITE setCustomTime); - Q_PROPERTY( - QString customUptime MEMBER m_customUptime WRITE setCustomUptime); + Q_PROPERTY(QString customUptime MEMBER m_customUptime WRITE setCustomUptime); Q_PROPERTY(QString tempUnits MEMBER m_tempUnits WRITE setTempUnits); Q_PROPERTY(bool translate MEMBER m_translate WRITE setTranslate); diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index b3d5ad5..c7feea7 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -24,8 +24,7 @@ #include "awkeysaggregator.h" -QString AWPatternFunctions::expandLambdas(QString _code, - AWKeysAggregator *_aggregator, +QString AWPatternFunctions::expandLambdas(QString _code, AWKeysAggregator *_aggregator, const QVariantHash &_metadata, const QStringList &_usedKeys) { @@ -41,9 +40,8 @@ QString AWPatternFunctions::expandLambdas(QString _code, qCInfo(LOG_AW) << "Expression" << _code; QJSValue result = engine.evaluate(_code); if (result.isError()) { - qCWarning(LOG_AW) << "Uncaught exception at line" - << result.property("lineNumber").toInt() << ":" - << result.toString(); + qCWarning(LOG_AW) << "Uncaught exception at line" << result.property("lineNumber").toInt() + << ":" << result.toString(); return ""; } else { return result.toString(); @@ -57,8 +55,7 @@ QString AWPatternFunctions::expandTemplates(QString _code) // match the following construction $template{{some code here}} QRegularExpression templatesRegexp("\\$template\\{\\{(?.*?)\\}\\}"); - templatesRegexp.setPatternOptions( - QRegularExpression::DotMatchesEverythingOption); + templatesRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatchIterator it = templatesRegexp.globalMatch(_code); while (it.hasNext()) { @@ -71,8 +68,7 @@ QString AWPatternFunctions::expandTemplates(QString _code) QString templateResult = ""; if (result.isError()) { qCWarning(LOG_AW) << "Uncaught exception at line" - << result.property("lineNumber").toInt() << ":" - << result.toString(); + << result.property("lineNumber").toInt() << ":" << result.toString(); } else { templateResult = result.toString(); } @@ -86,8 +82,7 @@ QString AWPatternFunctions::expandTemplates(QString _code) QList -AWPatternFunctions::findFunctionCalls(const QString &_function, - const QString &_code) +AWPatternFunctions::findFunctionCalls(const QString &_function, const QString &_code) { qCDebug(LOG_AW) << "Looking for function" << _function << "in" << _code; @@ -98,8 +93,7 @@ AWPatternFunctions::findFunctionCalls(const QString &_function, // * body depends on the function name, double brackets should be screened // by using $, e.g. ${ QRegularExpression regex( - QString("\\$%1\\<(?.*?)\\>\\{\\{(?.*?)\\}\\}") - .arg(_function)); + QString("\\$%1\\<(?.*?)\\>\\{\\{(?.*?)\\}\\}").arg(_function)); regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); QList foundFunctions; @@ -116,9 +110,8 @@ AWPatternFunctions::findFunctionCalls(const QString &_function, // replace '$,' to 0x1d argsString.replace("$,", QString(0x1d)); QStringList args = argsString.split(','); - std::for_each(args.begin(), args.end(), [](QString &arg) { - arg.replace(QString(0x1d), ","); - }); + std::for_each(args.begin(), args.end(), + [](QString &arg) { arg.replace(QString(0x1d), ","); }); metadata.args = args; } // other variables @@ -134,20 +127,17 @@ AWPatternFunctions::findFunctionCalls(const QString &_function, } -QString AWPatternFunctions::insertAllKeys(QString _code, - const QStringList &_keys) +QString AWPatternFunctions::insertAllKeys(QString _code, const QStringList &_keys) { - qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" - << _keys; + qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" << _keys; QList found = AWPatternFunctions::findFunctionCalls("aw_all", _code); for (auto &function : found) { QString separator = function.args.isEmpty() ? "," : 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); - }); + std::for_each(required.begin(), required.end(), + [](QString &value) { value = QString("%1: $%1").arg(value); }); _code.replace(function.what, required.join(separator)); } @@ -156,11 +146,9 @@ QString AWPatternFunctions::insertAllKeys(QString _code, } -QString AWPatternFunctions::insertKeyCount(QString _code, - const QStringList &_keys) +QString AWPatternFunctions::insertKeyCount(QString _code, const QStringList &_keys) { - qCDebug(LOG_AW) << "Looking for count in code" << _code << "using list" - << _keys; + qCDebug(LOG_AW) << "Looking for count in code" << _code << "using list" << _keys; QList found = AWPatternFunctions::findFunctionCalls("aw_count", _code); @@ -174,11 +162,9 @@ QString AWPatternFunctions::insertKeyCount(QString _code, } -QString AWPatternFunctions::insertKeyNames(QString _code, - const QStringList &_keys) +QString AWPatternFunctions::insertKeyNames(QString _code, const QStringList &_keys) { - qCDebug(LOG_AW) << "Looking for key names in code" << _code << "using list" - << _keys; + qCDebug(LOG_AW) << "Looking for key names in code" << _code << "using list" << _keys; QList found = AWPatternFunctions::findFunctionCalls("aw_names", _code); @@ -195,17 +181,15 @@ QString AWPatternFunctions::insertKeyNames(QString _code, QString AWPatternFunctions::insertKeys(QString _code, const QStringList &_keys) { - qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" - << _keys; + qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" << _keys; QList found = AWPatternFunctions::findFunctionCalls("aw_keys", _code); for (auto &function : found) { QString separator = function.args.isEmpty() ? "," : 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); - }); + std::for_each(required.begin(), required.end(), + [](QString &value) { value = QString("$%1").arg(value); }); _code.replace(function.what, required.join(separator)); } @@ -229,13 +213,11 @@ QString AWPatternFunctions::insertMacros(QString _code) QString name = macro.args.takeFirst(); // find macro usage QList macroUsage - = AWPatternFunctions::findFunctionCalls( - QString("aw_macro_%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" << function.what - << "with macro" << macro.what; + qCWarning(LOG_AW) << "Invalid args count found for call" << function.what + << "with macro" << macro.what; continue; } // generate body to replace @@ -243,8 +225,7 @@ QString AWPatternFunctions::insertMacros(QString _code) 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)); + result.replace(QString("$%1").arg(arg), function.args.at(index)); }); // do replace _code.replace(function.what, result); @@ -258,20 +239,17 @@ QString AWPatternFunctions::insertMacros(QString _code) } -QStringList AWPatternFunctions::findKeys(const QString &_code, - const QStringList &_keys, +QStringList AWPatternFunctions::findKeys(const QString &_code, const QStringList &_keys, const bool _isBars) { - qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" - << _keys; + qCDebug(LOG_AW) << "Looking for keys in code" << _code << "using list" << _keys; QStringList selectedKeys; QString replacedCode = _code; for (auto &key : _keys) if ((key.startsWith("bar") == _isBars) && (replacedCode.contains(QString("$%1").arg(key)))) { - qCInfo(LOG_AW) << "Found key" << key << "with bar enabled" - << _isBars; + qCInfo(LOG_AW) << "Found key" << key << "with bar enabled" << _isBars; selectedKeys.append(key); replacedCode.replace(QString("$%1").arg(key), ""); } @@ -289,8 +267,7 @@ QStringList AWPatternFunctions::findLambdas(const QString &_code) QStringList selectedKeys; // match the following construction ${{some code here}} QRegularExpression lambdaRegexp("\\$\\{\\{(?.*?)\\}\\}"); - lambdaRegexp.setPatternOptions( - QRegularExpression::DotMatchesEverythingOption); + lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(_code); while (it.hasNext()) { diff --git a/sources/awesome-widget/plugin/awpatternfunctions.h b/sources/awesome-widget/plugin/awpatternfunctions.h index 6c3f0ba..9ea3441 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.h +++ b/sources/awesome-widget/plugin/awpatternfunctions.h @@ -34,20 +34,17 @@ typedef struct { } AWFunction; // insert methods -QString expandLambdas(QString _code, AWKeysAggregator *_aggregator, - const QVariantHash &_metadata, +QString expandLambdas(QString _code, AWKeysAggregator *_aggregator, const QVariantHash &_metadata, const QStringList &_usedKeys); QString expandTemplates(QString _code); -QList 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); QString insertMacros(QString _code); // find methods -QStringList findKeys(const QString &_code, const QStringList &_keys, - const bool _isBars); +QStringList findKeys(const QString &_code, const QStringList &_keys, const bool _isBars); QStringList findLambdas(const QString &_code); }; diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.cpp b/sources/awesome-widget/plugin/awtelemetryhandler.cpp index 8eb0091..43efaee 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.cpp +++ b/sources/awesome-widget/plugin/awtelemetryhandler.cpp @@ -27,15 +27,13 @@ #include "awdebug.h" -AWTelemetryHandler::AWTelemetryHandler(QObject *_parent, - const QString &_clientId) +AWTelemetryHandler::AWTelemetryHandler(QObject *_parent, const QString &_clientId) : QObject(_parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; m_localFile = QString("%1/awesomewidgets/telemetry.ini") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); // override client id if any if (!_clientId.isEmpty()) @@ -73,11 +71,10 @@ QString AWTelemetryHandler::getLast(const QString &_group) const } -void AWTelemetryHandler::init(const int _count, const bool _enableRemote, - const QString &_clientId) +void AWTelemetryHandler::init(const int _count, const bool _enableRemote, const QString &_clientId) { - qCDebug(LOG_AW) << "Init telemetry with count" << _count << "enable remote" - << _enableRemote << "client ID" << _clientId; + qCDebug(LOG_AW) << "Init telemetry with count" << _count << "enable remote" << _enableRemote + << "client ID" << _clientId; m_storeCount = _count; m_uploadEnabled = _enableRemote; @@ -87,8 +84,7 @@ void AWTelemetryHandler::init(const int _count, const bool _enableRemote, bool AWTelemetryHandler::put(const QString &_group, const QString &_value) const { - qCDebug(LOG_AW) << "Store data with group" << _group << "and value" - << _value; + qCDebug(LOG_AW) << "Store data with group" << _group << "and value" << _value; QSettings settings(m_localFile, QSettings::IniFormat); settings.beginGroup(_group); @@ -99,8 +95,7 @@ bool AWTelemetryHandler::put(const QString &_group, const QString &_value) const saved.append(settings.value(key).toString()); // check if this value is already saved if (saved.contains(_value)) { - qCInfo(LOG_AW) << "Configuration" << _value << "for group" << _group - << "is already saved"; + qCInfo(LOG_AW) << "Configuration" << _value << "for group" << _group << "is already saved"; return false; } saved.append(_value); @@ -123,11 +118,9 @@ bool AWTelemetryHandler::put(const QString &_group, const QString &_value) const } -void AWTelemetryHandler::uploadTelemetry(const QString &_group, - const QString &_value) +void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_value) { - qCDebug(LOG_AW) << "Upload data with group" << _group << "and value" - << _value; + qCDebug(LOG_AW) << "Upload data with group" << _group << "and value" << _value; if (!m_uploadEnabled) { qCInfo(LOG_AW) << "Upload disabled by configuration"; return; @@ -148,10 +141,8 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, payload["metadata"] = _value; payload["type"] = _group; // convert to QByteArray to send request - QByteArray data - = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact); - qCInfo(LOG_AW) << "Send request with body" << data.data() << "and size" - << data.size(); + QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact); + qCInfo(LOG_AW) << "Send request with body" << data.data() << "and size" << data.size(); manager->post(request, data); } @@ -160,8 +151,8 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply) { if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() - << "with message" << _reply->errorString(); + qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" + << _reply->errorString(); return; } diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.h b/sources/awesome-widget/plugin/awtelemetryhandler.h index 9586db0..fb2d336 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.h +++ b/sources/awesome-widget/plugin/awtelemetryhandler.h @@ -31,16 +31,13 @@ class AWTelemetryHandler : public QObject public: const char *REMOTE_TELEMETRY_URL = "https://arcanis.me/telemetry"; - explicit AWTelemetryHandler(QObject *_parent = nullptr, - const QString &_clientId = ""); + explicit AWTelemetryHandler(QObject *_parent = nullptr, const QString &_clientId = ""); virtual ~AWTelemetryHandler(); Q_INVOKABLE QStringList get(const QString &_group) const; Q_INVOKABLE QString getLast(const QString &_group) const; - Q_INVOKABLE void init(const int _count, const bool _enableRemote, - const QString &_clientId); + Q_INVOKABLE void init(const int _count, const bool _enableRemote, const QString &_clientId); Q_INVOKABLE bool put(const QString &_group, const QString &_value) const; - Q_INVOKABLE void uploadTelemetry(const QString &_group, - const QString &_value); + Q_INVOKABLE void uploadTelemetry(const QString &_group, const QString &_value); signals: void replyReceived(const QString &_message); diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp index f4839e2..261f3ad 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.cpp +++ b/sources/awesome-widget/plugin/awupdatehelper.cpp @@ -34,9 +34,9 @@ AWUpdateHelper::AWUpdateHelper(QObject *_parent) qCDebug(LOG_AW) << __PRETTY_FUNCTION__; m_foundVersion = QVersionNumber::fromString(VERSION); - m_genericConfig = QString("%1/awesomewidgets/general.ini") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + m_genericConfig + = QString("%1/awesomewidgets/general.ini") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); } @@ -53,10 +53,9 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway) // showAnyway options requires to show message if no updates found on direct // request. In case of automatic check no message will be shown QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr); - connect(manager, &QNetworkAccessManager::finished, - [_showAnyway, this](QNetworkReply *reply) { - return versionReplyRecieved(reply, _showAnyway); - }); + connect(manager, &QNetworkAccessManager::finished, [_showAnyway, this](QNetworkReply *reply) { + return versionReplyRecieved(reply, _showAnyway); + }); manager->get(QNetworkRequest(QUrl(VERSION_API))); } @@ -65,17 +64,16 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway) bool AWUpdateHelper::checkVersion() { QSettings settings(m_genericConfig, QSettings::IniFormat); - QVersionNumber version = QVersionNumber::fromString( - settings.value("Version", QString(VERSION)).toString()); + QVersionNumber version + = QVersionNumber::fromString(settings.value("Version", QString(VERSION)).toString()); // update version settings.setValue("Version", QString(VERSION)); settings.sync(); - qCInfo(LOG_AW) << "Found version" << version << "actual one is" - << m_foundVersion; + qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion; if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) { - genMessageBox(i18n("Changelog of %1", VERSION), - QString(CHANGELOG).replace('@', '\n'), QMessageBox::Ok) + genMessageBox(i18n("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'), + QMessageBox::Ok) ->open(); return true; } else if (version != m_foundVersion) { @@ -93,12 +91,10 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version) { qCDebug(LOG_AW) << "Version" << _version; - QString text - = i18n("You are using the actual version %1", _version.toString()); + QString text = i18n("You are using the actual version %1", _version.toString()); if (!QString(COMMIT_SHA).isEmpty()) text += QString(" (%1)").arg(QString(COMMIT_SHA)); - return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok) - ->open(); + return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok)->open(); } @@ -108,28 +104,23 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version) QString text; text += i18n("Current version : %1", VERSION); - text += QString(COMMIT_SHA).isEmpty() - ? "\n" - : QString(" (%1)\n").arg(QString(COMMIT_SHA)); + text += QString(COMMIT_SHA).isEmpty() ? "\n" : QString(" (%1)\n").arg(QString(COMMIT_SHA)); text += i18n("New version : %1", _version.toString()) + "\n\n"; text += i18n("Click \"Ok\" to download"); - genMessageBox(i18n("There are updates"), text, - QMessageBox::Ok | QMessageBox::Cancel) + genMessageBox(i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel) ->open(this, SLOT(userReplyOnUpdates(QAbstractButton *))); } void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button) { - QMessageBox::ButtonRole ret - = static_cast(sender())->buttonRole(_button); + QMessageBox::ButtonRole ret = static_cast(sender())->buttonRole(_button); qCInfo(LOG_AW) << "User select" << ret; switch (ret) { case QMessageBox::AcceptRole: - QDesktopServices::openUrl(QString(RELEASES) - + m_foundVersion.toString()); + QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion.toString()); break; case QMessageBox::RejectRole: default: @@ -138,13 +129,12 @@ void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button) } -void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, - const bool _showAnyway) +void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway) { qCDebug(LOG_AW) << "Show message anyway" << _showAnyway; if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() - << "with message" << _reply->errorString(); + qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" + << _reply->errorString(); return; } @@ -172,12 +162,10 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, // additional method which is used to show message box which does not block UI -QMessageBox * -AWUpdateHelper::genMessageBox(const QString &_title, const QString &_body, - const QMessageBox::StandardButtons _buttons) +QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString &_body, + const QMessageBox::StandardButtons _buttons) { - qCDebug(LOG_AW) << "Construct message box with title" << _title - << "and body" << _body; + qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body; QMessageBox *msgBox = new QMessageBox(nullptr); msgBox->setAttribute(Qt::WA_DeleteOnClose); diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index 317578e..c41ef67 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -57,8 +57,7 @@ void AbstractExtItem::bumpApi(const int _newVer) // update for current API if ((apiVersion() > 0) && (apiVersion() < _newVer)) { - qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" - << _newVer; + qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << _newVer; setApiVersion(_newVer); writeConfiguration(); } @@ -104,8 +103,7 @@ QString AbstractExtItem::writtableConfig() const QString dir = QFileInfo(path).fileName(); return QString("%1/awesomewidgets/%2/%3") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)) + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)) .arg(dir) .arg(name); } @@ -202,8 +200,7 @@ void AbstractExtItem::setCron(const QString &_cron) qCDebug(LOG_LIB) << "Cron string" << _cron; // deinit module first if (m_scheduler) { - disconnect(m_scheduler, SIGNAL(activated()), this, - SIGNAL(requestDataUpdate())); + disconnect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate())); delete m_scheduler; } @@ -214,8 +211,7 @@ void AbstractExtItem::setCron(const QString &_cron) // init scheduler m_scheduler = new QCronScheduler(this); m_scheduler->parse(cron()); - connect(m_scheduler, SIGNAL(activated()), this, - SIGNAL(requestDataUpdate())); + connect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate())); } @@ -276,8 +272,7 @@ void AbstractExtItem::deinitSocket() m_socket->close(); m_socket->removeServer(socket()); delete m_socket; - disconnect(m_socket, SIGNAL(newConnection()), this, - SLOT(newConnectionReceived())); + disconnect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived())); } @@ -289,8 +284,7 @@ void AbstractExtItem::initSocket() m_socket = new QLocalServer(this); bool listening = m_socket->listen(socket()); qCInfo(LOG_LIB) << "Server listening on" << socket() << listening; - connect(m_socket, SIGNAL(newConnection()), this, - SLOT(newConnectionReceived())); + connect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived())); } diff --git a/sources/awesomewidgets/abstractextitem.h b/sources/awesomewidgets/abstractextitem.h index 1408f0b..f325db5 100644 --- a/sources/awesomewidgets/abstractextitem.h +++ b/sources/awesomewidgets/abstractextitem.h @@ -40,12 +40,10 @@ class AbstractExtItem : public QDialog Q_PROPERTY(QString uniq READ uniq) public: - explicit AbstractExtItem(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AbstractExtItem(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AbstractExtItem(); virtual void bumpApi(const int _newVer); - virtual AbstractExtItem *copy(const QString &_fileName, const int _number) - = 0; + virtual AbstractExtItem *copy(const QString &_fileName, const int _number) = 0; virtual void copyDefaults(AbstractExtItem *_other) const; virtual void startTimer(); QString writtableConfig() const; diff --git a/sources/awesomewidgets/abstractextitemaggregator.cpp b/sources/awesomewidgets/abstractextitemaggregator.cpp index a2d8663..1189795 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.cpp +++ b/sources/awesomewidgets/abstractextitemaggregator.cpp @@ -25,8 +25,7 @@ #include -AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, - const QString &_type) +AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, const QString &_type) : QDialog(_parent) , ui(new Ui::AbstractExtItemAggregator) , m_type(_type) @@ -34,21 +33,18 @@ AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; // create directory at $HOME - QString localDir = QString("%1/awesomewidgets/%2") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)) - .arg(type()); + QString localDir + = QString("%1/awesomewidgets/%2") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)) + .arg(type()); QDir localDirectory; if (localDirectory.mkpath(localDir)) qCInfo(LOG_LIB) << "Created directory" << localDir; ui->setupUi(this); - copyButton - = ui->buttonBox->addButton(i18n("Copy"), QDialogButtonBox::ActionRole); - createButton = ui->buttonBox->addButton(i18n("Create"), - QDialogButtonBox::ActionRole); - deleteButton = ui->buttonBox->addButton(i18n("Remove"), - QDialogButtonBox::ActionRole); + copyButton = ui->buttonBox->addButton(i18n("Copy"), QDialogButtonBox::ActionRole); + createButton = ui->buttonBox->addButton(i18n("Create"), QDialogButtonBox::ActionRole); + deleteButton = ui->buttonBox->addButton(i18n("Remove"), QDialogButtonBox::ActionRole); connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(editItemButtonPressed(QAbstractButton *))); @@ -72,8 +68,7 @@ void AbstractExtItemAggregator::copyItem() QString fileName = getName(); int number = uniqNumber(); QString dir = QString("%1/awesomewidgets/%2") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)) + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)) .arg(m_type); if ((!source) || (fileName.isEmpty())) { qCWarning(LOG_LIB) << "Nothing to copy"; @@ -122,9 +117,8 @@ void AbstractExtItemAggregator::editItem() QString AbstractExtItemAggregator::getName() { bool ok; - QString name - = QInputDialog::getText(this, i18n("Enter file name"), - i18n("File name"), QLineEdit::Normal, "", &ok); + QString name = QInputDialog::getText(this, i18n("Enter file name"), i18n("File name"), + QLineEdit::Normal, "", &ok); if ((!ok) || (name.isEmpty())) return ""; if (!name.endsWith(".desktop")) @@ -149,8 +143,7 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() break; } if (!found) - qCWarning(LOG_LIB) << "Could not find item by name" - << widgetItem->text(); + qCWarning(LOG_LIB) << "Could not find item by name" << widgetItem->text(); return found; } @@ -193,10 +186,9 @@ QVariant AbstractExtItemAggregator::configArgs() const QStringList AbstractExtItemAggregator::directories() const { - auto dirs - = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, - QString("awesomewidgets/%1").arg(type()), - QStandardPaths::LocateDirectory); + auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, + QString("awesomewidgets/%1").arg(type()), + QStandardPaths::LocateDirectory); return dirs; } diff --git a/sources/awesomewidgets/abstractextitemaggregator.h b/sources/awesomewidgets/abstractextitemaggregator.h index 7ef4d49..fc23c7a 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.h +++ b/sources/awesomewidgets/abstractextitemaggregator.h @@ -47,10 +47,10 @@ public: { QString fileName = getName(); int number = uniqNumber(); - QString dir = QString("%1/awesomewidgets/%2") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)) - .arg(m_type); + QString dir + = QString("%1/awesomewidgets/%2") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)) + .arg(m_type); if (fileName.isEmpty()) { qCWarning(LOG_LIB) << "Nothing to create"; return; diff --git a/sources/awesomewidgets/abstractquotesprovider.h b/sources/awesomewidgets/abstractquotesprovider.h new file mode 100644 index 0000000..1dee50a --- /dev/null +++ b/sources/awesomewidgets/abstractquotesprovider.h @@ -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/ * + ***************************************************************************/ + +#ifndef ABSTRACTQUOTESPROVIDER_H +#define ABSTRACTQUOTESPROVIDER_H + +#include +#include + +#include "abstractextitem.h" + + +class AbstractQuotesProvider : public QObject +{ + Q_OBJECT + +public: + explicit AbstractQuotesProvider(QObject *_parent) + : QObject(_parent){}; + virtual ~AbstractQuotesProvider(){}; + virtual void initUrl(const QString &_asset) = 0; + virtual QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const = 0; + QString tag(const QString &_type) const + { + return static_cast(parent())->tag(_type); + }; + virtual QUrl url() const = 0; +}; + + +#endif /* ABSTRACTQUOTESPROVIDER_H */ diff --git a/sources/awesomewidgets/abstractweatherprovider.h b/sources/awesomewidgets/abstractweatherprovider.h index 32fbaed..2bf6034 100644 --- a/sources/awesomewidgets/abstractweatherprovider.h +++ b/sources/awesomewidgets/abstractweatherprovider.h @@ -21,26 +21,24 @@ #include #include +#include "abstractextitem.h" + class AbstractWeatherProvider : public QObject { Q_OBJECT - Q_PROPERTY(int number READ number) public: - explicit AbstractWeatherProvider(QObject *_parent, const int _number) - : QObject(_parent) - , m_number(_number){}; + explicit AbstractWeatherProvider(QObject *_parent) + : QObject(_parent){}; virtual ~AbstractWeatherProvider(){}; - virtual void initUrl(const QString &_city, const QString &_country, - const int _ts) - = 0; + virtual void initUrl(const QString &_city, const QString &_country, const int _ts) = 0; virtual QVariantHash parse(const QVariantMap &_json) const = 0; + QString tag(const QString &_type) const + { + return static_cast(parent())->tag(_type); + }; virtual QUrl url() const = 0; - int number() const { return m_number; }; - -private: - int m_number; }; diff --git a/sources/awesomewidgets/awabstractformatter.cpp b/sources/awesomewidgets/awabstractformatter.cpp index 0ecfde1..ad3a0bf 100644 --- a/sources/awesomewidgets/awabstractformatter.cpp +++ b/sources/awesomewidgets/awabstractformatter.cpp @@ -22,8 +22,7 @@ #include "awdebug.h" -AWAbstractFormatter::AWAbstractFormatter(QWidget *_parent, - const QString &_filePath) +AWAbstractFormatter::AWAbstractFormatter(QWidget *_parent, const QString &_filePath) : AbstractExtItem(_parent, _filePath) { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; @@ -108,8 +107,7 @@ void AWAbstractFormatter::setStrType(const QString &_type) } -void AWAbstractFormatter::setType( - const AWAbstractFormatter::FormatterClass _type) +void AWAbstractFormatter::setType(const AWAbstractFormatter::FormatterClass _type) { qCDebug(LOG_LIB) << "Type" << static_cast(_type); diff --git a/sources/awesomewidgets/awabstractformatter.h b/sources/awesomewidgets/awabstractformatter.h index f575494..2e9dea2 100644 --- a/sources/awesomewidgets/awabstractformatter.h +++ b/sources/awesomewidgets/awabstractformatter.h @@ -28,18 +28,9 @@ class AWAbstractFormatter : public AbstractExtItem Q_PROPERTY(QString strType READ strType WRITE setStrType) public: - enum class FormatterClass { - DateTime, - Float, - List, - Script, - String, - NoFormat, - Json - }; + enum class FormatterClass { DateTime, Float, List, Script, String, NoFormat, Json }; - explicit AWAbstractFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWAbstractFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWAbstractFormatter(); virtual QString convert(const QVariant &_value) const = 0; void copyDefaults(AbstractExtItem *_other) const; diff --git a/sources/awesomewidgets/awdatetimeformatter.cpp b/sources/awesomewidgets/awdatetimeformatter.cpp index 44bdcca..db08a42 100644 --- a/sources/awesomewidgets/awdatetimeformatter.cpp +++ b/sources/awesomewidgets/awdatetimeformatter.cpp @@ -27,8 +27,7 @@ #include "awdebug.h" -AWDateTimeFormatter::AWDateTimeFormatter(QWidget *_parent, - const QString &_filePath) +AWDateTimeFormatter::AWDateTimeFormatter(QWidget *_parent, const QString &_filePath) : AWAbstractFormatter(_parent, _filePath) , ui(new Ui::AWDateTimeFormatter) { @@ -57,8 +56,7 @@ QString AWDateTimeFormatter::convert(const QVariant &_value) const } -AWDateTimeFormatter *AWDateTimeFormatter::copy(const QString &_fileName, - const int _number) +AWDateTimeFormatter *AWDateTimeFormatter::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; @@ -110,8 +108,7 @@ void AWDateTimeFormatter::readConfiguration() settings.beginGroup("Desktop Entry"); setFormat(settings.value("X-AW-Format", format()).toString()); - setTranslateString( - settings.value("X-AW-Translate", translateString()).toBool()); + setTranslateString(settings.value("X-AW-Translate", translateString()).toBool()); settings.endGroup(); bumpApi(AW_FORMATTER_API); @@ -126,8 +123,7 @@ int AWDateTimeFormatter::showConfiguration(const QVariant &_args) ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText("DateTime"); ui->lineEdit_format->setText(format()); - ui->checkBox_translate->setCheckState(translateString() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_translate->setCheckState(translateString() ? Qt::Checked : Qt::Unchecked); int ret = exec(); if (ret != 1) diff --git a/sources/awesomewidgets/awdatetimeformatter.h b/sources/awesomewidgets/awdatetimeformatter.h index c83bc6c..492663d 100644 --- a/sources/awesomewidgets/awdatetimeformatter.h +++ b/sources/awesomewidgets/awdatetimeformatter.h @@ -32,12 +32,10 @@ class AWDateTimeFormatter : public AWAbstractFormatter { Q_OBJECT Q_PROPERTY(QString format READ format WRITE setFormat) - Q_PROPERTY( - bool translateString READ translateString WRITE setTranslateString) + Q_PROPERTY(bool translateString READ translateString WRITE setTranslateString) public: - explicit AWDateTimeFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWDateTimeFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWDateTimeFormatter(); QString convert(const QVariant &_value) const; AWDateTimeFormatter *copy(const QString &_fileName, const int _number); diff --git a/sources/awesomewidgets/awfloatformatter.cpp b/sources/awesomewidgets/awfloatformatter.cpp index f587ae1..7e34335 100644 --- a/sources/awesomewidgets/awfloatformatter.cpp +++ b/sources/awesomewidgets/awfloatformatter.cpp @@ -51,9 +51,8 @@ QString AWFloatFormatter::convert(const QVariant &_value) const { qCDebug(LOG_LIB) << "Convert value" << _value; - QString output - = 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()); @@ -61,13 +60,11 @@ QString AWFloatFormatter::convert(const QVariant &_value) const } -AWFloatFormatter *AWFloatFormatter::copy(const QString &_fileName, - const int _number) +AWFloatFormatter *AWFloatFormatter::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWFloatFormatter *item - = new AWFloatFormatter(static_cast(parent()), _fileName); + AWFloatFormatter *item = new AWFloatFormatter(static_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setCount(count()); item->setFormat(format()); @@ -152,8 +149,8 @@ void AWFloatFormatter::setFormat(char _format) { qCDebug(LOG_LIB) << "Set format" << _format; // http://doc.qt.io/qt-5/qstring.html#argument-formats - if ((_format != 'e') && (_format != 'E') && (_format != 'f') - && (_format != 'g') && (_format != 'G')) { + if ((_format != 'e') && (_format != 'E') && (_format != 'f') && (_format != 'g') + && (_format != 'G')) { qCWarning(LOG_LIB) << "Invalid format" << _format; _format = 'f'; } @@ -196,10 +193,7 @@ void AWFloatFormatter::readConfiguration() setCount(settings.value("X-AW-Width", count()).toInt()); setFillChar(settings.value("X-AW-FillChar", fillChar()).toString().at(0)); setForceWidth(settings.value("X-AW-ForceWidth", forceWidth()).toBool()); - setFormat(settings.value("X-AW-Format", QString(format())) - .toString() - .at(0) - .toLatin1()); + setFormat(settings.value("X-AW-Format", QString(format())).toString().at(0).toLatin1()); setMultiplier(settings.value("X-AW-Multiplier", multiplier()).toDouble()); setPrecision(settings.value("X-AW-Precision", precision()).toInt()); setSummand(settings.value("X-AW-Summand", summand()).toDouble()); @@ -216,13 +210,11 @@ int AWFloatFormatter::showConfiguration(const QVariant &_args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText("Float"); - ui->comboBox_format->setCurrentIndex( - ui->comboBox_format->findText(QString(format()))); + ui->comboBox_format->setCurrentIndex(ui->comboBox_format->findText(QString(format()))); 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->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked : Qt::Unchecked); ui->doubleSpinBox_multiplier->setValue(multiplier()); ui->doubleSpinBox_summand->setValue(summand()); diff --git a/sources/awesomewidgets/awfloatformatter.h b/sources/awesomewidgets/awfloatformatter.h index d58fec1..f9bf166 100644 --- a/sources/awesomewidgets/awfloatformatter.h +++ b/sources/awesomewidgets/awfloatformatter.h @@ -38,8 +38,7 @@ class AWFloatFormatter : public AWAbstractFormatter Q_PROPERTY(double summand READ summand WRITE setSummand) public: - explicit AWFloatFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWFloatFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWFloatFormatter(); QString convert(const QVariant &_value) const; AWFloatFormatter *copy(const QString &_fileName, const int _number); diff --git a/sources/awesomewidgets/awjsonformatter.cpp b/sources/awesomewidgets/awjsonformatter.cpp index c9d9e67..0a27619 100644 --- a/sources/awesomewidgets/awjsonformatter.cpp +++ b/sources/awesomewidgets/awjsonformatter.cpp @@ -53,10 +53,9 @@ QString AWJsonFormatter::convert(const QVariant &_value) const qCDebug(LOG_LIB) << "Convert value" << _value; // check if _value is string and parse first if required - QJsonDocument json - = _value.type() == QVariant::String - ? QJsonDocument::fromJson(_value.toString().toUtf8()) - : QJsonDocument::fromVariant(_value); + QJsonDocument json = _value.type() == QVariant::String + ? QJsonDocument::fromJson(_value.toString().toUtf8()) + : QJsonDocument::fromVariant(_value); QVariant converted = json.toVariant(); for (auto &element : m_splittedPath) converted = getFromJson(converted, element); @@ -65,13 +64,11 @@ QString AWJsonFormatter::convert(const QVariant &_value) const } -AWJsonFormatter *AWJsonFormatter::copy(const QString &_fileName, - const int _number) +AWJsonFormatter *AWJsonFormatter::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWJsonFormatter *item - = new AWJsonFormatter(static_cast(parent()), _fileName); + AWJsonFormatter *item = new AWJsonFormatter(static_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setNumber(_number); item->setPath(path()); @@ -147,8 +144,7 @@ void AWJsonFormatter::writeConfiguration() const } -QVariant AWJsonFormatter::getFromJson(const QVariant &_value, - const QVariant &_element) const +QVariant AWJsonFormatter::getFromJson(const QVariant &_value, const QVariant &_element) const { qCDebug(LOG_LIB) << "Looking for element" << _element << "in" << _value; @@ -163,8 +159,7 @@ QVariant AWJsonFormatter::getFromJson(const QVariant &_value, } -QVariant AWJsonFormatter::getFromList(const QVariant &_value, - const int _index) const +QVariant AWJsonFormatter::getFromList(const QVariant &_value, const int _index) const { qCDebug(LOG_LIB) << "Looking for index" << _index << "in" << _value; @@ -172,8 +167,7 @@ QVariant AWJsonFormatter::getFromList(const QVariant &_value, } -QVariant AWJsonFormatter::getFromMap(const QVariant &_value, - const QString &_key) const +QVariant AWJsonFormatter::getFromMap(const QVariant &_value, const QString &_key) const { qCDebug(LOG_LIB) << "Looking for key" << _key << "in" << _value; diff --git a/sources/awesomewidgets/awjsonformatter.h b/sources/awesomewidgets/awjsonformatter.h index 56a673a..112452d 100644 --- a/sources/awesomewidgets/awjsonformatter.h +++ b/sources/awesomewidgets/awjsonformatter.h @@ -32,8 +32,7 @@ class AWJsonFormatter : public AWAbstractFormatter Q_PROPERTY(QString path READ path WRITE setPath) public: - explicit AWJsonFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWJsonFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWJsonFormatter(); QString convert(const QVariant &_value) const; AWJsonFormatter *copy(const QString &_fileName, const int _number); @@ -48,8 +47,7 @@ public slots: private: Ui::AWJsonFormatter *ui = nullptr; - QVariant getFromJson(const QVariant &_value, - const QVariant &_element) const; + QVariant getFromJson(const QVariant &_value, const QVariant &_element) const; QVariant getFromList(const QVariant &_value, const int _index) const; QVariant getFromMap(const QVariant &_value, const QString &_key) const; void initPath(); diff --git a/sources/awesomewidgets/awlistformatter.cpp b/sources/awesomewidgets/awlistformatter.cpp index c646d6c..f5207db 100644 --- a/sources/awesomewidgets/awlistformatter.cpp +++ b/sources/awesomewidgets/awlistformatter.cpp @@ -59,13 +59,11 @@ QString AWListFormatter::convert(const QVariant &_value) const } -AWListFormatter *AWListFormatter::copy(const QString &_fileName, - const int _number) +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); + AWListFormatter *item = new AWListFormatter(static_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setFilter(filter()); item->setSeparator(separator()); @@ -144,8 +142,7 @@ int AWListFormatter::showConfiguration(const QVariant &_args) ui->label_typeValue->setText("List"); ui->lineEdit_filter->setText(filter()); ui->lineEdit_separator->setText(separator()); - ui->checkBox_sorted->setCheckState(isSorted() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_sorted->setCheckState(isSorted() ? Qt::Checked : Qt::Unchecked); int ret = exec(); if (ret != 1) diff --git a/sources/awesomewidgets/awlistformatter.h b/sources/awesomewidgets/awlistformatter.h index e785b81..56f318a 100644 --- a/sources/awesomewidgets/awlistformatter.h +++ b/sources/awesomewidgets/awlistformatter.h @@ -34,8 +34,7 @@ class AWListFormatter : public AWAbstractFormatter Q_PROPERTY(bool sorted READ isSorted WRITE setSorted) public: - explicit AWListFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWListFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWListFormatter(); QString convert(const QVariant &_value) const; AWListFormatter *copy(const QString &_fileName, const int _number); diff --git a/sources/awesomewidgets/awnoformatter.cpp b/sources/awesomewidgets/awnoformatter.cpp index 42ecfeb..6409675 100644 --- a/sources/awesomewidgets/awnoformatter.cpp +++ b/sources/awesomewidgets/awnoformatter.cpp @@ -57,8 +57,7 @@ AWNoFormatter *AWNoFormatter::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWNoFormatter *item - = new AWNoFormatter(static_cast(parent()), _fileName); + AWNoFormatter *item = new AWNoFormatter(static_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setNumber(_number); diff --git a/sources/awesomewidgets/awnoformatter.h b/sources/awesomewidgets/awnoformatter.h index 4768e9e..2f617d5 100644 --- a/sources/awesomewidgets/awnoformatter.h +++ b/sources/awesomewidgets/awnoformatter.h @@ -31,8 +31,7 @@ class AWNoFormatter : public AWAbstractFormatter Q_OBJECT public: - explicit AWNoFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWNoFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWNoFormatter(); QString convert(const QVariant &_value) const; AWNoFormatter *copy(const QString &_fileName, const int _number); diff --git a/sources/awesomewidgets/awscriptformatter.cpp b/sources/awesomewidgets/awscriptformatter.cpp index f6943a4..455e932 100644 --- a/sources/awesomewidgets/awscriptformatter.cpp +++ b/sources/awesomewidgets/awscriptformatter.cpp @@ -59,9 +59,8 @@ QString AWScriptFormatter::convert(const QVariant &_value) const QJSValue result = fn.call(args); if (result.isError()) { - qCWarning(LOG_LIB) << "Uncaught exception at line" - << result.property("lineNumber").toInt() << ":" - << result.toString(); + qCWarning(LOG_LIB) << "Uncaught exception at line" << result.property("lineNumber").toInt() + << ":" << result.toString(); return ""; } else { return result.toString(); @@ -69,13 +68,11 @@ QString AWScriptFormatter::convert(const QVariant &_value) const } -AWScriptFormatter *AWScriptFormatter::copy(const QString &_fileName, - const int _number) +AWScriptFormatter *AWScriptFormatter::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWScriptFormatter *item - = new AWScriptFormatter(static_cast(parent()), _fileName); + AWScriptFormatter *item = new AWScriptFormatter(static_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setAppendCode(appendCode()); item->setCode(code()); @@ -160,10 +157,8 @@ int AWScriptFormatter::showConfiguration(const QVariant &_args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText("Script"); - ui->checkBox_appendCode->setCheckState(appendCode() ? Qt::Checked - : Qt::Unchecked); - ui->checkBox_hasReturn->setCheckState(hasReturn() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_appendCode->setCheckState(appendCode() ? Qt::Checked : Qt::Unchecked); + ui->checkBox_hasReturn->setCheckState(hasReturn() ? Qt::Checked : Qt::Unchecked); ui->textEdit_code->setPlainText(code()); int ret = exec(); diff --git a/sources/awesomewidgets/awscriptformatter.h b/sources/awesomewidgets/awscriptformatter.h index 45ef6b4..06cf4ac 100644 --- a/sources/awesomewidgets/awscriptformatter.h +++ b/sources/awesomewidgets/awscriptformatter.h @@ -35,8 +35,7 @@ class AWScriptFormatter : public AWAbstractFormatter Q_PROPERTY(QString program READ program) public: - explicit AWScriptFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWScriptFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWScriptFormatter(); QString convert(const QVariant &_value) const; AWScriptFormatter *copy(const QString &_fileName, const int _number); diff --git a/sources/awesomewidgets/awstringformatter.cpp b/sources/awesomewidgets/awstringformatter.cpp index 56c4e7f..87a19d6 100644 --- a/sources/awesomewidgets/awstringformatter.cpp +++ b/sources/awesomewidgets/awstringformatter.cpp @@ -59,13 +59,11 @@ QString AWStringFormatter::convert(const QVariant &_value) const } -AWStringFormatter *AWStringFormatter::copy(const QString &_fileName, - const int _number) +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); + AWStringFormatter *item = new AWStringFormatter(static_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setCount(count()); item->setFillChar(fillChar()); @@ -143,8 +141,7 @@ int AWStringFormatter::showConfiguration(const QVariant &_args) ui->label_typeValue->setText("String"); ui->spinBox_width->setValue(count()); ui->lineEdit_fill->setText(QString(fillChar())); - ui->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_forceWidth->setCheckState(forceWidth() ? Qt::Checked : Qt::Unchecked); int ret = exec(); if (ret != 1) diff --git a/sources/awesomewidgets/awstringformatter.h b/sources/awesomewidgets/awstringformatter.h index b08583e..2070bee 100644 --- a/sources/awesomewidgets/awstringformatter.h +++ b/sources/awesomewidgets/awstringformatter.h @@ -34,8 +34,7 @@ class AWStringFormatter : public AWAbstractFormatter Q_PROPERTY(bool forceWidth READ forceWidth WRITE setForceWidth) public: - explicit AWStringFormatter(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit AWStringFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~AWStringFormatter(); QString convert(const QVariant &_value) const; AWStringFormatter *copy(const QString &_fileName, const int _number); diff --git a/sources/awesomewidgets/extitemaggregator.h b/sources/awesomewidgets/extitemaggregator.h index 2a775ee..d0b4c9b 100644 --- a/sources/awesomewidgets/extitemaggregator.h +++ b/sources/awesomewidgets/extitemaggregator.h @@ -139,10 +139,9 @@ private: qCInfo(LOG_LIB) << "Found file" << file << "in" << dir; QString filePath = QString("%1/%2").arg(dir).arg(file); // check if already exists - if (std::any_of(items.cbegin(), items.cend(), - [&filePath](AbstractExtItem *item) { - return (item->fileName() == filePath); - })) + if (std::any_of(items.cbegin(), items.cend(), [&filePath](AbstractExtItem *item) { + return (item->fileName() == filePath); + })) continue; items.append(new T(this, filePath)); } diff --git a/sources/awesomewidgets/extnetworkrequest.cpp b/sources/awesomewidgets/extnetworkrequest.cpp index b8a85b9..73f9e92 100644 --- a/sources/awesomewidgets/extnetworkrequest.cpp +++ b/sources/awesomewidgets/extnetworkrequest.cpp @@ -65,13 +65,11 @@ ExtNetworkRequest::~ExtNetworkRequest() } -ExtNetworkRequest *ExtNetworkRequest::copy(const QString &_fileName, - const int _number) +ExtNetworkRequest *ExtNetworkRequest::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtNetworkRequest *item - = new ExtNetworkRequest(static_cast(parent()), _fileName); + ExtNetworkRequest *item = new ExtNetworkRequest(static_cast(parent()), _fileName); copyDefaults(item); item->setNumber(_number); item->setStringUrl(stringUrl()); @@ -133,8 +131,7 @@ int ExtNetworkRequest::showConfiguration(const QVariant &_args) ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); ui->lineEdit_url->setText(stringUrl()); - ui->checkBox_active->setCheckState(isActive() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->lineEdit_schedule->setText(cron()); ui->lineEdit_socket->setText(socket()); ui->spinBox_interval->setValue(interval()); @@ -174,8 +171,8 @@ void ExtNetworkRequest::writeConfiguration() const void ExtNetworkRequest::networkReplyReceived(QNetworkReply *_reply) { if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() - << "with message" << _reply->errorString(); + qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" + << _reply->errorString(); return; } diff --git a/sources/awesomewidgets/extnetworkrequest.h b/sources/awesomewidgets/extnetworkrequest.h index 7a35331..80fc3c3 100644 --- a/sources/awesomewidgets/extnetworkrequest.h +++ b/sources/awesomewidgets/extnetworkrequest.h @@ -34,8 +34,7 @@ class ExtNetworkRequest : public AbstractExtItem Q_PROPERTY(QString stringUrl READ stringUrl WRITE setStringUrl) public: - explicit ExtNetworkRequest(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit ExtNetworkRequest(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~ExtNetworkRequest(); ExtNetworkRequest *copy(const QString &_fileName, const int _number); // get methods diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 2a265d8..1eb2ca4 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -21,13 +21,13 @@ #include #include -#include #include -#include #include #include "awdebug.h" +#include "stooqquotesprovider.h" +#include "yahooquotesprovider.h" ExtQuotes::ExtQuotes(QWidget *_parent, const QString &_filePath) @@ -41,15 +41,12 @@ ExtQuotes::ExtQuotes(QWidget *_parent, const QString &_filePath) ui->setupUi(this); translate(); - m_values[tag("ask")] = 0.0; - m_values[tag("askchg")] = 0.0; - m_values[tag("percaskchg")] = 0.0; - m_values[tag("bid")] = 0.0; - m_values[tag("bidchg")] = 0.0; - m_values[tag("percbidchg")] = 0.0; m_values[tag("price")] = 0.0; m_values[tag("pricechg")] = 0.0; m_values[tag("percpricechg")] = 0.0; + m_values[tag("volume")] = 0; + m_values[tag("volumechg")] = 0; + m_values[tag("percvolumechg")] = 0.0; // HACK declare as child of nullptr to avoid crash with plasmawindowed // in the destructor @@ -78,8 +75,7 @@ ExtQuotes *ExtQuotes::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtQuotes *item - = new ExtQuotes(static_cast(parent()), _fileName); + ExtQuotes *item = new ExtQuotes(static_cast(parent()), _fileName); copyDefaults(item); item->setNumber(_number); item->setTicker(ticker()); @@ -105,7 +101,7 @@ void ExtQuotes::setTicker(const QString &_ticker) qCDebug(LOG_LIB) << "Ticker" << _ticker; m_ticker = _ticker; - initUrl(); + initProvider(); } @@ -141,8 +137,7 @@ int ExtQuotes::showConfiguration(const QVariant &_args) ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); ui->lineEdit_ticker->setText(ticker()); - ui->checkBox_active->setCheckState(isActive() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->lineEdit_schedule->setText(cron()); ui->lineEdit_socket->setText(socket()); ui->spinBox_interval->setValue(interval()); @@ -182,49 +177,19 @@ void ExtQuotes::writeConfiguration() const void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply) { if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() - << "with message" << _reply->errorString(); + qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" + << _reply->errorString(); return; } m_isRunning = false; - QJsonParseError error; - QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error); + auto text = _reply->readAll(); _reply->deleteLater(); - if (error.error != QJsonParseError::NoError) { - qCWarning(LOG_LIB) << "Parse error" << error.errorString(); + + QVariantHash data = m_providerObject->parse(text, m_values); + if (data.isEmpty()) return; - } - QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()["query"].toMap(); - jsonQuotes = jsonQuotes["results"].toMap()["quote"].toMap(); - double value; - - // ask - value = jsonQuotes["Ask"].toString().toDouble(); - m_values[tag("askchg")] = m_values[tag("ask")].toDouble() == 0.0 - ? 0.0 - : value - m_values[tag("ask")].toDouble(); - m_values[tag("percaskchg")] = 100.0 * m_values[tag("askchg")].toDouble() - / m_values[tag("ask")].toDouble(); - m_values[tag("ask")] = value; - - // bid - value = jsonQuotes["Bid"].toString().toDouble(); - m_values[tag("bidchg")] = m_values[tag("bid")].toDouble() == 0.0 - ? 0.0 - : value - m_values[tag("bid")].toDouble(); - m_values[tag("percbidchg")] = 100.0 * m_values[tag("bidchg")].toDouble() - / m_values[tag("bid")].toDouble(); - m_values[tag("bid")] = value; - - // last trade - value = jsonQuotes["LastTradePriceOnly"].toString().toDouble(); - m_values[tag("pricechg")] = m_values[tag("price")].toDouble() == 0.0 - ? 0.0 - : value - m_values[tag("price")].toDouble(); - m_values[tag("percpricechg")] = 100.0 * m_values[tag("pricechg")].toDouble() - / m_values[tag("price")].toDouble(); - m_values[tag("price")] = value; + m_values = data; emit(dataReceived(m_values)); } @@ -233,20 +198,19 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply) void ExtQuotes::sendRequest() { m_isRunning = true; - QNetworkReply *reply = m_manager->get(QNetworkRequest(m_url)); + QNetworkReply *reply = m_manager->get(QNetworkRequest(m_providerObject->url())); new QReplyTimeout(reply, REQUEST_TIMEOUT); } -void ExtQuotes::initUrl() +void ExtQuotes::initProvider() { - // init query - m_url = QUrl(YAHOO_QUOTES_URL); - QUrlQuery params; - params.addQueryItem("format", "json"); - params.addQueryItem("env", "store://datatables.org/alltableswithkeys"); - params.addQueryItem("q", QString(YAHOO_QUOTES_QUERY).arg(ticker())); - m_url.setQuery(params); + delete m_providerObject; + + // in the future release it is possible to change provider here + m_providerObject = new StooqQuotesProvider(this); + + return m_providerObject->initUrl(ticker()); } @@ -256,10 +220,9 @@ void ExtQuotes::translate() ui->label_comment->setText(i18n("Comment")); ui->label_number->setText(i18n("Tag")); ui->label->setText( - i18n("

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

    ")); + i18n("

    Use Stooq ticker to get quotes for the instrument. Refer to https://stooq.com/

    ")); ui->label_ticker->setText(i18n("Ticker")); ui->checkBox_active->setText(i18n("Active")); ui->label_schedule->setText(i18n("Schedule")); diff --git a/sources/awesomewidgets/extquotes.h b/sources/awesomewidgets/extquotes.h index ed7b31a..9237b31 100644 --- a/sources/awesomewidgets/extquotes.h +++ b/sources/awesomewidgets/extquotes.h @@ -23,6 +23,7 @@ #include "abstractextitem.h" +class AbstractQuotesProvider; namespace Ui { class ExtQuotes; @@ -34,12 +35,7 @@ class ExtQuotes : public AbstractExtItem Q_PROPERTY(QString ticker READ ticker WRITE setTicker) public: - const char *YAHOO_QUOTES_URL = "https://query.yahooapis.com/v1/public/yql"; - const char *YAHOO_QUOTES_QUERY - = "select * from yahoo.finance.quotes where symbol='%1'"; - - explicit ExtQuotes(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit ExtQuotes(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~ExtQuotes(); ExtQuotes *copy(const QString &_fileName, const int _number); // get methods @@ -59,11 +55,11 @@ private slots: void sendRequest(); private: + AbstractQuotesProvider *m_providerObject = nullptr; QNetworkAccessManager *m_manager = nullptr; - QUrl m_url; bool m_isRunning = false; Ui::ExtQuotes *ui = nullptr; - void initUrl(); + void initProvider(); void translate(); // properties QString m_ticker = "EURUSD=X"; diff --git a/sources/awesomewidgets/extquotes.ui b/sources/awesomewidgets/extquotes.ui index ccdecae..c8c7f44 100644 --- a/sources/awesomewidgets/extquotes.ui +++ b/sources/awesomewidgets/extquotes.ui @@ -84,7 +84,7 @@ - <html><head/><body><p>Use YAHOO! finance ticker to get quotes for the instrument. Refer to <a href="http://finance.yahoo.com/"><span style=" text-decoration: underline; color:#0057ae;">http://finance.yahoo.com/</span></a></p></body></html> + <html><head/><body><p>Use Stooq ticker to get quotes for the instrument. Refer to <a href="https://stooq.com/"><span style=" text-decoration: underline; color:#0057ae;">https://stooq.com/</span></a></p></body></html> Qt::AlignCenter diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index ef9c35d..8f0118d 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -44,8 +44,7 @@ ExtScript::ExtScript(QWidget *_parent, const QString &_filePath) m_values[tag("custom")] = ""; m_process = new QProcess(nullptr); - connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, - SLOT(updateValue())); + connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue())); m_process->waitForFinished(0); connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess())); @@ -56,8 +55,7 @@ ExtScript::~ExtScript() { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; - disconnect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, - SLOT(updateValue())); + disconnect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue())); m_process->kill(); m_process->deleteLater(); disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess())); @@ -69,8 +67,7 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtScript *item - = new ExtScript(static_cast(parent()), _fileName); + ExtScript *item = new ExtScript(static_cast(parent()), _fileName); copyDefaults(item); item->setExecutable(executable()); item->setNumber(_number); @@ -84,9 +81,9 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number) QString ExtScript::jsonFiltersFile() const { - QString fileName = QStandardPaths::locate( - QStandardPaths::GenericDataLocation, - "awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"); + QString fileName + = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + "awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"); qCInfo(LOG_LIB) << "Filters file" << fileName; return fileName; @@ -157,9 +154,8 @@ void ExtScript::setFilters(const QStringList &_filters) { qCDebug(LOG_LIB) << "Filters" << _filters; - std::for_each( - _filters.cbegin(), _filters.cend(), - [this](const QString &filter) { return updateFilter(filter, true); }); + std::for_each(_filters.cbegin(), _filters.cend(), + [this](const QString &filter) { return updateFilter(filter, true); }); } @@ -202,8 +198,7 @@ QString ExtScript::applyFilters(QString _value) const qCInfo(LOG_LIB) << "Found filter" << filt; QVariantMap filter = m_jsonFilters[filt].toMap(); if (filter.isEmpty()) { - qCWarning(LOG_LIB) - << "Could not find filter" << _value << "in the json"; + qCWarning(LOG_LIB) << "Could not find filter" << _value << "in the json"; continue; } for (auto &f : filter.keys()) @@ -239,9 +234,8 @@ void ExtScript::readConfiguration() setPrefix(settings.value("X-AW-Prefix", prefix()).toString()); setStrRedirect(settings.value("X-AW-Redirect", strRedirect()).toString()); // api == 3 - setFilters(settings.value("X-AW-Filters", filters()) - .toString() - .split(',', QString::SkipEmptyParts)); + setFilters( + settings.value("X-AW-Filters", filters()).toString().split(',', QString::SkipEmptyParts)); settings.endGroup(); bumpApi(AW_EXTSCRIPT_API); @@ -290,19 +284,18 @@ int ExtScript::showConfiguration(const QVariant &_args) ui->label_numberValue->setText(QString("%1").arg(number())); ui->lineEdit_command->setText(executable()); ui->lineEdit_prefix->setText(prefix()); - ui->checkBox_active->setCheckState(isActive() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->comboBox_redirect->setCurrentIndex(static_cast(redirect())); ui->lineEdit_schedule->setText(cron()); ui->lineEdit_socket->setText(socket()); ui->spinBox_interval->setValue(interval()); // filters - ui->checkBox_colorFilter->setCheckState( - filters().contains("color") ? Qt::Checked : Qt::Unchecked); - ui->checkBox_linesFilter->setCheckState( - filters().contains("newline") ? Qt::Checked : Qt::Unchecked); - ui->checkBox_spaceFilter->setCheckState( - filters().contains("space") ? Qt::Checked : Qt::Unchecked); + ui->checkBox_colorFilter->setCheckState(filters().contains("color") ? Qt::Checked + : Qt::Unchecked); + ui->checkBox_linesFilter->setCheckState(filters().contains("newline") ? Qt::Checked + : Qt::Unchecked); + ui->checkBox_spaceFilter->setCheckState(filters().contains("space") ? Qt::Checked + : Qt::Unchecked); int ret = exec(); if (ret != 1) @@ -319,12 +312,9 @@ int ExtScript::showConfiguration(const QVariant &_args) setSocket(ui->lineEdit_socket->text()); setInterval(ui->spinBox_interval->value()); // filters - updateFilter("color", - ui->checkBox_colorFilter->checkState() == Qt::Checked); - updateFilter("newline", - ui->checkBox_linesFilter->checkState() == Qt::Checked); - updateFilter("space", - ui->checkBox_spaceFilter->checkState() == Qt::Checked); + updateFilter("color", ui->checkBox_colorFilter->checkState() == Qt::Checked); + updateFilter("newline", ui->checkBox_linesFilter->checkState() == Qt::Checked); + updateFilter("space", ui->checkBox_spaceFilter->checkState() == Qt::Checked); writeConfiguration(); return ret; @@ -363,13 +353,11 @@ void ExtScript::startProcess() void ExtScript::updateValue() { qCInfo(LOG_LIB) << "Cmd returns" << m_process->exitCode(); - QString qdebug = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardError()) - .trimmed(); + QString qdebug + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardError()).trimmed(); qCInfo(LOG_LIB) << "Error" << qdebug; - QString qoutput = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardOutput()) - .trimmed(); + QString qoutput + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); qCInfo(LOG_LIB) << "Output" << qoutput; QString strValue; diff --git a/sources/awesomewidgets/extscript.h b/sources/awesomewidgets/extscript.h index de50223..79126dc 100644 --- a/sources/awesomewidgets/extscript.h +++ b/sources/awesomewidgets/extscript.h @@ -37,15 +37,9 @@ class ExtScript : public AbstractExtItem Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect) public: - enum class Redirect { - stdout2stderr = 0, - nothing = 1, - stderr2stdout = 2, - swap = 3 - }; + enum class Redirect { stdout2stderr = 0, nothing = 1, stderr2stdout = 2, swap = 3 }; - explicit ExtScript(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit ExtScript(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~ExtScript(); ExtScript *copy(const QString &_fileName, const int _number); QString jsonFiltersFile() const; diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 06bdbb9..303bc45 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -63,8 +63,7 @@ ExtUpgrade *ExtUpgrade::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtUpgrade *item - = new ExtUpgrade(static_cast(parent()), _fileName); + ExtUpgrade *item = new ExtUpgrade(static_cast(parent()), _fileName); copyDefaults(item); item->setExecutable(executable()); item->setFilter(filter()); @@ -161,8 +160,7 @@ int ExtUpgrade::showConfiguration(const QVariant &_args) ui->label_numberValue->setText(QString("%1").arg(number())); ui->lineEdit_command->setText(executable()); ui->lineEdit_filter->setText(filter()); - ui->checkBox_active->setCheckState(isActive() ? Qt::Checked - : Qt::Unchecked); + ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->spinBox_null->setValue(null()); ui->lineEdit_schedule->setText(cron()); ui->lineEdit_socket->setText(socket()); @@ -218,16 +216,12 @@ void ExtUpgrade::updateValue() qCInfo(LOG_LIB) << "Cmd returns" << m_process->exitCode(); qCInfo(LOG_LIB) << "Error" << m_process->readAllStandardError(); - QString qoutput = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardOutput()) - .trimmed(); + QString qoutput + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); m_values[tag("pkgcount")] = [this](QString output) { return filter().isEmpty() - ? output.split('\n', QString::SkipEmptyParts).count() - - null() - : output.split('\n', QString::SkipEmptyParts) - .filter(QRegExp(filter())) - .count(); + ? output.split('\n', QString::SkipEmptyParts).count() - null() + : output.split('\n', QString::SkipEmptyParts).filter(QRegExp(filter())).count(); }(qoutput); emit(dataReceived(m_values)); diff --git a/sources/awesomewidgets/extupgrade.h b/sources/awesomewidgets/extupgrade.h index e2783bd..f079144 100644 --- a/sources/awesomewidgets/extupgrade.h +++ b/sources/awesomewidgets/extupgrade.h @@ -36,8 +36,7 @@ class ExtUpgrade : public AbstractExtItem Q_PROPERTY(int null READ null WRITE setNull) public: - explicit ExtUpgrade(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit ExtUpgrade(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~ExtUpgrade(); ExtUpgrade *copy(const QString &_fileName, const int _number); // get methods diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 70a00a0..cca7b87 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -77,8 +77,7 @@ ExtWeather *ExtWeather::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "number" << _number; - ExtWeather *item - = new ExtWeather(static_cast(parent()), _fileName); + ExtWeather *item = new ExtWeather(static_cast(parent()), _fileName); copyDefaults(item); item->setCity(city()); item->setCountry(country()); @@ -93,9 +92,9 @@ ExtWeather *ExtWeather::copy(const QString &_fileName, const int _number) QString ExtWeather::jsonMapFile() const { - QString fileName = QStandardPaths::locate( - QStandardPaths::GenericDataLocation, - "awesomewidgets/weather/awesomewidgets-extweather-ids.json"); + QString fileName + = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + "awesomewidgets/weather/awesomewidgets-extweather-ids.json"); qCInfo(LOG_LIB) << "Map file" << fileName; return fileName; @@ -283,8 +282,7 @@ int ExtWeather::showConfiguration(const QVariant &_args) 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->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->lineEdit_schedule->setText(cron()); ui->lineEdit_socket->setText(socket()); ui->spinBox_interval->setValue(interval()); @@ -333,8 +331,7 @@ void ExtWeather::writeConfiguration() const void ExtWeather::sendRequest() { m_isRunning = true; - QNetworkReply *reply - = m_manager->get(QNetworkRequest(m_providerObject->url())); + QNetworkReply *reply = m_manager->get(QNetworkRequest(m_providerObject->url())); new QReplyTimeout(reply, REQUEST_TIMEOUT); } @@ -342,8 +339,8 @@ void ExtWeather::sendRequest() void ExtWeather::weatherReplyReceived(QNetworkReply *_reply) { if (_reply->error() != QNetworkReply::NoError) { - qCWarning(LOG_AW) << "An error occurs" << _reply->error() - << "with message" << _reply->errorString(); + qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" + << _reply->errorString(); return; } @@ -360,8 +357,7 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *_reply) if (data.isEmpty()) return; m_values = data; - m_values[tag("weather")] - = weatherFromInt(m_values[tag("weatherId")].toInt()); + m_values[tag("weather")] = weatherFromInt(m_values[tag("weatherId")].toInt()); emit(dataReceived(m_values)); } @@ -373,10 +369,10 @@ void ExtWeather::initProvider() switch (m_provider) { case Provider::OWM: - m_providerObject = new OWMWeatherProvider(this, number()); + m_providerObject = new OWMWeatherProvider(this); break; case Provider::Yahoo: - m_providerObject = new YahooWeatherProvider(this, number()); + m_providerObject = new YahooWeatherProvider(this); break; } diff --git a/sources/awesomewidgets/extweather.h b/sources/awesomewidgets/extweather.h index 3908ce1..8894dc3 100644 --- a/sources/awesomewidgets/extweather.h +++ b/sources/awesomewidgets/extweather.h @@ -42,8 +42,7 @@ class ExtWeather : public AbstractExtItem public: enum class Provider { OWM = 0, Yahoo = 1 }; - explicit ExtWeather(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit ExtWeather(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~ExtWeather(); ExtWeather *copy(const QString &_fileName, const int _number); QString jsonMapFile() const; @@ -76,8 +75,8 @@ private slots: void weatherReplyReceived(QNetworkReply *_reply); private: - QNetworkAccessManager *m_manager = nullptr; AbstractWeatherProvider *m_providerObject = nullptr; + QNetworkAccessManager *m_manager = nullptr; bool m_isRunning = false; Ui::ExtWeather *ui = nullptr; void initProvider(); diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 42e8442..5709fa0 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -56,14 +56,10 @@ GraphicalItem::GraphicalItem(QWidget *_parent, const QString &_filePath) ui->setupUi(this); translate(); - connect(ui->checkBox_custom, SIGNAL(stateChanged(int)), this, - SLOT(changeValue(int))); - connect(ui->comboBox_type, SIGNAL(currentIndexChanged(int)), this, - SLOT(changeCountState(int))); - connect(ui->toolButton_activeColor, SIGNAL(clicked()), this, - SLOT(changeColor())); - connect(ui->toolButton_inactiveColor, SIGNAL(clicked()), this, - SLOT(changeColor())); + connect(ui->checkBox_custom, SIGNAL(stateChanged(int)), this, SLOT(changeValue(int))); + connect(ui->comboBox_type, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCountState(int))); + connect(ui->toolButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor())); + connect(ui->toolButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor())); } @@ -79,8 +75,7 @@ GraphicalItem *GraphicalItem::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - GraphicalItem *item - = new GraphicalItem(static_cast(parent()), _fileName); + GraphicalItem *item = new GraphicalItem(static_cast(parent()), _fileName); copyDefaults(item); item->setActiveColor(activeColor()); item->setBar(bar()); @@ -105,8 +100,7 @@ QString GraphicalItem::image(const QVariant &value) m_scene->clear(); int scale[2] = {1, 1}; - float converted - = m_helper->getPercents(value.toFloat(), minValue(), maxValue()); + float converted = m_helper->getPercents(value.toFloat(), minValue(), maxValue()); // paint switch (m_type) { @@ -138,13 +132,12 @@ QString GraphicalItem::image(const QVariant &value) } // convert - QPixmap pixmap - = m_view->grab().transformed(QTransform().scale(scale[0], scale[1])); + QPixmap pixmap = m_view->grab().transformed(QTransform().scale(scale[0], scale[1])); QByteArray byteArray; QBuffer buffer(&byteArray); pixmap.save(&buffer, "PNG"); - QString url = QString("") - .arg(QString(byteArray.toBase64())); + QString url + = QString("").arg(QString(byteArray.toBase64())); return url; } @@ -153,8 +146,7 @@ QString GraphicalItem::image(const QVariant &value) void GraphicalItem::initScene() { m_view->resize(m_width + 5, m_height + 5); - m_helper->setParameters(activeColor(), inactiveColor(), itemWidth(), - itemHeight(), count()); + m_helper->setParameters(activeColor(), inactiveColor(), itemWidth(), itemHeight(), count()); } @@ -426,23 +418,18 @@ void GraphicalItem::readConfiguration() setBar(settings.value("X-AW-Value", bar()).toString()); setMaxValue(settings.value("X-AW-Max", maxValue()).toFloat()); setMinValue(settings.value("X-AW-Min", minValue()).toFloat()); - setActiveColor( - settings.value("X-AW-ActiveColor", activeColor()).toString()); - setInactiveColor( - settings.value("X-AW-InactiveColor", inactiveColor()).toString()); + setActiveColor(settings.value("X-AW-ActiveColor", activeColor()).toString()); + setInactiveColor(settings.value("X-AW-InactiveColor", inactiveColor()).toString()); setStrType(settings.value("X-AW-Type", strType()).toString()); - setStrDirection( - settings.value("X-AW-Direction", strDirection()).toString()); + setStrDirection(settings.value("X-AW-Direction", strDirection()).toString()); setItemHeight(settings.value("X-AW-Height", itemHeight()).toInt()); setItemWidth(settings.value("X-AW-Width", itemWidth()).toInt()); // api == 5 if (apiVersion() < 5) { QString prefix; - prefix = activeColor().startsWith("/") ? QString("file://%1") - : QString("color://%1"); + prefix = activeColor().startsWith("/") ? QString("file://%1") : QString("color://%1"); m_activeColor = prefix.arg(activeColor()); - prefix = inactiveColor().startsWith("/") ? QString("file://%1") - : QString("color://%1"); + prefix = inactiveColor().startsWith("/") ? QString("file://%1") : QString("color://%1"); m_inactiveColor = prefix.arg(inactiveColor()); } settings.endGroup(); @@ -487,8 +474,7 @@ int GraphicalItem::showConfiguration(const QVariant &_args) ui->spinBox_width->setValue(itemWidth()); // update UI - emit(ui->comboBox_type->currentIndexChanged( - ui->comboBox_type->currentIndex())); + emit(ui->comboBox_type->currentIndexChanged(ui->comboBox_type->currentIndex())); emit(ui->checkBox_custom->stateChanged(ui->checkBox_custom->checkState())); int ret = exec(); @@ -499,15 +485,13 @@ int GraphicalItem::showConfiguration(const QVariant &_args) setApiVersion(AW_GRAPHITEM_API); setCount(ui->spinBox_count->value()); setCustom(ui->checkBox_custom->isChecked()); - setBar(m_custom ? ui->lineEdit_customValue->text() - : ui->comboBox_value->currentText()); + setBar(m_custom ? ui->lineEdit_customValue->text() : ui->comboBox_value->currentText()); setMaxValue(ui->doubleSpinBox_max->value()); setMinValue(ui->doubleSpinBox_min->value()); setActiveColor(ui->lineEdit_activeColor->text()); setInactiveColor(ui->lineEdit_inactiveColor->text()); setType(static_cast(ui->comboBox_type->currentIndex())); - setDirection( - static_cast(ui->comboBox_direction->currentIndex())); + setDirection(static_cast(ui->comboBox_direction->currentIndex())); setItemHeight(ui->spinBox_height->value()); setItemWidth(ui->spinBox_width->value()); @@ -557,8 +541,8 @@ void GraphicalItem::changeColor() QString outputColor; if (state == 0) { QColor color = m_helper->stringToColor(lineEdit->text()); - QColor newColor = QColorDialog::getColor( - color, this, i18n("Select color"), QColorDialog::ShowAlphaChannel); + QColor newColor = QColorDialog::getColor(color, this, i18n("Select color"), + QColorDialog::ShowAlphaChannel); if (!newColor.isValid()) return; qCInfo(LOG_LIB) << "Selected color" << newColor; @@ -573,10 +557,10 @@ void GraphicalItem::changeColor() } else if (state == 1) { QString path = lineEdit->text(); QString directory = QFileInfo(path).absolutePath(); - outputColor = QFileDialog::getOpenFileUrl( - this, i18n("Select path"), directory, - i18n("Images (*.png *.bpm *.jpg);;All files (*.*)")) - .toString(); + outputColor + = QFileDialog::getOpenFileUrl(this, i18n("Select path"), directory, + i18n("Images (*.png *.bpm *.jpg);;All files (*.*)")) + .toString(); qCInfo(LOG_LIB) << "Selected path" << outputColor; } diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index c30b757..cc00212 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -50,16 +50,9 @@ class GraphicalItem : public AbstractExtItem public: enum class Direction { LeftToRight = 0, RightToLeft = 1 }; - enum class Type { - Horizontal = 0, - Vertical = 1, - Circle = 2, - Graph = 3, - Bars = 4 - }; + enum class Type { Horizontal = 0, Vertical = 1, Circle = 2, Graph = 3, Bars = 4 }; - explicit GraphicalItem(QWidget *_parent = nullptr, - const QString &_filePath = ""); + explicit GraphicalItem(QWidget *_parent = nullptr, const QString &_filePath = ""); virtual ~GraphicalItem(); GraphicalItem *copy(const QString &_fileName, const int _number); QString image(const QVariant &value); diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index 1fcc703..fc8cca1 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -26,8 +26,7 @@ #include "awdebug.h" -GraphicalItemHelper::GraphicalItemHelper(QObject *_parent, - QGraphicsScene *_scene) +GraphicalItemHelper::GraphicalItemHelper(QObject *_parent, QGraphicsScene *_scene) : QObject(_parent) , m_scene(_scene) { @@ -41,14 +40,11 @@ GraphicalItemHelper::~GraphicalItemHelper() } -void GraphicalItemHelper::setParameters(const QString &_active, - const QString &_inactive, - const int _width, const int _height, - const int _count) +void GraphicalItemHelper::setParameters(const QString &_active, const QString &_inactive, + const int _width, const int _height, const int _count) { - qCDebug(LOG_LIB) << "Use active color" << _active << ", inactive" - << _inactive << ", width" << _width << ", height" - << _height << ", count" << _count; + qCDebug(LOG_LIB) << "Use active color" << _active << ", inactive" << _inactive << ", width" + << _width << ", height" << _height << ", count" << _count; // put images to pens if any otherwise set pen colors // Images resize to content here as well @@ -67,8 +63,7 @@ void GraphicalItemHelper::setParameters(const QString &_active, if (isColor(_inactive)) { m_inactivePen.setBrush(QBrush(stringToColor(_inactive))); } else { - qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" - << _inactive; + qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << _inactive; QPixmap pixmap = QPixmap(QUrl(_inactive).toLocalFile()); if (pixmap.isNull()) { qCWarning(LOG_LIB) << "Invalid pixmap found" << _inactive; @@ -93,8 +88,7 @@ void GraphicalItemHelper::paintBars(const float _value) storeValue(_value); // default norms - float normX - = static_cast(m_width) / static_cast(m_values.count()); + float normX = static_cast(m_width) / static_cast(m_values.count()); float normY = static_cast(m_height - 1); // paint graph for (int i = 0; i < m_values.count(); i++) { @@ -118,13 +112,11 @@ void GraphicalItemHelper::paintCircle(const float _percent) // Returns the start angle for an ellipse segment in 16ths of a degree // inactive - circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_inactivePen, - m_inactivePen.brush()); + circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_inactivePen, m_inactivePen.brush()); circle->setSpanAngle(-(1.0f - _percent) * 360.0f * 16.0f); circle->setStartAngle(90.0f * 16.0f - _percent * 360.0f * 16.0f); // active - circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_activePen, - m_activePen.brush()); + circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_activePen, m_activePen.brush()); circle->setSpanAngle(-_percent * 360.0f * 16.0f); circle->setStartAngle(90 * 16); } @@ -140,8 +132,7 @@ void GraphicalItemHelper::paintGraph(const float _value) storeValue(_value); // default norms - float normX - = static_cast(m_width) / static_cast(m_values.count()); + float normX = static_cast(m_width) / static_cast(m_values.count()); float normY = static_cast(m_height - 1); // paint graph for (int i = 0; i < m_values.count() - 1; i++) { @@ -162,12 +153,11 @@ void GraphicalItemHelper::paintHorizontal(const float _percent) m_activePen.setWidth(m_height); m_inactivePen.setWidth(m_height); // inactive - m_scene->addLine(_percent * m_width + 0.5 * m_height, 0.5 * m_height, - m_width + 0.5 * m_height, 0.5 * m_height, m_inactivePen); + m_scene->addLine(_percent * m_width + 0.5 * m_height, 0.5 * m_height, m_width + 0.5 * m_height, + 0.5 * m_height, m_inactivePen); // active - m_scene->addLine(-0.5 * m_height, 0.5 * m_height, - _percent * m_width - 0.5 * m_height, 0.5 * m_height, - m_activePen); + m_scene->addLine(-0.5 * m_height, 0.5 * m_height, _percent * m_width - 0.5 * m_height, + 0.5 * m_height, m_activePen); } @@ -179,16 +169,14 @@ void GraphicalItemHelper::paintVertical(const float _percent) m_inactivePen.setWidth(m_height); // inactive m_scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width, - (1.0 - _percent) * m_height - 0.5 * m_width, - m_inactivePen); + (1.0 - _percent) * m_height - 0.5 * m_width, m_inactivePen); // active - m_scene->addLine(0.5 * m_width, (1.0 - _percent) * m_height + 0.5 * m_width, - 0.5 * m_width, m_height + 0.5 * m_width, m_activePen); + m_scene->addLine(0.5 * m_width, (1.0 - _percent) * m_height + 0.5 * m_width, 0.5 * m_width, + m_height + 0.5 * m_width, m_activePen); } -float GraphicalItemHelper::getPercents(const float _value, const float _min, - const float _max) +float GraphicalItemHelper::getPercents(const float _value, const float _min, const float _max) { qCDebug(LOG_LIB) << "Get percent value from" << _value; // newest Qt crashes here if value is nan diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index 5070e9a..f79dff5 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -30,12 +30,11 @@ class GraphicalItemHelper : public QObject Q_OBJECT public: - explicit GraphicalItemHelper(QObject *_parent = nullptr, - QGraphicsScene *_scene = nullptr); + explicit GraphicalItemHelper(QObject *_parent = nullptr, QGraphicsScene *_scene = nullptr); virtual ~GraphicalItemHelper(); // parameters - void setParameters(const QString &_active, const QString &_inactive, - const int _width, const int _height, const int _count); + void setParameters(const QString &_active, const QString &_inactive, const int _width, + const int _height, const int _count); // paint methods void paintBars(const float _value); void paintCircle(const float _percent); diff --git a/sources/awesomewidgets/owmweatherprovider.cpp b/sources/awesomewidgets/owmweatherprovider.cpp index 7cf67d5..6397ea7 100644 --- a/sources/awesomewidgets/owmweatherprovider.cpp +++ b/sources/awesomewidgets/owmweatherprovider.cpp @@ -23,8 +23,8 @@ #include "awdebug.h" -OWMWeatherProvider::OWMWeatherProvider(QObject *_parent, const int _number) - : AbstractWeatherProvider(_parent, _number) +OWMWeatherProvider::OWMWeatherProvider(QObject *_parent) + : AbstractWeatherProvider(_parent) { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; } @@ -36,11 +36,9 @@ OWMWeatherProvider::~OWMWeatherProvider() } -void OWMWeatherProvider::initUrl(const QString &_city, const QString &_country, - const int ts) +void OWMWeatherProvider::initUrl(const QString &_city, const QString &_country, const int ts) { - qCDebug(LOG_LIB) << "Init query for" << _city << _country << "with ts" - << ts; + qCDebug(LOG_LIB) << "Init query for" << _city << _country << "with ts" << ts; m_ts = ts; @@ -60,8 +58,7 @@ QVariantHash OWMWeatherProvider::parse(const QVariantMap &_json) const qCDebug(LOG_LIB) << "Parse json" << _json; if (_json["cod"].toInt() != 200) { - qCWarning(LOG_LIB) << "Invalid OpenWeatherMap return code" - << _json["cod"].toInt(); + qCWarning(LOG_LIB) << "Invalid OpenWeatherMap return code" << _json["cod"].toInt(); return QVariantHash(); } @@ -91,23 +88,19 @@ QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) const QVariantList weather = _json["weather"].toList(); if (!weather.isEmpty()) { int id = weather.first().toMap()["id"].toInt(); - output[QString("weatherId%1").arg(number())] = id; + output[tag("weatherId")] = id; } // main data QVariantMap mainWeather = _json["main"].toMap(); if (!weather.isEmpty()) { - output[QString("humidity%1").arg(number())] - = mainWeather["humidity"].toFloat(); - output[QString("pressure%1").arg(number())] - = mainWeather["pressure"].toFloat(); - output[QString("temperature%1").arg(number())] - = mainWeather["temp"].toFloat(); + output[tag("humidity")] = mainWeather["humidity"].toFloat(); + output[tag("pressure")] = mainWeather["pressure"].toFloat(); + output[tag("temperature")] = mainWeather["temp"].toFloat(); } // timestamp - output[QString("timestamp%1").arg(number())] - = QDateTime::fromTime_t(_json["dt"].toUInt()).toUTC(); + output[tag("timestamp")] = QDateTime::fromTime_t(_json["dt"].toUInt()).toUTC(); return output; } diff --git a/sources/awesomewidgets/owmweatherprovider.h b/sources/awesomewidgets/owmweatherprovider.h index e9e5ed1..7c23f8c 100644 --- a/sources/awesomewidgets/owmweatherprovider.h +++ b/sources/awesomewidgets/owmweatherprovider.h @@ -31,7 +31,7 @@ public: const char *OWM_WEATHER_URL = "https://arcanis.me/weather"; const char *OWM_FORECAST_URL = "https://arcanis.me/forecast"; - explicit OWMWeatherProvider(QObject *_parent, const int _number); + explicit OWMWeatherProvider(QObject *_parent); virtual ~OWMWeatherProvider(); void initUrl(const QString &_city, const QString &_country, const int); QVariantHash parse(const QVariantMap &_json) const; diff --git a/sources/awesomewidgets/qcronscheduler.cpp b/sources/awesomewidgets/qcronscheduler.cpp index 90d5adc..894a638 100644 --- a/sources/awesomewidgets/qcronscheduler.cpp +++ b/sources/awesomewidgets/qcronscheduler.cpp @@ -76,11 +76,9 @@ void QCronScheduler::expired() } -QList QCronScheduler::parseField(const QString &_value, const int _min, - const int _max) const +QList QCronScheduler::parseField(const QString &_value, const int _min, const int _max) const { - qCDebug(LOG_LIB) << "Parse field" << _value << "with corner values" << _min - << _max; + qCDebug(LOG_LIB) << "Parse field" << _value << "with corner values" << _min << _max; QList parsed; auto fields = _value.split(','); @@ -89,9 +87,7 @@ QList QCronScheduler::parseField(const QString &_value, const int _min, parsedField.fromRange(field.split('/').first(), _min, _max); if (field.contains('/')) { bool status; - parsedField.div = field.split('/', QString::SkipEmptyParts) - .at(1) - .toInt(&status); + parsedField.div = field.split('/', QString::SkipEmptyParts).at(1).toInt(&status); if (!status) parsedField.div = 1; } @@ -103,11 +99,9 @@ QList QCronScheduler::parseField(const QString &_value, const int _min, } -void QCronScheduler::QCronField::fromRange(const QString &_range, - const int _min, const int _max) +void QCronScheduler::QCronField::fromRange(const QString &_range, const int _min, const int _max) { - qCDebug(LOG_LIB) << "Parse field from range" << _range - << "with corner values" << _min << _max; + qCDebug(LOG_LIB) << "Parse field from range" << _range << "with corner values" << _min << _max; if (_range == "*") { minValue = _min; diff --git a/sources/awesomewidgets/qcronscheduler.h b/sources/awesomewidgets/qcronscheduler.h index 185c076..cfcbdec 100644 --- a/sources/awesomewidgets/qcronscheduler.h +++ b/sources/awesomewidgets/qcronscheduler.h @@ -56,8 +56,7 @@ private slots: private: QCronRunSchedule m_schedule; QTimer *m_timer = nullptr; - QList parseField(const QString &_value, const int _min, - const int _max) const; + QList parseField(const QString &_value, const int _min, const int _max) const; }; diff --git a/sources/awesomewidgets/quotes/aapl.desktop b/sources/awesomewidgets/quotes/aapl.desktop index c744c32..c2eb130 100644 --- a/sources/awesomewidgets/quotes/aapl.desktop +++ b/sources/awesomewidgets/quotes/aapl.desktop @@ -4,7 +4,7 @@ Name=AAPL.NASDAQ Comment=Apple Inc X-AW-Ticker="AAPL" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 X-AW-Number=0 X-AW-Schedule= diff --git a/sources/awesomewidgets/quotes/eurrub.desktop b/sources/awesomewidgets/quotes/eurrub.desktop index c5c0453..4f8cbcb 100644 --- a/sources/awesomewidgets/quotes/eurrub.desktop +++ b/sources/awesomewidgets/quotes/eurrub.desktop @@ -2,9 +2,9 @@ Encoding=UTF-8 Name=EUR/RUB Comment=EUR/RUB -X-AW-Ticker="EURRUB=X" +X-AW-Ticker="EURRUB" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 X-AW-Number=1 X-AW-Schedule= diff --git a/sources/awesomewidgets/quotes/eurusd.desktop b/sources/awesomewidgets/quotes/eurusd.desktop index 5d18f4d..564bbcd 100644 --- a/sources/awesomewidgets/quotes/eurusd.desktop +++ b/sources/awesomewidgets/quotes/eurusd.desktop @@ -2,9 +2,9 @@ Encoding=UTF-8 Name=EUR/USD Comment=EUR/USD -X-AW-Ticker="EURUSD=X" +X-AW-Ticker="EURUSD" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 X-AW-Number=2 X-AW-Schedule= diff --git a/sources/awesomewidgets/quotes/goog.desktop b/sources/awesomewidgets/quotes/goog.desktop index d27306d..85003b6 100644 --- a/sources/awesomewidgets/quotes/goog.desktop +++ b/sources/awesomewidgets/quotes/goog.desktop @@ -4,7 +4,7 @@ Name=GOOG.NASDAQ Comment=Google Inc X-AW-Ticker="GOOG" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 X-AW-Number=3 X-AW-Schedule= diff --git a/sources/awesomewidgets/quotes/msft.desktop b/sources/awesomewidgets/quotes/msft.desktop index b02e4d4..2fdcea3 100644 --- a/sources/awesomewidgets/quotes/msft.desktop +++ b/sources/awesomewidgets/quotes/msft.desktop @@ -4,7 +4,7 @@ Name=MSFT.NASDAQ Comment=Microsoft Corp X-AW-Ticker="MSFT" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 X-AW-Number=4 X-AW-Schedule= diff --git a/sources/awesomewidgets/quotes/rts.desktop b/sources/awesomewidgets/quotes/rts.desktop index 7b235a2..87a46c7 100644 --- a/sources/awesomewidgets/quotes/rts.desktop +++ b/sources/awesomewidgets/quotes/rts.desktop @@ -2,10 +2,10 @@ Encoding=UTF-8 Name=RTS Comment=RTS Index -X-AW-Ticker="RTS.RS" +X-AW-Ticker="^RTS" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 -X-AW-Number=5 +X-AW-Number=4 X-AW-Schedule= X-AW-Socket= diff --git a/sources/awesomewidgets/quotes/snp.desktop b/sources/awesomewidgets/quotes/snp.desktop deleted file mode 100644 index a5b955d..0000000 --- a/sources/awesomewidgets/quotes/snp.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=S&P -Comment=S&P 500 Index -X-AW-Ticker="^GSPC" -X-AW-Active=false -X-AW-ApiVersion=4 -X-AW-Interval=60 -X-AW-Number=6 -X-AW-Schedule= -X-AW-Socket= diff --git a/sources/awesomewidgets/quotes/usdrub.desktop b/sources/awesomewidgets/quotes/usdrub.desktop index 2b38ca0..6e51795 100644 --- a/sources/awesomewidgets/quotes/usdrub.desktop +++ b/sources/awesomewidgets/quotes/usdrub.desktop @@ -2,9 +2,9 @@ Encoding=UTF-8 Name=USD/RUB Comment=USD/RUB -X-AW-Ticker="USDRUB=X" +X-AW-Ticker="USDRUB" X-AW-Active=false -X-AW-ApiVersion=4 +X-AW-ApiVersion=5 X-AW-Interval=60 X-AW-Number=8 X-AW-Schedule= diff --git a/sources/awesomewidgets/quotes/vix.desktop b/sources/awesomewidgets/quotes/vix.desktop deleted file mode 100644 index 287c966..0000000 --- a/sources/awesomewidgets/quotes/vix.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=VIX -Comment=Volatility S&P 500 -X-AW-Ticker="^VIX" -X-AW-Active=false -X-AW-ApiVersion=4 -X-AW-Interval=60 -X-AW-Number=7 -X-AW-Schedule= -X-AW-Socket= diff --git a/sources/awesomewidgets/stooqquotesprovider.cpp b/sources/awesomewidgets/stooqquotesprovider.cpp new file mode 100644 index 0000000..dafa060 --- /dev/null +++ b/sources/awesomewidgets/stooqquotesprovider.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * 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 "stooqquotesprovider.h" + +#include +#include + +#include "awdebug.h" + + +StooqQuotesProvider::StooqQuotesProvider(QObject *_parent) + : AbstractQuotesProvider(_parent) +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; +} + + +StooqQuotesProvider::~StooqQuotesProvider() +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; +} + + +void StooqQuotesProvider::initUrl(const QString &_asset) +{ + qCDebug(LOG_LIB) << "Init query for" << _asset; + + m_url = QUrl(STOOQ_QUOTES_URL); + QUrlQuery params; + params.addQueryItem("s", _asset); + params.addQueryItem("f", "pv"); + params.addQueryItem("e", "csv"); + m_url.setQuery(params); +} + + +QVariantHash StooqQuotesProvider::parse(const QByteArray &_source, + const QVariantHash &_oldValues) const +{ + qCDebug(LOG_LIB) << "Parse csv" << _source; + + QVariantHash values; + + QStringList sourceValues + = QTextCodec::codecForMib(106)->toUnicode(_source).trimmed().split(','); + if (sourceValues.count() != 2) { + qCWarning(LOG_LIB) << "Parse error" << sourceValues; + return values; + } + + // extract old data + auto oldPrice = _oldValues[tag("price")].toDouble(); + auto oldVolume = _oldValues[tag("volume")].toInt(); + + // last trade + auto price = sourceValues.at(0).toDouble(); + values[tag("pricechg")] = oldPrice == 0.0 ? 0.0 : price - oldPrice; + values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / price; + values[tag("price")] = price; + // volume + auto volume = sourceValues.at(1).toInt(); + values[tag("volumechg")] = oldVolume == 0 ? 0 : volume - oldVolume; + values[tag("percvolumechg")] = 100.0 * values[tag("volumechg")].toDouble() / volume; + values[tag("volume")] = volume; + + return values; +} + + +QUrl StooqQuotesProvider::url() const +{ + return m_url; +} diff --git a/sources/awesomewidgets/stooqquotesprovider.h b/sources/awesomewidgets/stooqquotesprovider.h new file mode 100644 index 0000000..f38b068 --- /dev/null +++ b/sources/awesomewidgets/stooqquotesprovider.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * 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 STOOQQUOTESPROVIDER_H +#define STOOQQUOTESPROVIDER_H + +#include "abstractquotesprovider.h" + + +class StooqQuotesProvider : public AbstractQuotesProvider +{ + Q_OBJECT + +public: + const char *STOOQ_QUOTES_URL = "https://stooq.com/q/l/"; + + explicit StooqQuotesProvider(QObject *_parent); + virtual ~StooqQuotesProvider(); + void initUrl(const QString &_asset); + QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const; + QUrl url() const; + +private: + QUrl m_url; +}; + + +#endif /* STOOQQUOTESPROVIDER_H */ diff --git a/sources/awesomewidgets/yahooquotesprovider.cpp b/sources/awesomewidgets/yahooquotesprovider.cpp new file mode 100644 index 0000000..fb8d29e --- /dev/null +++ b/sources/awesomewidgets/yahooquotesprovider.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * 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 "yahooquotesprovider.h" + +#include +#include + +#include "awdebug.h" + + +YahooQuotesProvider::YahooQuotesProvider(QObject *_parent) + : AbstractQuotesProvider(_parent) +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; +} + + +YahooQuotesProvider::~YahooQuotesProvider() +{ + qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; +} + + +void YahooQuotesProvider::initUrl(const QString &_asset) +{ + qCDebug(LOG_LIB) << "Init query for" << _asset; + + m_url = QUrl(YAHOO_QUOTES_URL); + QUrlQuery params; + params.addQueryItem("format", "json"); + params.addQueryItem("env", "store://datatables.org/alltableswithkeys"); + params.addQueryItem("q", QString(YAHOO_QUOTES_QUERY).arg(_asset)); + m_url.setQuery(params); +} + + +QVariantHash YahooQuotesProvider::parse(const QByteArray &_source, + const QVariantHash &_oldValues) const +{ + qCDebug(LOG_LIB) << "Parse json" << _source; + + QVariantHash values; + + QJsonParseError error; + QJsonDocument jsonDoc = QJsonDocument::fromJson(_source, &error); + if (error.error != QJsonParseError::NoError) { + qCWarning(LOG_LIB) << "Parse error" << error.errorString(); + return values; + } + QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()["query"].toMap(); + jsonQuotes = jsonQuotes["results"].toMap()["quote"].toMap(); + + // extract old data + auto oldPrice = _oldValues[tag("price")].toDouble(); + + // last trade + auto value = jsonQuotes["LastTradePriceOnly"].toString().toDouble(); + values[tag("pricechg")] = oldPrice == 0.0 ? 0.0 : value - oldPrice; + values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / value; + values[tag("price")] = value; + // volume + values[tag("volume")] = 0; + values[tag("volumechg")] = 0; + values[tag("percvolumechg")] = 0.0; + + return values; +} + + +QUrl YahooQuotesProvider::url() const +{ + return m_url; +} diff --git a/sources/awesomewidgets/yahooquotesprovider.h b/sources/awesomewidgets/yahooquotesprovider.h new file mode 100644 index 0000000..00369b7 --- /dev/null +++ b/sources/awesomewidgets/yahooquotesprovider.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 YAHOOQUOTESPROVIDER_H +#define YAHOOQUOTESPROVIDER_H + +#include "abstractquotesprovider.h" + + +class YahooQuotesProvider : public AbstractQuotesProvider +{ + Q_OBJECT + +public: + const char *YAHOO_QUOTES_URL = "https://query.yahooapis.com/v1/public/yql"; + const char *YAHOO_QUOTES_QUERY = "select * from yahoo.finance.quotes where symbol='%1'"; + + explicit YahooQuotesProvider(QObject *_parent); + virtual ~YahooQuotesProvider(); + void initUrl(const QString &_asset); + QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const; + QUrl url() const; + +private: + QUrl m_url; +}; + + +#endif /* YAHOOQUOTESPROVIDER_H */ diff --git a/sources/awesomewidgets/yahooweatherprovider.cpp b/sources/awesomewidgets/yahooweatherprovider.cpp index 37729b4..efac315 100644 --- a/sources/awesomewidgets/yahooweatherprovider.cpp +++ b/sources/awesomewidgets/yahooweatherprovider.cpp @@ -22,8 +22,8 @@ #include "awdebug.h" -YahooWeatherProvider::YahooWeatherProvider(QObject *_parent, const int _number) - : AbstractWeatherProvider(_parent, _number) +YahooWeatherProvider::YahooWeatherProvider(QObject *_parent) + : AbstractWeatherProvider(_parent) { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; } @@ -35,11 +35,9 @@ YahooWeatherProvider::~YahooWeatherProvider() } -void YahooWeatherProvider::initUrl(const QString &_city, - const QString &_country, const int ts) +void YahooWeatherProvider::initUrl(const QString &_city, const QString &_country, const int ts) { - qCDebug(LOG_LIB) << "Init query for" << _city << _country << "with ts" - << ts; + qCDebug(LOG_LIB) << "Init query for" << _city << _country << "with ts" << ts; m_ts = ts; @@ -58,8 +56,7 @@ QVariantHash YahooWeatherProvider::parse(const QVariantMap &_json) const QVariantMap jsonMap = _json["query"].toMap(); if (jsonMap["count"].toInt() != 1) { - qCWarning(LOG_LIB) << "Found data count" << _json["count"].toInt() - << "is not 1"; + qCWarning(LOG_LIB) << "Found data count" << _json["count"].toInt() << "is not 1"; return QVariantHash(); } QVariantMap results = jsonMap["results"].toMap()["channel"].toMap(); @@ -76,9 +73,8 @@ QUrl YahooWeatherProvider::url() const } -QVariantHash -YahooWeatherProvider::parseCurrent(const QVariantMap &_json, - const QVariantMap &_atmosphere) const +QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, + const QVariantMap &_atmosphere) const { qCDebug(LOG_LIB) << "Parse current weather from" << _json; @@ -86,14 +82,12 @@ YahooWeatherProvider::parseCurrent(const QVariantMap &_json, QVariantHash values; int id = _json["condition"].toMap()["code"].toInt(); - values[QString("weatherId%1").arg(number())] = id; - values[QString("temperature%1").arg(number())] = condition["temp"].toInt(); - values[QString("timestamp%1").arg(number())] = condition["date"].toString(); - values[QString("humidity%1").arg(number())] - = _atmosphere["humidity"].toInt(); + values[tag("weatherId")] = id; + values[tag("temperature")] = condition["temp"].toInt(); + values[tag("timestamp")] = condition["date"].toString(); + values[tag("humidity")] = _atmosphere["humidity"].toInt(); // HACK temporary fix of invalid values on Yahoo! side - values[QString("pressure%1").arg(number())] - = static_cast(_atmosphere["pressure"].toFloat() / 33.863753); + values[tag("pressure")] = static_cast(_atmosphere["pressure"].toFloat() / 33.863753); return values; } @@ -105,19 +99,16 @@ QVariantHash YahooWeatherProvider::parseForecast(const QVariantMap &_json) const QVariantHash values; QVariantList weatherList = _json["forecast"].toList(); - QVariantMap weatherMap = weatherList.count() < m_ts - ? weatherList.last().toMap() - : weatherList.at(m_ts).toMap(); + QVariantMap weatherMap + = weatherList.count() < m_ts ? weatherList.last().toMap() : weatherList.at(m_ts).toMap(); int id = weatherMap["code"].toInt(); - values[QString("weatherId%1").arg(number())] = id; - values[QString("timestamp%1").arg(number())] - = weatherMap["date"].toString(); + values[tag("weatherId")] = id; + values[tag("timestamp")] = weatherMap["date"].toString(); // yahoo provides high and low temperatures. Lets calculate average one - values[QString("temperature%1").arg(number())] - = (weatherMap["high"].toFloat() + weatherMap["low"].toFloat()) / 2.0; + values[tag("temperature")] = (weatherMap["high"].toFloat() + weatherMap["low"].toFloat()) / 2.0; // ... and no forecast data for humidity and pressure - values[QString("humidity%1").arg(number())] = 0; - values[QString("pressure%1").arg(number())] = 0.0; + values[tag("humidity")] = 0; + values[tag("pressure")] = 0.0; return values; } diff --git a/sources/awesomewidgets/yahooweatherprovider.h b/sources/awesomewidgets/yahooweatherprovider.h index 342b8b9..8d99ef6 100644 --- a/sources/awesomewidgets/yahooweatherprovider.h +++ b/sources/awesomewidgets/yahooweatherprovider.h @@ -31,15 +31,14 @@ public: "u='c' and woeid in (select woeid from " "geo.places(1) where text='%1, %2')"; - explicit YahooWeatherProvider(QObject *_parent, const int _number); + explicit YahooWeatherProvider(QObject *_parent); virtual ~YahooWeatherProvider(); void initUrl(const QString &_city, const QString &_country, const int); QVariantHash parse(const QVariantMap &_json) const; QUrl url() const; private: - QVariantHash parseCurrent(const QVariantMap &_json, - const QVariantMap &_atmosphere) const; + QVariantHash parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const; QVariantHash parseForecast(const QVariantMap &_json) const; int m_ts = 0; QUrl m_url; diff --git a/sources/desktop-panel/plugin/dpadds.cpp b/sources/desktop-panel/plugin/dpadds.cpp index 098f737..15842f4 100644 --- a/sources/desktop-panel/plugin/dpadds.cpp +++ b/sources/desktop-panel/plugin/dpadds.cpp @@ -44,10 +44,8 @@ DPAdds::DPAdds(QObject *_parent) connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged())); - connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, - SIGNAL(windowListChanged())); - connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, - SIGNAL(windowListChanged())); + connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, SIGNAL(windowListChanged())); + connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, SIGNAL(windowListChanged())); } @@ -72,8 +70,7 @@ int DPAdds::currentDesktop() const QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp) const { - qCDebug(LOG_DP) << "Should be sorted" << _sorted << "and filter applied" - << _regexp; + qCDebug(LOG_DP) << "Should be sorted" << _sorted << "and filter applied" << _regexp; QStringList allKeys; allKeys.append("mark"); @@ -106,11 +103,9 @@ QString DPAdds::toolTipImage(const int _desktop) const // special tooltip format for names if (m_tooltipType == "names") { QStringList windowList; - std::for_each( - info.windowsData.cbegin(), info.windowsData.cend(), - [&windowList](WindowData data) { windowList.append(data.name); }); - return QString("
    • %1
    ") - .arg(windowList.join("
  • ")); + std::for_each(info.windowsData.cbegin(), info.windowsData.cend(), + [&windowList](WindowData data) { windowList.append(data.name); }); + return QString("
    • %1
    ").arg(windowList.join("
  • ")); } // init @@ -133,8 +128,7 @@ QString DPAdds::toolTipImage(const int _desktop) const toolTipScene->addLine(0, info.desktop.height() + 2.0 * margin, info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin); - toolTipScene->addLine(info.desktop.width() + 2.0 * margin, - info.desktop.height() + 2.0 * margin, + toolTipScene->addLine(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin, info.desktop.width() + 2.0 * margin, 0); toolTipScene->addLine(info.desktop.width() + 2.0 * margin, 0, 0, 0); @@ -145,39 +139,35 @@ QString DPAdds::toolTipImage(const int _desktop) const for (auto &data : info.windowsData) { QRect rect = data.rect; toolTipScene->addLine(rect.left() + margin, rect.bottom() + margin, - rect.left() + margin, rect.top() + margin, - pen); - toolTipScene->addLine(rect.left() + margin, rect.top() + margin, - rect.right() + margin, rect.top() + margin, - pen); - toolTipScene->addLine(rect.right() + margin, rect.top() + margin, - rect.right() + margin, rect.bottom() + margin, - pen); + rect.left() + margin, rect.top() + margin, pen); + toolTipScene->addLine(rect.left() + margin, rect.top() + margin, rect.right() + margin, + rect.top() + margin, pen); + toolTipScene->addLine(rect.right() + margin, rect.top() + margin, rect.right() + margin, + rect.bottom() + margin, pen); toolTipScene->addLine(rect.right() + margin, rect.bottom() + margin, - rect.left() + margin, rect.bottom() + margin, - pen); + rect.left() + margin, rect.bottom() + margin, pen); } } else if (m_tooltipType == "clean") { QScreen *screen = QGuiApplication::primaryScreen(); std::for_each(info.desktopsData.cbegin(), info.desktopsData.cend(), [&toolTipScene, &screen](const WindowData &data) { QPixmap desktop = screen->grabWindow(data.id); - toolTipScene->addPixmap(desktop)->setOffset( - data.rect.left(), data.rect.top()); + toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), + data.rect.top()); }); } else if (m_tooltipType == "windows") { QScreen *screen = QGuiApplication::primaryScreen(); std::for_each(info.desktopsData.cbegin(), info.desktopsData.cend(), [&toolTipScene, &screen](const WindowData &data) { QPixmap desktop = screen->grabWindow(data.id); - toolTipScene->addPixmap(desktop)->setOffset( - data.rect.left(), data.rect.top()); + toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), + data.rect.top()); }); std::for_each(info.windowsData.cbegin(), info.windowsData.cend(), [&toolTipScene, &screen](const WindowData &data) { QPixmap window = screen->grabWindow(data.id); - toolTipScene->addPixmap(window)->setOffset( - data.rect.left(), data.rect.top()); + toolTipScene->addPixmap(window)->setOffset(data.rect.left(), + data.rect.top()); }); } @@ -189,8 +179,7 @@ QString DPAdds::toolTipImage(const int _desktop) const delete toolTipView; delete toolTipScene; - return QString("") - .arg(QString(byteArray.toBase64())); + return QString("").arg(QString(byteArray.toBase64())); } @@ -271,11 +260,9 @@ QVariantMap DPAdds::getFont(const QVariantMap &_defaultFont) const QVariantMap fontMap; int ret = 0; - CFont defaultCFont - = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), - 400, false, _defaultFont["color"].toString()); - CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, - false, &ret); + CFont defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, + false, _defaultFont["color"].toString()); + CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret); fontMap["applied"] = ret; fontMap["color"] = font.color().name(); @@ -291,10 +278,9 @@ void DPAdds::sendNotification(const QString &_eventId, const QString &_message) { qCDebug(LOG_DP) << "Event" << _eventId << "with message" << _message; - KNotification *notification = KNotification::event( - _eventId, QString("Desktop Panel ::: %1").arg(_eventId), _message); - notification->setComponentName( - "plasma-applet-org.kde.plasma.desktop-panel"); + KNotification *notification + = KNotification::event(_eventId, QString("Desktop Panel ::: %1").arg(_eventId), _message); + notification->setComponentName("plasma-applet-org.kde.plasma.desktop-panel"); } @@ -317,18 +303,15 @@ DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int _desktop) const for (auto &id : KWindowSystem::windows()) { KWindowInfo winInfo = KWindowInfo( - id, - NET::Property::WMDesktop | NET::Property::WMGeometry - | NET::Property::WMState | NET::Property::WMWindowType - | NET::Property::WMVisibleName); + id, NET::Property::WMDesktop | NET::Property::WMGeometry | NET::Property::WMState + | NET::Property::WMWindowType | NET::Property::WMVisibleName); if (!winInfo.isOnDesktop(_desktop)) continue; WindowData data; data.id = id; data.name = winInfo.visibleName(); data.rect = winInfo.geometry(); - if (winInfo.windowType(NET::WindowTypeMask::NormalMask) - == NET::WindowType::Normal) { + if (winInfo.windowType(NET::WindowTypeMask::NormalMask) == NET::WindowType::Normal) { if (winInfo.isMinimized()) continue; info.windowsData.append(data); diff --git a/sources/desktop-panel/plugin/dpadds.h b/sources/desktop-panel/plugin/dpadds.h index b631c61..b8f8c2f 100644 --- a/sources/desktop-panel/plugin/dpadds.h +++ b/sources/desktop-panel/plugin/dpadds.h @@ -45,18 +45,15 @@ public: virtual ~DPAdds(); Q_INVOKABLE bool isDebugEnabled() const; Q_INVOKABLE int currentDesktop() const; - Q_INVOKABLE QStringList dictKeys(const bool _sorted = true, - const QString &_regexp = "") const; + Q_INVOKABLE QStringList dictKeys(const bool _sorted = true, const QString &_regexp = "") const; Q_INVOKABLE int numberOfDesktops() const; Q_INVOKABLE QString toolTipImage(const int _desktop) const; - Q_INVOKABLE QString parsePattern(const QString &_pattern, - const int _desktop) const; + Q_INVOKABLE QString parsePattern(const QString &_pattern, const int _desktop) const; // values Q_INVOKABLE void setMark(const QString &_newMark); Q_INVOKABLE void setToolTipData(const QVariantMap &_tooltipData); Q_INVOKABLE QString infoByKey(const QString &_key) const; - Q_INVOKABLE QString valueByKey(const QString &_key, - int _desktop = -1) const; + Q_INVOKABLE QString valueByKey(const QString &_key, int _desktop = -1) const; // configuration slots Q_INVOKABLE QString getAboutText(const QString &_type) const; Q_INVOKABLE QVariantMap getFont(const QVariantMap &_defaultFont) const; @@ -66,8 +63,7 @@ signals: void windowListChanged() const; public slots: - Q_INVOKABLE static void sendNotification(const QString &_eventId, - const QString &_message); + Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message); Q_INVOKABLE void setCurrentDesktop(const int _desktop) const; private: diff --git a/sources/extsysmon/extsysmon.cpp b/sources/extsysmon/extsysmon.cpp index fab99fd..65a8f1f 100644 --- a/sources/extsysmon/extsysmon.cpp +++ b/sources/extsysmon/extsysmon.cpp @@ -86,26 +86,22 @@ bool ExtendedSysMon::updateSourceEvent(const QString &_source) void ExtendedSysMon::readConfiguration() { - QString fileName = QStandardPaths::locate( - QStandardPaths::ConfigLocation, "plasma-dataengine-extsysmon.conf"); + QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, + "plasma-dataengine-extsysmon.conf"); qCInfo(LOG_ESM) << "Configuration file" << fileName; QSettings settings(fileName, QSettings::IniFormat); QHash rawConfig; settings.beginGroup("Configuration"); - rawConfig["ACPIPATH"] - = settings.value("ACPIPATH", "/sys/class/power_supply/").toString(); + rawConfig["ACPIPATH"] = settings.value("ACPIPATH", "/sys/class/power_supply/").toString(); rawConfig["GPUDEV"] = settings.value("GPUDEV", "auto").toString(); rawConfig["HDDDEV"] = settings.value("HDDDEV", "all").toString(); - rawConfig["HDDTEMPCMD"] - = settings.value("HDDTEMPCMD", "sudo smartctl -a").toString(); - rawConfig["MPDADDRESS"] - = settings.value("MPDADDRESS", "localhost").toString(); + rawConfig["HDDTEMPCMD"] = settings.value("HDDTEMPCMD", "sudo smartctl -a").toString(); + rawConfig["MPDADDRESS"] = settings.value("MPDADDRESS", "localhost").toString(); rawConfig["MPDPORT"] = settings.value("MPDPORT", "6600").toString(); rawConfig["MPRIS"] = settings.value("MPRIS", "auto").toString(); rawConfig["PLAYER"] = settings.value("PLAYER", "mpris").toString(); - rawConfig["PLAYERSYMBOLS"] - = settings.value("PLAYERSYMBOLS", "10").toString(); + rawConfig["PLAYERSYMBOLS"] = settings.value("PLAYERSYMBOLS", "10").toString(); settings.endGroup(); m_configuration = updateConfiguration(rawConfig); @@ -122,8 +118,7 @@ ExtendedSysMon::updateConfiguration(QHash _rawConfig) const ; else if (_rawConfig["GPUDEV"] == "auto") _rawConfig["GPUDEV"] = GPULoadSource::autoGpu(); - else if ((_rawConfig["GPUDEV"] != "ati") - && (_rawConfig["GPUDEV"] != "nvidia")) + else if ((_rawConfig["GPUDEV"] != "ati") && (_rawConfig["GPUDEV"] != "nvidia")) _rawConfig["GPUDEV"] = GPULoadSource::autoGpu(); // hdddev QStringList allHddDevices = HDDTemperatureSource::allHdd(); @@ -132,8 +127,7 @@ ExtendedSysMon::updateConfiguration(QHash _rawConfig) const } else if (_rawConfig["HDDDEV"] == "disable") { _rawConfig["HDDDEV"] = ""; } else { - QStringList deviceList - = _rawConfig["HDDDEV"].split(',', QString::SkipEmptyParts); + QStringList deviceList = _rawConfig["HDDDEV"].split(',', QString::SkipEmptyParts); QStringList devices; QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$"); for (auto &device : deviceList) @@ -158,7 +152,6 @@ ExtendedSysMon::updateConfiguration(QHash _rawConfig) const } -K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(extsysmon, ExtendedSysMon, - "plasma-dataengine-extsysmon.json") +K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(extsysmon, ExtendedSysMon, "plasma-dataengine-extsysmon.json") #include "extsysmon.moc" diff --git a/sources/extsysmon/extsysmon.h b/sources/extsysmon/extsysmon.h index 16e3224..a211579 100644 --- a/sources/extsysmon/extsysmon.h +++ b/sources/extsysmon/extsysmon.h @@ -42,8 +42,7 @@ private: QHash m_configuration; // methods void readConfiguration(); - QHash - updateConfiguration(QHash _rawConfig) const; + QHash updateConfiguration(QHash _rawConfig) const; }; diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index 342ad75..2ab3e6e 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -34,8 +34,7 @@ #include "weathersource.h" -ExtSysMonAggregator::ExtSysMonAggregator(QObject *_parent, - const QHash &_config) +ExtSysMonAggregator::ExtSysMonAggregator(QObject *_parent, const QHash &_config) : QObject(_parent) { qCDebug(LOG_ESM) << __PRETTY_FUNCTION__; @@ -72,8 +71,7 @@ QVariantMap ExtSysMonAggregator::initialData(const QString &_source) const { qCDebug(LOG_ESM) << "Source" << _source; - return hasSource(_source) ? m_map[_source]->initialData(_source) - : QVariantMap(); + return hasSource(_source) ? m_map[_source]->initialData(_source) : QVariantMap(); } @@ -97,8 +95,7 @@ void ExtSysMonAggregator::init(const QHash &_config) for (auto &source : customItem->sources()) m_map[source] = customItem; // desktop - AbstractExtSysMonSource *desktopItem - = new DesktopSource(this, QStringList()); + AbstractExtSysMonSource *desktopItem = new DesktopSource(this, QStringList()); for (auto &source : desktopItem->sources()) m_map[source] = desktopItem; // gpu load @@ -112,30 +109,26 @@ void ExtSysMonAggregator::init(const QHash &_config) for (auto &source : gpuTempItem->sources()) m_map[source] = gpuTempItem; // hdd temperature - AbstractExtSysMonSource *hddTempItem = new HDDTemperatureSource( - this, QStringList({_config["HDDDEV"], _config["HDDTEMPCMD"]})); + AbstractExtSysMonSource *hddTempItem + = new HDDTemperatureSource(this, QStringList({_config["HDDDEV"], _config["HDDTEMPCMD"]})); for (auto &source : hddTempItem->sources()) m_map[source] = hddTempItem; // network - AbstractExtSysMonSource *networkItem - = new NetworkSource(this, QStringList()); + AbstractExtSysMonSource *networkItem = new NetworkSource(this, QStringList()); for (auto &source : networkItem->sources()) m_map[source] = networkItem; // player AbstractExtSysMonSource *playerItem = new PlayerSource( - this, QStringList({_config["PLAYER"], _config["MPDADDRESS"], - _config["MPDPORT"], _config["MPRIS"], - _config["PLAYERSYMBOLS"]})); + this, QStringList({_config["PLAYER"], _config["MPDADDRESS"], _config["MPDPORT"], + _config["MPRIS"], _config["PLAYERSYMBOLS"]})); for (auto &source : playerItem->sources()) m_map[source] = playerItem; // processes - AbstractExtSysMonSource *processesItem - = new ProcessesSource(this, QStringList()); + AbstractExtSysMonSource *processesItem = new ProcessesSource(this, QStringList()); for (auto &source : processesItem->sources()) m_map[source] = processesItem; // network request - AbstractExtSysMonSource *requestItem - = new RequestSource(this, QStringList()); + AbstractExtSysMonSource *requestItem = new RequestSource(this, QStringList()); for (auto &source : requestItem->sources()) m_map[source] = requestItem; // quotes @@ -143,13 +136,11 @@ void ExtSysMonAggregator::init(const QHash &_config) for (auto &source : quotesItem->sources()) m_map[source] = quotesItem; // upgrade - AbstractExtSysMonSource *upgradeItem - = new UpgradeSource(this, QStringList()); + AbstractExtSysMonSource *upgradeItem = new UpgradeSource(this, QStringList()); for (auto &source : upgradeItem->sources()) m_map[source] = upgradeItem; // weather - AbstractExtSysMonSource *weatherItem - = new WeatherSource(this, QStringList()); + AbstractExtSysMonSource *weatherItem = new WeatherSource(this, QStringList()); for (auto &source : weatherItem->sources()) m_map[source] = weatherItem; #ifdef BUILD_LOAD diff --git a/sources/extsysmon/extsysmonaggregator.h b/sources/extsysmon/extsysmonaggregator.h index 8153141..f752f53 100644 --- a/sources/extsysmon/extsysmonaggregator.h +++ b/sources/extsysmon/extsysmonaggregator.h @@ -28,8 +28,7 @@ class ExtSysMonAggregator : public QObject Q_OBJECT public: - explicit ExtSysMonAggregator(QObject *_parent, - const QHash &_config); + explicit ExtSysMonAggregator(QObject *_parent, const QHash &_config); virtual ~ExtSysMonAggregator(); QVariant data(const QString &_source) const; bool hasSource(const QString &_source) const; diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp index 810ce9c..4e9423f 100644 --- a/sources/extsysmonsources/batterysource.cpp +++ b/sources/extsysmonsources/batterysource.cpp @@ -54,8 +54,7 @@ QStringList BatterySource::getSources() m_batteriesCount = QDir(m_acpiPath) - .entryList(QStringList({"BAT*"}), - QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) + .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) .count(); qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount; @@ -165,16 +164,14 @@ void BatterySource::run() // adaptor QFile acFile(QString("%1/AC/online").arg(m_acpiPath)); if (acFile.open(QIODevice::ReadOnly | QIODevice::Text)) - m_values["battery/ac"] - = (QString(acFile.readLine()).trimmed().toInt() == 1); + m_values["battery/ac"] = (QString(acFile.readLine()).trimmed().toInt() == 1); acFile.close(); // batteries float currentLevel = 0.0, fullLevel = 0.0; for (int i = 0; i < m_batteriesCount; i++) { // current level - QFile currentLevelFile( - QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i)); + QFile currentLevelFile(QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i)); if (currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) { auto value = QString(currentLevelFile.readLine()).toInt(); m_trend[i + 1].append(value); @@ -182,16 +179,15 @@ void BatterySource::run() } currentLevelFile.close(); // total - QFile fullLevelFile( - QString("%1/BAT%2/energy_full").arg(m_acpiPath).arg(i)); + QFile fullLevelFile(QString("%1/BAT%2/energy_full").arg(m_acpiPath).arg(i)); if (fullLevelFile.open(QIODevice::ReadOnly | QIODevice::Text)) m_values[QString("battery/battotal%1").arg(i)] = QString(fullLevelFile.readLine()).toInt(); fullLevelFile.close(); - m_values[QString("battery/bat%1").arg(i)] = static_cast( - 100 * m_values[QString("battery/batnow%1").arg(i)].toFloat() - / m_values[QString("battery/battotal%1").arg(i)].toFloat()); + m_values[QString("battery/bat%1").arg(i)] + = static_cast(100 * m_values[QString("battery/batnow%1").arg(i)].toFloat() + / m_values[QString("battery/battotal%1").arg(i)].toFloat()); // accumulate currentLevel += m_values[QString("battery/batnow%1").arg(i)].toFloat(); fullLevel += m_values[QString("battery/battotal%1").arg(i)].toFloat(); @@ -241,23 +237,20 @@ void BatterySource::calculateRates() // check time interval auto now = QDateTime::currentDateTimeUtc(); - auto interval - = (now.toMSecsSinceEpoch() - m_timestamp.toMSecsSinceEpoch()) / 1000.0f; + auto interval = (now.toMSecsSinceEpoch() - m_timestamp.toMSecsSinceEpoch()) / 1000.0f; m_timestamp.swap(now); for (int i = 0; i < m_batteriesCount; i++) { auto approx = approximate(m_trend[i + 1]); m_values[QString("battery/batrate%1").arg(i)] = approx / interval; m_values[QString("battery/batleft%1").arg(i)] - = interval * m_values[QString("battery/batnow%1").arg(i)].toFloat() - / approx; + = interval * m_values[QString("battery/batnow%1").arg(i)].toFloat() / approx; } // total auto approx = approximate(m_trend[0]); m_values["battery/batrate"] = approx / interval; - m_values["battery/batleft"] - = interval * m_values["battery/batnow"].toFloat() / approx; + m_values["battery/batleft"] = interval * m_values["battery/batnow"].toFloat() / approx; // old data cleanup for (auto &trend : m_trend.keys()) { diff --git a/sources/extsysmonsources/customsource.cpp b/sources/extsysmonsources/customsource.cpp index e4d9664..912a501 100644 --- a/sources/extsysmonsources/customsource.cpp +++ b/sources/extsysmonsources/customsource.cpp @@ -45,10 +45,7 @@ QVariant CustomSource::data(const QString &_source) qCDebug(LOG_ESS) << "Source" << _source; // there are only one value - return m_extScripts->itemByTagNumber(index(_source)) - ->run() - .values() - .first(); + return m_extScripts->itemByTagNumber(index(_source))->run().values().first(); } @@ -59,9 +56,8 @@ QVariantMap CustomSource::initialData(const QString &_source) const QVariantMap data; data["min"] = ""; data["max"] = ""; - data["name"] - = QString("Custom command '%1' output") - .arg(m_extScripts->itemByTagNumber(index(_source))->uniq()); + data["name"] = QString("Custom command '%1' output") + .arg(m_extScripts->itemByTagNumber(index(_source))->uniq()); data["type"] = "QString"; data["units"] = ""; diff --git a/sources/extsysmonsources/gpuloadsource.cpp b/sources/extsysmonsources/gpuloadsource.cpp index 72840fa..f35d73c 100644 --- a/sources/extsysmonsources/gpuloadsource.cpp +++ b/sources/extsysmonsources/gpuloadsource.cpp @@ -36,8 +36,7 @@ GPULoadSource::GPULoadSource(QObject *_parent, const QStringList &_args) m_process = new QProcess(nullptr); // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished connect(m_process, - static_cast( - &QProcess::finished), + static_cast(&QProcess::finished), [this](int, QProcess::ExitStatus) { return updateValue(); }); m_process->waitForFinished(0); } @@ -57,8 +56,7 @@ QString GPULoadSource::autoGpu() QString gpu = "disable"; QFile moduleFile("/proc/modules"); if (!moduleFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - qCWarning(LOG_AW) << "Could not open file as text" - << moduleFile.fileName(); + qCWarning(LOG_AW) << "Could not open file as text" << moduleFile.fileName(); return gpu; } @@ -107,8 +105,7 @@ void GPULoadSource::run() if ((m_device != "nvidia") && (m_device != "ati")) return; // build cmd - QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" - : "aticonfig --od-getclocks"; + QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" : "aticonfig --od-getclocks"; qCInfo(LOG_ESS) << "cmd" << cmd; m_process->start(cmd); @@ -127,21 +124,18 @@ QStringList GPULoadSource::sources() const void GPULoadSource::updateValue() { qCInfo(LOG_ESS) << "Cmd returns" << m_process->exitCode(); - QString qdebug = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardError()) - .trimmed(); + QString qdebug + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardError()).trimmed(); qCInfo(LOG_ESS) << "Error" << qdebug; - QString qoutput = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardOutput()) - .trimmed(); + QString qoutput + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); qCInfo(LOG_ESS) << "Output" << qoutput; if (m_device == "nvidia") { for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { if (!str.contains("")) continue; - auto load - = str.remove("").remove("").remove('%'); + auto load = str.remove("").remove("").remove('%'); m_values["gpu/load"] = load.toFloat(); break; } @@ -149,8 +143,7 @@ void GPULoadSource::updateValue() for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { if (!str.contains("load")) continue; - QString load - = str.split(' ', QString::SkipEmptyParts)[3].remove('%'); + QString load = str.split(' ', QString::SkipEmptyParts)[3].remove('%'); m_values["gpu/load"] = load.toFloat(); break; } diff --git a/sources/extsysmonsources/gputempsource.cpp b/sources/extsysmonsources/gputempsource.cpp index 1b6e401..6a3b796 100644 --- a/sources/extsysmonsources/gputempsource.cpp +++ b/sources/extsysmonsources/gputempsource.cpp @@ -25,8 +25,7 @@ #include "awdebug.h" -GPUTemperatureSource::GPUTemperatureSource(QObject *_parent, - const QStringList &_args) +GPUTemperatureSource::GPUTemperatureSource(QObject *_parent, const QStringList &_args) : AbstractExtSysMonSource(_parent, _args) { Q_ASSERT(_args.count() == 1); @@ -37,8 +36,7 @@ GPUTemperatureSource::GPUTemperatureSource(QObject *_parent, m_process = new QProcess(nullptr); // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished connect(m_process, - static_cast( - &QProcess::finished), + static_cast(&QProcess::finished), [this](int, QProcess::ExitStatus) { return updateValue(); }); m_process->waitForFinished(0); } @@ -86,8 +84,7 @@ void GPUTemperatureSource::run() if ((m_device != "nvidia") && (m_device != "ati")) return; // build cmd - QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" - : "aticonfig --od-gettemperature"; + QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" : "aticonfig --od-gettemperature"; qCInfo(LOG_ESS) << "cmd" << cmd; m_process->start(cmd); @@ -106,13 +103,11 @@ QStringList GPUTemperatureSource::sources() const void GPUTemperatureSource::updateValue() { qCInfo(LOG_ESS) << "Cmd returns" << m_process->exitCode(); - QString qdebug = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardError()) - .trimmed(); + QString qdebug + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardError()).trimmed(); qCInfo(LOG_ESS) << "Error" << qdebug; - QString qoutput = QTextCodec::codecForMib(106) - ->toUnicode(m_process->readAllStandardOutput()) - .trimmed(); + QString qoutput + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); qCInfo(LOG_ESS) << "Output" << qoutput; if (m_device == "nvidia") { diff --git a/sources/extsysmonsources/hddtempsource.cpp b/sources/extsysmonsources/hddtempsource.cpp index ef67deb..361c7be 100644 --- a/sources/extsysmonsources/hddtempsource.cpp +++ b/sources/extsysmonsources/hddtempsource.cpp @@ -25,8 +25,7 @@ #include "awdebug.h" -HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, - const QStringList &_args) +HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, const QStringList &_args) : AbstractExtSysMonSource(_parent, _args) { Q_ASSERT(_args.count() == 2); @@ -42,11 +41,8 @@ HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, m_processes[device] = new QProcess(nullptr); // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished connect(m_processes[device], - static_cast( - &QProcess::finished), - [this, device](int, QProcess::ExitStatus) { - return updateValue(device); - }); + static_cast(&QProcess::finished), + [this, device](int, QProcess::ExitStatus) { return updateValue(device); }); m_processes[device]->waitForFinished(0); } } @@ -121,15 +117,13 @@ void HDDTemperatureSource::updateValue(const QString &_device) qCDebug(LOG_ESS) << "Called with device" << _device; qCInfo(LOG_ESS) << "Cmd returns" << m_processes[_device]->exitCode(); - QString qdebug - = QTextCodec::codecForMib(106) - ->toUnicode(m_processes[_device]->readAllStandardError()) - .trimmed(); + QString qdebug = QTextCodec::codecForMib(106) + ->toUnicode(m_processes[_device]->readAllStandardError()) + .trimmed(); qCInfo(LOG_ESS) << "Error" << qdebug; - QString qoutput - = QTextCodec::codecForMib(106) - ->toUnicode(m_processes[_device]->readAllStandardOutput()) - .trimmed(); + QString qoutput = QTextCodec::codecForMib(106) + ->toUnicode(m_processes[_device]->readAllStandardOutput()) + .trimmed(); qCInfo(LOG_ESS) << "Output" << qoutput; // parse @@ -140,8 +134,7 @@ void HDDTemperatureSource::updateValue(const QString &_device) continue; if (str.split(' ', QString::SkipEmptyParts).count() < 9) continue; - m_values[_device] - = str.split(' ', QString::SkipEmptyParts).at(9).toFloat(); + m_values[_device] = str.split(' ', QString::SkipEmptyParts).at(9).toFloat(); break; } } else { diff --git a/sources/extsysmonsources/networksource.cpp b/sources/extsysmonsources/networksource.cpp index 754b14a..ebe41ca 100644 --- a/sources/extsysmonsources/networksource.cpp +++ b/sources/extsysmonsources/networksource.cpp @@ -43,13 +43,11 @@ QVariant NetworkSource::data(const QString &_source) if (_source == "network/current/name") { QString device = "lo"; - QList rawInterfaceList - = QNetworkInterface::allInterfaces(); + QList rawInterfaceList = QNetworkInterface::allInterfaces(); qCInfo(LOG_ESS) << "Devices" << rawInterfaceList; for (auto &interface : rawInterfaceList) { if ((interface.flags().testFlag(QNetworkInterface::IsLoopBack)) - || (interface.flags().testFlag( - QNetworkInterface::IsPointToPoint))) + || (interface.flags().testFlag(QNetworkInterface::IsPointToPoint))) continue; if (interface.addressEntries().isEmpty()) continue; diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index 17d90bc..add634e 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -40,12 +40,9 @@ PlayerSource::PlayerSource(QObject *_parent, const QStringList &_args) m_mpris = _args.at(3); m_symbols = _args.at(4).toInt(); - connect(&m_mpdSocket, SIGNAL(connected()), this, - SLOT(mpdSocketConnected())); - connect(&m_mpdSocket, SIGNAL(readyRead()), this, - SLOT(mpdSocketReadyRead())); - connect(&m_mpdSocket, SIGNAL(bytesWritten(qint64)), this, - SLOT(mpdSocketWritten(const qint64))); + connect(&m_mpdSocket, SIGNAL(connected()), this, SLOT(mpdSocketConnected())); + connect(&m_mpdSocket, SIGNAL(readyRead()), this, SLOT(mpdSocketReadyRead())); + connect(&m_mpdSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(mpdSocketWritten(const qint64))); m_mpdCached = defaultInfo(); } @@ -71,8 +68,8 @@ QVariant PlayerSource::data(const QString &_source) QString PlayerSource::getAutoMpris() const { - QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call( - QDBus::BlockWithGui, "ListNames"); + QDBusMessage listServices + = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, "ListNames"); if (listServices.arguments().isEmpty()) { qCWarning(LOG_ESS) << "Could not find any DBus service"; return ""; @@ -106,15 +103,13 @@ QVariantMap PlayerSource::initialData(const QString &_source) const } else if (_source == "player/salbum") { data["min"] = ""; data["max"] = ""; - data["name"] - = QString("Current song album (%1 symbols)").arg(m_symbols); + data["name"] = QString("Current song album (%1 symbols)").arg(m_symbols); data["type"] = "QString"; data["units"] = ""; } else if (_source == "player/dalbum") { data["min"] = ""; data["max"] = ""; - data["name"] = QString("Current song album (%1 symbols, dynamic)") - .arg(m_symbols); + data["name"] = QString("Current song album (%1 symbols, dynamic)").arg(m_symbols); data["type"] = "QString"; data["units"] = ""; } else if (_source == "player/artist") { @@ -126,15 +121,13 @@ QVariantMap PlayerSource::initialData(const QString &_source) const } else if (_source == "player/sartist") { data["min"] = ""; data["max"] = ""; - data["name"] - = QString("Current song artist (%1 symbols)").arg(m_symbols); + data["name"] = QString("Current song artist (%1 symbols)").arg(m_symbols); data["type"] = "QString"; data["units"] = ""; } else if (_source == "player/dartist") { data["min"] = ""; data["max"] = ""; - data["name"] = QString("Current song artist (%1 symbols, dynamic)") - .arg(m_symbols); + data["name"] = QString("Current song artist (%1 symbols, dynamic)").arg(m_symbols); data["type"] = "QString"; data["units"] = ""; } else if (_source == "player/duration") { @@ -158,15 +151,13 @@ QVariantMap PlayerSource::initialData(const QString &_source) const } else if (_source == "player/stitle") { data["min"] = ""; data["max"] = ""; - data["name"] - = QString("Current song title (%1 symbols)").arg(m_symbols); + data["name"] = QString("Current song title (%1 symbols)").arg(m_symbols); data["type"] = "QString"; data["units"] = ""; } else if (_source == "player/dtitle") { data["min"] = ""; data["max"] = ""; - data["name"] = QString("Current song title (%1 symbols, dynamic)") - .arg(m_symbols); + data["name"] = QString("Current song title (%1 symbols, dynamic)").arg(m_symbols); data["type"] = "QString"; data["units"] = ""; } @@ -192,22 +183,16 @@ void PlayerSource::run() // dymanic properties // solid - m_values["player/salbum"] - = stripString(m_values["player/album"].toString(), m_symbols); - m_values["player/sartist"] - = stripString(m_values["player/artist"].toString(), m_symbols); - m_values["player/stitle"] - = stripString(m_values["player/title"].toString(), m_symbols); + m_values["player/salbum"] = stripString(m_values["player/album"].toString(), m_symbols); + m_values["player/sartist"] = stripString(m_values["player/artist"].toString(), m_symbols); + m_values["player/stitle"] = stripString(m_values["player/title"].toString(), m_symbols); // dynamic - m_values["player/dalbum"] - = buildString(m_values["player/dalbum"].toString(), - m_values["player/album"].toString(), m_symbols); - m_values["player/dartist"] - = buildString(m_values["player/dartist"].toString(), - m_values["player/artist"].toString(), m_symbols); - m_values["player/dtitle"] - = buildString(m_values["player/dtitle"].toString(), - m_values["player/title"].toString(), m_symbols); + m_values["player/dalbum"] = buildString(m_values["player/dalbum"].toString(), + m_values["player/album"].toString(), m_symbols); + m_values["player/dartist"] = buildString(m_values["player/dartist"].toString(), + m_values["player/artist"].toString(), m_symbols); + m_values["player/dtitle"] = buildString(m_values["player/dtitle"].toString(), + m_values["player/title"].toString(), m_symbols); } @@ -230,8 +215,7 @@ QStringList PlayerSource::sources() const } -QString PlayerSource::buildString(const QString &_current, - const QString &_value, const int _s) +QString PlayerSource::buildString(const QString &_current, const QString &_value, const int _s) { qCDebug(LOG_ESS) << "Current value" << _current << "received" << _value << "will be stripped after" << _s; @@ -240,8 +224,7 @@ QString PlayerSource::buildString(const QString &_current, if ((_current.isEmpty()) || ((index + _s + 1) > _value.count())) return QString("%1").arg(_value.left(_s), -_s, QLatin1Char(' ')); else - return QString("%1").arg(_value.mid(index + 1, _s), -_s, - QLatin1Char(' ')); + return QString("%1").arg(_value.mid(index + 1, _s), -_s, QLatin1Char(' ')); } @@ -262,26 +245,22 @@ bool PlayerSource::isMpdSocketConnected() const void PlayerSource::mpdSocketConnected() { - qCDebug(LOG_ESS) << "MPD socket connected to" << m_mpdSocket.peerName() - << "with state" << m_mpdSocket.state(); + qCDebug(LOG_ESS) << "MPD socket connected to" << m_mpdSocket.peerName() << "with state" + << m_mpdSocket.state(); } void PlayerSource::mpdSocketReadyRead() { - QString qoutput = QTextCodec::codecForMib(106) - ->toUnicode(m_mpdSocket.readAll()) - .trimmed(); + QString qoutput = QTextCodec::codecForMib(106)->toUnicode(m_mpdSocket.readAll()).trimmed(); qCInfo(LOG_ESS) << "Output" << qoutput; // parse for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { if (str.split(": ", QString::SkipEmptyParts).count() == 2) { // "Metadata: data" - QString metadata - = str.split(": ", QString::SkipEmptyParts).first().toLower(); - QString data - = str.split(": ", QString::SkipEmptyParts).last().trimmed(); + QString metadata = str.split(": ", QString::SkipEmptyParts).first().toLower(); + QString data = str.split(": ", QString::SkipEmptyParts).last().trimmed(); // there are one more time... if ((metadata == "time") && (data.contains(':'))) { QStringList times = data.split(':'); @@ -299,8 +278,7 @@ void PlayerSource::mpdSocketReadyRead() void PlayerSource::mpdSocketWritten(const qint64 _bytes) { - qCDebug(LOG_ESS) << "Bytes written" << _bytes << "to" - << m_mpdSocket.peerName(); + qCDebug(LOG_ESS) << "Bytes written" << _bytes << "to" << m_mpdSocket.peerName(); } @@ -326,8 +304,7 @@ QVariantHash PlayerSource::getPlayerMpdInfo() } else if (m_mpdSocket.state() == QAbstractSocket::ConnectedState) { // send request if (m_mpdSocket.write(MPD_STATUS_REQUEST) == -1) - qCWarning(LOG_ESS) - << "Could not write request to" << m_mpdSocket.peerName(); + qCWarning(LOG_ESS) << "Could not write request to" << m_mpdSocket.peerName(); } return m_mpdCached; @@ -351,30 +328,22 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) const // dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.vlc // /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get // string:'org.mpris.MediaPlayer2.Player' string:'Metadata' - QVariantList args - = QVariantList({"org.mpris.MediaPlayer2.Player", "Metadata"}); + QVariantList args = QVariantList({"org.mpris.MediaPlayer2.Player", "Metadata"}); QDBusMessage request = QDBusMessage::createMethodCall( - QString("org.mpris.MediaPlayer2.%1").arg(_mpris), - "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Get"); + QString("org.mpris.MediaPlayer2.%1").arg(_mpris), "/org/mpris/MediaPlayer2", + "org.freedesktop.DBus.Properties", "Get"); request.setArguments(args); - QDBusMessage response - = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT); - if ((response.type() != QDBusMessage::ReplyMessage) - || (response.arguments().isEmpty())) { + QDBusMessage response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT); + if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) { qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); } else { // another portion of dirty magic - QVariantHash map - = qdbus_cast(response.arguments() - .first() - .value() - .variant() - .value()); + QVariantHash map = qdbus_cast( + response.arguments().first().value().variant().value()); info["player/album"] = map.value("xesam:album", "unknown"); // artist is array info["player/artist"] = map.value("xesam:artist", "unknown").toString(); - info["player/duration"] - = map.value("mpris:length", 0).toInt() / (1000 * 1000); + info["player/duration"] = map.value("mpris:length", 0).toInt() / (1000 * 1000); info["player/title"] = map.value("xesam:title", "unknown"); } @@ -382,17 +351,13 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) const args[1] = "Position"; request.setArguments(args); response = bus.call(request, QDBus::BlockWithGui); - if ((response.type() != QDBusMessage::ReplyMessage) - || (response.arguments().isEmpty())) { + if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) { qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); } else { // this cast is simpler than the previous one ;) - info["player/progress"] = response.arguments() - .first() - .value() - .variant() - .toLongLong() - / (1000 * 1000); + info["player/progress"] + = response.arguments().first().value().variant().toLongLong() + / (1000 * 1000); } return info; diff --git a/sources/extsysmonsources/playersource.h b/sources/extsysmonsources/playersource.h index 84ed556..ed30f78 100644 --- a/sources/extsysmonsources/playersource.h +++ b/sources/extsysmonsources/playersource.h @@ -42,8 +42,7 @@ public: void run(); QStringList sources() const; // additional method to build dynamic tags - static QString buildString(const QString &_current, const QString &_value, - const int _s); + static QString buildString(const QString &_current, const QString &_value, const int _s); static QString stripString(const QString &_value, const int _s); // additional test method bool isMpdSocketConnected() const; diff --git a/sources/extsysmonsources/processessource.cpp b/sources/extsysmonsources/processessource.cpp index 20c868e..99b3287 100644 --- a/sources/extsysmonsources/processessource.cpp +++ b/sources/extsysmonsources/processessource.cpp @@ -79,8 +79,8 @@ QVariantMap ProcessesSource::initialData(const QString &_source) const void ProcessesSource::run() { - QStringList allDirectories = QDir("/proc").entryList( - QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + QStringList allDirectories + = QDir("/proc").entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); QStringList directories = allDirectories.filter(QRegExp("(\\d+)")); QStringList running; diff --git a/sources/extsysmonsources/quotessource.cpp b/sources/extsysmonsources/quotessource.cpp index 2a29cad..3b07f08 100644 --- a/sources/extsysmonsources/quotessource.cpp +++ b/sources/extsysmonsources/quotessource.cpp @@ -63,49 +63,7 @@ QVariantMap QuotesSource::initialData(const QString &_source) const int ind = index(_source); QVariantMap data; - if (_source.startsWith("quotes/askchg")) { - data["min"] = 0.0; - data["max"] = 0.0; - data["name"] = QString("Absolute ask changes for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); - data["type"] = "double"; - data["units"] = ""; - } else if (_source.startsWith("quotes/ask")) { - data["min"] = 0.0; - data["max"] = 0.0; - data["name"] = QString("Ask for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); - data["type"] = "double"; - data["units"] = ""; - } else if (_source.startsWith("quotes/percaskchg")) { - data["min"] = -100.0; - data["max"] = 100.0; - data["name"] = QString("Ask changes for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); - data["type"] = "double"; - data["units"] = ""; - } else if (_source.startsWith("quotes/bidchg")) { - data["min"] = 0.0; - data["max"] = 0.0; - data["name"] = QString("Absolute bid changes for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); - data["type"] = "double"; - data["units"] = ""; - } else if (_source.startsWith("quotes/bid")) { - data["min"] = 0.0; - data["max"] = 0.0; - data["name"] = QString("Bid for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); - data["type"] = "double"; - data["units"] = ""; - } else if (_source.startsWith("quotes/percbidchg")) { - data["min"] = -100.0; - data["max"] = 100.0; - data["name"] = QString("Bid changes for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); - data["type"] = "double"; - data["units"] = ""; - } else if (_source.startsWith("quotes/pricechg")) { + if (_source.startsWith("quotes/pricechg")) { data["min"] = 0.0; data["max"] = 0.0; data["name"] = QString("Absolute prie changes for '%1'") @@ -115,15 +73,34 @@ QVariantMap QuotesSource::initialData(const QString &_source) const } else if (_source.startsWith("quotes/price")) { data["min"] = 0.0; data["max"] = 0.0; - data["name"] = QString("Price for '%1'") - .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); + data["name"] = QString("Price for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq()); data["type"] = "double"; data["units"] = ""; } else if (_source.startsWith("quotes/percpricechg")) { data["min"] = -100.0; data["max"] = 100.0; - data["name"] = QString("Price changes for '%1'") + data["name"] + = QString("Price changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq()); + data["type"] = "double"; + data["units"] = ""; + } else if (_source.startsWith("quotes/volumechg")) { + data["min"] = 0; + data["max"] = 0; + data["name"] = QString("Absolute volume changes for '%1'") .arg(m_extQuotes->itemByTagNumber(ind)->uniq()); + data["type"] = "int"; + data["units"] = ""; + } else if (_source.startsWith("quotes/volume")) { + data["min"] = 0; + data["max"] = 0; + data["name"] = QString("Volume for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq()); + data["type"] = "int"; + data["units"] = ""; + } else if (_source.startsWith("quotes/percvolumechg")) { + data["min"] = -100.0; + data["max"] = 100.0; + data["name"] + = QString("Volume changes for '%1'").arg(m_extQuotes->itemByTagNumber(ind)->uniq()); data["type"] = "double"; data["units"] = ""; } @@ -142,15 +119,12 @@ QStringList QuotesSource::getSources() { QStringList sources; for (auto &item : m_extQuotes->activeItems()) { - sources.append(QString("quotes/%1").arg(item->tag("ask"))); - sources.append(QString("quotes/%1").arg(item->tag("askchg"))); - sources.append(QString("quotes/%1").arg(item->tag("percaskchg"))); - sources.append(QString("quotes/%1").arg(item->tag("bid"))); - sources.append(QString("quotes/%1").arg(item->tag("bidchg"))); - sources.append(QString("quotes/%1").arg(item->tag("percbidchg"))); sources.append(QString("quotes/%1").arg(item->tag("price"))); sources.append(QString("quotes/%1").arg(item->tag("pricechg"))); sources.append(QString("quotes/%1").arg(item->tag("percpricechg"))); + sources.append(QString("quotes/%1").arg(item->tag("volume"))); + sources.append(QString("quotes/%1").arg(item->tag("volumechg"))); + sources.append(QString("quotes/%1").arg(item->tag("percvolumechg"))); } return sources; diff --git a/sources/extsysmonsources/requestsource.cpp b/sources/extsysmonsources/requestsource.cpp index 6ac889b..4e85008 100644 --- a/sources/extsysmonsources/requestsource.cpp +++ b/sources/extsysmonsources/requestsource.cpp @@ -28,8 +28,7 @@ RequestSource::RequestSource(QObject *_parent, const QStringList &_args) Q_ASSERT(_args.count() == 0); qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - m_extNetRequest - = new ExtItemAggregator(nullptr, "requests"); + m_extNetRequest = new ExtItemAggregator(nullptr, "requests"); m_extNetRequest->initSockets(); m_sources = getSources(); } @@ -67,8 +66,8 @@ QVariantMap RequestSource::initialData(const QString &_source) const if (_source.startsWith("network/response")) { data["min"] = ""; data["max"] = ""; - data["name"] = QString("Network response for %1") - .arg(m_extNetRequest->itemByTagNumber(ind)->uniq()); + data["name"] + = QString("Network response for %1").arg(m_extNetRequest->itemByTagNumber(ind)->uniq()); data["type"] = "QString"; data["units"] = ""; } diff --git a/sources/extsysmonsources/upgradesource.cpp b/sources/extsysmonsources/upgradesource.cpp index 1968e24..1ece01f 100644 --- a/sources/extsysmonsources/upgradesource.cpp +++ b/sources/extsysmonsources/upgradesource.cpp @@ -45,10 +45,7 @@ QVariant UpgradeSource::data(const QString &_source) qCDebug(LOG_ESS) << "Source" << _source; // there are only one value - return m_extUpgrade->itemByTagNumber(index(_source)) - ->run() - .values() - .first(); + return m_extUpgrade->itemByTagNumber(index(_source))->run().values().first(); } @@ -59,9 +56,8 @@ QVariantMap UpgradeSource::initialData(const QString &_source) const QVariantMap data; data["min"] = ""; data["max"] = ""; - data["name"] - = QString("Package manager '%1' metadata") - .arg(m_extUpgrade->itemByTagNumber(index(_source))->uniq()); + data["name"] = QString("Package manager '%1' metadata") + .arg(m_extUpgrade->itemByTagNumber(index(_source))->uniq()); data["type"] = "QString"; data["units"] = ""; diff --git a/sources/extsysmonsources/weathersource.cpp b/sources/extsysmonsources/weathersource.cpp index 576a285..6973ca1 100644 --- a/sources/extsysmonsources/weathersource.cpp +++ b/sources/extsysmonsources/weathersource.cpp @@ -73,15 +73,14 @@ QVariantMap WeatherSource::initialData(const QString &_source) const } else if (_source.startsWith("weather/weather")) { data["min"] = ""; data["max"] = ""; - data["name"] = QString("ID string map for '%1'") - .arg(m_extWeather->itemByTagNumber(ind)->uniq()); + data["name"] + = QString("ID string map for '%1'").arg(m_extWeather->itemByTagNumber(ind)->uniq()); data["type"] = "QString"; data["units"] = ""; } else if (_source.startsWith("weather/humidity")) { data["min"] = 0; data["max"] = 100; - data["name"] = QString("Humidity for '%1'") - .arg(m_extWeather->itemByTagNumber(ind)->uniq()); + data["name"] = QString("Humidity for '%1'").arg(m_extWeather->itemByTagNumber(ind)->uniq()); data["type"] = "integer"; data["units"] = "%"; } else if (_source.startsWith("weather/pressure")) { @@ -94,15 +93,15 @@ QVariantMap WeatherSource::initialData(const QString &_source) const } else if (_source.startsWith("weather/temperature")) { data["min"] = 0.0; data["max"] = 0.0; - data["name"] = QString("Temperature for '%1'") - .arg(m_extWeather->itemByTagNumber(ind)->uniq()); + data["name"] + = QString("Temperature for '%1'").arg(m_extWeather->itemByTagNumber(ind)->uniq()); data["type"] = "float"; data["units"] = "°C"; } else if (_source.startsWith("weather/timestamp")) { data["min"] = ""; data["max"] = ""; - data["name"] = QString("Timestamp for '%1'") - .arg(m_extWeather->itemByTagNumber(ind)->uniq()); + data["name"] + = QString("Timestamp for '%1'").arg(m_extWeather->itemByTagNumber(ind)->uniq()); data["type"] = "QString"; data["units"] = ""; } diff --git a/sources/qml/General.qml b/sources/qml/General.qml index 690e716..c96ede0 100644 --- a/sources/qml/General.qml +++ b/sources/qml/General.qml @@ -88,7 +88,7 @@ QtObject { }, { "label": i18n("Quotes"), - "regexp": "^(perc)?(ask|bid|price)(chg)?.*" + "regexp": "^(perc)?(price|volume)(chg)?.*" }, { "label": i18n("Upgrades"), diff --git a/sources/test/awtestlibrary.cpp b/sources/test/awtestlibrary.cpp index 4ba9ce2..ec6ddda 100644 --- a/sources/test/awtestlibrary.cpp +++ b/sources/test/awtestlibrary.cpp @@ -59,11 +59,11 @@ double AWTestLibrary::randomDouble() QPair AWTestLibrary::randomFilenames() { - QString fileName = QString("%1/").arg( - QStandardPaths::writableLocation(QStandardPaths::TempLocation)); - QString writeFileName = QString("%1/awesomewidgets/tmp/") - .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + QString fileName + = QString("%1/").arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); + QString writeFileName + = QString("%1/awesomewidgets/tmp/") + .arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); QString name = randomString(1, 20); fileName += name; diff --git a/sources/test/testabstractformatter.cpp b/sources/test/testabstractformatter.cpp index ac356f3..78cc30d 100644 --- a/sources/test/testabstractformatter.cpp +++ b/sources/test/testabstractformatter.cpp @@ -37,9 +37,7 @@ void TestAbstractFormatter::cleanupTestCase() } -void TestAbstractFormatter::test_values() -{ -} +void TestAbstractFormatter::test_values() {} void TestAbstractFormatter::test_type() diff --git a/sources/test/testawbugreporter.cpp b/sources/test/testawbugreporter.cpp index d57d88e..ed18109 100644 --- a/sources/test/testawbugreporter.cpp +++ b/sources/test/testawbugreporter.cpp @@ -40,8 +40,7 @@ void TestAWBugReporter::cleanupTestCase() void TestAWBugReporter::test_generateText() { data = AWTestLibrary::randomStringList(4); - QString output - = plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3)); + QString output = plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3)); for (auto &string : data) QVERIFY(output.contains(string)); @@ -51,9 +50,8 @@ void TestAWBugReporter::test_generateText() void TestAWBugReporter::test_sendBugReport() { QSignalSpy spy(plugin, SIGNAL(replyReceived(int, QString &))); - plugin->sendBugReport( - AWTestLibrary::randomString(), - plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3))); + plugin->sendBugReport(AWTestLibrary::randomString(), + plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3))); QVERIFY(spy.wait(5000)); QVariantList arguments = spy.takeFirst(); diff --git a/sources/test/testawconfighelper.cpp b/sources/test/testawconfighelper.cpp index 79ee180..18b7c56 100644 --- a/sources/test/testawconfighelper.cpp +++ b/sources/test/testawconfighelper.cpp @@ -56,8 +56,7 @@ 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/testawkeycache.cpp b/sources/test/testawkeycache.cpp index 2be9b0e..22c3cfc 100644 --- a/sources/test/testawkeycache.cpp +++ b/sources/test/testawkeycache.cpp @@ -30,9 +30,7 @@ void TestAWKeyCache::initTestCase() } -void TestAWKeyCache::cleanupTestCase() -{ -} +void TestAWKeyCache::cleanupTestCase() {} QTEST_MAIN(TestAWKeyCache); diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index 13c55b8..5551ddf 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -175,16 +175,15 @@ void TestAWKeys::test_dbus() QDBusConnection bus = QDBusConnection::sessionBus(); // check if there is active sessions first - QDBusMessage sessions = QDBusMessage::createMethodCall( - AWDBUS_SERVICE, AWDBUS_PATH, AWDBUS_SERVICE, "ActiveServicess"); + QDBusMessage sessions = QDBusMessage::createMethodCall(AWDBUS_SERVICE, AWDBUS_PATH, + AWDBUS_SERVICE, "ActiveServicess"); QDBusMessage sessionsResponse = bus.call(sessions, QDBus::BlockWithGui); if (sessionsResponse.arguments().isEmpty()) QSKIP("No active sessions found, skip DBus tests"); // dbus checks QDBusMessage request = QDBusMessage::createMethodCall( - QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id), AWDBUS_PATH, - AWDBUS_SERVICE, "WhoAmI"); + QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id), AWDBUS_PATH, AWDBUS_SERVICE, "WhoAmI"); // send message to dbus QDBusMessage response = bus.call(request, QDBus::BlockWithGui); diff --git a/sources/test/testawpatternfunctions.cpp b/sources/test/testawpatternfunctions.cpp index a57e457..8247996 100644 --- a/sources/test/testawpatternfunctions.cpp +++ b/sources/test/testawpatternfunctions.cpp @@ -30,9 +30,7 @@ void TestAWPatternFunctions::initTestCase() } -void TestAWPatternFunctions::cleanupTestCase() -{ -} +void TestAWPatternFunctions::cleanupTestCase() {} void TestAWPatternFunctions::test_findFunctionCalls() @@ -40,11 +38,9 @@ void TestAWPatternFunctions::test_findFunctionCalls() QString name = QString("aw_%1").arg(AWTestLibrary::randomString(1, 10)); QString code = AWTestLibrary::randomString(1, 20); QStringList args = AWTestLibrary::randomStringList(20); - QString function - = QString("$%1<%2>{{%3}}").arg(name).arg(args.join(',')).arg(code); + QString function = QString("$%1<%2>{{%3}}").arg(name).arg(args.join(',')).arg(code); - QString pattern = AWTestLibrary::randomString() + function - + AWTestLibrary::randomString(); + QString pattern = AWTestLibrary::randomString() + function + AWTestLibrary::randomString(); QList found = AWPatternFunctions::findFunctionCalls(name, pattern); @@ -69,10 +65,8 @@ void TestAWPatternFunctions::test_findKeys() auto keys = AWTestLibrary::randomSelect(allKeys); auto bars = AWTestLibrary::randomSelect(allKeys); - std::for_each(bars.begin(), bars.end(), - [](QString &bar) { bar.prepend("bar"); }); - QString pattern - = QString("$%1 $%2").arg(keys.join(" $")).arg(bars.join(" $")); + std::for_each(bars.begin(), bars.end(), [](QString &bar) { bar.prepend("bar"); }); + QString pattern = QString("$%1 $%2").arg(keys.join(" $")).arg(bars.join(" $")); allKeys.append(bars); allKeys.sort(); @@ -80,11 +74,9 @@ void TestAWPatternFunctions::test_findKeys() keys.sort(); bars.sort(); - QStringList foundKeys - = AWPatternFunctions::findKeys(pattern, allKeys, false); + QStringList foundKeys = AWPatternFunctions::findKeys(pattern, allKeys, false); foundKeys.sort(); - QStringList foundBars - = AWPatternFunctions::findKeys(pattern, allKeys, true); + QStringList foundBars = AWPatternFunctions::findKeys(pattern, allKeys, true); foundBars.sort(); QCOMPARE(foundKeys, keys); @@ -95,8 +87,7 @@ void TestAWPatternFunctions::test_findKeys() void TestAWPatternFunctions::test_findLambdas() { QStringList lambdas = AWTestLibrary::randomStringList(20); - QString pattern = AWTestLibrary::randomString() - + QString("${{%1}}").arg(lambdas.join("}}${{")) + QString pattern = AWTestLibrary::randomString() + QString("${{%1}}").arg(lambdas.join("}}${{")) + AWTestLibrary::randomString(); QCOMPARE(AWPatternFunctions::findLambdas(pattern), lambdas); @@ -108,13 +99,11 @@ 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 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)); + QCOMPARE(AWPatternFunctions::expandTemplates(pattern), QString("%1%2").arg(prefix).arg(result)); } diff --git a/sources/test/testbatterysource.cpp b/sources/test/testbatterysource.cpp index 843d986..2ad11ad 100644 --- a/sources/test/testbatterysource.cpp +++ b/sources/test/testbatterysource.cpp @@ -49,15 +49,13 @@ void TestBatterySource::test_battery() QSKIP("No battery found, test will be skipped"); QStringList batteries = source->sources(); - std::for_each(batteries.begin(), batteries.end(), - [this](const QString bat) { - QVariant value = source->data(bat); - if (bat == "battery/ac") - QCOMPARE(value.type(), QVariant::Bool); - else - QVERIFY((value.toFloat() >= battery.first) - && (value.toFloat() <= battery.second)); - }); + std::for_each(batteries.begin(), batteries.end(), [this](const QString bat) { + QVariant value = source->data(bat); + if (bat == "battery/ac") + QCOMPARE(value.type(), QVariant::Bool); + else + QVERIFY((value.toFloat() >= battery.first) && (value.toFloat() <= battery.second)); + }); } diff --git a/sources/test/testdatetimeformatter.cpp b/sources/test/testdatetimeformatter.cpp index 57dfa3a..501d6a7 100644 --- a/sources/test/testdatetimeformatter.cpp +++ b/sources/test/testdatetimeformatter.cpp @@ -28,8 +28,7 @@ void TestAWDateTimeFormatter::initTestCase() { AWTestLibrary::init(); - format - = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(',')).join(' '); + format = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(',')).join(' '); formatter = new AWDateTimeFormatter(nullptr); formatter->setFormat(format); diff --git a/sources/test/testextquotes.cpp b/sources/test/testextquotes.cpp index 10a8df1..e400609 100644 --- a/sources/test/testextquotes.cpp +++ b/sources/test/testextquotes.cpp @@ -64,8 +64,8 @@ void TestExtQuotes::test_run() for (auto &type : types) { QCOMPARE(firstValue[extQuotes->tag(type)].toDouble(), 0.0); - QVERIFY((cache[type].toDouble() > price.first) - && (cache[type].toDouble() < price.second)); + QVERIFY((cache[type].toDouble() >= price.first) + && (cache[type].toDouble() <= price.second)); } } @@ -84,9 +84,7 @@ void TestExtQuotes::test_derivatives() values[type] = arguments.at(0).toHash()[extQuotes->tag(type)]; for (auto &type : types) { - QCOMPARE(arguments.at(0) - .toHash()[extQuotes->tag(QString("%1chg").arg(type))] - .toDouble(), + QCOMPARE(arguments.at(0).toHash()[extQuotes->tag(QString("%1chg").arg(type))].toDouble(), (values[type].toDouble() - cache[type].toDouble())); } } diff --git a/sources/test/testextquotes.h b/sources/test/testextquotes.h index df5c16d..5997d0d 100644 --- a/sources/test/testextquotes.h +++ b/sources/test/testextquotes.h @@ -42,12 +42,10 @@ private slots: private: ExtQuotes *extQuotes = nullptr; QVariantHash cache; - QString ticker = "EURUSD=X"; - QStringList types = QStringList() << "ask" - << "bid" - << "price"; + QString ticker = "EURUSD"; + QStringList types = {"price", "volume"}; // we assume that price will not be differ more than in 2 times - QPair price = QPair(0.5, 2.0); + QPair price = QPair(0.0, 2.0); }; diff --git a/sources/test/testextupgrade.cpp b/sources/test/testextupgrade.cpp index 7e35e7a..129c1b3 100644 --- a/sources/test/testextupgrade.cpp +++ b/sources/test/testextupgrade.cpp @@ -64,8 +64,7 @@ void TestExtUpgrade::test_run() QList arguments = spy.takeFirst(); QCOMPARE(firstValue[extUpgrade->tag("pkgcount")].toInt(), 0); - QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), - randomStrings.count()); + QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), randomStrings.count()); } @@ -95,8 +94,7 @@ void TestExtUpgrade::test_filter() // check values QVERIFY(spy.wait(5000)); QList arguments = spy.takeFirst(); - QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), - filters.count()); + QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), filters.count()); } diff --git a/sources/test/testextweather.cpp b/sources/test/testextweather.cpp index 869704a..531f068 100644 --- a/sources/test/testextweather.cpp +++ b/sources/test/testextweather.cpp @@ -88,8 +88,7 @@ void TestExtWeather::test_image() // check values QVERIFY(spy.wait(5000)); QVariantHash arguments = spy.takeFirst().at(0).toHash(); - QVERIFY( - arguments[extWeather->tag("weather")].toString().startsWith("tag("weather")].toString().startsWith("tag("weatherId")].toInt(), 0); - QVERIFY( - (arguments[extWeather->tag("humidity")].toInt() >= humidity.first) - && (arguments[extWeather->tag("humidity")].toInt() <= humidity.second)); - QVERIFY( - (arguments[extWeather->tag("pressure")].toInt() > pressure.first) - && (arguments[extWeather->tag("pressure")].toInt() < pressure.second)); - QVERIFY( - (arguments[extWeather->tag("temperature")].toFloat() > temp.first) - && (arguments[extWeather->tag("temperature")].toFloat() < temp.second)); + QVERIFY((arguments[extWeather->tag("humidity")].toInt() >= humidity.first) + && (arguments[extWeather->tag("humidity")].toInt() <= humidity.second)); + QVERIFY((arguments[extWeather->tag("pressure")].toInt() > pressure.first) + && (arguments[extWeather->tag("pressure")].toInt() < pressure.second)); + QVERIFY((arguments[extWeather->tag("temperature")].toFloat() > temp.first) + && (arguments[extWeather->tag("temperature")].toFloat() < temp.second)); // image should be only one symbol here if (extWeather->jsonMapFile().isEmpty()) QSKIP("No json map found for weather, skip image test"); diff --git a/sources/test/testfloatformatter.cpp b/sources/test/testfloatformatter.cpp index 2e4a855..b1c90b4 100644 --- a/sources/test/testfloatformatter.cpp +++ b/sources/test/testfloatformatter.cpp @@ -37,9 +37,7 @@ void TestAWFloatFormatter::cleanupTestCase() } -void TestAWFloatFormatter::test_values() -{ -} +void TestAWFloatFormatter::test_values() {} void TestAWFloatFormatter::test_count() @@ -140,8 +138,7 @@ void TestAWFloatFormatter::test_multiplier() // test double value = AWTestLibrary::randomDouble(); - QCOMPARE(formatter->convert(value), - QString::number(value * multiplier, 'f', 6)); + QCOMPARE(formatter->convert(value), QString::number(value * multiplier, 'f', 6)); // reset formatter->setMultiplier(1.0); @@ -157,8 +154,7 @@ void TestAWFloatFormatter::test_summand() // test double value = AWTestLibrary::randomDouble(); - QCOMPARE(formatter->convert(value), - QString::number(value + summand, 'f', 6)); + QCOMPARE(formatter->convert(value), QString::number(value + summand, 'f', 6)); // reset formatter->setSummand(1.0); diff --git a/sources/test/testhddtempsource.cpp b/sources/test/testhddtempsource.cpp index 6c6e34e..bc51f58 100644 --- a/sources/test/testhddtempsource.cpp +++ b/sources/test/testhddtempsource.cpp @@ -30,10 +30,10 @@ void TestHDDTemperatureSource::initTestCase() devices = HDDTemperatureSource::allHdd(); QVERIFY(devices.count() > 0); - hddtempSource = new HDDTemperatureSource( - this, QStringList() << devices.join(',') << hddtempCmd); - smartctlSource = new HDDTemperatureSource( - this, QStringList() << devices.join(',') << smartctlCmd); + hddtempSource + = new HDDTemperatureSource(this, QStringList() << devices.join(',') << hddtempCmd); + smartctlSource + = new HDDTemperatureSource(this, QStringList() << devices.join(',') << smartctlCmd); } @@ -57,8 +57,7 @@ void TestHDDTemperatureSource::test_sources() void TestHDDTemperatureSource::test_hddtemp() { std::for_each(devices.begin(), devices.end(), [this](QString device) { - QSignalSpy spy(hddtempSource, - SIGNAL(dataReceived(const QVariantHash &))); + QSignalSpy spy(hddtempSource, SIGNAL(dataReceived(const QVariantHash &))); float firstValue = hddtempSource->data(device).toFloat(); QVERIFY(spy.wait(5000)); @@ -75,8 +74,7 @@ void TestHDDTemperatureSource::test_hddtemp() void TestHDDTemperatureSource::test_smartctl() { std::for_each(devices.begin(), devices.end(), [this](QString &device) { - QSignalSpy spy(smartctlSource, - SIGNAL(dataReceived(const QVariantHash &))); + QSignalSpy spy(smartctlSource, SIGNAL(dataReceived(const QVariantHash &))); float firstValue = smartctlSource->data(device).toFloat(); QVERIFY(spy.wait(5000)); diff --git a/sources/test/testlistformatter.cpp b/sources/test/testlistformatter.cpp index 353624c..bbc4f1a 100644 --- a/sources/test/testlistformatter.cpp +++ b/sources/test/testlistformatter.cpp @@ -73,8 +73,7 @@ void TestAWListFormatter::test_filter() value.sort(); formatter->setFilter(QString("(^%1$)").arg(filters.join("$|^"))); - QCOMPARE(formatter->convert(value).split(separator).count(), - filters.count()); + QCOMPARE(formatter->convert(value).split(separator).count(), filters.count()); } diff --git a/sources/test/testnoformatter.cpp b/sources/test/testnoformatter.cpp index 1f005da..cb9023a 100644 --- a/sources/test/testnoformatter.cpp +++ b/sources/test/testnoformatter.cpp @@ -37,9 +37,7 @@ void TestAWNoFormatter::cleanupTestCase() } -void TestAWNoFormatter::test_values() -{ -} +void TestAWNoFormatter::test_values() {} void TestAWNoFormatter::test_conversion() diff --git a/sources/test/testplayersource.cpp b/sources/test/testplayersource.cpp index b4e5b6b..6472546 100644 --- a/sources/test/testplayersource.cpp +++ b/sources/test/testplayersource.cpp @@ -30,9 +30,7 @@ void TestPlayerSource::initTestCase() } -void TestPlayerSource::cleanupTestCase() -{ -} +void TestPlayerSource::cleanupTestCase() {} void TestPlayerSource::_test_sources(const PlayerSource *_source) @@ -57,8 +55,7 @@ void TestPlayerSource::test_buildString() void TestPlayerSource::test_stripString() { - QString str - = PlayerSource::buildString("", AWTestLibrary::randomString(1, 40), 20); + QString str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 40), 20); QCOMPARE(str.count(), 20); str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 10), 20); @@ -68,9 +65,8 @@ void TestPlayerSource::test_stripString() void TestPlayerSource::test_autoMpris() { - QStringList args(QStringList() - << "mpris" << mpdAddress << QString::number(mpdPort) - << "auto" << QString::number(10)); + QStringList args(QStringList() << "mpris" << mpdAddress << QString::number(mpdPort) << "auto" + << QString::number(10)); PlayerSource *source = new PlayerSource(this, args); bool empty = source->getAutoMpris().isEmpty(); @@ -83,9 +79,8 @@ void TestPlayerSource::test_autoMpris() void TestPlayerSource::test_mpd() { - QStringList args(QStringList() - << "mpd" << mpdAddress << QString::number(mpdPort) - << "auto" << QString::number(10)); + QStringList args(QStringList() << "mpd" << mpdAddress << QString::number(mpdPort) << "auto" + << QString::number(10)); PlayerSource *source = new PlayerSource(this, args); _test_sources(source); @@ -104,16 +99,14 @@ void TestPlayerSource::test_mpd() if (secondValue["player/title"].toString() == "unknown") QSKIP("No mpd found"); - QVERIFY(secondValue["player/progress"].toInt() - < secondValue["player/duration"].toInt()); + QVERIFY(secondValue["player/progress"].toInt() < secondValue["player/duration"].toInt()); } void TestPlayerSource::test_mpris() { - QStringList args(QStringList() - << "mpris" << mpdAddress << QString::number(mpdPort) - << "auto" << QString::number(10)); + QStringList args(QStringList() << "mpris" << mpdAddress << QString::number(mpdPort) << "auto" + << QString::number(10)); PlayerSource *source = new PlayerSource(this, args); _test_sources(source); diff --git a/sources/test/teststringformatter.cpp b/sources/test/teststringformatter.cpp index 62bcb5d..85ec061 100644 --- a/sources/test/teststringformatter.cpp +++ b/sources/test/teststringformatter.cpp @@ -37,9 +37,7 @@ void TestAWStringFormatter::cleanupTestCase() } -void TestAWStringFormatter::test_values() -{ -} +void TestAWStringFormatter::test_values() {} void TestAWStringFormatter::test_count() diff --git a/sources/version.h.in b/sources/version.h.in index ad4b040..8cdb0a3 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -17,17 +17,16 @@ const char TRDPARTY_LICENSE[] = "QReplyTimeout " "wrapper,no,http://" "codereview.stackexchange.com/questions/30031/" "qnetworkreply-network-reply-timeout-helper"; -const char SPECIAL_THANKS[] - = "Yahoo! Finance,https://finance.yahoo.com/;Yahoo! " - "Weather,https://weather.yahoo.com/;JetBrains,https://www.jetbrains.com/" - ";OpenWeatherMap,http://openweathermap.org/"; +const char SPECIAL_THANKS[] = "Stooq,https://stooq.com/;Yahoo! " + "Weather,https://weather.yahoo.com/;JetBrains,https://" + "www.jetbrains.com/;OpenWeatherMap,http://openweathermap.org/"; const char CHANGELOG[] = "@PROJECT_CHANGELOG@"; // configuraion // graphical items api version const int AW_GRAPHITEM_API = 6; // extquotes api version -const int AW_EXTQUOTES_API = 4; +const int AW_EXTQUOTES_API = 5; // extscript api version const int AW_EXTSCRIPT_API = 5; // extupgrade api version @@ -48,8 +47,7 @@ const char AWDBUS_PATH[] = "/awesomewidgets"; // network requests timeout, ms const int REQUEST_TIMEOUT = 3000; // available time keys -const char TIME_KEYS[] - = "d,dd,ddd,dddd,M,MM,MMM,MMMM,yy,yyyy,h,hh,H,HH,m,mm,s,ss,t,a,ap,A,AP"; +const char TIME_KEYS[] = "d,dd,ddd,dddd,M,MM,MMM,MMMM,yy,yyyy,h,hh,H,HH,m,mm,s,ss,t,a,ap,A,AP"; // static keys const char STATIC_FUNCTIONS[] = "{{\n\n}},template{{\n\n}},aw_all<>{{}},aw_" "count<>{{}},aw_keys<>{{}},aw_macro<>{{}},aw_" @@ -69,19 +67,13 @@ const char STATIC_KEYS[] // links const char HOMEPAGE[] = "https://arcanis.me/projects/awesome-widgets"; const char REPOSITORY[] = "https://github.com/arcan1s/awesome-widgets"; -const char RELEASES[] - = "https://github.com/arcan1s/awesome-widgets/releases/tag/V."; -const char VERSION_API[] - = "https://api.github.com/repos/arcan1s/awesome-widgets/releases"; +const char RELEASES[] = "https://github.com/arcan1s/awesome-widgets/releases/tag/V."; +const char VERSION_API[] = "https://api.github.com/repos/arcan1s/awesome-widgets/releases"; const char BUGTRACKER[] = "https://github.com/arcan1s/awesome-widgets/issues"; -const char BUGTRACKER_API[] - = "https://arcanis.me/repos/arcan1s/awesome-widgets/issues"; -const char TRANSLATION[] - = "https://github.com/arcan1s/awesome-widgets/issues/14"; -const char AUR_PACKAGES[] - = "https://aur.archlinux.org/packages/plasma5-applet-awesome-widgets/"; -const char OPENSUSE_PACKAGES[] - = "http://software.opensuse.org/package/plasma5-awesome-widgets"; +const char BUGTRACKER_API[] = "https://arcanis.me/repos/arcan1s/awesome-widgets/issues"; +const char TRANSLATION[] = "https://github.com/arcan1s/awesome-widgets/issues/14"; +const char AUR_PACKAGES[] = "https://aur.archlinux.org/packages/plasma5-applet-awesome-widgets/"; +const char OPENSUSE_PACKAGES[] = "http://software.opensuse.org/package/plasma5-awesome-widgets"; // build information const char BUILD_DATE[] = "@CURRENT_DATE@"; From 423eabd857f4ac91375ffcbc8c155078c208351f Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 04:29:23 +0300 Subject: [PATCH 05/35] fix battery tests --- sources/extsysmonsources/batterysource.cpp | 28 ++++++++++++---------- sources/test/testbatterysource.cpp | 9 ++++--- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp index 4e9423f..7472db2 100644 --- a/sources/extsysmonsources/batterysource.cpp +++ b/sources/extsysmonsources/batterysource.cpp @@ -52,18 +52,22 @@ QStringList BatterySource::getSources() sources.append("battery/batrate"); sources.append("battery/battotal"); - m_batteriesCount - = QDir(m_acpiPath) - .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) - .count(); - qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount; + auto directory = QDir(m_acpiPath); - for (int i = 0; i < m_batteriesCount; i++) { - sources.append(QString("battery/bat%1").arg(i)); - sources.append(QString("battery/batleft%1").arg(i)); - sources.append(QString("battery/batnow%1").arg(i)); - sources.append(QString("battery/batrate%1").arg(i)); - sources.append(QString("battery/battotal%1").arg(i)); + if (directory.exists()) { + m_batteriesCount + = directory + .entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) + .count(); + qCInfo(LOG_ESS) << "Init batteries count as" << m_batteriesCount; + + for (int i = 0; i < m_batteriesCount; i++) { + sources.append(QString("battery/bat%1").arg(i)); + sources.append(QString("battery/batleft%1").arg(i)); + sources.append(QString("battery/batnow%1").arg(i)); + sources.append(QString("battery/batrate%1").arg(i)); + sources.append(QString("battery/battotal%1").arg(i)); + } } qCInfo(LOG_ESS) << "Sources list" << sources; @@ -123,7 +127,7 @@ QVariantMap BatterySource::initialData(const QString &_source) const data["name"] = "Full battery capacity"; data["type"] = "integer"; data["units"] = ""; - } else if (_source == "battery/batleft") { + } else if (_source.startsWith("battery/batleft")) { data["min"] = 0; data["max"] = 0; data["name"] = QString("Battery %1 discharge time").arg(index(_source)); diff --git a/sources/test/testbatterysource.cpp b/sources/test/testbatterysource.cpp index 2ad11ad..893a00d 100644 --- a/sources/test/testbatterysource.cpp +++ b/sources/test/testbatterysource.cpp @@ -20,6 +20,8 @@ #include +#include + #include "awtestlibrary.h" #include "batterysource.h" @@ -39,13 +41,14 @@ void TestBatterySource::cleanupTestCase() void TestBatterySource::test_sources() { - QVERIFY(source->sources().count() >= 2); + // + QVERIFY(source->sources().count() >= 6); } void TestBatterySource::test_battery() { - if (source->sources().count() == 2) + if (source->sources().count() == 6) QSKIP("No battery found, test will be skipped"); QStringList batteries = source->sources(); @@ -54,7 +57,7 @@ void TestBatterySource::test_battery() if (bat == "battery/ac") QCOMPARE(value.type(), QVariant::Bool); else - QVERIFY((value.toFloat() >= battery.first) && (value.toFloat() <= battery.second)); + QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat()))); }); } From ce30d90a23a5e51256514ba0f6fea4e383ef342f Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 05:07:50 +0300 Subject: [PATCH 06/35] fix hddtemp tests --- sources/test/testhddtempsource.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sources/test/testhddtempsource.cpp b/sources/test/testhddtempsource.cpp index bc51f58..225ba14 100644 --- a/sources/test/testhddtempsource.cpp +++ b/sources/test/testhddtempsource.cpp @@ -28,7 +28,6 @@ void TestHDDTemperatureSource::initTestCase() { AWTestLibrary::init(); devices = HDDTemperatureSource::allHdd(); - QVERIFY(devices.count() > 0); hddtempSource = new HDDTemperatureSource(this, QStringList() << devices.join(',') << hddtempCmd); @@ -46,6 +45,9 @@ void TestHDDTemperatureSource::cleanupTestCase() void TestHDDTemperatureSource::test_sources() { + if (devices.isEmpty()) + QSKIP("No hdd devices found, test will be skipped"); + std::for_each(devices.begin(), devices.end(), [](QString &device) { device.prepend("hdd/temperature"); }); @@ -56,6 +58,9 @@ void TestHDDTemperatureSource::test_sources() void TestHDDTemperatureSource::test_hddtemp() { + if (devices.isEmpty()) + QSKIP("No hdd devices found, test will be skipped"); + std::for_each(devices.begin(), devices.end(), [this](QString device) { QSignalSpy spy(hddtempSource, SIGNAL(dataReceived(const QVariantHash &))); float firstValue = hddtempSource->data(device).toFloat(); @@ -73,6 +78,9 @@ void TestHDDTemperatureSource::test_hddtemp() void TestHDDTemperatureSource::test_smartctl() { + if (devices.isEmpty()) + QSKIP("No hdd devices found, test will be skipped"); + std::for_each(devices.begin(), devices.end(), [this](QString &device) { QSignalSpy spy(smartctlSource, SIGNAL(dataReceived(const QVariantHash &))); float firstValue = smartctlSource->data(device).toFloat(); From 4bba061d669465ab3683d902d5d645a8c6c75560 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 06:24:41 +0300 Subject: [PATCH 07/35] fix lambda related code --- sources/awesome-widget/plugin/awpatternfunctions.cpp | 2 +- sources/awesomewidgets/graphicalitem.cpp | 6 +++--- sources/test/testawkeys.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index c7feea7..1658705 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -28,7 +28,7 @@ QString AWPatternFunctions::expandLambdas(QString _code, AWKeysAggregator *_aggr const QVariantHash &_metadata, const QStringList &_usedKeys) { - qCDebug(LOG_AW) << "Expand lamdas in" << _code; + qCDebug(LOG_AW) << "Expand lambdas in" << _code; QJSEngine engine; // apply $this values diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 5709fa0..28ca2e1 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -397,11 +397,11 @@ void GraphicalItem::setUsedKeys(const QStringList &_usedKeys) // remove dubs // HACK converting to set may break order - usedKeys().clear(); + m_usedKeys.clear(); for (auto &key : _usedKeys) { - if (usedKeys().contains(key)) + if (m_usedKeys.contains(key)) continue; - usedKeys().append(key); + m_usedKeys.append(key); } } diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index 5551ddf..3f47ce0 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -176,7 +176,7 @@ void TestAWKeys::test_dbus() // check if there is active sessions first QDBusMessage sessions = QDBusMessage::createMethodCall(AWDBUS_SERVICE, AWDBUS_PATH, - AWDBUS_SERVICE, "ActiveServicess"); + AWDBUS_SERVICE, "ActiveServices"); QDBusMessage sessionsResponse = bus.call(sessions, QDBus::BlockWithGui); if (sessionsResponse.arguments().isEmpty()) QSKIP("No active sessions found, skip DBus tests"); From b30bd35add909244a5d884362cd75b8896c78b08 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 16:44:43 +0300 Subject: [PATCH 08/35] remove hdddevices test --- sources/test/testawkeys.cpp | 6 ------ sources/test/testawkeys.h | 1 - 2 files changed, 7 deletions(-) diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index 3f47ce0..eba6ed8 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -74,12 +74,6 @@ void TestAWKeys::cleanupTestCase() } -void TestAWKeys::test_hddDevices() -{ - QVERIFY(plugin->getHddDevices().count() > 2); -} - - void TestAWKeys::test_dictKeys() { QStringList keys = plugin->dictKeys(); diff --git a/sources/test/testawkeys.h b/sources/test/testawkeys.h index 7a6c730..f8dfc7f 100644 --- a/sources/test/testawkeys.h +++ b/sources/test/testawkeys.h @@ -33,7 +33,6 @@ private slots: void initTestCase(); void cleanupTestCase(); // test - void test_hddDevices(); void test_dictKeys(); void test_pattern(); void test_tooltip(); From 3b412396720e3cf72af206589e12c18fe299c694 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 16:57:58 +0300 Subject: [PATCH 09/35] fix hddevices test --- sources/test/testawkeys.cpp | 6 ++++++ sources/test/testawkeys.h | 1 + 2 files changed, 7 insertions(+) diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index eba6ed8..bbd80a2 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -74,6 +74,12 @@ void TestAWKeys::cleanupTestCase() } +void TestAWKeys::test_hddDevices() +{ + QVERIFY(plugin->getHddDevices().count() >= 2); +} + + void TestAWKeys::test_dictKeys() { QStringList keys = plugin->dictKeys(); diff --git a/sources/test/testawkeys.h b/sources/test/testawkeys.h index f8dfc7f..7a6c730 100644 --- a/sources/test/testawkeys.h +++ b/sources/test/testawkeys.h @@ -33,6 +33,7 @@ private slots: void initTestCase(); void cleanupTestCase(); // test + void test_hddDevices(); void test_dictKeys(); void test_pattern(); void test_tooltip(); From 13edbc5eb1dd5bff783783b812dfcd4d1f33e987 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 17:53:37 +0300 Subject: [PATCH 10/35] docker iteration v10 --- .travis.yml | 35 ++++++++++------------------------- .travis.yml.bckp | 13 ------------- 2 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 .travis.yml.bckp diff --git a/.travis.yml b/.travis.yml index f3292aa..010ac22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,13 @@ sudo: required -arch: - packages: - - plasma-framework - # build deps - - cmake - - extra-cmake-modules - - python - # test - - xorg-server-xvfb - # additional targets - - clang - - cppcheck - script: - - export DISPLAY=:99.0 - - git clone https://github.com/arcan1s/awesome-widgets/ - - cd awesome-widgets; git submodule update --init --recursive - - mkdir awesome-widgets/build - - cd awesome-widgets/build; cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_BUILD_TYPE=Optimization -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_FUTURE=ON -DBUILD_TESTING=ON ../sources - - cd awesome-widgets/build; make - - cd awesome-widgets/build; make cppcheck - - cd awesome-widgets/build; make clangformat && ( [ `git status -s | wc -l` -eq 0 ] || exit 1 ) - - cd awesome-widgets/build; xvfb-run make test - - sleep 3 +env: + - DOCKER_TAG="arcan1s/awesome-widgets-arch" -script: - - "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash" +services: + - docker + +before_install: + - docker build --tag="${DOCKER_TAG}" -f ".docker/Dockerfile-arch" ".docker" + +scirpt: + - docker run --rm -v "$(pwd):/opt/build" -w /opt/build "${DOCKER_TAG}" ".docker/build-arch.sh" diff --git a/.travis.yml.bckp b/.travis.yml.bckp deleted file mode 100644 index dad2148..0000000 --- a/.travis.yml.bckp +++ /dev/null @@ -1,13 +0,0 @@ -sudo: required - -env: - - DOCKER_TAG="arcan1s/awesome-widgets" - -services: - - docker - -before_install: - - docker build --tag="${DOCKER_TAG}" .docker - -scirpt: - - docker run "${DOCKER_TAG}" .docker/build.sh From 5bd95fe41a9e2d7bb134773ff7226a3f884a8b80 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 18:01:56 +0300 Subject: [PATCH 11/35] simplify docker --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 010ac22..d512205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ before_install: - docker build --tag="${DOCKER_TAG}" -f ".docker/Dockerfile-arch" ".docker" scirpt: - - docker run --rm -v "$(pwd):/opt/build" -w /opt/build "${DOCKER_TAG}" ".docker/build-arch.sh" + - docker run "${DOCKER_TAG}" ".docker/build-arch.sh" From 5807d4d75e0a5d64f6f46ff51596a7b17fc10154 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 18:08:17 +0300 Subject: [PATCH 12/35] use language? --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d512205..6ce2ce7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ sudo: required +language: cpp env: - DOCKER_TAG="arcan1s/awesome-widgets-arch" From ed21e3fb1855d05a58c23f7cb5a5c3dc9dd11324 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 19:29:28 +0300 Subject: [PATCH 13/35] lang: generic --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ce2ce7..77c7221 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: required -language: cpp +language: generic env: - DOCKER_TAG="arcan1s/awesome-widgets-arch" From fee70b73852fcec6e6d03e59152ed0a606043689 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 21:13:12 +0300 Subject: [PATCH 14/35] fix typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 77c7221..006955c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,5 @@ services: before_install: - docker build --tag="${DOCKER_TAG}" -f ".docker/Dockerfile-arch" ".docker" -scirpt: +script: - docker run "${DOCKER_TAG}" ".docker/build-arch.sh" From 935fa04757483146238f9f4903a2eb162b75025c Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 21:20:55 +0300 Subject: [PATCH 15/35] some travis debug --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 006955c..f7396c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,8 @@ before_install: - docker build --tag="${DOCKER_TAG}" -f ".docker/Dockerfile-arch" ".docker" script: + - pwd + - ls -l + - ls -l .docker || true + - ls .docker/build-arch.sh || true - docker run "${DOCKER_TAG}" ".docker/build-arch.sh" From ffb66586d31a85c03dee1a2b46f8f3e13801dfd1 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 21:27:00 +0300 Subject: [PATCH 16/35] some docker changes --- .travis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f7396c0..c2bbf85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,17 +2,13 @@ sudo: required language: generic env: - - DOCKER_TAG="arcan1s/awesome-widgets-arch" + - DOCKER_TAG_ARCH=arcan1s/awesome-widgets-arch services: - docker before_install: - - docker build --tag="${DOCKER_TAG}" -f ".docker/Dockerfile-arch" ".docker" + - docker build --tag=${DOCKER_TAG_ARCH} -f .docker/Dockerfile-arch .docker script: - - pwd - - ls -l - - ls -l .docker || true - - ls .docker/build-arch.sh || true - - docker run "${DOCKER_TAG}" ".docker/build-arch.sh" + - docker run ${DOCKER_TAG_ARCH} sh -c .docker/build-arch.sh From c4c37406a56afdfcaad8852fa2327e5cab7f35f6 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 21:32:21 +0300 Subject: [PATCH 17/35] some docker changes (2) --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c2bbf85..e047b4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,13 @@ sudo: required language: generic env: - - DOCKER_TAG_ARCH=arcan1s/awesome-widgets-arch + - DOCKER_TAG_ARCH="arcan1s/awesome-widgets-arch" services: - docker before_install: - - docker build --tag=${DOCKER_TAG_ARCH} -f .docker/Dockerfile-arch .docker + - docker build --tag="${DOCKER_TAG_ARCH}" -f ".docker/Dockerfile-arch" ".docker" script: - - docker run ${DOCKER_TAG_ARCH} sh -c .docker/build-arch.sh + - docker run --rm -v "$(pwd):/opt/build" -w /opt/build "${DOCKER_TAG}" sh -c ".docker/build-arch.sh" From 308b721c87638b69c1405ae8b518024ae25439f6 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 17 Dec 2017 21:39:03 +0300 Subject: [PATCH 18/35] some docker changes (3) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e047b4a..80fdc9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,4 @@ before_install: - docker build --tag="${DOCKER_TAG_ARCH}" -f ".docker/Dockerfile-arch" ".docker" script: - - docker run --rm -v "$(pwd):/opt/build" -w /opt/build "${DOCKER_TAG}" sh -c ".docker/build-arch.sh" + - docker run --rm -v "$(pwd):/opt/build" -w /opt/build "${DOCKER_TAG_ARCH}" sh -c ".docker/build-arch.sh" From c2a18f8845462e01f39a64c141327a542050e478 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Mon, 17 Sep 2018 16:43:01 +0300 Subject: [PATCH 19/35] add git build instruction --- .docker/build-arch.sh | 2 +- .docker/build-ubuntu.sh | 2 +- README.md | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.docker/build-arch.sh b/.docker/build-arch.sh index 950ae21..5308d77 100755 --- a/.docker/build-arch.sh +++ b/.docker/build-arch.sh @@ -11,4 +11,4 @@ cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_BUILD_TYPE=Optimization -DCMAKE_ make # tests -xvfb-run make test +xvfb-run -a make test diff --git a/.docker/build-ubuntu.sh b/.docker/build-ubuntu.sh index 9ec2661..68ec9f8 100755 --- a/.docker/build-ubuntu.sh +++ b/.docker/build-ubuntu.sh @@ -15,4 +15,4 @@ cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_BUILD_TYPE=Optimization -DCMAKE_ make # tests -xvfb-run make test +xvfb-run -a make test diff --git a/README.md b/README.md index 242ac79..5b5feaa 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ Installation **NOTE** on Plasma 5 it very likely requires `-DKDE_INSTALL_USE_QT_SYS_PATHS=ON` flag + **NOTE** if you are going to build from git, you need to init submodules first, e.g.: + + git submodule update --init --recursive + Additional information ====================== From 9f46a17b9811b34ae92ae204cf42d34abc2a313e Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Fri, 26 Oct 2018 02:33:46 +0200 Subject: [PATCH 20/35] Add italian translation (#136) --- sources/translations/it.po | 775 +++++++++++++++++++++++++++++++++++++ 1 file changed, 775 insertions(+) create mode 100644 sources/translations/it.po diff --git a/sources/translations/it.po b/sources/translations/it.po new file mode 100644 index 0000000..5716d28 --- /dev/null +++ b/sources/translations/it.po @@ -0,0 +1,775 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" +"POT-Creation-Date: 2017-05-05 18:15+0300\n" +"PO-Revision-Date: 2018-10-02 11:37+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.1.1\n" +"Last-Translator: Antonio Vivace \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: it\n" + +msgid "Version %1 (build date %2)" +msgstr "Versione %1 (data build %2)" + +msgid "A set of minimalistic plasmoid widgets" +msgstr "Un insieme di widgets minimalistici per Plasma" + +msgid "Links:" +msgstr "Links:" + +msgid "Homepage" +msgstr "Sito web" + +msgid "Repository" +msgstr "Repository" + +msgid "Bugtracker" +msgstr "Bugtracker" + +msgid "Translation issue" +msgstr "Problema di traduzione" + +msgid "AUR packages" +msgstr "Pacchetti Aur" + +msgid "openSUSE packages" +msgstr "pacchetti openSUSE" + +msgid "This software is licensed under %1" +msgstr "Questo software è rilasciato sotto licenza %1" + +msgid "Translators:" +msgstr "Traduttori:" + +msgid "This software uses:" +msgstr "Questo software utilizza:" + +msgid "Special thanks to:" +msgstr "Ringraziamenti speciali a:" + +msgid "Widget" +msgstr "Widget" + +msgid "Advanced" +msgstr "Avanzate" + +msgid "Tooltip" +msgstr "Suggerimento" + +msgid "Appearance" +msgstr "Apparenza" + +msgid "DataEngine" +msgstr "DataEngine" + +msgid "About" +msgstr "Info" + +msgid "Enable background" +msgstr "Abilita sfondo" + +msgid "Translate strings" +msgstr "Traduci stringe" + +msgid "Wrap new lines" +msgstr "Manda a capo nuove righe" + +msgid "Enable word wrap" +msgstr "Manda a capo parole" + +msgid "Enable notifications" +msgstr "Abilita notifiche" + +msgid "Check updates on startup" +msgstr "Controlla aggiornamenti all'avvio" + +msgid "Optimize subscription" +msgstr "Ottimizza sottoscrizione" + +msgid "Widget height, px" +msgstr "Altezza del widget, in px" + +msgid "Widget width, px" +msgstr "Larghezza del widget, in px" + +msgid "Time interval" +msgstr "Intervallo di tempo" + +msgid "Messages queue limit" +msgstr "Limite coda messaggi" + +msgid "Celsius" +msgstr "Celsius" + +msgid "Fahrenheit" +msgstr "Fahrenheit" + +msgid "Kelvin" +msgstr "Kelvin" + +msgid "Reaumur" +msgstr "Reaumur" + +msgid "cm^-1" +msgstr "cm^-1" + +msgid "kJ/mol" +msgstr "kJ/mol" + +msgid "kcal/mol" +msgstr "kcal/mol" + +msgid "Temperature units" +msgstr "Unità di temperatura" + +msgid "Custom time format" +msgstr "Formato orario personalizzato" + +msgid "Custom uptime format" +msgstr "Formato tempo di attività personalizzato" + +msgid "AC online tag" +msgstr "Tag alimentazione attiva" + +msgid "AC offline tag" +msgstr "Tag alimentazione disattiva" + +msgid "Actions" +msgstr "Azioni" + +msgid "Drop key cache" +msgstr "Pulisci cache chiavi" + +msgid "Export configuration" +msgstr "Esporta configurazione" + +msgid "Import configuration" +msgstr "Importa configurazione" + +msgid "Telemetry" +msgstr "Telemetria" + +msgid "Enable remote telemetry" +msgstr "Abilita telemetria remota" + +msgid "History count" +msgstr "Conteggio cronologia" + +msgid "Telemetry ID" +msgstr "ID Telemetria" + +msgid "Font" +msgstr "Font" + +msgid "Font size" +msgstr "Dimensioni font" + +msgid "Font weight" +msgstr "Spessore font" + +msgid "Font style" +msgstr "Stile font" + +msgid "Font color" +msgstr "Colore font" + +msgid "Style" +msgstr "Stile" + +msgid "Style color" +msgstr "Colore stile" + +msgid "ACPI" +msgstr "ACPI" + +msgid "ACPI path" +msgstr "Path ACPI" + +msgid "GPU" +msgstr "GPU" + +msgid "GPU device" +msgstr "Dispositivo GPU" + +msgid "HDD temperature" +msgstr "Temperatura HDD" + +msgid "HDD" +msgstr "HDD" + +msgid "hddtemp cmd" +msgstr "comando temperatura HDD" + +msgid "Player" +msgstr "Riproduttore" + +msgid "Player data symbols" +msgstr "Simboli riproduttore" + +msgid "Music player" +msgstr "Riproduttore musicale" + +msgid "MPRIS player name" +msgstr "Nome riproduttore MPRIS" + +msgid "MPD address" +msgstr "Indirizzo MPD" + +msgid "MPD port" +msgstr "Porta MPD" + +msgid "Extensions" +msgstr "Estensioni" + +msgid "Custom scripts" +msgstr "Script personalizzati" + +msgid "Network requests" +msgstr "Richieste di rete" + +msgid "Package manager" +msgstr "Gestore pacchetti" + +msgid "Quotes monitor" +msgstr "Monitor quote" + +msgid "Weather" +msgstr "Previsioni del tempo" + +msgid "Select tag" +msgstr "Tag selezione" + +msgid "Tag: %1" +msgstr "Tag: %1" + +msgid "Value: %1" +msgstr "Valore: %1" + +msgid "Info: %1" +msgstr "Info: %1" + +msgid "Request key" +msgstr "Chiave richiesta" + +msgid "Show README" +msgstr "Mostra LEGGIMI" + +msgid "Check updates" +msgstr "Controlla aggiornamenti" + +msgid "Report bug" +msgstr "Segnala problema" + +msgid "" +"CPU, CPU clock, memory, swap and network labels support graphical tooltip. " +"To enable them just make needed checkbox checked." +msgstr "" +"Le etichette GPU, CPU clock, memoria, swap e rete supportano i tooltip. " +"Per abilitarli, clicca sulle checkbox." + +msgid "Number of values for tooltips" +msgstr "Numero di valori per tooltip" + +msgid "Background" +msgstr "Sfondo" + +msgid "Background color" +msgstr "Colore sfondo" + +msgid "CPU" +msgstr "CPU" + +msgid "CPU color" +msgstr "Colore CPU" + +msgid "CPU clock" +msgstr "Velocità CPU" + +msgid "CPU clock color" +msgstr "Colore velocità CPU" + +msgid "Memory" +msgstr "Memoria" + +msgid "Memory color" +msgstr "Colore memoria" + +msgid "Swap" +msgstr "Swap" + +msgid "Swap color" +msgstr "Colore Swap" + +msgid "Network" +msgstr "Rete" + +msgid "Download speed color" +msgstr "Colore velocità di download" + +msgid "Upload speed color" +msgstr "Colore velocità di upload" + +msgid "Battery" +msgstr "Batteria" + +msgid "Battery active color" +msgstr "Colore batteria attiva" + +msgid "Battery inactive color" +msgstr "Colore batteria disattiva" + +msgid "Run %1" +msgstr "Esegui %1" + +msgid "Not supported" +msgstr "Non supportato" + +msgid "You are using mammoth's Qt version, try to update it first" +msgstr "Stai usando una versione di Qt antiquata, prova ad aggiornarla" + +msgid "Select font" +msgstr "Seleziona font" + +msgid "Issue created" +msgstr "Segnalazione aperta" + +msgid "Issue %1 has been created" +msgstr "La segnalazione %1 è stata aperta" + +msgid "AC online" +msgstr "Alimentatore attivo" + +msgid "AC offline" +msgstr "Alimentatore disattivo" + +msgid "High CPU load" +msgstr "Alto carico sulla CPU" + +msgid "High memory usage" +msgstr "Alto consumo di memoria" + +msgid "Swap is used" +msgstr "Swap in uso" + +msgid "High GPU load" +msgstr "Alto carico della GPU" + +msgid "Network device has been changed to %1" +msgstr "Il dispositivo di rete è stato cambiato in %1" + +msgid "Edit" +msgstr "Modifica" + +msgid "Select type" +msgstr "Seleziona tipo" + +msgid "Type:" +msgstr "Tipo:" + +msgid "MB/s" +msgstr "MB/s" + +msgid "KB/s" +msgstr "KB/s" + +msgid "Changelog of %1" +msgstr "Lista cambiamenti di %1" + +msgid "You are using the actual version %1" +msgstr "Stai usando la versione attuale %1" + +msgid "No new version found" +msgstr "Nessuna nuova versione trovata" + +msgid "Current version : %1" +msgstr "Versione attuale: %1" + +msgid "New version : %1" +msgstr "Nuova versione: %1" + +msgid "Click \"Ok\" to download" +msgstr "Clicca \"Ok\" per scaricare" + +msgid "There are updates" +msgstr "Ci sono aggiornamenti" + +msgid "Copy" +msgstr "Copia" + +msgid "Create" +msgstr "Crea" + +msgid "Remove" +msgstr "Rimuovi" + +msgid "Enter file name" +msgstr "Inserisci nome del file" + +msgid "File name" +msgstr "Nome del file" + +msgid "Name: %1" +msgstr "Nome: %1" + +msgid "Comment: %1" +msgstr "Commento: %1" + +msgid "Identity: %1" +msgstr "Identità: %1" + +msgid "Name" +msgstr "Nome" + +msgid "Comment" +msgstr "Commento" + +msgid "Type" +msgstr "Tipo" + +msgid "Format" +msgstr "Formato" + +msgid "Precision" +msgstr "Precisione" + +msgid "Width" +msgstr "Larghezza" + +msgid "Fill char" +msgstr "Carattere di riempimento" + +msgid "Force width" +msgstr "Forza larghezza" + +msgid "Multiplier" +msgstr "Moltiplicatore" + +msgid "Summand" +msgstr "Summand" + +msgid "Path" +msgstr "Path" + +msgid "Filter" +msgstr "Filtro" + +msgid "Separator" +msgstr "Separatore" + +msgid "Sort" +msgstr "Ordina" + +msgid "Append code" +msgstr "Aggiungi codice" + +msgid "Has return" +msgstr "Ha ritorno" + +msgid "Code" +msgstr "Codice" + +msgid "Tag" +msgstr "Tag" + +msgid "URL" +msgstr "URL" + +msgid "Active" +msgstr "Attivo" + +msgid "Schedule" +msgstr "Programma" + +msgid "Socket" +msgstr "Socket" + +msgid "Interval" +msgstr "Intervallo" + +msgid "" +"

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

    " +msgstr "" +"

    Usa YAHOO! finance ticker per ottere quote sullo " +"strumento. Vedi http://finance.yahoo.com/

    " + +msgid "Ticker" +msgstr "Ticker" + +msgid "Command" +msgstr "Comando" + +msgid "Prefix" +msgstr "Prefisso" + +msgid "Redirect" +msgstr "Redireziona" + +msgid "Additional filters" +msgstr "Filtri aggiuntivi" + +msgid "Wrap colors" +msgstr "Manda a capo colori" + +msgid "Wrap spaces" +msgstr "Manda a capo spazi" + +msgid "Null" +msgstr "Vuoto" + +msgid "Provider" +msgstr "Provider" + +msgid "City" +msgstr "Città" + +msgid "Country" +msgstr "Paese" + +msgid "Timestamp" +msgstr "Time stamp" + +msgid "Use images" +msgstr "Usa immagini" + +msgid "Select color" +msgstr "Seleziona colore" + +msgid "Select path" +msgstr "Seleziona path" + +msgid "Images (*.png *.bpm *.jpg);;All files (*.*)" +msgstr "Immagini (*.png *.bpm *.jpg);;Tutti i file (*.*)" + +msgid "Use custom formula" +msgstr "Usa formula personalizzata" + +msgid "Value" +msgstr "Valora" + +msgid "Max value" +msgstr "Valore massimo" + +msgid "Min value" +msgstr "Valore minimo" + +msgid "Active filling type" +msgstr "Tipo di riempimento attivo" + +msgid "Inctive filling type" +msgstr "Tipo di riempimento disattivo" + +msgid "Points count" +msgstr "Numero punti" + +msgid "Direction" +msgstr "Direzione" + +msgid "Height" +msgstr "Altezza" + +msgid "color" +msgstr "colore" + +msgid "image" +msgstr "immagine" + +msgid "Active desktop" +msgstr "Desktop attivo" + +msgid "Inactive desktop" +msgstr "Desktop disattivo" + +msgid "Vertical layout" +msgstr "Layout verticale" + +msgid "Mark" +msgstr "Mark" + +msgid "contours" +msgstr "contorni" + +msgid "windows" +msgstr "finestre" + +msgid "clean desktop" +msgstr "pulisci desktop" + +msgid "names" +msgstr "nomi" + +msgid "none" +msgstr "nessuno" + +msgid "Tooltip type" +msgstr "Tipo tooltip" + +msgid "Tooltip width" +msgstr "Larghezza tooltip" + +msgid "Edit bars" +msgstr "Modifica barre" + +msgid "Formatters" +msgstr "Formattatori" + +msgid "Preview" +msgstr "Anteprima" + +msgid "" +"Detailed information may be found on project homepage" +msgstr "" +"Informazioni dettagliate sul sito web del progetto" + +msgid "Add" +msgstr "Aggiungi" + +msgid "Show value" +msgstr "Mostra valore" + +msgid "Acknowledgment" +msgstr "Riconoscimenti" + +msgid "Report a bug" +msgstr "Segnala problema" + +msgid "Report subject" +msgstr "Segnala" + +msgid "Description" +msgstr "Descrizione" + +msgid "Steps to reproduce" +msgstr "Azioni per riprodurre" + +msgid "Expected result" +msgstr "Risultato aspettato" + +msgid "Logs" +msgstr "Logs" + +msgid "Use command" +msgstr "Usa comando" + +msgid "Load log file" +msgstr "Carica file di log" + +msgid "Open log file" +msgstr "Apri file di log" + +msgid "Select a color" +msgstr "Seleziona colore" + +msgid "Export" +msgstr "Esporta" + +msgid "Success" +msgstr "Successo" + +msgid "Please note that binary files were not copied" +msgstr "I file binari non sono stati copiati" + +msgid "Ooops..." +msgstr "Ooops..." + +msgid "Could not save configuration file" +msgstr "Impossibile salvare file di configurazione" + +msgid "Select a font" +msgstr "Seleziona font" + +msgid "Bgcolor" +msgstr "Colore di sfondo" + +msgid "Import" +msgstr "Importa" + +msgid "Import plasmoid settings" +msgstr "Importa impostazioni plasmoide" + +msgid "Import extensions" +msgstr "Importa estensioni" + +msgid "Import additional files" +msgstr "Importa file addizionali" + +msgid "AC" +msgstr "AC" + +msgid "Bars" +msgstr "Barre" + +msgid "Desktops" +msgstr "Desktop" + +msgid "Scripts" +msgstr "Script" + +msgid "Time" +msgstr "Orario" + +msgid "Quotes" +msgstr "Quote" + +msgid "Upgrades" +msgstr "Aggiornamenti" + +msgid "Weathers" +msgstr "Previsioni del tempo" + +msgid "Functions" +msgstr "Funzioni" + +msgid "All" +msgstr "Tutto" + +msgid "normal" +msgstr "normale" + +msgid "italic" +msgstr "corsivo" + +msgid "light" +msgstr "sottile" + +msgid "demi bold" +msgstr "semi grassetto" + +msgid "bold" +msgstr "grassetto" + +msgid "black" +msgstr "grassetto spesso" + +msgid "outline" +msgstr "contorni" + +msgid "raised" +msgstr "sollevato" + +msgid "sunken" +msgstr "affondato" + +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "Antonio Vivace" + +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "avivace4@gmail.com" From c05a87a540052d74335979d4c952f653233b7007 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 7 Dec 2019 11:47:45 +0300 Subject: [PATCH 21/35] add notes about dependencies --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b5feaa..0df934f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ Make dependencies * cmake * extra-cmake-modules +In addition some distros might require to install some -dev packages, e.g. the list of required packages for deb-based distros can be found [here](https://github.com/arcan1s/awesome-widgets/blob/development/.docker/Dockerfile-ubuntu-amd64#L7). + Installation ------------ @@ -53,7 +55,7 @@ Installation * install mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../ + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../sources make && sudo make install **NOTE** on Plasma 5 it very likely requires `-DKDE_INSTALL_USE_QT_SYS_PATHS=ON` flag From 276248a748b1b1f5356cf6e07139d836c3270cf2 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 14 Dec 2019 23:54:15 +0300 Subject: [PATCH 22/35] system source, some code improvements --- .gitignore | 1 + .vscode/temp.sql | 0 sources/.clang-format | 7 +- sources/.kdev4/awesomewidgets.kdev4 | 26 --- sources/.kdev4/sources.kdev4 | 23 --- .../3rdparty/qreplytimeout/qreplytimeout.cpp | 2 +- sources/CMakeLists.txt | 2 +- sources/awdebug.cpp | 4 +- sources/awdebug.h | 2 +- sources/awesome-widget/metadata.desktop | 1 - .../awesome-widget/package/metadata.desktop | 1 - .../plugin/awabstractpairconfig.cpp | 12 +- .../plugin/awabstractpairconfig.h | 8 +- .../plugin/awabstractpairhelper.cpp | 7 +- .../plugin/awabstractpairhelper.h | 2 +- .../plugin/awabstractselector.h | 2 +- sources/awesome-widget/plugin/awactions.cpp | 16 +- sources/awesome-widget/plugin/awactions.h | 16 +- .../awesome-widget/plugin/awbugreporter.cpp | 10 +- sources/awesome-widget/plugin/awbugreporter.h | 6 +- .../awesome-widget/plugin/awconfighelper.cpp | 20 +- .../awesome-widget/plugin/awconfighelper.h | 16 +- .../plugin/awcustomkeysconfig.h | 2 +- .../plugin/awcustomkeyshelper.h | 8 +- .../plugin/awdataaggregator.cpp | 11 +- .../awesome-widget/plugin/awdataaggregator.h | 9 +- .../plugin/awdataengineaggregator.cpp | 16 +- .../plugin/awdataengineaggregator.h | 2 +- .../plugin/awdataenginemapper.h | 2 +- sources/awesome-widget/plugin/awdbusadaptor.h | 2 +- sources/awesome-widget/plugin/awesomewidget.h | 2 +- .../awesome-widget/plugin/awformatterconfig.h | 2 +- .../plugin/awformatterhelper.cpp | 2 +- .../awesome-widget/plugin/awformatterhelper.h | 16 +- sources/awesome-widget/plugin/awkeycache.cpp | 1 + sources/awesome-widget/plugin/awkeycache.h | 2 +- .../awesome-widget/plugin/awkeyoperations.h | 2 +- sources/awesome-widget/plugin/awkeys.cpp | 7 +- sources/awesome-widget/plugin/awkeys.h | 4 +- .../plugin/awkeysaggregator.cpp | 2 +- .../awesome-widget/plugin/awkeysaggregator.h | 2 +- .../plugin/awpairconfigfactory.cpp | 4 +- .../plugin/awpairconfigfactory.h | 6 +- .../plugin/awpatternfunctions.cpp | 7 +- .../plugin/awpatternfunctions.h | 2 +- .../plugin/awtelemetryhandler.cpp | 6 +- .../plugin/awtelemetryhandler.h | 4 +- .../awesome-widget/plugin/awupdatehelper.cpp | 12 +- .../awesome-widget/plugin/awupdatehelper.h | 8 +- sources/awesomewidgets/abstractextitem.cpp | 4 +- sources/awesomewidgets/abstractextitem.h | 2 +- .../abstractextitemaggregator.cpp | 17 +- .../abstractextitemaggregator.h | 8 +- .../awesomewidgets/abstractquotesprovider.h | 4 +- .../awesomewidgets/abstractweatherprovider.h | 4 +- .../awesomewidgets/awabstractformatter.cpp | 2 +- sources/awesomewidgets/awabstractformatter.h | 12 +- .../awesomewidgets/awdatetimeformatter.cpp | 3 +- sources/awesomewidgets/awdatetimeformatter.h | 14 +- sources/awesomewidgets/awfloatformatter.cpp | 2 +- sources/awesomewidgets/awfloatformatter.h | 14 +- sources/awesomewidgets/awjsonformatter.cpp | 6 +- sources/awesomewidgets/awjsonformatter.h | 18 +- sources/awesomewidgets/awlistformatter.cpp | 2 +- sources/awesomewidgets/awlistformatter.h | 14 +- sources/awesomewidgets/awnoformatter.cpp | 2 +- sources/awesomewidgets/awnoformatter.h | 10 +- sources/awesomewidgets/awscriptformatter.cpp | 2 +- sources/awesomewidgets/awscriptformatter.h | 14 +- sources/awesomewidgets/awstringformatter.cpp | 2 +- sources/awesomewidgets/awstringformatter.h | 14 +- sources/awesomewidgets/extitemaggregator.h | 8 +- sources/awesomewidgets/extnetworkrequest.cpp | 2 +- sources/awesomewidgets/extnetworkrequest.h | 16 +- sources/awesomewidgets/extquotes.cpp | 3 +- sources/awesomewidgets/extquotes.h | 16 +- sources/awesomewidgets/extscript.cpp | 6 +- sources/awesomewidgets/extscript.h | 18 +- sources/awesomewidgets/extupgrade.cpp | 4 +- sources/awesomewidgets/extupgrade.h | 16 +- sources/awesomewidgets/extweather.cpp | 8 +- sources/awesomewidgets/extweather.h | 18 +- sources/awesomewidgets/graphicalitem.cpp | 6 +- sources/awesomewidgets/graphicalitem.h | 16 +- .../awesomewidgets/graphicalitemhelper.cpp | 10 +- sources/awesomewidgets/graphicalitemhelper.h | 8 +- sources/awesomewidgets/owmweatherprovider.h | 8 +- sources/awesomewidgets/qcronscheduler.cpp | 2 +- sources/awesomewidgets/qcronscheduler.h | 4 +- sources/awesomewidgets/stooqquotesprovider.h | 8 +- .../awesomewidgets/yahooquotesprovider.cpp | 2 +- sources/awesomewidgets/yahooquotesprovider.h | 8 +- sources/awesomewidgets/yahooweatherprovider.h | 8 +- sources/desktop-panel/metadata.desktop | 1 - .../desktop-panel/package/metadata.desktop | 1 - sources/desktop-panel/plugin/desktoppanel.h | 2 +- sources/desktop-panel/plugin/dpadds.cpp | 28 +-- sources/desktop-panel/plugin/dpadds.h | 20 +- sources/extsysmon/extsysmon.h | 8 +- sources/extsysmon/extsysmonaggregator.cpp | 5 + sources/extsysmon/extsysmonaggregator.h | 2 +- .../abstractextsysmonsource.h | 4 +- sources/extsysmonsources/batterysource.h | 12 +- sources/extsysmonsources/customsource.h | 10 +- sources/extsysmonsources/desktopsource.h | 10 +- sources/extsysmonsources/gpuloadsource.cpp | 5 +- sources/extsysmonsources/gpuloadsource.h | 10 +- sources/extsysmonsources/gputempsource.cpp | 5 +- sources/extsysmonsources/gputempsource.h | 10 +- sources/extsysmonsources/hddtempsource.cpp | 5 +- sources/extsysmonsources/hddtempsource.h | 10 +- sources/extsysmonsources/loadsource.h | 10 +- sources/extsysmonsources/networksource.cpp | 78 ++++++-- sources/extsysmonsources/networksource.h | 20 +- sources/extsysmonsources/playersource.cpp | 14 +- sources/extsysmonsources/playersource.h | 14 +- sources/extsysmonsources/processessource.h | 10 +- sources/extsysmonsources/quotessource.h | 10 +- sources/extsysmonsources/requestsource.h | 10 +- sources/extsysmonsources/systeminfosource.cpp | 174 ++++++++++++++++++ sources/extsysmonsources/systeminfosource.h | 50 +++++ sources/extsysmonsources/upgradesource.h | 10 +- sources/extsysmonsources/weathersource.h | 10 +- sources/qml/General.qml | 6 +- sources/test/awtestlibrary.h | 2 +- sources/test/testabstractformatter.h | 2 +- sources/test/testawkeycache.h | 2 +- sources/test/testawpatternfunctions.h | 2 +- sources/test/testfloatformatter.h | 2 +- sources/test/testnoformatter.h | 2 +- sources/test/testplayersource.h | 2 +- sources/test/teststringformatter.h | 2 +- sources/version.h.in | 2 +- 133 files changed, 748 insertions(+), 526 deletions(-) delete mode 100644 .vscode/temp.sql delete mode 100644 sources/.kdev4/awesomewidgets.kdev4 delete mode 100644 sources/.kdev4/sources.kdev4 create mode 100644 sources/extsysmonsources/systeminfosource.cpp create mode 100644 sources/extsysmonsources/systeminfosource.h diff --git a/.gitignore b/.gitignore index 9a0d19c..9684c5e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ pkg # clion settings .idea +cmake-build* diff --git a/.vscode/temp.sql b/.vscode/temp.sql deleted file mode 100644 index e69de29..0000000 diff --git a/sources/.clang-format b/sources/.clang-format index a3de373..05d985c 100644 --- a/sources/.clang-format +++ b/sources/.clang-format @@ -1,20 +1,19 @@ --- Language: Cpp AccessModifierOffset: -4 -AlignAfterOpenBracket: true +AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false -AlignEscapedNewlinesLeft: false AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false +AlwaysBreakTemplateDeclarations: No BinPackArguments: true BinPackParameters: true BreakBeforeBinaryOperators: All diff --git a/sources/.kdev4/awesomewidgets.kdev4 b/sources/.kdev4/awesomewidgets.kdev4 deleted file mode 100644 index 5da78b6..0000000 --- a/sources/.kdev4/awesomewidgets.kdev4 +++ /dev/null @@ -1,26 +0,0 @@ -[Buildset] -BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s) - -[CMake] -Build Directory Count=1 -Current Build Directory Index=0 -ProjectRootRelative=./ - -[CMake][CMake Build Directory 0] -Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build -Build Type=Optimization -CMake Binary=file:///usr/bin/cmake -Environment Profile= -Extra Arguments= -Install Directory=file:///usr - -[Defines And Includes][Compiler] -Name=GCC -Path=gcc -Type=GCC - -[Launch] -Launch Configurations= - -[Project] -VersionControlSupport=kdevgit diff --git a/sources/.kdev4/sources.kdev4 b/sources/.kdev4/sources.kdev4 deleted file mode 100644 index ea73c1d..0000000 --- a/sources/.kdev4/sources.kdev4 +++ /dev/null @@ -1,23 +0,0 @@ -[Buildset] -BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s) - -[CMake] -Build Directory Count=1 -Current Build Directory Index=0 -ProjectRootRelative=./ - -[CMake][CMake Build Directory 0] -Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build -Build Type=Release -CMake Binary=file:///usr/bin/cmake -Environment Profile= -Extra Arguments= -Install Directory=file:///usr - -[Defines And Includes][Compiler] -Name=GCC -Path=gcc -Type=GCC - -[Project] -VersionControlSupport=kdevgit diff --git a/sources/3rdparty/qreplytimeout/qreplytimeout.cpp b/sources/3rdparty/qreplytimeout/qreplytimeout.cpp index eb3c4ad..ee500bd 100644 --- a/sources/3rdparty/qreplytimeout/qreplytimeout.cpp +++ b/sources/3rdparty/qreplytimeout/qreplytimeout.cpp @@ -12,7 +12,7 @@ QReplyTimeout::QReplyTimeout(QNetworkReply *reply, const int timeout) void QReplyTimeout::timeout() { - QNetworkReply *reply = static_cast(parent()); + auto *reply = dynamic_cast(parent()); if (reply->isRunning()) reply->close(); } diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index d5b6fe4..4dd30a1 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.8.12) cmake_policy(SET CMP0011 NEW) cmake_policy(SET CMP0015 NEW) if (POLICY CMP0063) - cmake_policy(SET CMP0063 OLD) + cmake_policy(SET CMP0063 NEW) endif () if (POLICY CMP0071) cmake_policy(SET CMP0071 NEW) diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index 852b18d..2046e6a 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -35,7 +35,7 @@ QString AWDebug::getAboutText(const QString &_type) if (_type == "header") { text = NAME; } else if (_type == "version") { - text = i18n("Version %1 (build date %2)", VERSION, BUILD_DATE); + text = i18np("Version %1 (build date %2)", VERSION, BUILD_DATE); if (!QString(COMMIT_SHA).isEmpty()) text += QString(" (%1)").arg(COMMIT_SHA); } else if (_type == "description") { @@ -60,7 +60,7 @@ QString AWDebug::getAboutText(const QString &_type) .arg(DATE) .arg(EMAIL) .arg(AUTHOR) - + i18n("This software is licensed under %1", LICENSE) + ""; + + i18nc("This software is licensed under %1", LICENSE) + ""; } else if (_type == "translators") { QStringList translatorList = QString(TRANSLATORS).split(','); for (auto &translator : translatorList) diff --git a/sources/awdebug.h b/sources/awdebug.h index 8447c65..a43db77 100644 --- a/sources/awdebug.h +++ b/sources/awdebug.h @@ -33,7 +33,7 @@ const char LOG_FORMAT[] = "[%{time " QString getAboutText(const QString &_type); QStringList getBuildData(); -} +} // namespace AWDebug Q_DECLARE_LOGGING_CATEGORY(LOG_AW) diff --git a/sources/awesome-widget/metadata.desktop b/sources/awesome-widget/metadata.desktop index 52f21e6..09fd0c1 100644 --- a/sources/awesome-widget/metadata.desktop +++ b/sources/awesome-widget/metadata.desktop @@ -15,7 +15,6 @@ Icon=utilities-system-monitor X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com diff --git a/sources/awesome-widget/package/metadata.desktop b/sources/awesome-widget/package/metadata.desktop index 7a33208..22a5b57 100644 --- a/sources/awesome-widget/package/metadata.desktop +++ b/sources/awesome-widget/package/metadata.desktop @@ -15,7 +15,6 @@ Icon=utilities-system-monitor X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.cpp b/sources/awesome-widget/plugin/awabstractpairconfig.cpp index 2b378cf..f18fb98 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.cpp +++ b/sources/awesome-widget/plugin/awabstractpairconfig.cpp @@ -21,17 +21,17 @@ #include #include +#include #include "awabstractselector.h" #include "awdebug.h" -AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit, - const QStringList &_keys) +AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit, QStringList _keys) : QDialog(_parent) , ui(new Ui::AWAbstractPairConfig) , m_hasEdit(_hasEdit) - , m_keys(_keys) + , m_keys(std::move(_keys)) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; @@ -84,8 +84,8 @@ void AWAbstractPairConfig::edit() void AWAbstractPairConfig::updateUi() { - QPair current = static_cast(sender())->current(); - int index = m_selectors.indexOf(static_cast(sender())); + QPair current = dynamic_cast(sender())->current(); + int index = m_selectors.indexOf(dynamic_cast(sender())); if ((current.first.isEmpty()) && (current.second.isEmpty())) { // remove current selector if it is empty and does not last @@ -110,7 +110,7 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values << "and current ones" << _current; - AWAbstractSelector *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable); + auto *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable); selector->init(_keys, _values, _current); ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, selector); connect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi())); diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.h b/sources/awesome-widget/plugin/awabstractpairconfig.h index 2834ee6..579b865 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.h +++ b/sources/awesome-widget/plugin/awabstractpairconfig.h @@ -36,12 +36,12 @@ class AWAbstractPairConfig : public QDialog public: explicit AWAbstractPairConfig(QWidget *_parent = nullptr, const bool _hasEdit = false, - const QStringList &_keys = QStringList()); - virtual ~AWAbstractPairConfig(); + QStringList _keys = QStringList()); + ~AWAbstractPairConfig() override; template void initHelper() { - if (m_helper) - delete m_helper; + + delete m_helper; m_helper = new T(this); } void showDialog(); diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.cpp b/sources/awesome-widget/plugin/awabstractpairhelper.cpp index aac202e..43c828d 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.cpp +++ b/sources/awesome-widget/plugin/awabstractpairhelper.cpp @@ -19,13 +19,14 @@ #include #include +#include #include "awdebug.h" -AWAbstractPairHelper::AWAbstractPairHelper(const QString &_filePath, const QString &_section) - : m_filePath(_filePath) - , m_section(_section) +AWAbstractPairHelper::AWAbstractPairHelper(QString _filePath, QString _section) + : m_filePath(std::move(_filePath)) + , m_section(std::move(_section)) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.h b/sources/awesome-widget/plugin/awabstractpairhelper.h index c1eac82..404fb84 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.h +++ b/sources/awesome-widget/plugin/awabstractpairhelper.h @@ -25,7 +25,7 @@ class AWAbstractPairHelper { public: - explicit AWAbstractPairHelper(const QString &_filePath = "", const QString &_section = ""); + explicit AWAbstractPairHelper(QString _filePath = "", QString _section = ""); virtual ~AWAbstractPairHelper(); QStringList keys() const; QHash pairs() const; diff --git a/sources/awesome-widget/plugin/awabstractselector.h b/sources/awesome-widget/plugin/awabstractselector.h index ef586ec..2cac132 100644 --- a/sources/awesome-widget/plugin/awabstractselector.h +++ b/sources/awesome-widget/plugin/awabstractselector.h @@ -34,7 +34,7 @@ class AWAbstractSelector : public QWidget public: explicit AWAbstractSelector(QWidget *_parent = nullptr, const QPair &_editable = {false, false}); - virtual ~AWAbstractSelector(); + ~AWAbstractSelector() override; QPair current() const; void init(const QStringList &_keys, const QStringList &_values, const QPair &_current); diff --git a/sources/awesome-widget/plugin/awactions.cpp b/sources/awesome-widget/plugin/awactions.cpp index 4935099..c854770 100644 --- a/sources/awesome-widget/plugin/awactions.cpp +++ b/sources/awesome-widget/plugin/awactions.cpp @@ -55,7 +55,7 @@ void AWActions::checkUpdates(const bool _showAnyway) } -QString AWActions::getFileContent(const QString &_path) const +QString AWActions::getFileContent(const QString &_path) { qCDebug(LOG_AW) << "Get content from file" << _path; @@ -72,13 +72,13 @@ QString AWActions::getFileContent(const QString &_path) const // HACK: since QML could not use QLoggingCategory I need this hack -bool AWActions::isDebugEnabled() const +bool AWActions::isDebugEnabled() { return LOG_AW().isDebugEnabled(); } -bool AWActions::runCmd(const QString &_cmd) const +bool AWActions::runCmd(const QString &_cmd) { qCDebug(LOG_AW) << "Cmd" << _cmd; @@ -89,15 +89,15 @@ bool AWActions::runCmd(const QString &_cmd) const // HACK: this method uses variable from version.h -void AWActions::showReadme() const +void AWActions::showReadme() { QDesktopServices::openUrl(QUrl(HOMEPAGE)); } -void AWActions::showLegacyInfo() const +void AWActions::showLegacyInfo() { - QMessageBox *msgBox = new QMessageBox(nullptr); + auto *msgBox = new QMessageBox(nullptr); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->setWindowTitle(i18n("Not supported")); @@ -110,7 +110,7 @@ void AWActions::showLegacyInfo() const // HACK: this method uses variables from version.h -QString AWActions::getAboutText(const QString &_type) const +QString AWActions::getAboutText(const QString &_type) { qCDebug(LOG_AW) << "Type" << _type; @@ -118,7 +118,7 @@ QString AWActions::getAboutText(const QString &_type) const } -QVariantMap AWActions::getFont(const QVariantMap &_defaultFont) const +QVariantMap AWActions::getFont(const QVariantMap &_defaultFont) { qCDebug(LOG_AW) << "Default font is" << _defaultFont; diff --git a/sources/awesome-widget/plugin/awactions.h b/sources/awesome-widget/plugin/awactions.h index a70d7b5..c804123 100644 --- a/sources/awesome-widget/plugin/awactions.h +++ b/sources/awesome-widget/plugin/awactions.h @@ -31,16 +31,16 @@ class AWActions : public QObject public: explicit AWActions(QObject *_parent = nullptr); - virtual ~AWActions(); + ~AWActions() override; Q_INVOKABLE void checkUpdates(const bool _showAnyway = false); - Q_INVOKABLE QString getFileContent(const QString &_path) const; - Q_INVOKABLE bool isDebugEnabled() const; - Q_INVOKABLE bool runCmd(const QString &_cmd) const; - Q_INVOKABLE void showLegacyInfo() const; - Q_INVOKABLE void showReadme() const; + Q_INVOKABLE static QString getFileContent(const QString &_path); + Q_INVOKABLE static bool isDebugEnabled(); + Q_INVOKABLE static bool runCmd(const QString &_cmd); + Q_INVOKABLE static void showLegacyInfo(); + Q_INVOKABLE static void showReadme(); // configuration slots - Q_INVOKABLE QString getAboutText(const QString &_type) const; - Q_INVOKABLE QVariantMap getFont(const QVariantMap &_defaultFont) const; + Q_INVOKABLE static QString getAboutText(const QString &_type); + Q_INVOKABLE static QVariantMap getFont(const QVariantMap &_defaultFont); public slots: Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message); diff --git a/sources/awesome-widget/plugin/awbugreporter.cpp b/sources/awesome-widget/plugin/awbugreporter.cpp index a2410db..337d603 100644 --- a/sources/awesome-widget/plugin/awbugreporter.cpp +++ b/sources/awesome-widget/plugin/awbugreporter.cpp @@ -50,7 +50,7 @@ void AWBugReporter::doConnect() QString AWBugReporter::generateText(const QString &_description, const QString &_reproduce, - const QString &_expected, const QString &_logs) const + const QString &_expected, const QString &_logs) { // do not log _logs here, it may have quite large size qCDebug(LOG_AW) << "Generate text with description" << _description << "steps" << _reproduce @@ -72,7 +72,7 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body) { qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" << _body; - QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr); + auto *manager = new QNetworkAccessManager(nullptr); connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(issueReplyRecieved(QNetworkReply *))); @@ -100,7 +100,7 @@ void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply) return emit(replyReceived(0, "")); } - QJsonParseError error; + QJsonParseError error{}; QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error); if (error.error != QJsonParseError::NoError) { qCWarning(LOG_AW) << "Parse error" << error.errorString(); @@ -124,7 +124,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url) // cache url first m_lastBugUrl = _url; - QMessageBox *msgBox = new QMessageBox(nullptr); + auto *msgBox = new QMessageBox(nullptr); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->setWindowTitle(i18n("Issue created")); @@ -138,7 +138,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url) void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button) { - QMessageBox::ButtonRole ret = static_cast(sender())->buttonRole(_button); + QMessageBox::ButtonRole ret = dynamic_cast(sender())->buttonRole(_button); qCInfo(LOG_AW) << "User select" << ret; switch (ret) { diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index 88aed69..57ada94 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -31,10 +31,10 @@ class AWBugReporter : public QObject public: explicit AWBugReporter(QObject *_parent = nullptr); - virtual ~AWBugReporter(); + ~AWBugReporter() override; Q_INVOKABLE void doConnect(); - Q_INVOKABLE QString generateText(const QString &_description, const QString &_reproduce, - const QString &_expected, const QString &_logs) const; + Q_INVOKABLE static QString generateText(const QString &_description, const QString &_reproduce, + const QString &_expected, const QString &_logs); Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body); signals: diff --git a/sources/awesome-widget/plugin/awconfighelper.cpp b/sources/awesome-widget/plugin/awconfighelper.cpp index edffc40..70d76b1 100644 --- a/sources/awesome-widget/plugin/awconfighelper.cpp +++ b/sources/awesome-widget/plugin/awconfighelper.cpp @@ -17,8 +17,6 @@ #include "awconfighelper.h" -#include - #include #include #include @@ -62,7 +60,7 @@ QString AWConfigHelper::configurationDirectory() const } -bool AWConfigHelper::dropCache() const +bool AWConfigHelper::dropCache() { QString fileName = QString("%1/awesomewidgets.ndx") @@ -78,7 +76,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString & QSettings settings(_fileName, QSettings::IniFormat); // plasmoid configuration - const QQmlPropertyMap *configuration = static_cast(_nativeConfig); + const auto *configuration = dynamic_cast(_nativeConfig); settings.beginGroup("plasmoid"); for (auto &key : configuration->keys()) { QVariant value = configuration->value(key); @@ -173,7 +171,7 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName, } -QVariantMap AWConfigHelper::readDataEngineConfiguration() const +QVariantMap AWConfigHelper::readDataEngineConfiguration() { QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, "plasma-dataengine-extsysmon.conf"); @@ -199,7 +197,7 @@ QVariantMap AWConfigHelper::readDataEngineConfiguration() const } -bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configuration) const +bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configuration) { qCDebug(LOG_AW) << "Configuration" << _configuration; @@ -226,7 +224,7 @@ bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configurat } -void AWConfigHelper::copyConfigs(const QString &_localDir) const +void AWConfigHelper::copyConfigs(const QString &_localDir) { qCDebug(LOG_AW) << "Local directory" << _localDir; @@ -268,15 +266,14 @@ void AWConfigHelper::copyExtensions(const QString &_item, const QString &_type, } -void AWConfigHelper::copySettings(QSettings &_from, QSettings &_to) const +void AWConfigHelper::copySettings(QSettings &_from, QSettings &_to) { for (auto &key : _from.childKeys()) _to.setValue(key, _from.value(key)); } -void AWConfigHelper::readFile(QSettings &_settings, const QString &_key, - const QString &_fileName) const +void AWConfigHelper::readFile(QSettings &_settings, const QString &_key, const QString &_fileName) { qCDebug(LOG_AW) << "Key" << _key << "from file" << _fileName; @@ -291,8 +288,7 @@ void AWConfigHelper::readFile(QSettings &_settings, const QString &_key, } -void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, - const QString &_fileName) const +void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, const QString &_fileName) { qCDebug(LOG_AW) << "Key" << _key << "to file" << _fileName; diff --git a/sources/awesome-widget/plugin/awconfighelper.h b/sources/awesome-widget/plugin/awconfighelper.h index e008a64..957431f 100644 --- a/sources/awesome-widget/plugin/awconfighelper.h +++ b/sources/awesome-widget/plugin/awconfighelper.h @@ -31,26 +31,26 @@ class AWConfigHelper : public QObject public: explicit AWConfigHelper(QObject *_parent = nullptr); - virtual ~AWConfigHelper(); + ~AWConfigHelper() override; Q_INVOKABLE QString configurationDirectory() const; - Q_INVOKABLE bool dropCache() const; + Q_INVOKABLE static bool dropCache(); Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const; Q_INVOKABLE QVariantMap importConfiguration(const QString &_fileName, const bool _importPlasmoid, const bool _importExtensions, const bool _importAdds) const; // dataengine - Q_INVOKABLE QVariantMap readDataEngineConfiguration() const; - Q_INVOKABLE bool writeDataEngineConfiguration(const QVariantMap &_configuration) const; + Q_INVOKABLE static QVariantMap readDataEngineConfiguration(); + Q_INVOKABLE static bool writeDataEngineConfiguration(const QVariantMap &_configuration); private: // methods - void copyConfigs(const QString &_localDir) const; + static void copyConfigs(const QString &_localDir); void copyExtensions(const QString &_item, const QString &_type, QSettings &_settings, const bool _inverse) const; - void copySettings(QSettings &_from, QSettings &_to) const; - void readFile(QSettings &_settings, const QString &_key, const QString &_fileName) const; - void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName) const; + static void copySettings(QSettings &_from, QSettings &_to); + static void readFile(QSettings &_settings, const QString &_key, const QString &_fileName); + static void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName); // properties QString m_baseDir; QStringList m_dirs = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"}; diff --git a/sources/awesome-widget/plugin/awcustomkeysconfig.h b/sources/awesome-widget/plugin/awcustomkeysconfig.h index 5554c82..794956e 100644 --- a/sources/awesome-widget/plugin/awcustomkeysconfig.h +++ b/sources/awesome-widget/plugin/awcustomkeysconfig.h @@ -29,7 +29,7 @@ class AWCustomKeysConfig : public AWAbstractPairConfig public: explicit AWCustomKeysConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList()); - virtual ~AWCustomKeysConfig(); + ~AWCustomKeysConfig() override; }; diff --git a/sources/awesome-widget/plugin/awcustomkeyshelper.h b/sources/awesome-widget/plugin/awcustomkeyshelper.h index 42b8af7..7a3b179 100644 --- a/sources/awesome-widget/plugin/awcustomkeyshelper.h +++ b/sources/awesome-widget/plugin/awcustomkeyshelper.h @@ -30,15 +30,15 @@ class AWCustomKeysHelper : public QObject, public AWAbstractPairHelper public: explicit AWCustomKeysHelper(QObject *_parent = nullptr); - virtual ~AWCustomKeysHelper(); + ~AWCustomKeysHelper() override; // get QString source(const QString &_key) const; QStringList sources() const; QStringList refinedSources() const; // configuration related - virtual void editPairs(){}; - virtual QStringList leftKeys(); - virtual QStringList rightKeys(); + void editPairs() override{}; + QStringList leftKeys() override; + QStringList rightKeys() override; private: }; diff --git a/sources/awesome-widget/plugin/awdataaggregator.cpp b/sources/awesome-widget/plugin/awdataaggregator.cpp index 48e9e1e..feb000c 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataaggregator.cpp @@ -54,7 +54,7 @@ AWDataAggregator::~AWDataAggregator() } -QString AWDataAggregator::htmlImage(const QPixmap &_source) const +QString AWDataAggregator::htmlImage(const QPixmap &_source) { QByteArray byteArray; QBuffer buffer(&byteArray); @@ -195,7 +195,7 @@ void AWDataAggregator::initScene() } -QString AWDataAggregator::notificationText(const QString &_source, const float _value) const +QString AWDataAggregator::notificationText(const QString &_source, const float _value) { qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value; @@ -215,7 +215,7 @@ QString AWDataAggregator::notificationText(const QString &_source, const float _ } -QString AWDataAggregator::notificationText(const QString &_source, const QString &_value) const +QString AWDataAggregator::notificationText(const QString &_source, const QString &_value) { qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value; @@ -246,10 +246,7 @@ void AWDataAggregator::setData(const QVariantHash &_values) m_currentNetworkDevice = value; }(_values["netdev"].toString()); // additional check for GPU load - [this](const float value) { - checkValue("gpu", value, 90.0); - m_currentGPULoad = value; - }(_values["gpu"].toFloat()); + [this](const float value) { checkValue("gpu", value, 90.0); }(_values["gpu"].toFloat()); } diff --git a/sources/awesome-widget/plugin/awdataaggregator.h b/sources/awesome-widget/plugin/awdataaggregator.h index d0769dd..e5c75a1 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.h +++ b/sources/awesome-widget/plugin/awdataaggregator.h @@ -34,8 +34,8 @@ class AWDataAggregator : public QObject public: explicit AWDataAggregator(QObject *_parent = nullptr); - virtual ~AWDataAggregator(); - QString htmlImage(const QPixmap &_source) const; + ~AWDataAggregator() override; + static QString htmlImage(const QPixmap &_source); void setParameters(const QVariantMap &_settings); QPixmap tooltipImage(); @@ -53,8 +53,8 @@ private: void checkValue(const QString &_source, const QString &_current, const QString &_received) const; void initScene(); - QString notificationText(const QString &_source, const float _value) const; - QString notificationText(const QString &_source, const QString &_value) const; + static QString notificationText(const QString &_source, const float _value); + static QString notificationText(const QString &_source, const QString &_value); // main method void setData(const QVariantHash &_values); void setData(const QString &_source, float _value, const float _extremum = -1.0f); @@ -63,7 +63,6 @@ private: // variables int m_counts = 0; QVariantHash m_configuration; - float m_currentGPULoad = 0.0f; QString m_currentNetworkDevice = "lo"; QHash m_boundaries; QHash> m_values; diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index e6d2c1c..e0e048c 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -69,16 +69,16 @@ void AWDataEngineAggregator::reconnectSources(const int _interval) disconnectSources(); - m_dataEngines["systemmonitor"]->connectAllSources(parent(), _interval); - m_dataEngines["extsysmon"]->connectAllSources(parent(), _interval); + m_dataEngines["systemmonitor"]->connectAllSources(parent(), (uint)_interval); + m_dataEngines["extsysmon"]->connectAllSources(parent(), (uint)_interval); m_dataEngines["time"]->connectSource("Local", parent(), 1000); - m_newSourceConnection - = connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, - [this, _interval](const QString source) { - emit(deviceAdded(source)); - m_dataEngines["systemmonitor"]->connectSource(source, parent(), _interval); - }); + m_newSourceConnection = connect( + m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, + [this, _interval](const QString source) { + emit(deviceAdded(source)); + m_dataEngines["systemmonitor"]->connectSource(source, parent(), (uint)_interval); + }); #ifdef BUILD_FUTURE createQueuedConnection(); diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.h b/sources/awesome-widget/plugin/awdataengineaggregator.h index a2def21..dae35a6 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.h +++ b/sources/awesome-widget/plugin/awdataengineaggregator.h @@ -31,7 +31,7 @@ class AWDataEngineAggregator : public QObject public: explicit AWDataEngineAggregator(QObject *_parent = nullptr); - virtual ~AWDataEngineAggregator(); + ~AWDataEngineAggregator() override; void disconnectSources(); void reconnectSources(const int _interval); diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index 9f00e75..c088a93 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -33,7 +33,7 @@ class AWDataEngineMapper : public QObject public: explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr); - virtual ~AWDataEngineMapper(); + ~AWDataEngineMapper() override; // get methods AWKeysAggregator::FormatterType formatter(const QString &_key) const; QStringList keysFromSource(const QString &_source) const; diff --git a/sources/awesome-widget/plugin/awdbusadaptor.h b/sources/awesome-widget/plugin/awdbusadaptor.h index a790c2d..31309ec 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.h +++ b/sources/awesome-widget/plugin/awdbusadaptor.h @@ -33,7 +33,7 @@ class AWDBusAdaptor : public QDBusAbstractAdaptor public: explicit AWDBusAdaptor(AWKeys *_parent = nullptr); - virtual ~AWDBusAdaptor(); + ~AWDBusAdaptor() override; public slots: // get methods diff --git a/sources/awesome-widget/plugin/awesomewidget.h b/sources/awesome-widget/plugin/awesomewidget.h index 743e2c9..86ab973 100644 --- a/sources/awesome-widget/plugin/awesomewidget.h +++ b/sources/awesome-widget/plugin/awesomewidget.h @@ -28,7 +28,7 @@ class AWPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void registerTypes(const char *uri); + void registerTypes(const char *uri) override; }; diff --git a/sources/awesome-widget/plugin/awformatterconfig.h b/sources/awesome-widget/plugin/awformatterconfig.h index c706bf9..9af1e1d 100644 --- a/sources/awesome-widget/plugin/awformatterconfig.h +++ b/sources/awesome-widget/plugin/awformatterconfig.h @@ -29,7 +29,7 @@ class AWFormatterConfig : public AWAbstractPairConfig public: explicit AWFormatterConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList()); - virtual ~AWFormatterConfig(); + ~AWFormatterConfig() override; }; diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index d00d844..0eadc67 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -122,7 +122,7 @@ void AWFormatterHelper::editItems() AWAbstractFormatter::FormatterClass -AWFormatterHelper::defineFormatterClass(const QString &_stringType) const +AWFormatterHelper::defineFormatterClass(const QString &_stringType) { qCDebug(LOG_AW) << "Define formatter class for" << _stringType; diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h index a1cfd71..3152d61 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.h +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -30,29 +30,29 @@ class AWFormatterHelper : public AbstractExtItemAggregator, public AWAbstractPai public: explicit AWFormatterHelper(QWidget *_parent = nullptr); - virtual ~AWFormatterHelper(); + ~AWFormatterHelper() override; // read-write methods - void initItems(); + void initItems() override; // methods QString convert(const QVariant &_value, const QString &_name) const; QStringList definedFormatters() const; - QList items() const; + QList items() const override; // configuration related - virtual void editPairs(); - virtual QStringList leftKeys(); - virtual QStringList rightKeys(); + void editPairs() override; + QStringList leftKeys() override; + QStringList rightKeys() override; public slots: void editItems(); private: // methods - AWAbstractFormatter::FormatterClass defineFormatterClass(const QString &_stringType) const; + static AWAbstractFormatter::FormatterClass defineFormatterClass(const QString &_stringType); void initFormatters(); QPair readMetadata(const QString &_filePath) const; // parent methods - void doCreateItem(); + void doCreateItem() override; // properties QHash m_formatters; QHash m_formattersClasses; diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp index eac2749..92f77a5 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -15,6 +15,7 @@ * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ + #include "awkeycache.h" #include diff --git a/sources/awesome-widget/plugin/awkeycache.h b/sources/awesome-widget/plugin/awkeycache.h index 0317cc2..272c6ee 100644 --- a/sources/awesome-widget/plugin/awkeycache.h +++ b/sources/awesome-widget/plugin/awkeycache.h @@ -31,7 +31,7 @@ QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars, const QVariantMap &_tooltip, const QStringList &_userKeys, const QStringList &_allKeys); QHash loadKeysFromCache(); -}; +} // namespace AWKeyCache #endif /* AWKEYCACHE_H */ diff --git a/sources/awesome-widget/plugin/awkeyoperations.h b/sources/awesome-widget/plugin/awkeyoperations.h index a58d99f..57c0a7e 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.h +++ b/sources/awesome-widget/plugin/awkeyoperations.h @@ -39,7 +39,7 @@ class AWKeyOperations : public QObject public: explicit AWKeyOperations(QObject *_parent = nullptr); - virtual ~AWKeyOperations(); + ~AWKeyOperations() override; QStringList devices(const QString &_type) const; QHash devices() const; void updateCache(); diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 208d392..36f0705 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -345,10 +345,9 @@ QString AWKeys::parsePattern(QString _pattern) const // bars for (auto &bar : m_foundBars) { GraphicalItem *item = m_keyOperator->giByKey(bar); - QString image = item->isCustom() - ? item->image(AWPatternFunctions::expandLambdas( - item->bar(), m_aggregator, m_values, item->usedKeys())) - : item->image(m_values[item->bar()]); + QString image = item->isCustom() ? item->image(AWPatternFunctions::expandLambdas( + item->bar(), m_aggregator, m_values, item->usedKeys())) + : item->image(m_values[item->bar()]); _pattern.replace(QString("$%1").arg(bar), image); } diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index a1864ee..8f0ebce 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -38,7 +38,7 @@ class AWKeys : public QObject public: explicit AWKeys(QObject *_parent = nullptr); - virtual ~AWKeys(); + ~AWKeys() override; Q_INVOKABLE void initDataAggregator(const QVariantMap &_tooltipParams); Q_INVOKABLE void initKeys(const QString &_currentPattern, const int _interval, const int _limit, const bool _optimize); @@ -59,7 +59,7 @@ public: public slots: void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data); // dummy method required by DataEngine connections - void modelChanged(QString, QAbstractItemModel *){}; + static void modelChanged(QString, QAbstractItemModel *){}; signals: void dropSourceFromDataengine(const QString &_source); diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 47632cb..d9c460f 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -117,7 +117,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key) break; case FormatterType::TimeCustom: output = m_customTime; - [&output, loc, this](const QDateTime dt) { + [&output, loc, this](const QDateTime &dt) { for (auto &key : m_timeKeys) output.replace(QString("$%1").arg(key), loc.toString(dt, key)); }(_data.toDateTime()); diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index 8f99846..83ef50f 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -66,7 +66,7 @@ public: }; explicit AWKeysAggregator(QObject *_parent = nullptr); - virtual ~AWKeysAggregator(); + ~AWKeysAggregator() override; void initFormatters(); // get methods QString formatter(const QVariant &_data, const QString &_key) const; diff --git a/sources/awesome-widget/plugin/awpairconfigfactory.cpp b/sources/awesome-widget/plugin/awpairconfigfactory.cpp index 7de5dc3..893d9d2 100644 --- a/sources/awesome-widget/plugin/awpairconfigfactory.cpp +++ b/sources/awesome-widget/plugin/awpairconfigfactory.cpp @@ -37,7 +37,7 @@ AWPairConfigFactory::~AWPairConfigFactory() void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys) { - AWFormatterConfig *config = new AWFormatterConfig(nullptr, _keys); + auto *config = new AWFormatterConfig(nullptr, _keys); config->showDialog(); config->deleteLater(); } @@ -45,7 +45,7 @@ void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys) void AWPairConfigFactory::showKeysDialog(const QStringList &_keys) { - AWCustomKeysConfig *config = new AWCustomKeysConfig(nullptr, _keys); + auto *config = new AWCustomKeysConfig(nullptr, _keys); config->showDialog(); config->deleteLater(); } diff --git a/sources/awesome-widget/plugin/awpairconfigfactory.h b/sources/awesome-widget/plugin/awpairconfigfactory.h index 40d0d08..5ecb661 100644 --- a/sources/awesome-widget/plugin/awpairconfigfactory.h +++ b/sources/awesome-widget/plugin/awpairconfigfactory.h @@ -28,9 +28,9 @@ class AWPairConfigFactory : public QObject public: explicit AWPairConfigFactory(QObject *_parent = nullptr); - virtual ~AWPairConfigFactory(); - Q_INVOKABLE void showFormatterDialog(const QStringList &_keys); - Q_INVOKABLE void showKeysDialog(const QStringList &_keys); + ~AWPairConfigFactory() override; + Q_INVOKABLE static void showFormatterDialog(const QStringList &_keys); + Q_INVOKABLE static void showKeysDialog(const QStringList &_keys); private: }; diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index 1658705..5cbe322 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -54,7 +54,7 @@ QString AWPatternFunctions::expandTemplates(QString _code) qCDebug(LOG_AW) << "Expand templates in" << _code; // match the following construction $template{{some code here}} - QRegularExpression templatesRegexp("\\$template\\{\\{(?.*?)\\}\\}"); + QRegularExpression templatesRegexp(R"(\$template\{\{(?.*?)\}\})"); templatesRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatchIterator it = templatesRegexp.globalMatch(_code); @@ -92,8 +92,7 @@ AWPatternFunctions::findFunctionCalls(const QString &_function, const QString &_ // in this field if they are not screened by $, i.e. '$,' // * body depends on the function name, double brackets should be screened // by using $, e.g. ${ - QRegularExpression regex( - QString("\\$%1\\<(?.*?)\\>\\{\\{(?.*?)\\}\\}").arg(_function)); + QRegularExpression regex(QString(R"(\$%1\<(?.*?)\>\{\{(?.*?)\}\})").arg(_function)); regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); QList foundFunctions; @@ -266,7 +265,7 @@ QStringList AWPatternFunctions::findLambdas(const QString &_code) QStringList selectedKeys; // match the following construction ${{some code here}} - QRegularExpression lambdaRegexp("\\$\\{\\{(?.*?)\\}\\}"); + QRegularExpression lambdaRegexp(R"(\$\{\{(?.*?)\}\})"); lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(_code); diff --git a/sources/awesome-widget/plugin/awpatternfunctions.h b/sources/awesome-widget/plugin/awpatternfunctions.h index 9ea3441..c57ffd0 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.h +++ b/sources/awesome-widget/plugin/awpatternfunctions.h @@ -46,7 +46,7 @@ QString insertMacros(QString _code); // find methods QStringList findKeys(const QString &_code, const QStringList &_keys, const bool _isBars); QStringList findLambdas(const QString &_code); -}; +} // namespace AWPatternFunctions #endif /* AWPATTERNFUNCTIONS_H */ diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.cpp b/sources/awesome-widget/plugin/awtelemetryhandler.cpp index 43efaee..08ce41a 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.cpp +++ b/sources/awesome-widget/plugin/awtelemetryhandler.cpp @@ -126,7 +126,7 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_ return; } - QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr); + auto *manager = new QNetworkAccessManager(nullptr); connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(telemetryReplyRecieved(QNetworkReply *))); @@ -156,7 +156,7 @@ void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply) return; } - QJsonParseError error; + QJsonParseError error{}; QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error); if (error.error != QJsonParseError::NoError) { qCWarning(LOG_AW) << "Parse error" << error.errorString(); @@ -173,7 +173,7 @@ void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply) } -QString AWTelemetryHandler::getKey(const int _count) const +QString AWTelemetryHandler::getKey(const int _count) { qCDebug(LOG_AW) << "Get key for keys count" << _count; diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.h b/sources/awesome-widget/plugin/awtelemetryhandler.h index fb2d336..42eb3f1 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.h +++ b/sources/awesome-widget/plugin/awtelemetryhandler.h @@ -32,7 +32,7 @@ public: const char *REMOTE_TELEMETRY_URL = "https://arcanis.me/telemetry"; explicit AWTelemetryHandler(QObject *_parent = nullptr, const QString &_clientId = ""); - virtual ~AWTelemetryHandler(); + ~AWTelemetryHandler() override; Q_INVOKABLE QStringList get(const QString &_group) const; Q_INVOKABLE QString getLast(const QString &_group) const; Q_INVOKABLE void init(const int _count, const bool _enableRemote, const QString &_clientId); @@ -46,7 +46,7 @@ private slots: void telemetryReplyRecieved(QNetworkReply *_reply); private: - QString getKey(const int _count) const; + static QString getKey(const int _count); QString m_clientId; QString m_localFile; int m_storeCount = 0; diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp index 261f3ad..3142d70 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.cpp +++ b/sources/awesome-widget/plugin/awupdatehelper.cpp @@ -52,7 +52,7 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway) // showAnyway options requires to show message if no updates found on direct // request. In case of automatic check no message will be shown - QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr); + auto *manager = new QNetworkAccessManager(nullptr); connect(manager, &QNetworkAccessManager::finished, [_showAnyway, this](QNetworkReply *reply) { return versionReplyRecieved(reply, _showAnyway); }); @@ -72,7 +72,7 @@ bool AWUpdateHelper::checkVersion() qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion; if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) { - genMessageBox(i18n("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'), + genMessageBox(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'), QMessageBox::Ok) ->open(); return true; @@ -103,7 +103,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version) qCDebug(LOG_AW) << "Version" << _version; QString text; - text += i18n("Current version : %1", VERSION); + text += i18nc("Current version : %1", VERSION); text += QString(COMMIT_SHA).isEmpty() ? "\n" : QString(" (%1)\n").arg(QString(COMMIT_SHA)); text += i18n("New version : %1", _version.toString()) + "\n\n"; text += i18n("Click \"Ok\" to download"); @@ -115,7 +115,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version) void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button) { - QMessageBox::ButtonRole ret = static_cast(sender())->buttonRole(_button); + QMessageBox::ButtonRole ret = dynamic_cast(sender())->buttonRole(_button); qCInfo(LOG_AW) << "User select" << ret; switch (ret) { @@ -138,7 +138,7 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, const bool _sho return; } - QJsonParseError error; + QJsonParseError error = QJsonParseError(); QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error); if (error.error != QJsonParseError::NoError) { qCWarning(LOG_AW) << "Parse error" << error.errorString(); @@ -167,7 +167,7 @@ QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString { qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body; - QMessageBox *msgBox = new QMessageBox(nullptr); + auto *msgBox = new QMessageBox(nullptr); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->setWindowTitle(_title); diff --git a/sources/awesome-widget/plugin/awupdatehelper.h b/sources/awesome-widget/plugin/awupdatehelper.h index cfd26e7..ae650fd 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.h +++ b/sources/awesome-widget/plugin/awupdatehelper.h @@ -32,19 +32,19 @@ class AWUpdateHelper : public QObject public: explicit AWUpdateHelper(QObject *_parent = nullptr); - virtual ~AWUpdateHelper(); + ~AWUpdateHelper() override; void checkUpdates(const bool _showAnyway = false); bool checkVersion(); private slots: - void showInfo(const QVersionNumber &_version); + static void showInfo(const QVersionNumber &_version); void showUpdates(const QVersionNumber &_version); void userReplyOnUpdates(QAbstractButton *_button); void versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway); private: - QMessageBox *genMessageBox(const QString &_title, const QString &_body, - const QMessageBox::StandardButtons _buttons); + static QMessageBox *genMessageBox(const QString &_title, const QString &_body, + const QMessageBox::StandardButtons _buttons); QVersionNumber m_foundVersion; QString m_genericConfig; }; diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index c41ef67..44a55f7 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -45,7 +45,7 @@ AbstractExtItem::~AbstractExtItem() if (m_socket) { m_socket->close(); - m_socket->removeServer(socket()); + QLocalServer::removeServer(socket()); m_socket->deleteLater(); } } @@ -270,7 +270,7 @@ void AbstractExtItem::deinitSocket() return; m_socket->close(); - m_socket->removeServer(socket()); + QLocalServer::removeServer(socket()); delete m_socket; disconnect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived())); } diff --git a/sources/awesomewidgets/abstractextitem.h b/sources/awesomewidgets/abstractextitem.h index f325db5..8e0300b 100644 --- a/sources/awesomewidgets/abstractextitem.h +++ b/sources/awesomewidgets/abstractextitem.h @@ -41,7 +41,7 @@ class AbstractExtItem : public QDialog public: explicit AbstractExtItem(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AbstractExtItem(); + ~AbstractExtItem() override; virtual void bumpApi(const int _newVer); virtual AbstractExtItem *copy(const QString &_fileName, const int _number) = 0; virtual void copyDefaults(AbstractExtItem *_other) const; diff --git a/sources/awesomewidgets/abstractextitemaggregator.cpp b/sources/awesomewidgets/abstractextitemaggregator.cpp index 1189795..8fb22a8 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.cpp +++ b/sources/awesomewidgets/abstractextitemaggregator.cpp @@ -23,12 +23,13 @@ #include #include #include +#include -AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, const QString &_type) +AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *_parent, QString _type) : QDialog(_parent) , ui(new Ui::AbstractExtItemAggregator) - , m_type(_type) + , m_type(std::move(_type)) { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; @@ -90,7 +91,7 @@ void AbstractExtItemAggregator::deleteItem() if (!source) { qCWarning(LOG_LIB) << "Nothing to delete"; return; - }; + } if (source->tryDelete()) { initItems(); @@ -105,7 +106,7 @@ void AbstractExtItemAggregator::editItem() if (!source) { qCWarning(LOG_LIB) << "Nothing to edit"; return; - }; + } if (source->showConfiguration(configArgs()) == 1) { initItems(); @@ -154,7 +155,7 @@ void AbstractExtItemAggregator::repaintList() ui->listWidget->clear(); for (auto &_item : items()) { QString fileName = QFileInfo(_item->fileName()).fileName(); - QListWidgetItem *item = new QListWidgetItem(fileName, ui->listWidget); + auto *item = new QListWidgetItem(fileName, ui->listWidget); QStringList tooltip; tooltip.append(i18n("Name: %1", _item->name())); tooltip.append(i18n("Comment: %1", _item->comment())); @@ -216,11 +217,11 @@ void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *) void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *_button) { - if (static_cast(_button) == copyButton) + if (dynamic_cast(_button) == copyButton) return copyItem(); - else if (static_cast(_button) == createButton) + else if (dynamic_cast(_button) == createButton) return doCreateItem(); - else if (static_cast(_button) == deleteButton) + else if (dynamic_cast(_button) == deleteButton) return deleteItem(); else if (ui->buttonBox->buttonRole(_button) == QDialogButtonBox::AcceptRole) return editItem(); diff --git a/sources/awesomewidgets/abstractextitemaggregator.h b/sources/awesomewidgets/abstractextitemaggregator.h index fc23c7a..418d386 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.h +++ b/sources/awesomewidgets/abstractextitemaggregator.h @@ -39,8 +39,8 @@ class AbstractExtItemAggregator : public QDialog Q_PROPERTY(QVariant type READ type) public: - explicit AbstractExtItemAggregator(QWidget *_parent, const QString &_type); - virtual ~AbstractExtItemAggregator(); + explicit AbstractExtItemAggregator(QWidget *_parent, QString _type); + ~AbstractExtItemAggregator() override; // methods void copyItem(); template void createItem() @@ -54,7 +54,7 @@ public: if (fileName.isEmpty()) { qCWarning(LOG_LIB) << "Nothing to create"; return; - }; + } QString filePath = QString("%1/%2").arg(dir).arg(fileName); T *newItem = new T(this, filePath); @@ -62,7 +62,7 @@ public: if (newItem->showConfiguration(configArgs()) == 1) { initItems(); repaintList(); - }; + } }; void deleteItem(); void editItem(); diff --git a/sources/awesomewidgets/abstractquotesprovider.h b/sources/awesomewidgets/abstractquotesprovider.h index 1dee50a..53b94ff 100644 --- a/sources/awesomewidgets/abstractquotesprovider.h +++ b/sources/awesomewidgets/abstractquotesprovider.h @@ -31,12 +31,12 @@ class AbstractQuotesProvider : public QObject public: explicit AbstractQuotesProvider(QObject *_parent) : QObject(_parent){}; - virtual ~AbstractQuotesProvider(){}; + ~AbstractQuotesProvider() override = default; virtual void initUrl(const QString &_asset) = 0; virtual QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const = 0; QString tag(const QString &_type) const { - return static_cast(parent())->tag(_type); + return dynamic_cast(parent())->tag(_type); }; virtual QUrl url() const = 0; }; diff --git a/sources/awesomewidgets/abstractweatherprovider.h b/sources/awesomewidgets/abstractweatherprovider.h index 2bf6034..10895a0 100644 --- a/sources/awesomewidgets/abstractweatherprovider.h +++ b/sources/awesomewidgets/abstractweatherprovider.h @@ -31,12 +31,12 @@ class AbstractWeatherProvider : public QObject public: explicit AbstractWeatherProvider(QObject *_parent) : QObject(_parent){}; - virtual ~AbstractWeatherProvider(){}; + ~AbstractWeatherProvider() override = default; virtual void initUrl(const QString &_city, const QString &_country, const int _ts) = 0; virtual QVariantHash parse(const QVariantMap &_json) const = 0; QString tag(const QString &_type) const { - return static_cast(parent())->tag(_type); + return dynamic_cast(parent())->tag(_type); }; virtual QUrl url() const = 0; }; diff --git a/sources/awesomewidgets/awabstractformatter.cpp b/sources/awesomewidgets/awabstractformatter.cpp index ad3a0bf..5e1978c 100644 --- a/sources/awesomewidgets/awabstractformatter.cpp +++ b/sources/awesomewidgets/awabstractformatter.cpp @@ -39,7 +39,7 @@ void AWAbstractFormatter::copyDefaults(AbstractExtItem *_other) const { AbstractExtItem::copyDefaults(_other); - static_cast(_other)->setType(type()); + dynamic_cast(_other)->setType(type()); } diff --git a/sources/awesomewidgets/awabstractformatter.h b/sources/awesomewidgets/awabstractformatter.h index 2e9dea2..b254271 100644 --- a/sources/awesomewidgets/awabstractformatter.h +++ b/sources/awesomewidgets/awabstractformatter.h @@ -31,10 +31,10 @@ public: enum class FormatterClass { DateTime, Float, List, Script, String, NoFormat, Json }; explicit AWAbstractFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWAbstractFormatter(); + ~AWAbstractFormatter() override; virtual QString convert(const QVariant &_value) const = 0; - void copyDefaults(AbstractExtItem *_other) const; - QString uniq() const; + void copyDefaults(AbstractExtItem *_other) const override; + QString uniq() const override; // properties QString strType() const; FormatterClass type() const; @@ -42,9 +42,9 @@ public: void setType(const FormatterClass _type); public slots: - virtual void readConfiguration(); - QVariantHash run() { return QVariantHash(); }; - virtual void writeConfiguration() const; + void readConfiguration() override; + QVariantHash run() override { return QVariantHash(); }; + void writeConfiguration() const override; private: // properties diff --git a/sources/awesomewidgets/awdatetimeformatter.cpp b/sources/awesomewidgets/awdatetimeformatter.cpp index db08a42..b2a18a4 100644 --- a/sources/awesomewidgets/awdatetimeformatter.cpp +++ b/sources/awesomewidgets/awdatetimeformatter.cpp @@ -60,8 +60,7 @@ AWDateTimeFormatter *AWDateTimeFormatter::copy(const QString &_fileName, const i { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWDateTimeFormatter *item - = new AWDateTimeFormatter(static_cast(parent()), _fileName); + auto *item = new AWDateTimeFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setFormat(format()); item->setTranslateString(translateString()); diff --git a/sources/awesomewidgets/awdatetimeformatter.h b/sources/awesomewidgets/awdatetimeformatter.h index 492663d..b2e1d78 100644 --- a/sources/awesomewidgets/awdatetimeformatter.h +++ b/sources/awesomewidgets/awdatetimeformatter.h @@ -36,9 +36,9 @@ class AWDateTimeFormatter : public AWAbstractFormatter public: explicit AWDateTimeFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWDateTimeFormatter(); - QString convert(const QVariant &_value) const; - AWDateTimeFormatter *copy(const QString &_fileName, const int _number); + ~AWDateTimeFormatter() override; + QString convert(const QVariant &_value) const override; + AWDateTimeFormatter *copy(const QString &_fileName, const int _number) override; // properties QString format() const; bool translateString() const; @@ -46,14 +46,14 @@ public: void setTranslateString(const bool _translate); public slots: - void readConfiguration(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private: Ui::AWDateTimeFormatter *ui = nullptr; void initLocale(); - void translate(); + void translate() override; // properties QLocale m_locale; QString m_format = ""; diff --git a/sources/awesomewidgets/awfloatformatter.cpp b/sources/awesomewidgets/awfloatformatter.cpp index 7e34335..2c51b28 100644 --- a/sources/awesomewidgets/awfloatformatter.cpp +++ b/sources/awesomewidgets/awfloatformatter.cpp @@ -64,7 +64,7 @@ AWFloatFormatter *AWFloatFormatter::copy(const QString &_fileName, const int _nu { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWFloatFormatter *item = new AWFloatFormatter(static_cast(parent()), _fileName); + auto *item = new AWFloatFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setCount(count()); item->setFormat(format()); diff --git a/sources/awesomewidgets/awfloatformatter.h b/sources/awesomewidgets/awfloatformatter.h index f9bf166..bbedf22 100644 --- a/sources/awesomewidgets/awfloatformatter.h +++ b/sources/awesomewidgets/awfloatformatter.h @@ -39,9 +39,9 @@ class AWFloatFormatter : public AWAbstractFormatter public: explicit AWFloatFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWFloatFormatter(); - QString convert(const QVariant &_value) const; - AWFloatFormatter *copy(const QString &_fileName, const int _number); + ~AWFloatFormatter() override; + QString convert(const QVariant &_value) const override; + AWFloatFormatter *copy(const QString &_fileName, const int _number) override; // properties int count() const; QChar fillChar() const; @@ -59,13 +59,13 @@ public: void setSummand(const double _summand); public slots: - void readConfiguration(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private: Ui::AWFloatFormatter *ui = nullptr; - void translate(); + void translate() override; // properties int m_count = 0; QChar m_fillChar = QChar(); diff --git a/sources/awesomewidgets/awjsonformatter.cpp b/sources/awesomewidgets/awjsonformatter.cpp index 0a27619..d59963f 100644 --- a/sources/awesomewidgets/awjsonformatter.cpp +++ b/sources/awesomewidgets/awjsonformatter.cpp @@ -68,7 +68,7 @@ AWJsonFormatter *AWJsonFormatter::copy(const QString &_fileName, const int _numb { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWJsonFormatter *item = new AWJsonFormatter(static_cast(parent()), _fileName); + auto *item = new AWJsonFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setNumber(_number); item->setPath(path()); @@ -159,7 +159,7 @@ QVariant AWJsonFormatter::getFromJson(const QVariant &_value, const QVariant &_e } -QVariant AWJsonFormatter::getFromList(const QVariant &_value, const int _index) const +QVariant AWJsonFormatter::getFromList(const QVariant &_value, const int _index) { qCDebug(LOG_LIB) << "Looking for index" << _index << "in" << _value; @@ -167,7 +167,7 @@ QVariant AWJsonFormatter::getFromList(const QVariant &_value, const int _index) } -QVariant AWJsonFormatter::getFromMap(const QVariant &_value, const QString &_key) const +QVariant AWJsonFormatter::getFromMap(const QVariant &_value, const QString &_key) { qCDebug(LOG_LIB) << "Looking for key" << _key << "in" << _value; diff --git a/sources/awesomewidgets/awjsonformatter.h b/sources/awesomewidgets/awjsonformatter.h index 112452d..bb06f2b 100644 --- a/sources/awesomewidgets/awjsonformatter.h +++ b/sources/awesomewidgets/awjsonformatter.h @@ -33,25 +33,25 @@ class AWJsonFormatter : public AWAbstractFormatter public: explicit AWJsonFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWJsonFormatter(); - QString convert(const QVariant &_value) const; - AWJsonFormatter *copy(const QString &_fileName, const int _number); + ~AWJsonFormatter() override; + QString convert(const QVariant &_value) const override; + AWJsonFormatter *copy(const QString &_fileName, const int _number) override; // properties QString path() const; void setPath(const QString &_path); public slots: - void readConfiguration(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private: Ui::AWJsonFormatter *ui = nullptr; QVariant getFromJson(const QVariant &_value, const QVariant &_element) const; - QVariant getFromList(const QVariant &_value, const int _index) const; - QVariant getFromMap(const QVariant &_value, const QString &_key) const; + static QVariant getFromList(const QVariant &_value, const int _index); + static QVariant getFromMap(const QVariant &_value, const QString &_key); void initPath(); - void translate(); + void translate() override; // properties QString m_path; QVariantList m_splittedPath; diff --git a/sources/awesomewidgets/awlistformatter.cpp b/sources/awesomewidgets/awlistformatter.cpp index f5207db..85dbd96 100644 --- a/sources/awesomewidgets/awlistformatter.cpp +++ b/sources/awesomewidgets/awlistformatter.cpp @@ -63,7 +63,7 @@ AWListFormatter *AWListFormatter::copy(const QString &_fileName, const int _numb { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWListFormatter *item = new AWListFormatter(static_cast(parent()), _fileName); + auto *item = new AWListFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setFilter(filter()); item->setSeparator(separator()); diff --git a/sources/awesomewidgets/awlistformatter.h b/sources/awesomewidgets/awlistformatter.h index 56f318a..888c414 100644 --- a/sources/awesomewidgets/awlistformatter.h +++ b/sources/awesomewidgets/awlistformatter.h @@ -35,9 +35,9 @@ class AWListFormatter : public AWAbstractFormatter public: explicit AWListFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWListFormatter(); - QString convert(const QVariant &_value) const; - AWListFormatter *copy(const QString &_fileName, const int _number); + ~AWListFormatter() override; + QString convert(const QVariant &_value) const override; + AWListFormatter *copy(const QString &_fileName, const int _number) override; // properties QString filter() const; bool isSorted() const; @@ -47,13 +47,13 @@ public: void setSorted(const bool _sorted); public slots: - void readConfiguration(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private: Ui::AWListFormatter *ui = nullptr; - void translate(); + void translate() override; // properties QString m_filter = ""; QString m_separator = ""; diff --git a/sources/awesomewidgets/awnoformatter.cpp b/sources/awesomewidgets/awnoformatter.cpp index 6409675..695ffba 100644 --- a/sources/awesomewidgets/awnoformatter.cpp +++ b/sources/awesomewidgets/awnoformatter.cpp @@ -57,7 +57,7 @@ AWNoFormatter *AWNoFormatter::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWNoFormatter *item = new AWNoFormatter(static_cast(parent()), _fileName); + auto *item = new AWNoFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setNumber(_number); diff --git a/sources/awesomewidgets/awnoformatter.h b/sources/awesomewidgets/awnoformatter.h index 2f617d5..8e2113f 100644 --- a/sources/awesomewidgets/awnoformatter.h +++ b/sources/awesomewidgets/awnoformatter.h @@ -32,16 +32,16 @@ class AWNoFormatter : public AWAbstractFormatter public: explicit AWNoFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWNoFormatter(); - QString convert(const QVariant &_value) const; - AWNoFormatter *copy(const QString &_fileName, const int _number); + ~AWNoFormatter() override; + QString convert(const QVariant &_value) const override; + AWNoFormatter *copy(const QString &_fileName, const int _number) override; public slots: - int showConfiguration(const QVariant &_args); + int showConfiguration(const QVariant &_args) override; private: Ui::AWNoFormatter *ui = nullptr; - void translate(); + void translate() override; // properties }; diff --git a/sources/awesomewidgets/awscriptformatter.cpp b/sources/awesomewidgets/awscriptformatter.cpp index 455e932..9ba6315 100644 --- a/sources/awesomewidgets/awscriptformatter.cpp +++ b/sources/awesomewidgets/awscriptformatter.cpp @@ -72,7 +72,7 @@ AWScriptFormatter *AWScriptFormatter::copy(const QString &_fileName, const int _ { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWScriptFormatter *item = new AWScriptFormatter(static_cast(parent()), _fileName); + auto *item = new AWScriptFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setAppendCode(appendCode()); item->setCode(code()); diff --git a/sources/awesomewidgets/awscriptformatter.h b/sources/awesomewidgets/awscriptformatter.h index 06cf4ac..71e5967 100644 --- a/sources/awesomewidgets/awscriptformatter.h +++ b/sources/awesomewidgets/awscriptformatter.h @@ -36,9 +36,9 @@ class AWScriptFormatter : public AWAbstractFormatter public: explicit AWScriptFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWScriptFormatter(); - QString convert(const QVariant &_value) const; - AWScriptFormatter *copy(const QString &_fileName, const int _number); + ~AWScriptFormatter() override; + QString convert(const QVariant &_value) const override; + AWScriptFormatter *copy(const QString &_fileName, const int _number) override; // properties bool appendCode() const; QString code() const; @@ -49,14 +49,14 @@ public: void setHasReturn(const bool _hasReturn); public slots: - void readConfiguration(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private: Ui::AWScriptFormatter *ui = nullptr; void initProgram(); - void translate(); + void translate() override; // properties bool m_appendCode = true; QString m_code = ""; diff --git a/sources/awesomewidgets/awstringformatter.cpp b/sources/awesomewidgets/awstringformatter.cpp index 87a19d6..952238e 100644 --- a/sources/awesomewidgets/awstringformatter.cpp +++ b/sources/awesomewidgets/awstringformatter.cpp @@ -63,7 +63,7 @@ AWStringFormatter *AWStringFormatter::copy(const QString &_fileName, const int _ { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - AWStringFormatter *item = new AWStringFormatter(static_cast(parent()), _fileName); + auto *item = new AWStringFormatter(dynamic_cast(parent()), _fileName); AWAbstractFormatter::copyDefaults(item); item->setCount(count()); item->setFillChar(fillChar()); diff --git a/sources/awesomewidgets/awstringformatter.h b/sources/awesomewidgets/awstringformatter.h index 2070bee..7af6516 100644 --- a/sources/awesomewidgets/awstringformatter.h +++ b/sources/awesomewidgets/awstringformatter.h @@ -35,9 +35,9 @@ class AWStringFormatter : public AWAbstractFormatter public: explicit AWStringFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~AWStringFormatter(); - QString convert(const QVariant &_value) const; - AWStringFormatter *copy(const QString &_fileName, const int _number); + ~AWStringFormatter() override; + QString convert(const QVariant &_value) const override; + AWStringFormatter *copy(const QString &_fileName, const int _number) override; // properties int count() const; QChar fillChar() const; @@ -47,13 +47,13 @@ public: void setForceWidth(const bool _forceWidth); public slots: - void readConfiguration(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private: Ui::AWStringFormatter *ui = nullptr; - void translate(); + void translate() override; // properties int m_count = 0; QChar m_fillChar = QChar(); diff --git a/sources/awesomewidgets/extitemaggregator.h b/sources/awesomewidgets/extitemaggregator.h index d0b4c9b..6bd106d 100644 --- a/sources/awesomewidgets/extitemaggregator.h +++ b/sources/awesomewidgets/extitemaggregator.h @@ -44,7 +44,7 @@ public: initItems(); }; - virtual ~ExtItemAggregator() + ~ExtItemAggregator() override { qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; @@ -61,7 +61,7 @@ public: qCInfo(LOG_LIB) << "Dialog returns" << ret; }; - void initItems() + void initItems() override { m_items.clear(); m_activeItems.clear(); @@ -117,13 +117,13 @@ public: return found; }; - QList items() const { return m_items; }; + QList items() const override { return m_items; }; private: QList m_items; QList m_activeItems; - void doCreateItem() { return createItem(); } + void doCreateItem() override { return createItem(); } QList getItems() { diff --git a/sources/awesomewidgets/extnetworkrequest.cpp b/sources/awesomewidgets/extnetworkrequest.cpp index 73f9e92..ac23f90 100644 --- a/sources/awesomewidgets/extnetworkrequest.cpp +++ b/sources/awesomewidgets/extnetworkrequest.cpp @@ -69,7 +69,7 @@ ExtNetworkRequest *ExtNetworkRequest::copy(const QString &_fileName, const int _ { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtNetworkRequest *item = new ExtNetworkRequest(static_cast(parent()), _fileName); + auto *item = new ExtNetworkRequest(dynamic_cast(parent()), _fileName); copyDefaults(item); item->setNumber(_number); item->setStringUrl(stringUrl()); diff --git a/sources/awesomewidgets/extnetworkrequest.h b/sources/awesomewidgets/extnetworkrequest.h index 80fc3c3..b55e2a3 100644 --- a/sources/awesomewidgets/extnetworkrequest.h +++ b/sources/awesomewidgets/extnetworkrequest.h @@ -35,19 +35,19 @@ class ExtNetworkRequest : public AbstractExtItem public: explicit ExtNetworkRequest(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~ExtNetworkRequest(); - ExtNetworkRequest *copy(const QString &_fileName, const int _number); + ~ExtNetworkRequest() override; + ExtNetworkRequest *copy(const QString &_fileName, const int _number) override; // get methods QString stringUrl() const; - QString uniq() const; + QString uniq() const override; // set methods void setStringUrl(const QString &_url); public slots: - void readConfiguration(); - QVariantHash run(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + QVariantHash run() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private slots: void networkReplyReceived(QNetworkReply *_reply); @@ -59,7 +59,7 @@ private: bool m_isRunning = false; Ui::ExtNetworkRequest *ui = nullptr; void initUrl(); - void translate(); + void translate() override; // properties QString m_stringUrl = "https://httpbin.org/get"; // values diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 1eb2ca4..2c9e0d3 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -27,7 +27,6 @@ #include "awdebug.h" #include "stooqquotesprovider.h" -#include "yahooquotesprovider.h" ExtQuotes::ExtQuotes(QWidget *_parent, const QString &_filePath) @@ -75,7 +74,7 @@ ExtQuotes *ExtQuotes::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtQuotes *item = new ExtQuotes(static_cast(parent()), _fileName); + auto *item = new ExtQuotes(dynamic_cast(parent()), _fileName); copyDefaults(item); item->setNumber(_number); item->setTicker(ticker()); diff --git a/sources/awesomewidgets/extquotes.h b/sources/awesomewidgets/extquotes.h index 9237b31..439fac6 100644 --- a/sources/awesomewidgets/extquotes.h +++ b/sources/awesomewidgets/extquotes.h @@ -36,19 +36,19 @@ class ExtQuotes : public AbstractExtItem public: explicit ExtQuotes(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~ExtQuotes(); - ExtQuotes *copy(const QString &_fileName, const int _number); + ~ExtQuotes() override; + ExtQuotes *copy(const QString &_fileName, const int _number) override; // get methods QString ticker() const; - QString uniq() const; + QString uniq() const override; // set methods void setTicker(const QString &_ticker); public slots: - void readConfiguration(); - QVariantHash run(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + QVariantHash run() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private slots: void quotesReplyReceived(QNetworkReply *_reply); @@ -60,7 +60,7 @@ private: bool m_isRunning = false; Ui::ExtQuotes *ui = nullptr; void initProvider(); - void translate(); + void translate() override; // properties QString m_ticker = "EURUSD=X"; // values diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index 8f0118d..e38a4a0 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -67,7 +67,7 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtScript *item = new ExtScript(static_cast(parent()), _fileName); + auto *item = new ExtScript(dynamic_cast(parent()), _fileName); copyDefaults(item); item->setExecutable(executable()); item->setNumber(_number); @@ -79,7 +79,7 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number) } -QString ExtScript::jsonFiltersFile() const +QString ExtScript::jsonFiltersFile() { QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, @@ -253,7 +253,7 @@ void ExtScript::readJsonFilters() QString jsonText = jsonFile.readAll(); jsonFile.close(); - QJsonParseError error; + QJsonParseError error{}; QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error); if (error.error != QJsonParseError::NoError) { qCWarning(LOG_LIB) << "Parse error" << error.errorString(); diff --git a/sources/awesomewidgets/extscript.h b/sources/awesomewidgets/extscript.h index 79126dc..0f83a10 100644 --- a/sources/awesomewidgets/extscript.h +++ b/sources/awesomewidgets/extscript.h @@ -40,15 +40,15 @@ public: enum class Redirect { stdout2stderr = 0, nothing = 1, stderr2stdout = 2, swap = 3 }; explicit ExtScript(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~ExtScript(); - ExtScript *copy(const QString &_fileName, const int _number); - QString jsonFiltersFile() const; + ~ExtScript() override; + ExtScript *copy(const QString &_fileName, const int _number) override; + static QString jsonFiltersFile(); // get methods QString executable() const; QStringList filters() const; QString prefix() const; Redirect redirect() const; - QString uniq() const; + QString uniq() const override; // derivatives QString strRedirect() const; // set methods @@ -62,11 +62,11 @@ public: void updateFilter(const QString &_filter, const bool _add); public slots: - void readConfiguration(); + void readConfiguration() override; void readJsonFilters(); - QVariantHash run(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + QVariantHash run() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private slots: void startProcess(); @@ -75,7 +75,7 @@ private slots: private: QProcess *m_process = nullptr; Ui::ExtScript *ui = nullptr; - void translate(); + void translate() override; // properties QString m_executable = "/usr/bin/true"; QStringList m_filters = QStringList(); diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 303bc45..3461f8c 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -63,7 +63,7 @@ ExtUpgrade *ExtUpgrade::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - ExtUpgrade *item = new ExtUpgrade(static_cast(parent()), _fileName); + auto *item = new ExtUpgrade(dynamic_cast(parent()), _fileName); copyDefaults(item); item->setExecutable(executable()); item->setFilter(filter()); @@ -218,7 +218,7 @@ void ExtUpgrade::updateValue() QString qoutput = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); - m_values[tag("pkgcount")] = [this](QString output) { + m_values[tag("pkgcount")] = [this](const QString &output) { return filter().isEmpty() ? output.split('\n', QString::SkipEmptyParts).count() - null() : output.split('\n', QString::SkipEmptyParts).filter(QRegExp(filter())).count(); diff --git a/sources/awesomewidgets/extupgrade.h b/sources/awesomewidgets/extupgrade.h index f079144..aedc0dc 100644 --- a/sources/awesomewidgets/extupgrade.h +++ b/sources/awesomewidgets/extupgrade.h @@ -37,23 +37,23 @@ class ExtUpgrade : public AbstractExtItem public: explicit ExtUpgrade(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~ExtUpgrade(); - ExtUpgrade *copy(const QString &_fileName, const int _number); + ~ExtUpgrade() override; + ExtUpgrade *copy(const QString &_fileName, const int _number) override; // get methods QString executable() const; QString filter() const; int null() const; - QString uniq() const; + QString uniq() const override; // set methods void setExecutable(const QString &_executable); void setFilter(const QString &_filter); void setNull(const int _null); public slots: - void readConfiguration(); - QVariantHash run(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + QVariantHash run() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private slots: void startProcess(); @@ -62,7 +62,7 @@ private slots: private: QProcess *m_process = nullptr; Ui::ExtUpgrade *ui = nullptr; - void translate(); + void translate() override; // properties QString m_executable = "/usr/bin/true"; QString m_filter = ""; diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index cca7b87..4853fa6 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -77,7 +77,7 @@ ExtWeather *ExtWeather::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "number" << _number; - ExtWeather *item = new ExtWeather(static_cast(parent()), _fileName); + auto *item = new ExtWeather(dynamic_cast(parent()), _fileName); copyDefaults(item); item->setCity(city()); item->setCountry(country()); @@ -90,7 +90,7 @@ ExtWeather *ExtWeather::copy(const QString &_fileName, const int _number) } -QString ExtWeather::jsonMapFile() const +QString ExtWeather::jsonMapFile() { QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, @@ -248,7 +248,7 @@ void ExtWeather::readJsonMap() QString jsonText = jsonFile.readAll(); jsonFile.close(); - QJsonParseError error; + QJsonParseError error{}; QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error); if (error.error != QJsonParseError::NoError) { qCWarning(LOG_LIB) << "Parse error" << error.errorString(); @@ -345,7 +345,7 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *_reply) } m_isRunning = false; - QJsonParseError error; + QJsonParseError error{}; QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error); _reply->deleteLater(); if (error.error != QJsonParseError::NoError) { diff --git a/sources/awesomewidgets/extweather.h b/sources/awesomewidgets/extweather.h index 8894dc3..b9ab53c 100644 --- a/sources/awesomewidgets/extweather.h +++ b/sources/awesomewidgets/extweather.h @@ -43,9 +43,9 @@ public: enum class Provider { OWM = 0, Yahoo = 1 }; explicit ExtWeather(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~ExtWeather(); - ExtWeather *copy(const QString &_fileName, const int _number); - QString jsonMapFile() const; + ~ExtWeather() override; + ExtWeather *copy(const QString &_fileName, const int _number) override; + static QString jsonMapFile(); QString weatherFromInt(const int _id) const; // get methods QString city() const; @@ -54,7 +54,7 @@ public: Provider provider() const; QString strProvider() const; int ts() const; - QString uniq() const; + QString uniq() const override; // set methods void setCity(const QString &_city); void setCountry(const QString &_country); @@ -64,11 +64,11 @@ public: void setTs(const int _ts); public slots: - void readConfiguration(); + void readConfiguration() override; void readJsonMap(); - QVariantHash run(); - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + QVariantHash run() override; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private slots: void sendRequest(); @@ -80,7 +80,7 @@ private: bool m_isRunning = false; Ui::ExtWeather *ui = nullptr; void initProvider(); - void translate(); + void translate() override; // properties QString m_city = "London"; QString m_country = "uk"; diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 28ca2e1..4b9bd6f 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -75,7 +75,7 @@ GraphicalItem *GraphicalItem::copy(const QString &_fileName, const int _number) { qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number; - GraphicalItem *item = new GraphicalItem(static_cast(parent()), _fileName); + auto *item = new GraphicalItem(dynamic_cast(parent()), _fileName); copyDefaults(item); item->setActiveColor(activeColor()); item->setBar(bar()); @@ -486,8 +486,8 @@ int GraphicalItem::showConfiguration(const QVariant &_args) setCount(ui->spinBox_count->value()); setCustom(ui->checkBox_custom->isChecked()); setBar(m_custom ? ui->lineEdit_customValue->text() : ui->comboBox_value->currentText()); - setMaxValue(ui->doubleSpinBox_max->value()); - setMinValue(ui->doubleSpinBox_min->value()); + setMaxValue(static_cast(ui->doubleSpinBox_max->value())); + setMinValue(static_cast(ui->doubleSpinBox_min->value())); setActiveColor(ui->lineEdit_activeColor->text()); setInactiveColor(ui->lineEdit_inactiveColor->text()); setType(static_cast(ui->comboBox_type->currentIndex())); diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index cc00212..544a193 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -53,8 +53,8 @@ public: enum class Type { Horizontal = 0, Vertical = 1, Circle = 2, Graph = 3, Bars = 4 }; explicit GraphicalItem(QWidget *_parent = nullptr, const QString &_filePath = ""); - virtual ~GraphicalItem(); - GraphicalItem *copy(const QString &_fileName, const int _number); + ~GraphicalItem() override; + GraphicalItem *copy(const QString &_fileName, const int _number) override; QString image(const QVariant &value); void initScene(); // get methods @@ -72,7 +72,7 @@ public: Direction direction() const; QString strDirection() const; QStringList usedKeys() const; - QString uniq() const; + QString uniq() const override; // set methods void setBar(const QString &_bar); void setActiveColor(const QString &_color); @@ -90,10 +90,10 @@ public: void setUsedKeys(const QStringList &_usedKeys); public slots: - void readConfiguration(); - QVariantHash run() { return QVariantHash(); }; - int showConfiguration(const QVariant &_args); - void writeConfiguration() const; + void readConfiguration() override; + QVariantHash run() override { return QVariantHash(); }; + int showConfiguration(const QVariant &_args) override; + void writeConfiguration() const override; private slots: void changeColor(); @@ -105,7 +105,7 @@ private: QGraphicsScene *m_scene = nullptr; QGraphicsView *m_view = nullptr; Ui::GraphicalItem *ui = nullptr; - void translate(); + void translate() override; // properties QString m_bar = "cpu"; int m_count = 100; diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index fc8cca1..5a039d0 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -89,7 +89,7 @@ void GraphicalItemHelper::paintBars(const float _value) // default norms float normX = static_cast(m_width) / static_cast(m_values.count()); - float normY = static_cast(m_height - 1); + auto normY = static_cast(m_height - 1); // paint graph for (int i = 0; i < m_values.count(); i++) { float x = i * normX; @@ -113,11 +113,11 @@ void GraphicalItemHelper::paintCircle(const float _percent) // inactive circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_inactivePen, m_inactivePen.brush()); - circle->setSpanAngle(-(1.0f - _percent) * 360.0f * 16.0f); - circle->setStartAngle(90.0f * 16.0f - _percent * 360.0f * 16.0f); + circle->setSpanAngle(static_cast(-(1.0f - _percent) * 360.0f * 16.0f)); + circle->setStartAngle(static_cast(90.0f * 16.0f - _percent * 360.0f * 16.0f)); // active circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_activePen, m_activePen.brush()); - circle->setSpanAngle(-_percent * 360.0f * 16.0f); + circle->setSpanAngle(static_cast(-_percent * 360.0f * 16.0f)); circle->setStartAngle(90 * 16); } @@ -133,7 +133,7 @@ void GraphicalItemHelper::paintGraph(const float _value) // default norms float normX = static_cast(m_width) / static_cast(m_values.count()); - float normY = static_cast(m_height - 1); + auto normY = static_cast(m_height - 1); // paint graph for (int i = 0; i < m_values.count() - 1; i++) { // some magic here diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index f79dff5..8cbb1b4 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -31,7 +31,7 @@ class GraphicalItemHelper : public QObject public: explicit GraphicalItemHelper(QObject *_parent = nullptr, QGraphicsScene *_scene = nullptr); - virtual ~GraphicalItemHelper(); + ~GraphicalItemHelper() override; // parameters void setParameters(const QString &_active, const QString &_inactive, const int _width, const int _height, const int _count); @@ -42,9 +42,9 @@ public: void paintHorizontal(const float _percent); void paintVertical(const float _percent); // additional conversion methods - float getPercents(const float _value, const float _min, const float _max); - bool isColor(const QString &_input); - QColor stringToColor(const QString &_color); + static float getPercents(const float _value, const float _min, const float _max); + static bool isColor(const QString &_input); + static QColor stringToColor(const QString &_color); private: void storeValue(const float _value); diff --git a/sources/awesomewidgets/owmweatherprovider.h b/sources/awesomewidgets/owmweatherprovider.h index 7c23f8c..3222e5c 100644 --- a/sources/awesomewidgets/owmweatherprovider.h +++ b/sources/awesomewidgets/owmweatherprovider.h @@ -32,10 +32,10 @@ public: const char *OWM_FORECAST_URL = "https://arcanis.me/forecast"; explicit OWMWeatherProvider(QObject *_parent); - virtual ~OWMWeatherProvider(); - void initUrl(const QString &_city, const QString &_country, const int); - QVariantHash parse(const QVariantMap &_json) const; - QUrl url() const; + ~OWMWeatherProvider() override; + void initUrl(const QString &_city, const QString &_country, const int) override; + QVariantHash parse(const QVariantMap &_json) const override; + QUrl url() const override; private: QVariantHash parseSingleJson(const QVariantMap &_json) const; diff --git a/sources/awesomewidgets/qcronscheduler.cpp b/sources/awesomewidgets/qcronscheduler.cpp index 894a638..c72abc9 100644 --- a/sources/awesomewidgets/qcronscheduler.cpp +++ b/sources/awesomewidgets/qcronscheduler.cpp @@ -76,7 +76,7 @@ void QCronScheduler::expired() } -QList QCronScheduler::parseField(const QString &_value, const int _min, const int _max) const +QList QCronScheduler::parseField(const QString &_value, const int _min, const int _max) { qCDebug(LOG_LIB) << "Parse field" << _value << "with corner values" << _min << _max; diff --git a/sources/awesomewidgets/qcronscheduler.h b/sources/awesomewidgets/qcronscheduler.h index cfcbdec..b42c495 100644 --- a/sources/awesomewidgets/qcronscheduler.h +++ b/sources/awesomewidgets/qcronscheduler.h @@ -44,7 +44,7 @@ public: } QCronField; explicit QCronScheduler(QObject *_parent = nullptr); - virtual ~QCronScheduler(); + ~QCronScheduler() override; void parse(const QString &_timer); signals: @@ -56,7 +56,7 @@ private slots: private: QCronRunSchedule m_schedule; QTimer *m_timer = nullptr; - QList parseField(const QString &_value, const int _min, const int _max) const; + static QList parseField(const QString &_value, const int _min, const int _max); }; diff --git a/sources/awesomewidgets/stooqquotesprovider.h b/sources/awesomewidgets/stooqquotesprovider.h index f38b068..ae232d7 100644 --- a/sources/awesomewidgets/stooqquotesprovider.h +++ b/sources/awesomewidgets/stooqquotesprovider.h @@ -29,10 +29,10 @@ public: const char *STOOQ_QUOTES_URL = "https://stooq.com/q/l/"; explicit StooqQuotesProvider(QObject *_parent); - virtual ~StooqQuotesProvider(); - void initUrl(const QString &_asset); - QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const; - QUrl url() const; + ~StooqQuotesProvider() override; + void initUrl(const QString &_asset) override; + QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override; + QUrl url() const override; private: QUrl m_url; diff --git a/sources/awesomewidgets/yahooquotesprovider.cpp b/sources/awesomewidgets/yahooquotesprovider.cpp index fb8d29e..d7ddac6 100644 --- a/sources/awesomewidgets/yahooquotesprovider.cpp +++ b/sources/awesomewidgets/yahooquotesprovider.cpp @@ -56,7 +56,7 @@ QVariantHash YahooQuotesProvider::parse(const QByteArray &_source, QVariantHash values; - QJsonParseError error; + QJsonParseError error{}; QJsonDocument jsonDoc = QJsonDocument::fromJson(_source, &error); if (error.error != QJsonParseError::NoError) { qCWarning(LOG_LIB) << "Parse error" << error.errorString(); diff --git a/sources/awesomewidgets/yahooquotesprovider.h b/sources/awesomewidgets/yahooquotesprovider.h index 00369b7..c63a007 100644 --- a/sources/awesomewidgets/yahooquotesprovider.h +++ b/sources/awesomewidgets/yahooquotesprovider.h @@ -30,10 +30,10 @@ public: const char *YAHOO_QUOTES_QUERY = "select * from yahoo.finance.quotes where symbol='%1'"; explicit YahooQuotesProvider(QObject *_parent); - virtual ~YahooQuotesProvider(); - void initUrl(const QString &_asset); - QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const; - QUrl url() const; + ~YahooQuotesProvider() override; + void initUrl(const QString &_asset) override; + QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override; + QUrl url() const override; private: QUrl m_url; diff --git a/sources/awesomewidgets/yahooweatherprovider.h b/sources/awesomewidgets/yahooweatherprovider.h index 8d99ef6..20e0eee 100644 --- a/sources/awesomewidgets/yahooweatherprovider.h +++ b/sources/awesomewidgets/yahooweatherprovider.h @@ -32,10 +32,10 @@ public: "geo.places(1) where text='%1, %2')"; explicit YahooWeatherProvider(QObject *_parent); - virtual ~YahooWeatherProvider(); - void initUrl(const QString &_city, const QString &_country, const int); - QVariantHash parse(const QVariantMap &_json) const; - QUrl url() const; + ~YahooWeatherProvider() override; + void initUrl(const QString &_city, const QString &_country, const int) override; + QVariantHash parse(const QVariantMap &_json) const override; + QUrl url() const override; private: QVariantHash parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const; diff --git a/sources/desktop-panel/metadata.desktop b/sources/desktop-panel/metadata.desktop index f18af63..a2df8bf 100644 --- a/sources/desktop-panel/metadata.desktop +++ b/sources/desktop-panel/metadata.desktop @@ -15,7 +15,6 @@ Icon=utilities-system-monitor X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com diff --git a/sources/desktop-panel/package/metadata.desktop b/sources/desktop-panel/package/metadata.desktop index 8620000..db9fc5c 100644 --- a/sources/desktop-panel/package/metadata.desktop +++ b/sources/desktop-panel/package/metadata.desktop @@ -15,7 +15,6 @@ Icon=utilities-system-monitor X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com diff --git a/sources/desktop-panel/plugin/desktoppanel.h b/sources/desktop-panel/plugin/desktoppanel.h index cd7d0cb..49d50db 100644 --- a/sources/desktop-panel/plugin/desktoppanel.h +++ b/sources/desktop-panel/plugin/desktoppanel.h @@ -28,7 +28,7 @@ class DPPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void registerTypes(const char *uri); + void registerTypes(const char *uri) override; }; diff --git a/sources/desktop-panel/plugin/dpadds.cpp b/sources/desktop-panel/plugin/dpadds.cpp index 15842f4..1b53277 100644 --- a/sources/desktop-panel/plugin/dpadds.cpp +++ b/sources/desktop-panel/plugin/dpadds.cpp @@ -56,19 +56,19 @@ DPAdds::~DPAdds() // HACK: since QML could not use QLoggingCategory I need this hack -bool DPAdds::isDebugEnabled() const +bool DPAdds::isDebugEnabled() { return LOG_DP().isDebugEnabled(); } -int DPAdds::currentDesktop() const +int DPAdds::currentDesktop() { return KWindowSystem::currentDesktop(); } -QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp) const +QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp) { qCDebug(LOG_DP) << "Should be sorted" << _sorted << "and filter applied" << _regexp; @@ -85,7 +85,7 @@ QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp) const } -int DPAdds::numberOfDesktops() const +int DPAdds::numberOfDesktops() { return KWindowSystem::numberOfDesktops(); } @@ -104,13 +104,13 @@ QString DPAdds::toolTipImage(const int _desktop) const if (m_tooltipType == "names") { QStringList windowList; std::for_each(info.windowsData.cbegin(), info.windowsData.cend(), - [&windowList](WindowData data) { windowList.append(data.name); }); + [&windowList](const WindowData &data) { windowList.append(data.name); }); return QString("
    • %1
    ").arg(windowList.join("
  • ")); } // init - QGraphicsScene *toolTipScene = new QGraphicsScene(); - QGraphicsView *toolTipView = new QGraphicsView(toolTipScene); + auto *toolTipScene = new QGraphicsScene(); + auto *toolTipView = new QGraphicsView(toolTipScene); toolTipView->setStyleSheet("background: transparent"); toolTipView->setContentsMargins(0, 0, 0, 0); toolTipView->setFrameShape(QFrame::NoFrame); @@ -119,8 +119,8 @@ QString DPAdds::toolTipImage(const int _desktop) const // update float margin = 5.0f * info.desktop.width() / 400.0f; - toolTipView->resize(info.desktop.width() + 2.0f * margin, - info.desktop.height() + 2.0f * margin); + toolTipView->resize(static_cast(info.desktop.width() + 2.0f * margin), + static_cast(info.desktop.height() + 2.0f * margin)); toolTipScene->clear(); toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush)); // borders @@ -215,7 +215,7 @@ void DPAdds::setToolTipData(const QVariantMap &_tooltipData) } -QString DPAdds::infoByKey(const QString &_key) const +QString DPAdds::infoByKey(const QString &_key) { qCDebug(LOG_AW) << "Requested info for key" << _key; @@ -246,7 +246,7 @@ QString DPAdds::valueByKey(const QString &_key, int _desktop) const // HACK: this method uses variables from version.h -QString DPAdds::getAboutText(const QString &_type) const +QString DPAdds::getAboutText(const QString &_type) { qCDebug(LOG_DP) << "Type" << _type; @@ -254,7 +254,7 @@ QString DPAdds::getAboutText(const QString &_type) const } -QVariantMap DPAdds::getFont(const QVariantMap &_defaultFont) const +QVariantMap DPAdds::getFont(const QVariantMap &_defaultFont) { qCDebug(LOG_DP) << "Default font is" << _defaultFont; @@ -285,7 +285,7 @@ void DPAdds::sendNotification(const QString &_eventId, const QString &_message) // slot for mouse click -void DPAdds::setCurrentDesktop(const int _desktop) const +void DPAdds::setCurrentDesktop(const int _desktop) { qCDebug(LOG_DP) << "Desktop" << _desktop; @@ -293,7 +293,7 @@ void DPAdds::setCurrentDesktop(const int _desktop) const } -DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int _desktop) const +DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int _desktop) { qCDebug(LOG_DP) << "Desktop" << _desktop; diff --git a/sources/desktop-panel/plugin/dpadds.h b/sources/desktop-panel/plugin/dpadds.h index b8f8c2f..8604716 100644 --- a/sources/desktop-panel/plugin/dpadds.h +++ b/sources/desktop-panel/plugin/dpadds.h @@ -42,21 +42,21 @@ class DPAdds : public QObject public: explicit DPAdds(QObject *_parent = nullptr); - virtual ~DPAdds(); - Q_INVOKABLE bool isDebugEnabled() const; - Q_INVOKABLE int currentDesktop() const; - Q_INVOKABLE QStringList dictKeys(const bool _sorted = true, const QString &_regexp = "") const; - Q_INVOKABLE int numberOfDesktops() const; + ~DPAdds() override; + Q_INVOKABLE static bool isDebugEnabled(); + Q_INVOKABLE static int currentDesktop(); + Q_INVOKABLE static QStringList dictKeys(const bool _sorted = true, const QString &_regexp = ""); + Q_INVOKABLE static int numberOfDesktops(); Q_INVOKABLE QString toolTipImage(const int _desktop) const; Q_INVOKABLE QString parsePattern(const QString &_pattern, const int _desktop) const; // values Q_INVOKABLE void setMark(const QString &_newMark); Q_INVOKABLE void setToolTipData(const QVariantMap &_tooltipData); - Q_INVOKABLE QString infoByKey(const QString &_key) const; + Q_INVOKABLE static QString infoByKey(const QString &_key); Q_INVOKABLE QString valueByKey(const QString &_key, int _desktop = -1) const; // configuration slots - Q_INVOKABLE QString getAboutText(const QString &_type) const; - Q_INVOKABLE QVariantMap getFont(const QVariantMap &_defaultFont) const; + Q_INVOKABLE static QString getAboutText(const QString &_type); + Q_INVOKABLE static QVariantMap getFont(const QVariantMap &_defaultFont); signals: void desktopChanged() const; @@ -64,10 +64,10 @@ signals: public slots: Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message); - Q_INVOKABLE void setCurrentDesktop(const int _desktop) const; + Q_INVOKABLE static void setCurrentDesktop(const int _desktop); private: - DesktopWindowsInfo getInfoByDesktop(const int _desktop) const; + static DesktopWindowsInfo getInfoByDesktop(const int _desktop); // variables int m_tooltipWidth = 200; QString m_mark = "*"; diff --git a/sources/extsysmon/extsysmon.h b/sources/extsysmon/extsysmon.h index a211579..c1aded3 100644 --- a/sources/extsysmon/extsysmon.h +++ b/sources/extsysmon/extsysmon.h @@ -29,12 +29,12 @@ class ExtendedSysMon : public Plasma::DataEngine public: explicit ExtendedSysMon(QObject *_parent, const QVariantList &_args); - virtual ~ExtendedSysMon(); + ~ExtendedSysMon() override; protected: - QStringList sources() const; - bool sourceRequestEvent(const QString &_source); - bool updateSourceEvent(const QString &_source); + QStringList sources() const override; + bool sourceRequestEvent(const QString &_source) override; + bool updateSourceEvent(const QString &_source) override; private: // configuration diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index 2ab3e6e..36f8dff 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -30,6 +30,7 @@ #include "processessource.h" #include "quotessource.h" #include "requestsource.h" +#include "systeminfosource.h" #include "upgradesource.h" #include "weathersource.h" @@ -135,6 +136,10 @@ void ExtSysMonAggregator::init(const QHash &_config) AbstractExtSysMonSource *quotesItem = new QuotesSource(this, QStringList()); for (auto &source : quotesItem->sources()) m_map[source] = quotesItem; + // system + AbstractExtSysMonSource *systemItem = new SystemInfoSource(this, QStringList()); + for (auto &source : systemItem->sources()) + m_map[source] = systemItem; // upgrade AbstractExtSysMonSource *upgradeItem = new UpgradeSource(this, QStringList()); for (auto &source : upgradeItem->sources()) diff --git a/sources/extsysmon/extsysmonaggregator.h b/sources/extsysmon/extsysmonaggregator.h index f752f53..6543fe5 100644 --- a/sources/extsysmon/extsysmonaggregator.h +++ b/sources/extsysmon/extsysmonaggregator.h @@ -29,7 +29,7 @@ class ExtSysMonAggregator : public QObject public: explicit ExtSysMonAggregator(QObject *_parent, const QHash &_config); - virtual ~ExtSysMonAggregator(); + ~ExtSysMonAggregator() override; QVariant data(const QString &_source) const; bool hasSource(const QString &_source) const; QVariantMap initialData(const QString &_source) const; diff --git a/sources/extsysmonsources/abstractextsysmonsource.h b/sources/extsysmonsources/abstractextsysmonsource.h index f2d97cc..5b5dcc8 100644 --- a/sources/extsysmonsources/abstractextsysmonsource.h +++ b/sources/extsysmonsources/abstractextsysmonsource.h @@ -30,13 +30,13 @@ class AbstractExtSysMonSource : public QObject public: explicit AbstractExtSysMonSource(QObject *_parent, const QStringList &) : QObject(_parent){}; - virtual ~AbstractExtSysMonSource(){}; + ~AbstractExtSysMonSource() override = default; virtual QVariant data(const QString &_source) = 0; virtual QVariantMap initialData(const QString &_source) const = 0; virtual void run() = 0; virtual QStringList sources() const = 0; // used by extensions - int index(const QString &_source) const + static int index(const QString &_source) { QRegExp rx("\\d+"); rx.indexIn(_source); diff --git a/sources/extsysmonsources/batterysource.h b/sources/extsysmonsources/batterysource.h index 11763f3..5de7efd 100644 --- a/sources/extsysmonsources/batterysource.h +++ b/sources/extsysmonsources/batterysource.h @@ -32,15 +32,15 @@ public: const int TREND_LIMIT = 20; explicit BatterySource(QObject *_parent, const QStringList &_args); - virtual ~BatterySource(); + ~BatterySource() override; QStringList getSources(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(); - QStringList sources() const; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; private: - double approximate(const QList &_trend); + static double approximate(const QList &_trend); void calculateRates(); // configuration and values int m_batteriesCount = 0; diff --git a/sources/extsysmonsources/customsource.h b/sources/extsysmonsources/customsource.h index fb36c82..290bcd6 100644 --- a/sources/extsysmonsources/customsource.h +++ b/sources/extsysmonsources/customsource.h @@ -32,11 +32,11 @@ class CustomSource : public AbstractExtSysMonSource public: explicit CustomSource(QObject *_parent, const QStringList &_args); - virtual ~CustomSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~CustomSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/desktopsource.h b/sources/extsysmonsources/desktopsource.h index 2fab1e9..8a2b235 100644 --- a/sources/extsysmonsources/desktopsource.h +++ b/sources/extsysmonsources/desktopsource.h @@ -29,11 +29,11 @@ class DesktopSource : public AbstractExtSysMonSource public: explicit DesktopSource(QObject *_parent, const QStringList &_args); - virtual ~DesktopSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~DesktopSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; }; diff --git a/sources/extsysmonsources/gpuloadsource.cpp b/sources/extsysmonsources/gpuloadsource.cpp index f35d73c..ef59396 100644 --- a/sources/extsysmonsources/gpuloadsource.cpp +++ b/sources/extsysmonsources/gpuloadsource.cpp @@ -35,9 +35,8 @@ GPULoadSource::GPULoadSource(QObject *_parent, const QStringList &_args) m_process = new QProcess(nullptr); // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished - connect(m_process, - static_cast(&QProcess::finished), - [this](int, QProcess::ExitStatus) { return updateValue(); }); + connect(m_process, QOverload::of(&QProcess::finished), + [=](int, QProcess::ExitStatus) { return updateValue(); }); m_process->waitForFinished(0); } diff --git a/sources/extsysmonsources/gpuloadsource.h b/sources/extsysmonsources/gpuloadsource.h index 9cced01..8662cca 100644 --- a/sources/extsysmonsources/gpuloadsource.h +++ b/sources/extsysmonsources/gpuloadsource.h @@ -31,12 +31,12 @@ class GPULoadSource : public AbstractExtSysMonSource public: explicit GPULoadSource(QObject *_parent, const QStringList &_args); - virtual ~GPULoadSource(); + ~GPULoadSource() override; static QString autoGpu(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(); - QStringList sources() const; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; private slots: void updateValue(); diff --git a/sources/extsysmonsources/gputempsource.cpp b/sources/extsysmonsources/gputempsource.cpp index 6a3b796..efd7dcb 100644 --- a/sources/extsysmonsources/gputempsource.cpp +++ b/sources/extsysmonsources/gputempsource.cpp @@ -35,9 +35,8 @@ GPUTemperatureSource::GPUTemperatureSource(QObject *_parent, const QStringList & m_process = new QProcess(nullptr); // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished - connect(m_process, - static_cast(&QProcess::finished), - [this](int, QProcess::ExitStatus) { return updateValue(); }); + connect(m_process, QOverload::of(&QProcess::finished), + [=](int, QProcess::ExitStatus) { return updateValue(); }); m_process->waitForFinished(0); } diff --git a/sources/extsysmonsources/gputempsource.h b/sources/extsysmonsources/gputempsource.h index e570e32..cfd7edb 100644 --- a/sources/extsysmonsources/gputempsource.h +++ b/sources/extsysmonsources/gputempsource.h @@ -31,11 +31,11 @@ class GPUTemperatureSource : public AbstractExtSysMonSource public: explicit GPUTemperatureSource(QObject *_parent, const QStringList &_args); - virtual ~GPUTemperatureSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(); - QStringList sources() const; + ~GPUTemperatureSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; private slots: void updateValue(); diff --git a/sources/extsysmonsources/hddtempsource.cpp b/sources/extsysmonsources/hddtempsource.cpp index 361c7be..4d45a97 100644 --- a/sources/extsysmonsources/hddtempsource.cpp +++ b/sources/extsysmonsources/hddtempsource.cpp @@ -40,9 +40,8 @@ HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, const QStringList & for (auto &device : m_devices) { m_processes[device] = new QProcess(nullptr); // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished - connect(m_processes[device], - static_cast(&QProcess::finished), - [this, device](int, QProcess::ExitStatus) { return updateValue(device); }); + connect(m_processes[device], QOverload::of(&QProcess::finished), + [=](int, QProcess::ExitStatus) { return updateValue(device); }); m_processes[device]->waitForFinished(0); } } diff --git a/sources/extsysmonsources/hddtempsource.h b/sources/extsysmonsources/hddtempsource.h index 6116c12..de33c7a 100644 --- a/sources/extsysmonsources/hddtempsource.h +++ b/sources/extsysmonsources/hddtempsource.h @@ -31,12 +31,12 @@ class HDDTemperatureSource : public AbstractExtSysMonSource public: explicit HDDTemperatureSource(QObject *_parent, const QStringList &_args); - virtual ~HDDTemperatureSource(); + ~HDDTemperatureSource() override; static QStringList allHdd(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; private slots: void updateValue(const QString &_device); diff --git a/sources/extsysmonsources/loadsource.h b/sources/extsysmonsources/loadsource.h index a0990a9..e3f68f4 100644 --- a/sources/extsysmonsources/loadsource.h +++ b/sources/extsysmonsources/loadsource.h @@ -29,11 +29,11 @@ class LoadSource : public AbstractExtSysMonSource public: explicit LoadSource(QObject *_parent, const QStringList &_args); - virtual ~LoadSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~LoadSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; }; diff --git a/sources/extsysmonsources/networksource.cpp b/sources/extsysmonsources/networksource.cpp index ebe41ca..f201579 100644 --- a/sources/extsysmonsources/networksource.cpp +++ b/sources/extsysmonsources/networksource.cpp @@ -19,6 +19,8 @@ #include "networksource.h" #include +#include +#include #include "awdebug.h" @@ -28,6 +30,12 @@ NetworkSource::NetworkSource(QObject *_parent, const QStringList &_args) { Q_ASSERT(_args.count() == 0); qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; + + m_process = new QProcess(nullptr); + // fucking magic from http://doc.qt.io/qt-5/qprocess.html#finished + connect(m_process, QOverload::of(&QProcess::finished), + [=](int, QProcess::ExitStatus) { return updateSsid(); }); + m_process->waitForFinished(0); } @@ -41,23 +49,9 @@ QVariant NetworkSource::data(const QString &_source) { qCDebug(LOG_ESS) << "Source" << _source; - if (_source == "network/current/name") { - QString device = "lo"; - QList rawInterfaceList = QNetworkInterface::allInterfaces(); - qCInfo(LOG_ESS) << "Devices" << rawInterfaceList; - for (auto &interface : rawInterfaceList) { - if ((interface.flags().testFlag(QNetworkInterface::IsLoopBack)) - || (interface.flags().testFlag(QNetworkInterface::IsPointToPoint))) - continue; - if (interface.addressEntries().isEmpty()) - continue; - device = interface.name(); - break; - } - return device; - } - - return QVariant(); + if (!m_values.contains(_source)) + run(); + return m_values.take(_source); } @@ -72,16 +66,66 @@ QVariantMap NetworkSource::initialData(const QString &_source) const data["name"] = "Current network device name"; data["type"] = "QString"; data["units"] = ""; + } else if (_source == "network/current/ssid") { + data["min"] = ""; + data["max"] = ""; + data["name"] = "Current SSID name"; + data["type"] = "QString"; + data["units"] = ""; } return data; } +void NetworkSource::run() +{ + m_values["network/current/name"] = NetworkSource::getCurrentDevice(); + m_process->start("iwgetid -r"); +} + + QStringList NetworkSource::sources() const { QStringList sources; sources.append("network/current/name"); + sources.append("network/current/ssid"); return sources; } + + +void NetworkSource::updateSsid() +{ + qCInfo(LOG_ESS) << "Cmd returns" << m_process->exitCode(); + QString qdebug + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardError()).trimmed(); + qCInfo(LOG_ESS) << "Error" << qdebug; + QString qoutput + = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); + qCInfo(LOG_ESS) << "Output" << qoutput; + + m_values["network/current/ssid"] = qoutput; +} + + +QString NetworkSource::getCurrentDevice() +{ + qCDebug(LOG_ESS) << "Get current devices"; + + QString device = "lo"; + auto rawInterfaceList = QNetworkInterface::allInterfaces(); + qCInfo(LOG_ESS) << "Devices" << rawInterfaceList; + + for (auto &interface : rawInterfaceList) { + if ((interface.flags().testFlag(QNetworkInterface::IsLoopBack)) + || (interface.flags().testFlag(QNetworkInterface::IsPointToPoint))) + continue; + if (interface.addressEntries().isEmpty()) + continue; + device = interface.name(); + break; + } + + return device; +} diff --git a/sources/extsysmonsources/networksource.h b/sources/extsysmonsources/networksource.h index 1041605..7144543 100644 --- a/sources/extsysmonsources/networksource.h +++ b/sources/extsysmonsources/networksource.h @@ -23,17 +23,27 @@ #include "abstractextsysmonsource.h" +class QProcess; + class NetworkSource : public AbstractExtSysMonSource { Q_OBJECT public: explicit NetworkSource(QObject *_parent, const QStringList &_args); - virtual ~NetworkSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~NetworkSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; + +private slots: + void updateSsid(); + +private: + QVariantHash m_values; + QProcess *m_process = nullptr; + static QString getCurrentDevice(); }; diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index add634e..da0fd5a 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -66,7 +66,7 @@ QVariant PlayerSource::data(const QString &_source) } -QString PlayerSource::getAutoMpris() const +QString PlayerSource::getAutoMpris() { QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, "ListNames"); @@ -282,7 +282,7 @@ void PlayerSource::mpdSocketWritten(const qint64 _bytes) } -QVariantHash PlayerSource::defaultInfo() const +QVariantHash PlayerSource::defaultInfo() { QVariantHash info; info["player/album"] = "unknown"; @@ -300,7 +300,7 @@ QVariantHash PlayerSource::getPlayerMpdInfo() if (m_mpdSocket.state() == QAbstractSocket::UnconnectedState) { // connect to host qCInfo(LOG_ESS) << "Connect to" << m_mpdAddress << m_mpdPort; - m_mpdSocket.connectToHost(m_mpdAddress, m_mpdPort); + m_mpdSocket.connectToHost(m_mpdAddress, static_cast(m_mpdPort)); } else if (m_mpdSocket.state() == QAbstractSocket::ConnectedState) { // send request if (m_mpdSocket.write(MPD_STATUS_REQUEST) == -1) @@ -315,11 +315,11 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) const { qCDebug(LOG_ESS) << "MPRIS" << _mpris; - QVariantHash info = defaultInfo(); + auto info = defaultInfo(); if (_mpris.isEmpty()) return info; - QDBusConnection bus = QDBusConnection::sessionBus(); + auto bus = QDBusConnection::sessionBus(); // comes from the following request: // qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 // org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player @@ -328,12 +328,12 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) const // dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.vlc // /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get // string:'org.mpris.MediaPlayer2.Player' string:'Metadata' - QVariantList args = QVariantList({"org.mpris.MediaPlayer2.Player", "Metadata"}); + auto args = QVariantList({"org.mpris.MediaPlayer2.Player", "Metadata"}); QDBusMessage request = QDBusMessage::createMethodCall( QString("org.mpris.MediaPlayer2.%1").arg(_mpris), "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Get"); request.setArguments(args); - QDBusMessage response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT); + auto response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT); if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) { qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); } else { diff --git a/sources/extsysmonsources/playersource.h b/sources/extsysmonsources/playersource.h index ed30f78..ec42bce 100644 --- a/sources/extsysmonsources/playersource.h +++ b/sources/extsysmonsources/playersource.h @@ -35,12 +35,12 @@ public: const char *MPD_STATUS_REQUEST = "currentsong\nstatus\n"; explicit PlayerSource(QObject *_parent, const QStringList &_args); - virtual ~PlayerSource(); - QVariant data(const QString &_source); - QString getAutoMpris() const; - QVariantMap initialData(const QString &_source) const; - void run(); - QStringList sources() const; + ~PlayerSource() override; + QVariant data(const QString &_source) override; + static QString getAutoMpris(); + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; // additional method to build dynamic tags static QString buildString(const QString &_current, const QString &_value, const int _s); static QString stripString(const QString &_value, const int _s); @@ -53,7 +53,7 @@ private slots: void mpdSocketWritten(const qint64 _bytes); private: - inline QVariantHash defaultInfo() const; + static inline QVariantHash defaultInfo(); QVariantHash getPlayerMpdInfo(); QVariantHash getPlayerMprisInfo(const QString &_mpris) const; QTcpSocket m_mpdSocket; diff --git a/sources/extsysmonsources/processessource.h b/sources/extsysmonsources/processessource.h index 3193cab..2f44781 100644 --- a/sources/extsysmonsources/processessource.h +++ b/sources/extsysmonsources/processessource.h @@ -29,11 +29,11 @@ class ProcessesSource : public AbstractExtSysMonSource public: explicit ProcessesSource(QObject *_parent, const QStringList &_args); - virtual ~ProcessesSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(); - QStringList sources() const; + ~ProcessesSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; private: // configuration and values diff --git a/sources/extsysmonsources/quotessource.h b/sources/extsysmonsources/quotessource.h index ad250b1..21470bc 100644 --- a/sources/extsysmonsources/quotessource.h +++ b/sources/extsysmonsources/quotessource.h @@ -32,11 +32,11 @@ class QuotesSource : public AbstractExtSysMonSource public: explicit QuotesSource(QObject *_parent, const QStringList &_args); - virtual ~QuotesSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~QuotesSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/requestsource.h b/sources/extsysmonsources/requestsource.h index dd87ec0..6661aa4 100644 --- a/sources/extsysmonsources/requestsource.h +++ b/sources/extsysmonsources/requestsource.h @@ -32,11 +32,11 @@ class RequestSource : public AbstractExtSysMonSource public: explicit RequestSource(QObject *_parent, const QStringList &_args); - virtual ~RequestSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~RequestSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/systeminfosource.cpp b/sources/extsysmonsources/systeminfosource.cpp new file mode 100644 index 0000000..54848b1 --- /dev/null +++ b/sources/extsysmonsources/systeminfosource.cpp @@ -0,0 +1,174 @@ +/*************************************************************************** + * 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 "systeminfosource.h" + +#include +#include +#include + +#include + +#include "awdebug.h" + + +SystemInfoSource::SystemInfoSource(QObject *_parent, const QStringList &_args) + : AbstractExtSysMonSource(_parent, _args) +{ + Q_ASSERT(_args.count() == 0); + qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; +} + + +SystemInfoSource::~SystemInfoSource() +{ + qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; +} + + +QVariant SystemInfoSource::data(const QString &_source) +{ + qCDebug(LOG_ESS) << "Source" << _source; + + if (!m_values.contains(_source)) + run(); + return m_values.take(_source); +} + + +QVariantMap SystemInfoSource::initialData(const QString &_source) const +{ + qCDebug(LOG_ESS) << "Source" << _source; + + QVariantMap data; + if (_source == "system/brightness") { + data["min"] = 0.0; + data["max"] = 100.0; + data["name"] = "Screen brightness"; + data["type"] = "float"; + data["units"] = "%"; + } else if (_source == "system/volume") { + data["min"] = 0.0; + data["max"] = 100.0; + data["name"] = "Master volume"; + data["type"] = "float"; + data["units"] = "%"; + } + + return data; +} + + +void SystemInfoSource::run() +{ + m_values["system/brightness"] = SystemInfoSource::getCurrentBrightness(); + m_values["system/volume"] = SystemInfoSource::getCurrentVolume(); +} + + +QStringList SystemInfoSource::sources() const +{ + QStringList sources; + sources.append("system/brightness"); + sources.append("system/volume"); + + return sources; +} + + +QVariant SystemInfoSource::fromDBusVariant(const QVariant &value) +{ + return value.value().variant(); +} + + +float SystemInfoSource::getCurrentBrightness() +{ + qCDebug(LOG_ESS) << "Get current brightness"; + + auto maxBrightness = sendDBusRequest("org.kde.Solid.PowerManagement", + "/org/kde/Solid/PowerManagement/Actions/BrightnessControl", + "org.kde.Solid.PowerManagement.Actions.BrightnessControl", + "brightnessMax") + .toFloat(); + auto brightness + = sendDBusRequest("org.kde.Solid.PowerManagement", + "/org/kde/Solid/PowerManagement/Actions/BrightnessControl", + "org.kde.Solid.PowerManagement.Actions.BrightnessControl", "brightness") + .toFloat(); + + return std::round(100.0f * brightness / maxBrightness); +} + + +float SystemInfoSource::getCurrentVolume() +{ + qCDebug(LOG_ESS) << "Get current volume"; + + // current device first + auto currentMixer + = fromDBusVariant( + sendDBusRequest("org.kde.kmix", "/Mixers", "org.freedesktop.DBus.Properties", "Get", + QVariantList({"org.kde.KMix.MixSet", "currentMasterMixer"}))) + .toString(); + + if (currentMixer.isEmpty()) { + qCWarning(LOG_ESS) << "Mixer is empty"; + return std::numeric_limits::quiet_NaN(); + } + currentMixer.replace(":", "_").replace(".", "_").replace("-", "_"); + + // get capture device + auto currentControl + = fromDBusVariant( + sendDBusRequest("org.kde.kmix", "/Mixers", "org.freedesktop.DBus.Properties", "Get", + QVariantList({"org.kde.KMix.MixSet", "currentMasterControl"}))) + .toString(); + if (currentControl.isEmpty()) { + qCWarning(LOG_ESS) << "Control is empty"; + return std::numeric_limits::quiet_NaN(); + } + currentControl.replace(":", "_").replace(".", "_").replace("-", "_"); + + auto path = QString("/Mixers/%1/%2").arg(currentMixer).arg(currentControl); + return fromDBusVariant(sendDBusRequest("org.kde.kmix", path, "org.freedesktop.DBus.Properties", + "Get", QVariantList({"org.kde.KMix.Control", "volume"}))) + .toFloat(); +} + + +QVariant SystemInfoSource::sendDBusRequest(const QString &destination, const QString &path, + const QString &interface, const QString &method, + const QVariantList &args) +{ + qCDebug(LOG_ESS) << "Send dbus request" << destination << path << interface << method << args; + + auto bus = QDBusConnection::sessionBus(); + auto request = QDBusMessage::createMethodCall(destination, path, interface, method); + if (!args.isEmpty()) + request.setArguments(args); + + auto response = bus.call(request, QDBus::BlockWithGui, REQUEST_TIMEOUT); + + if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) { + qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); + return QVariant(); + } else { + return response.arguments().first(); + } +} diff --git a/sources/extsysmonsources/systeminfosource.h b/sources/extsysmonsources/systeminfosource.h new file mode 100644 index 0000000..521b025 --- /dev/null +++ b/sources/extsysmonsources/systeminfosource.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * 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 SYSTEMINFOSOURCE_H +#define SYSTEMINFOSOURCE_H + +#include + +#include "abstractextsysmonsource.h" + + +class SystemInfoSource : public AbstractExtSysMonSource +{ + Q_OBJECT + +public: + explicit SystemInfoSource(QObject *_parent, const QStringList &_args); + ~SystemInfoSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override; + QStringList sources() const override; + +private: + // configuration and values + QVariantHash m_values; + static QVariant fromDBusVariant(const QVariant &value); + static float getCurrentBrightness(); + static float getCurrentVolume(); + static QVariant sendDBusRequest(const QString &destination, const QString &path, + const QString &interface, const QString &method, + const QVariantList &args = QVariantList()); +}; + + +#endif /* SYSTEMINFOSOURCE_H */ diff --git a/sources/extsysmonsources/upgradesource.h b/sources/extsysmonsources/upgradesource.h index 99510ed..21db72c 100644 --- a/sources/extsysmonsources/upgradesource.h +++ b/sources/extsysmonsources/upgradesource.h @@ -32,11 +32,11 @@ class UpgradeSource : public AbstractExtSysMonSource public: explicit UpgradeSource(QObject *_parent, const QStringList &_args); - virtual ~UpgradeSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~UpgradeSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/weathersource.h b/sources/extsysmonsources/weathersource.h index 52983ad..3ed8cea 100644 --- a/sources/extsysmonsources/weathersource.h +++ b/sources/extsysmonsources/weathersource.h @@ -32,11 +32,11 @@ class WeatherSource : public AbstractExtSysMonSource public: explicit WeatherSource(QObject *_parent, const QStringList &_args); - virtual ~WeatherSource(); - QVariant data(const QString &_source); - QVariantMap initialData(const QString &_source) const; - void run(){}; - QStringList sources() const; + ~WeatherSource() override; + QVariant data(const QString &_source) override; + QVariantMap initialData(const QString &_source) const override; + void run() override{}; + QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/qml/General.qml b/sources/qml/General.qml index c96ede0..32885cf 100644 --- a/sources/qml/General.qml +++ b/sources/qml/General.qml @@ -68,7 +68,7 @@ QtObject { }, { "label": i18n("Network"), - "regexp": "^(netdev|(down|up(?!time)).*)" + "regexp": "^(netdev|ssid|(down|up(?!time)).*)" }, { "label": i18n("Network request"), @@ -82,6 +82,10 @@ QtObject { "label": i18n("Scripts"), "regexp": "^custom.*" }, + { + "label": i18n("System"), + "regexp": "^(volume|brightness)" + }, { "label": i18n("Time"), "regexp": ".*time$" diff --git a/sources/test/awtestlibrary.h b/sources/test/awtestlibrary.h index 4e3405f..87499ae 100644 --- a/sources/test/awtestlibrary.h +++ b/sources/test/awtestlibrary.h @@ -34,7 +34,7 @@ int randomInt(const int _max = 100); QString randomString(const int _min = 1, const int _max = 100); QStringList randomStringList(const int _max = 100); QStringList randomSelect(const QStringList &_available); -}; +} // namespace AWTestLibrary #endif /* AWTESTLIBRARY_H */ diff --git a/sources/test/testabstractformatter.h b/sources/test/testabstractformatter.h index ec94f93..dca1933 100644 --- a/sources/test/testabstractformatter.h +++ b/sources/test/testabstractformatter.h @@ -33,7 +33,7 @@ private slots: void initTestCase(); void cleanupTestCase(); // test - void test_values(); + static void test_values(); void test_type(); void test_copy(); diff --git a/sources/test/testawkeycache.h b/sources/test/testawkeycache.h index ec2ca37..cbeccde 100644 --- a/sources/test/testawkeycache.h +++ b/sources/test/testawkeycache.h @@ -29,7 +29,7 @@ class TestAWKeyCache : public QObject private slots: // initialization void initTestCase(); - void cleanupTestCase(); + static void cleanupTestCase(); // test private: diff --git a/sources/test/testawpatternfunctions.h b/sources/test/testawpatternfunctions.h index d0c09b5..2380e7e 100644 --- a/sources/test/testawpatternfunctions.h +++ b/sources/test/testawpatternfunctions.h @@ -29,7 +29,7 @@ class TestAWPatternFunctions : public QObject private slots: // initialization void initTestCase(); - void cleanupTestCase(); + static void cleanupTestCase(); // test void test_findFunctionCalls(); void test_findKeys(); diff --git a/sources/test/testfloatformatter.h b/sources/test/testfloatformatter.h index bdb0e0d..89ba3e4 100644 --- a/sources/test/testfloatformatter.h +++ b/sources/test/testfloatformatter.h @@ -33,7 +33,7 @@ private slots: void initTestCase(); void cleanupTestCase(); // test - void test_values(); + static void test_values(); void test_count(); void test_fillChar(); void test_forceWidth(); diff --git a/sources/test/testnoformatter.h b/sources/test/testnoformatter.h index b9cf531..6d52a54 100644 --- a/sources/test/testnoformatter.h +++ b/sources/test/testnoformatter.h @@ -33,7 +33,7 @@ private slots: void initTestCase(); void cleanupTestCase(); // test - void test_values(); + static void test_values(); void test_conversion(); void test_copy(); diff --git a/sources/test/testplayersource.h b/sources/test/testplayersource.h index 0b11bf5..4a3768b 100644 --- a/sources/test/testplayersource.h +++ b/sources/test/testplayersource.h @@ -31,7 +31,7 @@ class TestPlayerSource : public QObject private slots: // initialization void initTestCase(); - void cleanupTestCase(); + static void cleanupTestCase(); // test void _test_sources(const PlayerSource *_source); void test_buildString(); diff --git a/sources/test/teststringformatter.h b/sources/test/teststringformatter.h index 6ebe95d..a614aef 100644 --- a/sources/test/teststringformatter.h +++ b/sources/test/teststringformatter.h @@ -33,7 +33,7 @@ private slots: void initTestCase(); void cleanupTestCase(); // test - void test_values(); + static void test_values(); void test_count(); void test_fillChar(); void test_forceWidth(); diff --git a/sources/version.h.in b/sources/version.h.in index 8cdb0a3..e96897f 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -59,7 +59,7 @@ const char STATIC_KEYS[] "swap,downunits,upunits,downkb,downtotkb,downtot,down,uptotkb,uptot,upkb," "up,netdev,ac,bat,batleft,batnow,batrate,battotal,album,artist,duration," "progress,title,dalbum,dartist,dtitle,salbum,sartist,stitle,pscount,pstot" - ",ps,desktop,ndesktop,tdesktops,la15,la5,la1"; + ",ps,desktop,ndesktop,tdesktops,la15,la5,la1,ssid,volume,brightness"; #cmakedefine BUILD_FUTURE #cmakedefine BUILD_LOAD #cmakedefine BUILD_TESTING From e0df575aa993ab10ea5d2c73022ce07c14768381 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 15 Dec 2019 11:23:18 +0300 Subject: [PATCH 23/35] hanle new sources --- sources/awesome-widget/plugin/awdataenginemapper.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index fa7f004..82f1554 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -260,6 +260,10 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt // network device m_map[_source] = "netdev"; m_formatter["netdev"] = AWKeysAggregator::FormatterType::NoFormat; + } else if (_source == "network/current/ssid") { + // current ssid + m_map[_source] = "ssid"; + m_formatter["ssid"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source.startsWith("network/response")) { // network response QString key = _source; @@ -375,6 +379,12 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt // timestamp m_map.insertMulti(_source, "tstime"); m_formatter["tstime"] = AWKeysAggregator::FormatterType::Timestamp; + } else if (_source == "system/brightness") { + m_map[_source] = "brightness"; + m_formatter["brightness"] = AWKeysAggregator::FormatterType::IntegerThree; + } else if (_source == "system/volume") { + m_map[_source] = "volume"; + m_formatter["volume"] = AWKeysAggregator::FormatterType::IntegerThree; } else if (_source == "system/uptime") { // uptime m_map[_source] = "uptime"; From 0f19bce80ddefdcb3d1e814d6b328f7283d15e9e Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 15 Dec 2019 11:31:49 +0300 Subject: [PATCH 24/35] close process in destructor --- sources/extsysmonsources/networksource.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/extsysmonsources/networksource.cpp b/sources/extsysmonsources/networksource.cpp index f201579..48dd60f 100644 --- a/sources/extsysmonsources/networksource.cpp +++ b/sources/extsysmonsources/networksource.cpp @@ -42,6 +42,9 @@ NetworkSource::NetworkSource(QObject *_parent, const QStringList &_args) NetworkSource::~NetworkSource() { qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; + + m_process->kill(); + m_process->deleteLater(); } From e525cb47423796aa28f18423eb6e3893b9a4f991 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 18 Apr 2020 03:04:32 +0300 Subject: [PATCH 25/35] do not replace space to nbsp in some cases (#143) --- CONTRIBUTING.md | 2 +- README.md | 1 + sources/awesome-widget/plugin/awabstractpairhelper.cpp | 9 ++++++++- sources/awesome-widget/plugin/awabstractpairhelper.h | 1 + sources/awesome-widget/plugin/awcustomkeyshelper.cpp | 6 +++--- sources/awesome-widget/plugin/awkeycache.cpp | 8 ++++---- sources/awesome-widget/plugin/awkeys.cpp | 4 ++-- sources/awesome-widget/plugin/awkeysaggregator.cpp | 5 +++-- sources/awesome-widget/plugin/awkeysaggregator.h | 2 +- sources/awesome-widget/plugin/awpatternfunctions.cpp | 2 +- sources/compiler.cmake | 2 +- sources/test/testawtelemetryhandler.cpp | 2 +- 12 files changed, 27 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67bf515..7875483 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ for more details. To avoid manual labor there is automatic cmake target named * `Q_PROPERTY` macro is allowed and recommended for QObject based classes. * Qt macros (e.g. `signals`, `slots`, `Q_OBJECT`, etc) are allowed. In other hand `Q_FOREACH` (`foreach`) is not allowed use `for (auto &foo : bar)` instead. -* Current project standard is **C++11**. +* Current project standard is **C++17**. * Do not use C-like code: * C-like style iteration if possible. Use `for (auto &foo : bar)` and `std::for_each` instead if possible. It is also recommended to use iterators. diff --git a/README.md b/README.md index 0df934f..4b50279 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Optional dependencies * hddtemp * smartmontools * music player (mpd or MPRIS supported) +* wireless_tools Make dependencies ----------------- diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.cpp b/sources/awesome-widget/plugin/awabstractpairhelper.cpp index 43c828d..e8d8426 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.cpp +++ b/sources/awesome-widget/plugin/awabstractpairhelper.cpp @@ -58,6 +58,13 @@ QStringList AWAbstractPairHelper::values() const } +QSet AWAbstractPairHelper::valuesSet() const +{ + auto values = m_pairs.values(); + return QSet(values.cbegin(), values.cend()); +} + + void AWAbstractPairHelper::initItems() { m_pairs.clear(); @@ -131,4 +138,4 @@ bool AWAbstractPairHelper::removeUnusedKeys(const QStringList &_keys) const settings.sync(); return (settings.status() == QSettings::NoError); -} +} \ No newline at end of file diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.h b/sources/awesome-widget/plugin/awabstractpairhelper.h index 404fb84..bc05669 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.h +++ b/sources/awesome-widget/plugin/awabstractpairhelper.h @@ -30,6 +30,7 @@ public: QStringList keys() const; QHash pairs() const; QStringList values() const; + QSet valuesSet() const; // read-write methods virtual void initItems(); virtual bool writeItems(const QHash &_configuration) const; diff --git a/sources/awesome-widget/plugin/awcustomkeyshelper.cpp b/sources/awesome-widget/plugin/awcustomkeyshelper.cpp index efda044..0be9c4d 100644 --- a/sources/awesome-widget/plugin/awcustomkeyshelper.cpp +++ b/sources/awesome-widget/plugin/awcustomkeyshelper.cpp @@ -46,13 +46,13 @@ QString AWCustomKeysHelper::source(const QString &_key) const QStringList AWCustomKeysHelper::sources() const { - return QSet::fromList(values()).toList(); + return valuesSet().values(); } QStringList AWCustomKeysHelper::refinedSources() const { - auto allSources = QSet::fromList(pairs().values()); + auto allSources = valuesSet(); QSet output; while (output != allSources) { @@ -62,7 +62,7 @@ QStringList AWCustomKeysHelper::refinedSources() const allSources = output; } - return output.toList(); + return output.values(); } diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp index 92f77a5..15aab94 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -83,9 +83,9 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL << _tooltip; // initial copy - QSet used = QSet::fromList(_keys); - used.unite(QSet::fromList(_bars)); - used.unite(QSet::fromList(_userKeys)); + QSet used(_keys.cbegin(), _keys.cend()); + used.unite(QSet(_bars.cbegin(), _bars.cend())); + used.unite(QSet(_userKeys.cbegin(), _userKeys.cend())); // insert keys from tooltip for (auto &key : _tooltip.keys()) { if ((key.endsWith("Tooltip")) && (_tooltip[key].toBool())) { @@ -155,7 +155,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL if (used.isEmpty()) used << "dummy"; - return used.toList(); + return used.values(); } diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 36f0705..af9b52d 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -189,7 +189,7 @@ QString AWKeys::valueByKey(const QString &_key) const QString trueKey = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key; - return m_aggregator->formatter(m_values[trueKey], trueKey); + return m_aggregator->formatter(m_values[trueKey], trueKey, true); } @@ -340,7 +340,7 @@ QString AWKeys::parsePattern(QString _pattern) const // main keys for (auto &key : m_foundKeys) - _pattern.replace(QString("$%1").arg(key), m_aggregator->formatter(m_values[key], key)); + _pattern.replace(QString("$%1").arg(key), m_aggregator->formatter(m_values[key], key, true)); // bars for (auto &bar : m_foundBars) { diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index d9c460f..de7c339 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -55,7 +55,7 @@ void AWKeysAggregator::initFormatters() } -QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key) const +QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const { qCDebug(LOG_AW) << "Data" << _data << "for key" << _key; @@ -162,7 +162,8 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key) } // replace spaces to non-breakable ones - if (!_key.startsWith("custom") && (!_key.startsWith("weather"))) + replaceSpace &= (!_key.startsWith("custom") && (!_key.startsWith("weather"))); + if (replaceSpace) output.replace(" ", " "); return output; diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index 83ef50f..c2bd1c1 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -69,7 +69,7 @@ public: ~AWKeysAggregator() override; void initFormatters(); // get methods - QString formatter(const QVariant &_data, const QString &_key) const; + QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const; QStringList keysFromSource(const QString &_source) const; // set methods void setAcOffline(const QString &_inactive); diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index 5cbe322..1e5e00f 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -36,7 +36,7 @@ QString AWPatternFunctions::expandLambdas(QString _code, AWKeysAggregator *_aggr // parsed values for (auto &lambdaKey : _usedKeys) _code.replace(QString("$%1").arg(lambdaKey), - _aggregator->formatter(_metadata[lambdaKey], lambdaKey)); + _aggregator->formatter(_metadata[lambdaKey], lambdaKey, false)); qCInfo(LOG_AW) << "Expression" << _code; QJSValue result = engine.evaluate(_code); if (result.isError()) { diff --git a/sources/compiler.cmake b/sources/compiler.cmake index 9e6a05c..0e25c13 100644 --- a/sources/compiler.cmake +++ b/sources/compiler.cmake @@ -17,7 +17,7 @@ else () endif () # some flags -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # verbose output for debug builds diff --git a/sources/test/testawtelemetryhandler.cpp b/sources/test/testawtelemetryhandler.cpp index b4181e0..ffb0e79 100644 --- a/sources/test/testawtelemetryhandler.cpp +++ b/sources/test/testawtelemetryhandler.cpp @@ -51,7 +51,7 @@ void TestAWTelemetryHandler::test_get() QStringList output = plugin->get(telemetryGroup); QVERIFY(!output.isEmpty()); - QCOMPARE(QSet::fromList(output).count(), output.count()); + QCOMPARE(QSet(output.cbegin(), output.cend()).count(), output.count()); QVERIFY(output.contains(telemetryData)); } From 55319521b2e6cc73791b026ff7604aeffb2f664c Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 18 Apr 2020 16:51:52 +0300 Subject: [PATCH 26/35] replace all nbsp in previews (#142) --- sources/awesome-widget/plugin/awkeys.cpp | 3 ++- sources/awesome-widget/plugin/awkeysaggregator.cpp | 3 ++- sources/qml/AWExtensions.qml | 2 +- sources/qml/AWTagSelector.qml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index af9b52d..9ff94a9 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -340,7 +340,8 @@ QString AWKeys::parsePattern(QString _pattern) const // main keys for (auto &key : m_foundKeys) - _pattern.replace(QString("$%1").arg(key), m_aggregator->formatter(m_values[key], key, true)); + _pattern.replace(QString("$%1").arg(key), + m_aggregator->formatter(m_values[key], key, true)); // bars for (auto &bar : m_foundBars) { diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index de7c339..669fc47 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -55,7 +55,8 @@ void AWKeysAggregator::initFormatters() } -QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const +QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key, + bool replaceSpace) const { qCDebug(LOG_AW) << "Data" << _data << "for key" << _key; diff --git a/sources/qml/AWExtensions.qml b/sources/qml/AWExtensions.qml index d048ac8..c83fca5 100644 --- a/sources/qml/AWExtensions.qml +++ b/sources/qml/AWExtensions.qml @@ -92,7 +92,7 @@ Row { } onShowMessage: { - compiledText.text = message.replace(" ", " ") + compiledText.text = message.split(" ").join(" ") // replaceAll lols compiledText.open() } } diff --git a/sources/qml/AWTagSelector.qml b/sources/qml/AWTagSelector.qml index 628d6e3..52b6571 100644 --- a/sources/qml/AWTagSelector.qml +++ b/sources/qml/AWTagSelector.qml @@ -68,7 +68,7 @@ Row { // generate message var message = i18n("Tag: %1", tags.currentText) message += "
    " - message += i18n("Value: %1", backend.valueByKey(tags.currentText)) + message += i18n("Value: %1", backend.valueByKey(tags.currentText).split(" ").join(" ")) message += "
    " message += i18n("Info: %1", backend.infoByKey(tags.currentText)) notifyBackend.sendNotification("tag", message) From 3e81cd16bbb15f7e3bd18e6bb3cdba1182fde78c Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 31 Oct 2020 22:02:42 +0300 Subject: [PATCH 27/35] update for docker --- .docker/Dockerfile-ubuntu-amd64 | 2 +- .docker/Dockerfile-ubuntu-i386 | 2 +- .docker/build-ubuntu-package.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.docker/Dockerfile-ubuntu-amd64 b/.docker/Dockerfile-ubuntu-amd64 index 0484b44..4b955a9 100644 --- a/.docker/Dockerfile-ubuntu-amd64 +++ b/.docker/Dockerfile-ubuntu-amd64 @@ -1,4 +1,4 @@ -FROM multiarch/ubuntu-core:amd64-xenial +FROM ubuntu:bionic RUN apt-get update # toolchain diff --git a/.docker/Dockerfile-ubuntu-i386 b/.docker/Dockerfile-ubuntu-i386 index 4fa8923..a88060d 100644 --- a/.docker/Dockerfile-ubuntu-i386 +++ b/.docker/Dockerfile-ubuntu-i386 @@ -1,4 +1,4 @@ -FROM multiarch/ubuntu-core:i386-xenial +FROM multiarch/ubuntu-core:i386-bionic RUN apt-get update # toolchain diff --git a/.docker/build-ubuntu-package.sh b/.docker/build-ubuntu-package.sh index a0427fa..8cf2372 100755 --- a/.docker/build-ubuntu-package.sh +++ b/.docker/build-ubuntu-package.sh @@ -6,8 +6,8 @@ rm -rf build-ubuntu mkdir build-ubuntu # patches -git apply patches/qt5.6-qversionnumber.patch -git apply patches/qt5.5-qstringlist-and-qinfo.patch +#git apply patches/qt5.6-qversionnumber.patch +#git apply patches/qt5.5-qstringlist-and-qinfo.patch # build cd build-ubuntu From a4a1ae064f6c8eabab1dc863d45d43e6551695c9 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 1 Nov 2020 00:38:59 +0300 Subject: [PATCH 28/35] newest qt fixes --- sources/awdebug.cpp | 4 +- .../plugin/awdataenginemapper.cpp | 118 +++++++++--------- .../plugin/awdataenginemapper.h | 4 +- sources/awesomewidgets/abstractextitem.cpp | 5 +- sources/awesomewidgets/awjsonformatter.cpp | 2 +- sources/awesomewidgets/extscript.cpp | 2 +- sources/awesomewidgets/extupgrade.cpp | 4 +- sources/awesomewidgets/extweather.cpp | 10 +- sources/awesomewidgets/qcronscheduler.cpp | 4 +- sources/extsysmon/extsysmon.cpp | 2 +- sources/extsysmonsources/gpuloadsource.cpp | 6 +- sources/extsysmonsources/gputempsource.cpp | 6 +- sources/extsysmonsources/hddtempsource.cpp | 10 +- sources/extsysmonsources/loadsource.cpp | 6 +- sources/extsysmonsources/playersource.cpp | 8 +- sources/test/awtestlibrary.cpp | 15 +-- sources/test/awtestlibrary.h | 1 - sources/test/testextweather.cpp | 8 -- sources/test/testextweather.h | 1 - sources/test/testfloatformatter.cpp | 21 ++-- sources/test/testnetworksource.cpp | 2 +- 21 files changed, 107 insertions(+), 132 deletions(-) diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index 2046e6a..a568db4 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -67,7 +67,7 @@ QString AWDebug::getAboutText(const QString &_type) translator = QString("
  • %1
  • ").arg(translator); text = i18n("Translators:") + "
      " + translatorList.join("") + "
    "; } else if (_type == "3rdparty") { - QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(';', QString::SkipEmptyParts); + QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(';', Qt::SkipEmptyParts); for (int i = 0; i < trdPartyList.count(); i++) trdPartyList[i] = QString("
  • %1 (%2 license)
  • ") .arg(trdPartyList.at(i).split(',')[0]) @@ -75,7 +75,7 @@ QString AWDebug::getAboutText(const QString &_type) .arg(trdPartyList.at(i).split(',')[2]); text = i18n("This software uses:") + "
      " + trdPartyList.join("") + "
    "; } else if (_type == "thanks") { - QStringList thanks = QString(SPECIAL_THANKS).split(';', QString::SkipEmptyParts); + QStringList thanks = QString(SPECIAL_THANKS).split(';', Qt::SkipEmptyParts); for (int i = 0; i < thanks.count(); i++) thanks[i] = QString("
  • %1
  • ") .arg(thanks.at(i).split(',')[0]) diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index 82f1554..7357198 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -94,53 +94,53 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt if (_source == "battery/ac") { // AC - m_map[_source] = "ac"; + m_map.insert(_source, "ac"); m_formatter["ac"] = AWKeysAggregator::FormatterType::ACFormat; } else if (_source.startsWith("battery/")) { // battery stats QString key = _source; key.remove("battery/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float : AWKeysAggregator::FormatterType::IntegerThree; } else if (_source == "cpu/system/TotalLoad") { // cpu - m_map[_source] = "cpu"; + m_map.insert(_source, "cpu"); m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float; } else if (_source.contains(cpuRegExp)) { // cpus QString key = _source; key.remove("cpu/").remove("/TotalLoad"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Float; } else if (_source == "cpu/system/AverageClock") { // cpucl - m_map[_source] = "cpucl"; + m_map.insert(_source, "cpucl"); m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer; } else if (_source.contains(cpuclRegExp)) { // cpucls QString key = _source; key.remove("cpu/cpu").remove("/clock"); key = QString("cpucl%1").arg(key); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Integer; } else if (_source.startsWith("custom")) { // custom QString key = _source; key.remove("custom/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source == "desktop/current/name") { // current desktop name - m_map[_source] = "desktop"; + m_map.insert(_source, "desktop"); m_formatter["desktop"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source == "desktop/current/number") { // current desktop number - m_map[_source] = "ndesktop"; + m_map.insert(_source, "ndesktop"); m_formatter["ndesktop"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source == "desktop/total/number") { // desktop count - m_map[_source] = "tdesktops"; + m_map.insert(_source, "tdesktops"); m_formatter["tdesktops"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source.contains(hddrRegExp)) { // read speed @@ -149,7 +149,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt int index = m_devices["disk"].indexOf(device); if (index > -1) { QString key = QString("hddr%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Integer; } } else if (_source.contains(hddwRegExp)) { @@ -159,16 +159,16 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt int index = m_devices["disk"].indexOf(device); if (index > -1) { QString key = QString("hddw%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Integer; } } else if (_source == "gpu/load") { // gpu load - m_map[_source] = "gpu"; + m_map.insert(_source, "gpu"); m_formatter["gpu"] = AWKeysAggregator::FormatterType::Float; } else if (_source == "gpu/temperature") { // gpu temperature - m_map[_source] = "gputemp"; + m_map.insert(_source, "gputemp"); m_formatter["gputemp"] = AWKeysAggregator::FormatterType::Temperature; } else if (_source.contains(mountFillRegExp)) { // fill level @@ -177,7 +177,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt int index = m_devices["mount"].indexOf(device); if (index > -1) { QString key = QString("hdd%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Float; // additional keys m_formatter[QString("hddtotmb%1").arg(index)] @@ -193,11 +193,11 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt if (index > -1) { // mb QString key = QString("hddfreemb%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat; // gb key = QString("hddfreegb%1").arg(index); - m_map.insertMulti(_source, key); + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat; } } else if (_source.contains(mountUsedRegExp)) { @@ -208,11 +208,11 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt if (index > -1) { // mb QString key = QString("hddmb%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat; // gb key = QString("hddgb%1").arg(index); - m_map.insertMulti(_source, key); + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat; } } else if (_source.startsWith("hdd/temperature")) { @@ -222,7 +222,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt int index = m_devices["hdd"].indexOf(device); if (index > -1) { QString key = QString("hddtemp%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; } } else if (_source.startsWith("cpu/system/loadavg")) { @@ -230,45 +230,45 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt QString time = _source; time.remove("cpu/system/loadavg"); QString key = QString("la%1").arg(time); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols; } else if (_source == "mem/physical/application") { // app memory // mb - m_map[_source] = "memmb"; + m_map.insert(_source, "memmb"); m_formatter["memmb"] = AWKeysAggregator::FormatterType::MemMBFormat; // gb - m_map.insertMulti(_source, "memgb"); + m_map.insert(_source, "memgb"); m_formatter["memgb"] = AWKeysAggregator::FormatterType::MemGBFormat; } else if (_source == "mem/physical/free") { // free memory // mb - m_map[_source] = "memfreemb"; + m_map.insert(_source, "memfreemb"); m_formatter["memfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat; // gb - m_map.insertMulti(_source, "memfreegb"); + m_map.insert(_source, "memfreegb"); m_formatter["memfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat; } else if (_source == "mem/physical/used") { // used memory // mb - m_map[_source] = "memusedmb"; + m_map.insert(_source, "memusedmb"); m_formatter["memusedmb"] = AWKeysAggregator::FormatterType::MemMBFormat; // gb - m_map.insertMulti(_source, "memusedgb"); + m_map.insert(_source, "memusedgb"); m_formatter["memusedgb"] = AWKeysAggregator::FormatterType::MemGBFormat; } else if (_source == "network/current/name") { // network device - m_map[_source] = "netdev"; + m_map.insert(_source, "netdev"); m_formatter["netdev"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source == "network/current/ssid") { // current ssid - m_map[_source] = "ssid"; + m_map.insert(_source, "ssid"); m_formatter["ssid"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source.startsWith("network/response")) { // network response QString key = _source; key.remove("network/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source.contains(netRegExp)) { // network speed @@ -277,15 +277,15 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt if (index > -1) { // kb QString key = QString("%1kb%2").arg(type).arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Integer; // smart key = QString("%1%2").arg(type).arg(index); - m_map.insertMulti(_source, key); + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::NetSmartFormat; // units key = QString("%1units%2").arg(type).arg(index); - m_map.insertMulti(_source, key); + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::NetSmartUnits; } } else if (_source.contains(netTotalRegExp)) { @@ -295,58 +295,58 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt if (index > -1) { // kb QString key = QString("%1totkb%2").arg(type).arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Integer; // mb key = QString("%1tot%2").arg(type).arg(index); - m_map.insertMulti(_source, key); + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat; } } else if (_source.startsWith("upgrade")) { // package manager QString key = _source; key.remove("upgrade/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::IntegerThree; } else if (_source.startsWith("player")) { // player QString key = _source; key.remove("player/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source == "ps/running/count") { // running processes count - m_map[_source] = "pscount"; + m_map.insert(_source, "pscount"); m_formatter["pscount"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source == "ps/running/list") { // list of running processes - m_map[_source] = "ps"; + m_map.insert(_source, "ps"); m_formatter["ps"] = AWKeysAggregator::FormatterType::List; } else if (_source == "ps/total/count") { // total processes count - m_map[_source] = "pstot"; + m_map.insert(_source, "pstot"); m_formatter["pstot"] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source.startsWith("quotes")) { // quotes QString key = _source; key.remove("quotes/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Quotes; } else if (_source == "mem/swap/free") { // free swap // mb - m_map[_source] = "swapfreemb"; + m_map.insert(_source, "swapfreemb"); m_formatter["swapfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat; // gb - m_map.insertMulti(_source, "swapfreegb"); + m_map.insert(_source, "swapfreegb"); m_formatter["swapfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat; } else if (_source == "mem/swap/used") { // used swap // mb - m_map[_source] = "swapmb"; + m_map.insert(_source, "swapmb"); m_formatter["swapmb"] = AWKeysAggregator::FormatterType::MemMBFormat; // gb - m_map.insertMulti(_source, "swapgb"); + m_map.insert(_source, "swapgb"); m_formatter["swapgb"] = AWKeysAggregator::FormatterType::MemGBFormat; } else if (_source.startsWith("lmsensors/")) { // temperature @@ -356,59 +356,59 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt return QStringList({QString("temp%1").arg(index)}); if (index > -1) { QString key = QString("temp%1").arg(index); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = _units == "°C" ? AWKeysAggregator::FormatterType::Temperature : AWKeysAggregator::FormatterType::Integer; } } else if (_source == "Local") { // time - m_map[_source] = "time"; + m_map.insert(_source, "time"); m_formatter["time"] = AWKeysAggregator::FormatterType::Time; // custom time - m_map.insertMulti(_source, "ctime"); + m_map.insert(_source, "ctime"); m_formatter["ctime"] = AWKeysAggregator::FormatterType::TimeCustom; // ISO time - m_map.insertMulti(_source, "isotime"); + m_map.insert(_source, "isotime"); m_formatter["isotime"] = AWKeysAggregator::FormatterType::TimeISO; // long time - m_map.insertMulti(_source, "longtime"); + m_map.insert(_source, "longtime"); m_formatter["longtime"] = AWKeysAggregator::FormatterType::TimeLong; // short time - m_map.insertMulti(_source, "shorttime"); + m_map.insert(_source, "shorttime"); m_formatter["shorttime"] = AWKeysAggregator::FormatterType::TimeShort; // timestamp - m_map.insertMulti(_source, "tstime"); + m_map.insert(_source, "tstime"); m_formatter["tstime"] = AWKeysAggregator::FormatterType::Timestamp; } else if (_source == "system/brightness") { - m_map[_source] = "brightness"; + m_map.insert(_source, "brightness"); m_formatter["brightness"] = AWKeysAggregator::FormatterType::IntegerThree; } else if (_source == "system/volume") { - m_map[_source] = "volume"; + m_map.insert(_source, "volume"); m_formatter["volume"] = AWKeysAggregator::FormatterType::IntegerThree; } else if (_source == "system/uptime") { // uptime - m_map[_source] = "uptime"; + m_map.insert(_source, "uptime"); m_formatter["uptime"] = AWKeysAggregator::FormatterType::Uptime; // custom uptime - m_map.insertMulti(_source, "cuptime"); + m_map.insert(_source, "cuptime"); m_formatter["cuptime"] = AWKeysAggregator::FormatterType::UptimeCustom; } else if (_source.startsWith("weather/temperature")) { // temperature QString key = _source; key.remove("weather/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; } else if (_source.startsWith("weather/")) { // other weather QString key = _source; key.remove("weather/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; } else if (_source.startsWith("load/load")) { // load source QString key = _source; key.remove("load/"); - m_map[_source] = key; + m_map.insert(_source, key); m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; } diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index c088a93..2d5adde 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -19,7 +19,7 @@ #ifndef AWDATAENGINEMAPPER_H #define AWDATAENGINEMAPPER_H -#include +#include #include #include "awkeysaggregator.h" @@ -47,7 +47,7 @@ private: // variables QHash m_devices; QHash m_formatter; - QHash m_map; + QMultiHash m_map; }; diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index 44a55f7..98e80a9 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -19,9 +19,9 @@ #include #include +#include #include #include -#include #include "abstractextitemaggregator.h" #include "qcronscheduler.h" @@ -241,8 +241,7 @@ void AbstractExtItem::setNumber(int _number) _number = []() { qCWarning(LOG_LIB) << "Number is empty, generate new one"; // we suppose that currentTIme().msec() is always valid time - qsrand(static_cast(QTime::currentTime().msec())); - int n = qrand() % 1000; + int n = QRandomGenerator::global()->generate() % 1000; qCInfo(LOG_LIB) << "Generated number is" << n; return n; }(); diff --git a/sources/awesomewidgets/awjsonformatter.cpp b/sources/awesomewidgets/awjsonformatter.cpp index d59963f..7d0fc3a 100644 --- a/sources/awesomewidgets/awjsonformatter.cpp +++ b/sources/awesomewidgets/awjsonformatter.cpp @@ -178,7 +178,7 @@ QVariant AWJsonFormatter::getFromMap(const QVariant &_value, const QString &_key void AWJsonFormatter::initPath() { m_splittedPath.clear(); - QStringList splittedByDot = m_path.split('.', QString::SkipEmptyParts); + QStringList splittedByDot = m_path.split('.', Qt::SkipEmptyParts); for (auto &element : splittedByDot) { bool ok; diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index e38a4a0..8e0ee5f 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -235,7 +235,7 @@ void ExtScript::readConfiguration() setStrRedirect(settings.value("X-AW-Redirect", strRedirect()).toString()); // api == 3 setFilters( - settings.value("X-AW-Filters", filters()).toString().split(',', QString::SkipEmptyParts)); + settings.value("X-AW-Filters", filters()).toString().split(',', Qt::SkipEmptyParts)); settings.endGroup(); bumpApi(AW_EXTSCRIPT_API); diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 3461f8c..53da8f1 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -220,8 +220,8 @@ void ExtUpgrade::updateValue() = QTextCodec::codecForMib(106)->toUnicode(m_process->readAllStandardOutput()).trimmed(); m_values[tag("pkgcount")] = [this](const QString &output) { return filter().isEmpty() - ? output.split('\n', QString::SkipEmptyParts).count() - null() - : output.split('\n', QString::SkipEmptyParts).filter(QRegExp(filter())).count(); + ? output.split('\n', Qt::SkipEmptyParts).count() - null() + : output.split('\n', Qt::SkipEmptyParts).filter(QRegExp(filter())).count(); }(qoutput); emit(dataReceived(m_values)); diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 4853fa6..99232c9 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -367,14 +367,8 @@ void ExtWeather::initProvider() { delete m_providerObject; - switch (m_provider) { - case Provider::OWM: - m_providerObject = new OWMWeatherProvider(this); - break; - case Provider::Yahoo: - m_providerObject = new YahooWeatherProvider(this); - break; - } + // in the future release it is possible to change provider here + m_providerObject = new OWMWeatherProvider(this); return m_providerObject->initUrl(city(), country(), ts()); } diff --git a/sources/awesomewidgets/qcronscheduler.cpp b/sources/awesomewidgets/qcronscheduler.cpp index c72abc9..6f67590 100644 --- a/sources/awesomewidgets/qcronscheduler.cpp +++ b/sources/awesomewidgets/qcronscheduler.cpp @@ -87,7 +87,7 @@ QList QCronScheduler::parseField(const QString &_value, const int _min, con parsedField.fromRange(field.split('/').first(), _min, _max); if (field.contains('/')) { bool status; - parsedField.div = field.split('/', QString::SkipEmptyParts).at(1).toInt(&status); + parsedField.div = field.split('/', Qt::SkipEmptyParts).at(1).toInt(&status); if (!status) parsedField.div = 1; } @@ -107,7 +107,7 @@ void QCronScheduler::QCronField::fromRange(const QString &_range, const int _min minValue = _min; maxValue = _max; } else if (_range.contains("-")) { - auto interval = _range.split('-', QString::SkipEmptyParts); + auto interval = _range.split('-', Qt::SkipEmptyParts); if (interval.count() != 2) return; bool status; diff --git a/sources/extsysmon/extsysmon.cpp b/sources/extsysmon/extsysmon.cpp index 65a8f1f..17f56fc 100644 --- a/sources/extsysmon/extsysmon.cpp +++ b/sources/extsysmon/extsysmon.cpp @@ -127,7 +127,7 @@ ExtendedSysMon::updateConfiguration(QHash _rawConfig) const } else if (_rawConfig["HDDDEV"] == "disable") { _rawConfig["HDDDEV"] = ""; } else { - QStringList deviceList = _rawConfig["HDDDEV"].split(',', QString::SkipEmptyParts); + QStringList deviceList = _rawConfig["HDDDEV"].split(',', Qt::SkipEmptyParts); QStringList devices; QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$"); for (auto &device : deviceList) diff --git a/sources/extsysmonsources/gpuloadsource.cpp b/sources/extsysmonsources/gpuloadsource.cpp index ef59396..816cc8c 100644 --- a/sources/extsysmonsources/gpuloadsource.cpp +++ b/sources/extsysmonsources/gpuloadsource.cpp @@ -131,7 +131,7 @@ void GPULoadSource::updateValue() qCInfo(LOG_ESS) << "Output" << qoutput; if (m_device == "nvidia") { - for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { + for (auto &str : qoutput.split('\n', Qt::SkipEmptyParts)) { if (!str.contains("")) continue; auto load = str.remove("").remove("").remove('%'); @@ -139,10 +139,10 @@ void GPULoadSource::updateValue() break; } } else if (m_device == "ati") { - for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { + for (auto &str : qoutput.split('\n', Qt::SkipEmptyParts)) { if (!str.contains("load")) continue; - QString load = str.split(' ', QString::SkipEmptyParts)[3].remove('%'); + QString load = str.split(' ', Qt::SkipEmptyParts)[3].remove('%'); m_values["gpu/load"] = load.toFloat(); break; } diff --git a/sources/extsysmonsources/gputempsource.cpp b/sources/extsysmonsources/gputempsource.cpp index efd7dcb..dbf654b 100644 --- a/sources/extsysmonsources/gputempsource.cpp +++ b/sources/extsysmonsources/gputempsource.cpp @@ -110,7 +110,7 @@ void GPUTemperatureSource::updateValue() qCInfo(LOG_ESS) << "Output" << qoutput; if (m_device == "nvidia") { - for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { + for (auto &str : qoutput.split('\n', Qt::SkipEmptyParts)) { if (!str.contains("")) continue; QString temp = str.remove("").remove("C"); @@ -118,10 +118,10 @@ void GPUTemperatureSource::updateValue() break; } } else if (m_device == "ati") { - for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { + for (auto &str : qoutput.split('\n', Qt::SkipEmptyParts)) { if (!str.contains("Temperature")) continue; - QString temp = str.split(' ', QString::SkipEmptyParts).at(4); + QString temp = str.split(' ', Qt::SkipEmptyParts).at(4); m_values["gpu/temperature"] = temp.toFloat(); break; } diff --git a/sources/extsysmonsources/hddtempsource.cpp b/sources/extsysmonsources/hddtempsource.cpp index 4d45a97..35c9cb7 100644 --- a/sources/extsysmonsources/hddtempsource.cpp +++ b/sources/extsysmonsources/hddtempsource.cpp @@ -31,7 +31,7 @@ HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, const QStringList & Q_ASSERT(_args.count() == 2); qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - m_devices = _args.at(0).split(',', QString::SkipEmptyParts); + m_devices = _args.at(0).split(',', Qt::SkipEmptyParts); m_cmd = _args.at(1); m_smartctl = m_cmd.contains("smartctl"); @@ -127,17 +127,17 @@ void HDDTemperatureSource::updateValue(const QString &_device) // parse if (m_smartctl) { - QStringList lines = qoutput.split('\n', QString::SkipEmptyParts); + QStringList lines = qoutput.split('\n', Qt::SkipEmptyParts); for (auto &str : lines) { if (!str.startsWith("194")) continue; - if (str.split(' ', QString::SkipEmptyParts).count() < 9) + if (str.split(' ', Qt::SkipEmptyParts).count() < 9) continue; - m_values[_device] = str.split(' ', QString::SkipEmptyParts).at(9).toFloat(); + m_values[_device] = str.split(' ', Qt::SkipEmptyParts).at(9).toFloat(); break; } } else { - QStringList lines = qoutput.split(':', QString::SkipEmptyParts); + QStringList lines = qoutput.split(':', Qt::SkipEmptyParts); if (lines.count() >= 3) { QString temp = lines.at(2); temp.remove(QChar(0260)).remove('C'); diff --git a/sources/extsysmonsources/loadsource.cpp b/sources/extsysmonsources/loadsource.cpp index 49547ef..958a3c0 100644 --- a/sources/extsysmonsources/loadsource.cpp +++ b/sources/extsysmonsources/loadsource.cpp @@ -18,7 +18,7 @@ #include "loadsource.h" -#include +#include #include "awdebug.h" @@ -28,8 +28,6 @@ LoadSource::LoadSource(QObject *_parent, const QStringList &_args) { Q_ASSERT(_args.count() == 0); qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; - - qsrand(static_cast(QTime::currentTime().msec())); } @@ -43,7 +41,7 @@ QVariant LoadSource::data(const QString &_source) { qCDebug(LOG_ESS) << "Source" << _source; - return qrand(); + return QRandomGenerator::global()->generate(); } diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index da0fd5a..6700138 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -256,11 +256,11 @@ void PlayerSource::mpdSocketReadyRead() qCInfo(LOG_ESS) << "Output" << qoutput; // parse - for (auto &str : qoutput.split('\n', QString::SkipEmptyParts)) { - if (str.split(": ", QString::SkipEmptyParts).count() == 2) { + for (auto &str : qoutput.split('\n', Qt::SkipEmptyParts)) { + if (str.split(": ", Qt::SkipEmptyParts).count() == 2) { // "Metadata: data" - QString metadata = str.split(": ", QString::SkipEmptyParts).first().toLower(); - QString data = str.split(": ", QString::SkipEmptyParts).last().trimmed(); + QString metadata = str.split(": ", Qt::SkipEmptyParts).first().toLower(); + QString data = str.split(": ", Qt::SkipEmptyParts).last().trimmed(); // there are one more time... if ((metadata == "time") && (data.contains(':'))) { QStringList times = data.split(':'); diff --git a/sources/test/awtestlibrary.cpp b/sources/test/awtestlibrary.cpp index ec6ddda..f702381 100644 --- a/sources/test/awtestlibrary.cpp +++ b/sources/test/awtestlibrary.cpp @@ -22,13 +22,12 @@ #include #include #include -#include +#include #include void AWTestLibrary::init() { - qsrand(static_cast(QTime::currentTime().msec())); } @@ -47,13 +46,7 @@ bool AWTestLibrary::isKWinActive() char AWTestLibrary::randomChar() { - return 'A' + (qrand() % static_cast('Z' - 'A')); -} - - -double AWTestLibrary::randomDouble() -{ - return static_cast(qrand()) / static_cast(RAND_MAX); + return 'A' + (QRandomGenerator::global()->generate() % static_cast('Z' - 'A')); } @@ -75,7 +68,7 @@ QPair AWTestLibrary::randomFilenames() int AWTestLibrary::randomInt(const int _max) { - return qrand() % _max; + return QRandomGenerator::global()->generate() % _max; } @@ -113,5 +106,5 @@ QStringList AWTestLibrary::randomSelect(const QStringList &_available) output << _available.at(index); } - return output.toList(); + return output.values(); } diff --git a/sources/test/awtestlibrary.h b/sources/test/awtestlibrary.h index 87499ae..97b569f 100644 --- a/sources/test/awtestlibrary.h +++ b/sources/test/awtestlibrary.h @@ -28,7 +28,6 @@ namespace AWTestLibrary void init(); bool isKWinActive(); char randomChar(); -double randomDouble(); QPair randomFilenames(); int randomInt(const int _max = 100); QString randomString(const int _min = 1, const int _max = 100); diff --git a/sources/test/testextweather.cpp b/sources/test/testextweather.cpp index 531f068..0ba8a21 100644 --- a/sources/test/testextweather.cpp +++ b/sources/test/testextweather.cpp @@ -60,14 +60,6 @@ void TestExtWeather::test_runOWM() } -void TestExtWeather::test_runYahoo() -{ - extWeather->setProvider(ExtWeather::Provider::Yahoo); - run(); - extWeather->setProvider(ExtWeather::Provider::OWM); -} - - void TestExtWeather::test_ts() { extWeather->setTs(1); diff --git a/sources/test/testextweather.h b/sources/test/testextweather.h index 9e179f7..fa6d07a 100644 --- a/sources/test/testextweather.h +++ b/sources/test/testextweather.h @@ -36,7 +36,6 @@ private slots: // test void test_values(); void test_runOWM(); - void test_runYahoo(); void test_ts(); void test_image(); void test_copy(); diff --git a/sources/test/testfloatformatter.cpp b/sources/test/testfloatformatter.cpp index b1c90b4..24abf6d 100644 --- a/sources/test/testfloatformatter.cpp +++ b/sources/test/testfloatformatter.cpp @@ -19,6 +19,7 @@ #include "testfloatformatter.h" #include +#include #include "awfloatformatter.h" #include "awtestlibrary.h" @@ -48,7 +49,7 @@ void TestAWFloatFormatter::test_count() QCOMPARE(formatter->count(), count); // test - QString output = formatter->convert(AWTestLibrary::randomDouble()); + QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); QCOMPARE(output.count(), count); // reset @@ -83,7 +84,7 @@ void TestAWFloatFormatter::test_forceWidth() QCOMPARE(formatter->forceWidth(), true); // test - QString output = formatter->convert(AWTestLibrary::randomDouble()); + QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); QCOMPARE(output.count(), count); // reset @@ -102,7 +103,7 @@ void TestAWFloatFormatter::test_format() QCOMPARE(formatter->format(), 'e'); // test - QString output = formatter->convert(AWTestLibrary::randomDouble()); + QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); QVERIFY(output.contains('e')); // reset @@ -118,7 +119,7 @@ void TestAWFloatFormatter::test_precision() QCOMPARE(formatter->precision(), precision); // test - QString output = formatter->convert(AWTestLibrary::randomDouble()); + QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); output.remove("0."); QCOMPARE(output.count(), precision); @@ -132,12 +133,12 @@ void TestAWFloatFormatter::test_multiplier() formatter->setPrecision(6); // assign - double multiplier = AWTestLibrary::randomDouble(); + double multiplier = QRandomGenerator::global()->generateDouble(); formatter->setMultiplier(multiplier); QCOMPARE(formatter->multiplier(), multiplier); // test - double value = AWTestLibrary::randomDouble(); + double value = QRandomGenerator::global()->generateDouble(); QCOMPARE(formatter->convert(value), QString::number(value * multiplier, 'f', 6)); // reset @@ -148,12 +149,12 @@ void TestAWFloatFormatter::test_multiplier() void TestAWFloatFormatter::test_summand() { // assign - double summand = AWTestLibrary::randomDouble(); + double summand = QRandomGenerator::global()->generateDouble(); formatter->setSummand(summand); QCOMPARE(formatter->summand(), summand); // test - double value = AWTestLibrary::randomDouble(); + double value = QRandomGenerator::global()->generateDouble(); QCOMPARE(formatter->convert(value), QString::number(value + summand, 'f', 6)); // reset @@ -185,9 +186,9 @@ void TestAWFloatFormatter::doRandom() formatter->setFillChar(AWTestLibrary::randomChar()); formatter->setForceWidth(AWTestLibrary::randomInt() % 2); formatter->setFormat(AWTestLibrary::randomChar()); - formatter->setMultiplier(AWTestLibrary::randomDouble()); + formatter->setMultiplier(QRandomGenerator::global()->generateDouble()); formatter->setPrecision(AWTestLibrary::randomInt()); - formatter->setSummand(AWTestLibrary::randomDouble()); + formatter->setSummand(QRandomGenerator::global()->generateDouble()); } diff --git a/sources/test/testnetworksource.cpp b/sources/test/testnetworksource.cpp index 878e258..ee3a7db 100644 --- a/sources/test/testnetworksource.cpp +++ b/sources/test/testnetworksource.cpp @@ -39,7 +39,7 @@ void TestNetworkSource::cleanupTestCase() void TestNetworkSource::test_sources() { - QCOMPARE(source->sources(), QStringList() << src); + QCOMPARE(source->sources(), QStringList() << src << "network/current/ssid"); } From 183e7d8a206ed4b409ec67ac9a72d1a330d51522 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 1 Nov 2020 00:43:00 +0300 Subject: [PATCH 29/35] correct image spelling --- .docker/Dockerfile-arch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/Dockerfile-arch b/.docker/Dockerfile-arch index ca63def..6e5fe9a 100644 --- a/.docker/Dockerfile-arch +++ b/.docker/Dockerfile-arch @@ -1,4 +1,4 @@ -FROM base/archlinux +FROM archlinux RUN pacman -Sy From 8eaf444a25c77aeb19b73bd3216e76187a073b2a Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 1 Nov 2020 01:16:10 +0300 Subject: [PATCH 30/35] fix dockerfile again --- .docker/Dockerfile-arch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.docker/Dockerfile-arch b/.docker/Dockerfile-arch index 6e5fe9a..5a52504 100644 --- a/.docker/Dockerfile-arch +++ b/.docker/Dockerfile-arch @@ -3,7 +3,8 @@ FROM archlinux RUN pacman -Sy # toolchain -RUN pacman -S --noconfirm base-devel cmake extra-cmake-modules python +RUN echo -e 'y\ny' | pacman -S util-linux-libs +RUN pacman -S --noconfirm base-devel cmake extra-cmake-modules python util-linux-libs # kf5 and qt5 libraries RUN pacman -S --noconfirm plasma-framework From e81d7650981d1958ca568b2e16b020522e9a10de Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 1 Nov 2020 14:33:17 +0300 Subject: [PATCH 31/35] update to new process api --- sources/awesome-widget/plugin/awactions.cpp | 6 +++--- sources/awesome-widget/plugin/awactions.h | 2 +- sources/awesomewidgets/extscript.cpp | 2 +- sources/awesomewidgets/extupgrade.cpp | 5 ++--- sources/extsysmonsources/gpuloadsource.cpp | 5 +++-- sources/extsysmonsources/gputempsource.cpp | 5 +++-- sources/extsysmonsources/hddtempsource.cpp | 10 +++++++--- sources/extsysmonsources/hddtempsource.h | 2 +- sources/extsysmonsources/networksource.cpp | 2 +- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/sources/awesome-widget/plugin/awactions.cpp b/sources/awesome-widget/plugin/awactions.cpp index c854770..cd1afa3 100644 --- a/sources/awesome-widget/plugin/awactions.cpp +++ b/sources/awesome-widget/plugin/awactions.cpp @@ -78,13 +78,13 @@ bool AWActions::isDebugEnabled() } -bool AWActions::runCmd(const QString &_cmd) +bool AWActions::runCmd(const QString &_cmd, const QStringList &_args) { - qCDebug(LOG_AW) << "Cmd" << _cmd; + qCDebug(LOG_AW) << "Cmd" << _cmd << "args" << _args; sendNotification(QString("Info"), i18n("Run %1", _cmd)); - return QProcess::startDetached(_cmd); + return QProcess::startDetached(_cmd, _args); } diff --git a/sources/awesome-widget/plugin/awactions.h b/sources/awesome-widget/plugin/awactions.h index c804123..73133e6 100644 --- a/sources/awesome-widget/plugin/awactions.h +++ b/sources/awesome-widget/plugin/awactions.h @@ -35,7 +35,7 @@ public: Q_INVOKABLE void checkUpdates(const bool _showAnyway = false); Q_INVOKABLE static QString getFileContent(const QString &_path); Q_INVOKABLE static bool isDebugEnabled(); - Q_INVOKABLE static bool runCmd(const QString &_cmd); + Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args); Q_INVOKABLE static void showLegacyInfo(); Q_INVOKABLE static void showReadme(); // configuration slots diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index 8e0ee5f..ba9b909 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -346,7 +346,7 @@ void ExtScript::startProcess() cmdList.append(prefix()); cmdList.append(executable()); qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(' '); - m_process->start(cmdList.join(' ')); + m_process->start("sh", QStringList() << "-c" << cmdList); } diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 53da8f1..6673ec2 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -205,9 +205,8 @@ void ExtUpgrade::writeConfiguration() const void ExtUpgrade::startProcess() { - QString cmd = QString("sh -c \"%1\"").arg(executable()); - qCInfo(LOG_LIB) << "Run cmd" << cmd; - m_process->start(cmd); + qCInfo(LOG_LIB) << "Run cmd" << executable(); + m_process->start("sh", QStringList() << "-c" << executable()); } diff --git a/sources/extsysmonsources/gpuloadsource.cpp b/sources/extsysmonsources/gpuloadsource.cpp index 816cc8c..6281637 100644 --- a/sources/extsysmonsources/gpuloadsource.cpp +++ b/sources/extsysmonsources/gpuloadsource.cpp @@ -104,10 +104,11 @@ void GPULoadSource::run() if ((m_device != "nvidia") && (m_device != "ati")) return; // build cmd - QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" : "aticonfig --od-getclocks"; + QString cmd = m_device == "nvidia" ? "nvidia-smi" : "aticonfig"; + auto args = m_device == "nvidia" ? QStringList({"-q", "-x"}) : QStringList({"--od-getclocks"}); qCInfo(LOG_ESS) << "cmd" << cmd; - m_process->start(cmd); + m_process->start(cmd, args); } diff --git a/sources/extsysmonsources/gputempsource.cpp b/sources/extsysmonsources/gputempsource.cpp index dbf654b..a7edad0 100644 --- a/sources/extsysmonsources/gputempsource.cpp +++ b/sources/extsysmonsources/gputempsource.cpp @@ -83,10 +83,11 @@ void GPUTemperatureSource::run() if ((m_device != "nvidia") && (m_device != "ati")) return; // build cmd - QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" : "aticonfig --od-gettemperature"; + QString cmd = m_device == "nvidia" ? "nvidia-smi" : "aticonfig"; + auto args = m_device == "nvidia" ? QStringList({"-q", "-x"}) : QStringList({"--od-gettemperature"}); qCInfo(LOG_ESS) << "cmd" << cmd; - m_process->start(cmd); + m_process->start(cmd, args); } diff --git a/sources/extsysmonsources/hddtempsource.cpp b/sources/extsysmonsources/hddtempsource.cpp index 35c9cb7..d434db7 100644 --- a/sources/extsysmonsources/hddtempsource.cpp +++ b/sources/extsysmonsources/hddtempsource.cpp @@ -32,7 +32,7 @@ HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, const QStringList & qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; m_devices = _args.at(0).split(',', Qt::SkipEmptyParts); - m_cmd = _args.at(1); + m_cmd = _args.at(1).split(' '); // lets hope no one put cmd with spaces here lol m_smartctl = m_cmd.contains("smartctl"); qCInfo(LOG_ESS) << "Parse as smartctl" << m_smartctl; @@ -77,8 +77,12 @@ QVariant HDDTemperatureSource::data(const QString &_source) QString device = _source; device.remove("hdd/temperature"); // run cmd - if (m_processes[device]->state() == QProcess::NotRunning) - m_processes[device]->start(QString("%1 %2").arg(m_cmd).arg(device)); + if (m_processes[device]->state() == QProcess::NotRunning) { + auto cmd = m_cmd.first(); + auto args = m_cmd.mid(1); + args.append(device); + m_processes[device]->start(cmd, args); + } return m_values[device]; } diff --git a/sources/extsysmonsources/hddtempsource.h b/sources/extsysmonsources/hddtempsource.h index de33c7a..469a67a 100644 --- a/sources/extsysmonsources/hddtempsource.h +++ b/sources/extsysmonsources/hddtempsource.h @@ -45,7 +45,7 @@ private: // properties QHash m_processes; // configuration and values - QString m_cmd; + QStringList m_cmd; QStringList m_devices; bool m_smartctl; QHash m_values; diff --git a/sources/extsysmonsources/networksource.cpp b/sources/extsysmonsources/networksource.cpp index 48dd60f..a34cdcc 100644 --- a/sources/extsysmonsources/networksource.cpp +++ b/sources/extsysmonsources/networksource.cpp @@ -84,7 +84,7 @@ QVariantMap NetworkSource::initialData(const QString &_source) const void NetworkSource::run() { m_values["network/current/name"] = NetworkSource::getCurrentDevice(); - m_process->start("iwgetid -r"); + m_process->start("iwgetid", QStringList() << "-r"); } From 91abbdcd968c037754df866d95ef86c7b6759c81 Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Tue, 3 Nov 2020 04:23:01 +0300 Subject: [PATCH 32/35] clang-tidy warning fixes --- .../plugin/awabstractpairconfig.cpp | 6 ++- .../plugin/awabstractpairconfig.h | 6 +-- .../plugin/awabstractpairhelper.cpp | 2 +- .../plugin/awabstractpairhelper.h | 12 ++--- .../plugin/awabstractselector.h | 2 +- sources/awesome-widget/plugin/awactions.h | 2 +- .../awesome-widget/plugin/awbugreporter.cpp | 2 +- sources/awesome-widget/plugin/awbugreporter.h | 2 +- .../awesome-widget/plugin/awconfighelper.cpp | 2 +- .../awesome-widget/plugin/awconfighelper.h | 12 ++--- .../plugin/awcustomkeyshelper.h | 6 +-- .../plugin/awdataaggregator.cpp | 2 +- .../awesome-widget/plugin/awdataaggregator.h | 8 +-- .../plugin/awdataengineaggregator.cpp | 14 ++--- .../plugin/awdataengineaggregator.h | 2 +- .../plugin/awdataenginemapper.h | 4 +- .../awesome-widget/plugin/awdbusadaptor.cpp | 2 +- sources/awesome-widget/plugin/awdbusadaptor.h | 14 ++--- .../plugin/awformatterhelper.cpp | 5 +- .../awesome-widget/plugin/awformatterhelper.h | 10 ++-- .../awesome-widget/plugin/awkeyoperations.h | 18 +++---- sources/awesome-widget/plugin/awkeys.cpp | 4 +- sources/awesome-widget/plugin/awkeys.h | 17 +++--- .../awesome-widget/plugin/awkeysaggregator.h | 9 ++-- .../plugin/awpatternfunctions.h | 2 +- .../plugin/awtelemetryhandler.h | 10 ++-- .../awesome-widget/plugin/awupdatehelper.h | 6 +-- sources/awesomewidgets/abstractextitem.cpp | 3 +- sources/awesomewidgets/abstractextitem.h | 36 ++++++------- .../abstractextitemaggregator.cpp | 4 +- .../abstractextitemaggregator.h | 14 ++--- .../awesomewidgets/abstractquotesprovider.h | 7 +-- .../awesomewidgets/abstractweatherprovider.h | 6 +-- sources/awesomewidgets/awabstractformatter.h | 10 ++-- .../awesomewidgets/awdatetimeformatter.cpp | 4 +- sources/awesomewidgets/awdatetimeformatter.h | 10 ++-- sources/awesomewidgets/awfloatformatter.cpp | 4 +- sources/awesomewidgets/awfloatformatter.h | 28 +++++----- sources/awesomewidgets/awjsonformatter.cpp | 6 +-- sources/awesomewidgets/awjsonformatter.h | 10 ++-- sources/awesomewidgets/awlistformatter.cpp | 4 +- sources/awesomewidgets/awlistformatter.h | 12 ++--- sources/awesomewidgets/awnoformatter.cpp | 4 +- sources/awesomewidgets/awnoformatter.h | 4 +- sources/awesomewidgets/awscriptformatter.cpp | 4 +- sources/awesomewidgets/awscriptformatter.h | 16 +++--- sources/awesomewidgets/awstringformatter.cpp | 4 +- sources/awesomewidgets/awstringformatter.h | 14 ++--- sources/awesomewidgets/extitemaggregator.h | 4 +- sources/awesomewidgets/extnetworkrequest.cpp | 4 +- sources/awesomewidgets/extnetworkrequest.h | 6 +-- sources/awesomewidgets/extquotes.cpp | 4 +- sources/awesomewidgets/extquotes.h | 6 +-- sources/awesomewidgets/extscript.cpp | 35 ++----------- sources/awesomewidgets/extscript.h | 21 ++++---- sources/awesomewidgets/extscript.ui | 25 +-------- sources/awesomewidgets/extupgrade.cpp | 4 +- sources/awesomewidgets/extupgrade.h | 12 ++--- sources/awesomewidgets/extweather.cpp | 4 +- sources/awesomewidgets/extweather.h | 24 ++++----- sources/awesomewidgets/graphicalitem.cpp | 4 +- sources/awesomewidgets/graphicalitem.h | 52 +++++++++---------- .../awesomewidgets/graphicalitemhelper.cpp | 12 +++-- sources/awesomewidgets/graphicalitemhelper.h | 18 +++---- sources/awesomewidgets/owmweatherprovider.h | 8 +-- sources/awesomewidgets/qcronscheduler.h | 4 +- .../scripts/get-external-ip.desktop | 3 +- sources/awesomewidgets/stooqquotesprovider.h | 5 +- sources/awesomewidgets/yahooquotesprovider.h | 5 +- sources/awesomewidgets/yahooweatherprovider.h | 11 ++-- sources/desktop-panel/plugin/dpadds.cpp | 39 +++++++------- sources/desktop-panel/plugin/dpadds.h | 12 ++--- sources/extsysmon/extsysmon.cpp | 3 +- sources/extsysmon/extsysmon.h | 5 +- sources/extsysmon/extsysmonaggregator.h | 8 +-- .../abstractextsysmonsource.h | 4 +- sources/extsysmonsources/batterysource.cpp | 3 +- sources/extsysmonsources/batterysource.h | 4 +- sources/extsysmonsources/customsource.h | 4 +- sources/extsysmonsources/desktopsource.h | 4 +- sources/extsysmonsources/gpuloadsource.h | 4 +- sources/extsysmonsources/gputempsource.cpp | 3 +- sources/extsysmonsources/gputempsource.h | 4 +- sources/extsysmonsources/hddtempsource.cpp | 2 +- sources/extsysmonsources/hddtempsource.h | 4 +- sources/extsysmonsources/loadsource.h | 4 +- sources/extsysmonsources/networksource.h | 4 +- sources/extsysmonsources/playersource.cpp | 4 +- sources/extsysmonsources/playersource.h | 14 ++--- sources/extsysmonsources/processessource.h | 4 +- sources/extsysmonsources/quotessource.h | 4 +- sources/extsysmonsources/requestsource.h | 4 +- sources/extsysmonsources/systeminfosource.h | 4 +- sources/extsysmonsources/upgradesource.h | 4 +- sources/extsysmonsources/weathersource.h | 4 +- sources/test/awtestlibrary.cpp | 6 +-- sources/test/testbatterysource.cpp | 4 +- sources/test/testextscript.cpp | 7 +-- sources/test/testfloatformatter.cpp | 2 +- 99 files changed, 392 insertions(+), 436 deletions(-) diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.cpp b/sources/awesome-widget/plugin/awabstractpairconfig.cpp index f18fb98..95ea6b9 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.cpp +++ b/sources/awesome-widget/plugin/awabstractpairconfig.cpp @@ -141,15 +141,17 @@ void AWAbstractPairConfig::execDialog() } // save configuration if required + auto status = true; switch (ret) { case 0: break; case 1: default: - m_helper->writeItems(data); - m_helper->removeUnusedKeys(data.keys()); + status &= m_helper->writeItems(data); + status &= m_helper->removeUnusedKeys(data.keys()); break; } + qCDebug(LOG_AW) << "Configuration save status" << status; } diff --git a/sources/awesome-widget/plugin/awabstractpairconfig.h b/sources/awesome-widget/plugin/awabstractpairconfig.h index 579b865..2f36b37 100644 --- a/sources/awesome-widget/plugin/awabstractpairconfig.h +++ b/sources/awesome-widget/plugin/awabstractpairconfig.h @@ -35,7 +35,7 @@ class AWAbstractPairConfig : public QDialog Q_OBJECT public: - explicit AWAbstractPairConfig(QWidget *_parent = nullptr, const bool _hasEdit = false, + explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false, QStringList _keys = QStringList()); ~AWAbstractPairConfig() override; template void initHelper() @@ -46,7 +46,7 @@ public: } void showDialog(); // properties - void setEditable(const bool _first, const bool _second); + void setEditable(bool _first, bool _second); private slots: void edit(); @@ -66,7 +66,7 @@ private: const QPair &_current); void clearSelectors(); void execDialog(); - QPair initKeys() const; + [[nodiscard]] QPair initKeys() const; void updateDialog(); }; diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.cpp b/sources/awesome-widget/plugin/awabstractpairhelper.cpp index e8d8426..55a4e91 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.cpp +++ b/sources/awesome-widget/plugin/awabstractpairhelper.cpp @@ -30,7 +30,7 @@ AWAbstractPairHelper::AWAbstractPairHelper(QString _filePath, QString _section) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; - initItems(); + AWAbstractPairHelper::initItems(); } diff --git a/sources/awesome-widget/plugin/awabstractpairhelper.h b/sources/awesome-widget/plugin/awabstractpairhelper.h index bc05669..b5817c4 100644 --- a/sources/awesome-widget/plugin/awabstractpairhelper.h +++ b/sources/awesome-widget/plugin/awabstractpairhelper.h @@ -27,14 +27,14 @@ class AWAbstractPairHelper public: explicit AWAbstractPairHelper(QString _filePath = "", QString _section = ""); virtual ~AWAbstractPairHelper(); - QStringList keys() const; - QHash pairs() const; - QStringList values() const; - QSet valuesSet() const; + [[nodiscard]] QStringList keys() const; + [[nodiscard]] QHash pairs() const; + [[nodiscard]] QStringList values() const; + [[nodiscard]] QSet valuesSet() const; // read-write methods virtual void initItems(); - virtual bool writeItems(const QHash &_configuration) const; - virtual bool removeUnusedKeys(const QStringList &_keys) const; + [[nodiscard]] virtual bool writeItems(const QHash &_configuration) const; + [[nodiscard]] virtual bool removeUnusedKeys(const QStringList &_keys) const; // configuration related virtual void editPairs() = 0; virtual QStringList leftKeys() = 0; diff --git a/sources/awesome-widget/plugin/awabstractselector.h b/sources/awesome-widget/plugin/awabstractselector.h index 2cac132..1faffc9 100644 --- a/sources/awesome-widget/plugin/awabstractselector.h +++ b/sources/awesome-widget/plugin/awabstractselector.h @@ -35,7 +35,7 @@ public: explicit AWAbstractSelector(QWidget *_parent = nullptr, const QPair &_editable = {false, false}); ~AWAbstractSelector() override; - QPair current() const; + [[nodiscard]] QPair current() const; void init(const QStringList &_keys, const QStringList &_values, const QPair &_current); diff --git a/sources/awesome-widget/plugin/awactions.h b/sources/awesome-widget/plugin/awactions.h index 73133e6..cd63371 100644 --- a/sources/awesome-widget/plugin/awactions.h +++ b/sources/awesome-widget/plugin/awactions.h @@ -32,7 +32,7 @@ class AWActions : public QObject public: explicit AWActions(QObject *_parent = nullptr); ~AWActions() override; - Q_INVOKABLE void checkUpdates(const bool _showAnyway = false); + Q_INVOKABLE void checkUpdates(bool _showAnyway = false); Q_INVOKABLE static QString getFileContent(const QString &_path); Q_INVOKABLE static bool isDebugEnabled(); Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args); diff --git a/sources/awesome-widget/plugin/awbugreporter.cpp b/sources/awesome-widget/plugin/awbugreporter.cpp index 337d603..13390ee 100644 --- a/sources/awesome-widget/plugin/awbugreporter.cpp +++ b/sources/awesome-widget/plugin/awbugreporter.cpp @@ -45,7 +45,7 @@ void AWBugReporter::doConnect() { // additional method for testing needs connect(this, SIGNAL(replyReceived(const int, const QString &)), this, - SLOT(showInformation(const int, const QString &))); + SLOT(showInformation(int, const QString &))); } diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index 57ada94..fa89fde 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -42,7 +42,7 @@ signals: private slots: void issueReplyRecieved(QNetworkReply *_reply); - void showInformation(const int _number, const QString &_url); + void showInformation(int _number, const QString &_url); void userReplyOnBugReport(QAbstractButton *_button); private: diff --git a/sources/awesome-widget/plugin/awconfighelper.cpp b/sources/awesome-widget/plugin/awconfighelper.cpp index 70d76b1..30a7289 100644 --- a/sources/awesome-widget/plugin/awconfighelper.cpp +++ b/sources/awesome-widget/plugin/awconfighelper.cpp @@ -42,7 +42,7 @@ AWConfigHelper::~AWConfigHelper() } -QString AWConfigHelper::configurationDirectory() const +QString AWConfigHelper::configurationDirectory() { // get readable directory QString localDir diff --git a/sources/awesome-widget/plugin/awconfighelper.h b/sources/awesome-widget/plugin/awconfighelper.h index 957431f..496334f 100644 --- a/sources/awesome-widget/plugin/awconfighelper.h +++ b/sources/awesome-widget/plugin/awconfighelper.h @@ -32,13 +32,13 @@ class AWConfigHelper : public QObject public: explicit AWConfigHelper(QObject *_parent = nullptr); ~AWConfigHelper() override; - Q_INVOKABLE QString configurationDirectory() const; + Q_INVOKABLE [[nodiscard]] static QString configurationDirectory(); Q_INVOKABLE static bool dropCache(); Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const; - Q_INVOKABLE QVariantMap importConfiguration(const QString &_fileName, - const bool _importPlasmoid, - const bool _importExtensions, - const bool _importAdds) const; + Q_INVOKABLE [[nodiscard]] QVariantMap importConfiguration(const QString &_fileName, + bool _importPlasmoid, + bool _importExtensions, + bool _importAdds) const; // dataengine Q_INVOKABLE static QVariantMap readDataEngineConfiguration(); Q_INVOKABLE static bool writeDataEngineConfiguration(const QVariantMap &_configuration); @@ -47,7 +47,7 @@ private: // methods static void copyConfigs(const QString &_localDir); void copyExtensions(const QString &_item, const QString &_type, QSettings &_settings, - const bool _inverse) const; + bool _inverse) const; static void copySettings(QSettings &_from, QSettings &_to); static void readFile(QSettings &_settings, const QString &_key, const QString &_fileName); static void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName); diff --git a/sources/awesome-widget/plugin/awcustomkeyshelper.h b/sources/awesome-widget/plugin/awcustomkeyshelper.h index 7a3b179..87dff8a 100644 --- a/sources/awesome-widget/plugin/awcustomkeyshelper.h +++ b/sources/awesome-widget/plugin/awcustomkeyshelper.h @@ -32,9 +32,9 @@ public: explicit AWCustomKeysHelper(QObject *_parent = nullptr); ~AWCustomKeysHelper() override; // get - QString source(const QString &_key) const; - QStringList sources() const; - QStringList refinedSources() const; + [[nodiscard]] QString source(const QString &_key) const; + [[nodiscard]] QStringList sources() const; + [[nodiscard]] QStringList refinedSources() const; // configuration related void editPairs() override{}; QStringList leftKeys() override; diff --git a/sources/awesome-widget/plugin/awdataaggregator.cpp b/sources/awesome-widget/plugin/awdataaggregator.cpp index feb000c..145d665 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataaggregator.cpp @@ -119,7 +119,7 @@ QPixmap AWDataAggregator::tooltipImage() // create frame float normX = 100.0f / static_cast(m_values[key].count()); float normY = 100.0f / (1.5f * m_boundaries[key]); - float shift = requiredKeys.indexOf(key) * 100.0f; + float shift = static_cast(requiredKeys.indexOf(key)) * 100.0f; if (down) shift -= 100.0; // apply pen color diff --git a/sources/awesome-widget/plugin/awdataaggregator.h b/sources/awesome-widget/plugin/awdataaggregator.h index e5c75a1..fb0824f 100644 --- a/sources/awesome-widget/plugin/awdataaggregator.h +++ b/sources/awesome-widget/plugin/awdataaggregator.h @@ -49,17 +49,17 @@ private: // ui QGraphicsScene *m_toolTipScene = nullptr; QGraphicsView *m_toolTipView = nullptr; - void checkValue(const QString &_source, const float _value, const float _extremum) const; + void checkValue(const QString &_source, float _value, float _extremum) const; void checkValue(const QString &_source, const QString &_current, const QString &_received) const; void initScene(); - static QString notificationText(const QString &_source, const float _value); + static QString notificationText(const QString &_source, float _value); static QString notificationText(const QString &_source, const QString &_value); // main method void setData(const QVariantHash &_values); - void setData(const QString &_source, float _value, const float _extremum = -1.0f); + void setData(const QString &_source, float _value, float _extremum = -1.0f); // different signature for battery device - void setData(const bool _dontInvert, const QString &_source, float _value); + void setData(bool _dontInvert, const QString &_source, float _value); // variables int m_counts = 0; QVariantHash m_configuration; diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.cpp b/sources/awesome-widget/plugin/awdataengineaggregator.cpp index e0e048c..1f69dd3 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.cpp +++ b/sources/awesome-widget/plugin/awdataengineaggregator.cpp @@ -36,7 +36,7 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent) // additional method required by systemmonitor structure m_newSourceConnection = connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, - [this](const QString source) { + [this](const QString &source) { emit(deviceAdded(source)); m_dataEngines["systemmonitor"]->connectSource(source, parent(), 1000); }); @@ -56,9 +56,9 @@ AWDataEngineAggregator::~AWDataEngineAggregator() void AWDataEngineAggregator::disconnectSources() { - for (auto dataengine : m_dataEngines.values()) - for (auto &source : dataengine->sources()) - dataengine->disconnectSource(source, parent()); + for (auto dataEngine : m_dataEngines.values()) + for (auto &source : dataEngine->sources()) + dataEngine->disconnectSource(source, parent()); disconnect(m_newSourceConnection); } @@ -75,7 +75,7 @@ void AWDataEngineAggregator::reconnectSources(const int _interval) m_newSourceConnection = connect( m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, - [this, _interval](const QString source) { + [this, _interval](const QString &source) { emit(deviceAdded(source)); m_dataEngines["systemmonitor"]->connectSource(source, parent(), (uint)_interval); }); @@ -92,8 +92,8 @@ void AWDataEngineAggregator::dropSource(const QString &_source) // HACK there is no possibility to check to which dataengine source // connected we will try to disconnect it from all engines - for (auto dataengine : m_dataEngines.values()) - dataengine->disconnectSource(_source, parent()); + for (auto dataEngine : m_dataEngines.values()) + dataEngine->disconnectSource(_source, parent()); } diff --git a/sources/awesome-widget/plugin/awdataengineaggregator.h b/sources/awesome-widget/plugin/awdataengineaggregator.h index dae35a6..580b9b8 100644 --- a/sources/awesome-widget/plugin/awdataengineaggregator.h +++ b/sources/awesome-widget/plugin/awdataengineaggregator.h @@ -33,7 +33,7 @@ public: explicit AWDataEngineAggregator(QObject *_parent = nullptr); ~AWDataEngineAggregator() override; void disconnectSources(); - void reconnectSources(const int _interval); + void reconnectSources(int _interval); signals: void deviceAdded(const QString &_source); diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index 2d5adde..0d55f03 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -35,8 +35,8 @@ public: explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr); ~AWDataEngineMapper() override; // get methods - AWKeysAggregator::FormatterType formatter(const QString &_key) const; - QStringList keysFromSource(const QString &_source) const; + [[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const; + [[nodiscard]] QStringList keysFromSource(const QString &_source) const; // set methods QStringList registerSource(const QString &_source, const QString &_units, const QStringList &_keys); diff --git a/sources/awesome-widget/plugin/awdbusadaptor.cpp b/sources/awesome-widget/plugin/awdbusadaptor.cpp index 10a7906..1cb38a0 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.cpp +++ b/sources/awesome-widget/plugin/awdbusadaptor.cpp @@ -49,7 +49,7 @@ QStringList AWDBusAdaptor::ActiveServices() const QStringList arguments = listServices.arguments().first().toStringList(); return std::accumulate(arguments.cbegin(), arguments.cend(), QStringList(), - [](QStringList &source, QString service) { + [](QStringList &source, const QString &service) { if (service.startsWith(AWDBUS_SERVICE)) source.append(service); return source; diff --git a/sources/awesome-widget/plugin/awdbusadaptor.h b/sources/awesome-widget/plugin/awdbusadaptor.h index 31309ec..2f55f48 100644 --- a/sources/awesome-widget/plugin/awdbusadaptor.h +++ b/sources/awesome-widget/plugin/awdbusadaptor.h @@ -37,14 +37,14 @@ public: public slots: // get methods - QStringList ActiveServices() const; - QString Info(const QString &key) const; - QStringList Keys(const QString ®exp) const; - QString Value(const QString &key) const; - qlonglong WhoAmI() const; + [[nodiscard]] QStringList ActiveServices() const; + [[nodiscard]] QString Info(const QString &key) const; + [[nodiscard]] QStringList Keys(const QString ®exp) const; + [[nodiscard]] QString Value(const QString &key) const; + [[nodiscard]] qlonglong WhoAmI() const; // set methods - void SetLogLevel(const QString &what, const int level); - void SetLogLevel(const QString &what, const QString &level, const bool enabled); + void SetLogLevel(const QString &what, int level); + void SetLogLevel(const QString &what, const QString &level, bool enabled); private: AWKeys *m_plugin = nullptr; diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index 0eadc67..ef5d0b1 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -39,7 +39,7 @@ AWFormatterHelper::AWFormatterHelper(QWidget *_parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; - initItems(); + AWFormatterHelper::initItems(); } @@ -55,7 +55,6 @@ AWFormatterHelper::~AWFormatterHelper() void AWFormatterHelper::initItems() { initFormatters(); - AWAbstractPairHelper::initItems(); // assign internal storage m_formatters.clear(); @@ -199,7 +198,7 @@ void AWFormatterHelper::initFormatters() QPair -AWFormatterHelper::readMetadata(const QString &_filePath) const +AWFormatterHelper::readMetadata(const QString &_filePath) { qCDebug(LOG_AW) << "Read initial parameters from" << _filePath; diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h index 3152d61..66864bf 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.h +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -34,9 +34,9 @@ public: // read-write methods void initItems() override; // methods - QString convert(const QVariant &_value, const QString &_name) const; - QStringList definedFormatters() const; - QList items() const override; + [[nodiscard]] QString convert(const QVariant &_value, const QString &_name) const; + [[nodiscard]] QStringList definedFormatters() const; + [[nodiscard]] QList items() const override; // configuration related void editPairs() override; QStringList leftKeys() override; @@ -49,8 +49,8 @@ private: // methods static AWAbstractFormatter::FormatterClass defineFormatterClass(const QString &_stringType); void initFormatters(); - QPair - readMetadata(const QString &_filePath) const; + [[nodiscard]] static QPair + readMetadata(const QString &_filePath); // parent methods void doCreateItem() override; // properties diff --git a/sources/awesome-widget/plugin/awkeyoperations.h b/sources/awesome-widget/plugin/awkeyoperations.h index 57c0a7e..ee01197 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.h +++ b/sources/awesome-widget/plugin/awkeyoperations.h @@ -40,18 +40,18 @@ class AWKeyOperations : public QObject public: explicit AWKeyOperations(QObject *_parent = nullptr); ~AWKeyOperations() override; - QStringList devices(const QString &_type) const; - QHash devices() const; + [[nodiscard]] QStringList devices(const QString &_type) const; + [[nodiscard]] QHash devices() const; void updateCache(); // keys - QStringList dictKeys() const; - GraphicalItem *giByKey(const QString &_key) const; - QStringList requiredUserKeys() const; - QStringList userKeys() const; - QString userKeySource(const QString &_key) const; + [[nodiscard]] QStringList dictKeys() const; + [[nodiscard]] GraphicalItem *giByKey(const QString &_key) const; + [[nodiscard]] QStringList requiredUserKeys() const; + [[nodiscard]] QStringList userKeys() const; + [[nodiscard]] QString userKeySource(const QString &_key) const; // values - QString infoByKey(const QString &_key) const; - QString pattern() const; + [[nodiscard]] QString infoByKey(const QString &_key) const; + [[nodiscard]] QString pattern() const; void setPattern(const QString &_currentPattern); // configuration void editItem(const QString &_type); diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 9ff94a9..9d4e57c 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -76,7 +76,7 @@ AWKeys::~AWKeys() m_timer->stop(); // delete dbus session - qlonglong id = reinterpret_cast(this); + auto id = reinterpret_cast(this); QDBusConnection::sessionBus().unregisterObject(QString("/%1").arg(id)); } @@ -305,7 +305,7 @@ void AWKeys::calculateValues() void AWKeys::createDBusInterface() { // get this object id - qlonglong id = reinterpret_cast(this); + auto id = reinterpret_cast(this); // create session QDBusConnection instanceBus = QDBusConnection::sessionBus(); diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index 8f0ebce..756eb86 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -40,19 +40,20 @@ public: explicit AWKeys(QObject *_parent = nullptr); ~AWKeys() override; Q_INVOKABLE void initDataAggregator(const QVariantMap &_tooltipParams); - Q_INVOKABLE void initKeys(const QString &_currentPattern, const int _interval, const int _limit, - const bool _optimize); + Q_INVOKABLE void initKeys(const QString &_currentPattern, int _interval, int _limit, + bool _optimize); Q_INVOKABLE void setAggregatorProperty(const QString &_key, const QVariant &_value); - Q_INVOKABLE void setWrapNewLines(const bool _wrap); + Q_INVOKABLE void setWrapNewLines(bool _wrap); // additional method to force load keys from Qml UI. Used in some // configuration pages Q_INVOKABLE void updateCache(); // keys - Q_INVOKABLE QStringList dictKeys(const bool _sorted = false, const QString &_regexp = "") const; - Q_INVOKABLE QVariantList getHddDevices() const; + Q_INVOKABLE [[nodiscard]] QStringList dictKeys(bool _sorted = false, + const QString &_regexp = "") const; + Q_INVOKABLE [[nodiscard]] QVariantList getHddDevices() const; // values - Q_INVOKABLE QString infoByKey(const QString &_key) const; - Q_INVOKABLE QString valueByKey(const QString &_key) const; + Q_INVOKABLE [[nodiscard]] QString infoByKey(const QString &_key) const; + Q_INVOKABLE [[nodiscard]] QString valueByKey(const QString &_key) const; // configuration Q_INVOKABLE void editItem(const QString &_type); @@ -74,7 +75,7 @@ private: // methods void calculateValues(); void createDBusInterface(); - QString parsePattern(QString _pattern) const; + [[nodiscard]] QString parsePattern(QString _pattern) const; void setDataBySource(const QString &_sourceName, const QVariantMap &_data); // objects AWDataAggregator *m_dataAggregator = nullptr; diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index c2bd1c1..4c1def7 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -69,8 +69,9 @@ public: ~AWKeysAggregator() override; void initFormatters(); // get methods - QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const; - QStringList keysFromSource(const QString &_source) const; + [[nodiscard]] QString formatter(const QVariant &_data, const QString &_key, + bool replaceSpace) const; + [[nodiscard]] QStringList keysFromSource(const QString &_source) const; // set methods void setAcOffline(const QString &_inactive); void setAcOnline(const QString &_active); @@ -78,14 +79,14 @@ public: void setCustomUptime(const QString &_customUptime); void setDevices(const QHash &_devices); void setTempUnits(const QString &_units); - void setTranslate(const bool _translate); + void setTranslate(bool _translate); public slots: QStringList registerSource(const QString &_source, const QString &_units, const QStringList &_keys); private: - float temperature(const float temp) const; + [[nodiscard]] float temperature(float temp) const; AWFormatterHelper *m_customFormatters = nullptr; AWDataEngineMapper *m_mapper = nullptr; QStringList m_timeKeys; diff --git a/sources/awesome-widget/plugin/awpatternfunctions.h b/sources/awesome-widget/plugin/awpatternfunctions.h index c57ffd0..5e89406 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.h +++ b/sources/awesome-widget/plugin/awpatternfunctions.h @@ -44,7 +44,7 @@ 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); +QStringList findKeys(const QString &_code, const QStringList &_keys, bool _isBars); QStringList findLambdas(const QString &_code); } // namespace AWPatternFunctions diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.h b/sources/awesome-widget/plugin/awtelemetryhandler.h index 42eb3f1..2dfa2ad 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.h +++ b/sources/awesome-widget/plugin/awtelemetryhandler.h @@ -33,10 +33,10 @@ public: explicit AWTelemetryHandler(QObject *_parent = nullptr, const QString &_clientId = ""); ~AWTelemetryHandler() override; - Q_INVOKABLE QStringList get(const QString &_group) const; - Q_INVOKABLE QString getLast(const QString &_group) const; - Q_INVOKABLE void init(const int _count, const bool _enableRemote, const QString &_clientId); - Q_INVOKABLE bool put(const QString &_group, const QString &_value) const; + Q_INVOKABLE [[nodiscard]] QStringList get(const QString &_group) const; + Q_INVOKABLE [[nodiscard]] QString getLast(const QString &_group) const; + Q_INVOKABLE void init(int _count, bool _enableRemote, const QString &_clientId); + Q_INVOKABLE [[nodiscard]] bool put(const QString &_group, const QString &_value) const; Q_INVOKABLE void uploadTelemetry(const QString &_group, const QString &_value); signals: @@ -46,7 +46,7 @@ private slots: void telemetryReplyRecieved(QNetworkReply *_reply); private: - static QString getKey(const int _count); + static QString getKey(int _count); QString m_clientId; QString m_localFile; int m_storeCount = 0; diff --git a/sources/awesome-widget/plugin/awupdatehelper.h b/sources/awesome-widget/plugin/awupdatehelper.h index ae650fd..0d6a7bc 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.h +++ b/sources/awesome-widget/plugin/awupdatehelper.h @@ -33,18 +33,18 @@ class AWUpdateHelper : public QObject public: explicit AWUpdateHelper(QObject *_parent = nullptr); ~AWUpdateHelper() override; - void checkUpdates(const bool _showAnyway = false); + void checkUpdates(bool _showAnyway = false); bool checkVersion(); private slots: static void showInfo(const QVersionNumber &_version); void showUpdates(const QVersionNumber &_version); void userReplyOnUpdates(QAbstractButton *_button); - void versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway); + void versionReplyRecieved(QNetworkReply *_reply, bool _showAnyway); private: static QMessageBox *genMessageBox(const QString &_title, const QString &_body, - const QMessageBox::StandardButtons _buttons); + QMessageBox::StandardButtons _buttons); QVersionNumber m_foundVersion; QString m_genericConfig; }; diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index 98e80a9..ab6ad2f 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -240,8 +240,7 @@ void AbstractExtItem::setNumber(int _number) if (generateNumber) { _number = []() { qCWarning(LOG_LIB) << "Number is empty, generate new one"; - // we suppose that currentTIme().msec() is always valid time - int n = QRandomGenerator::global()->generate() % 1000; + auto n = QRandomGenerator::global()->generate() % 1000; qCInfo(LOG_LIB) << "Generated number is" << n; return n; }(); diff --git a/sources/awesomewidgets/abstractextitem.h b/sources/awesomewidgets/abstractextitem.h index 8e0300b..91fe620 100644 --- a/sources/awesomewidgets/abstractextitem.h +++ b/sources/awesomewidgets/abstractextitem.h @@ -42,29 +42,29 @@ class AbstractExtItem : public QDialog public: explicit AbstractExtItem(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AbstractExtItem() override; - virtual void bumpApi(const int _newVer); - virtual AbstractExtItem *copy(const QString &_fileName, const int _number) = 0; + virtual void bumpApi(int _newVer); + virtual AbstractExtItem *copy(const QString &_fileName, int _number) = 0; virtual void copyDefaults(AbstractExtItem *_other) const; virtual void startTimer(); - QString writtableConfig() const; + [[nodiscard]] QString writtableConfig() const; // get methods - int apiVersion() const; - QString comment() const; - QString cron() const; - QString fileName() const; - int interval() const; - bool isActive() const; - QString name() const; - int number() const; - QString socket() const; - QString tag(const QString &_type) const; - virtual QString uniq() const = 0; + [[nodiscard]] int apiVersion() const; + [[nodiscard]] QString comment() const; + [[nodiscard]] QString cron() const; + [[nodiscard]] QString fileName() const; + [[nodiscard]] int interval() const; + [[nodiscard]] bool isActive() const; + [[nodiscard]] QString name() const; + [[nodiscard]] int number() const; + [[nodiscard]] QString socket() const; + [[nodiscard]] QString tag(const QString &_type) const; + [[nodiscard]] virtual QString uniq() const = 0; // set methods - void setApiVersion(const int _apiVersion); - void setActive(const bool _state); + void setApiVersion(int _apiVersion); + void setActive(bool _state); void setComment(const QString &_comment); void setCron(const QString &_cron); - void setInterval(const int _interval); + void setInterval(int _interval); void setName(const QString &_name); void setNumber(int _number); void setSocket(const QString &_socket); @@ -79,7 +79,7 @@ public slots: virtual void readConfiguration(); virtual QVariantHash run() = 0; virtual int showConfiguration(const QVariant &_args) = 0; - virtual bool tryDelete() const; + [[nodiscard]] virtual bool tryDelete() const; virtual void writeConfiguration() const; private slots: diff --git a/sources/awesomewidgets/abstractextitemaggregator.cpp b/sources/awesomewidgets/abstractextitemaggregator.cpp index 8fb22a8..b15be31 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.cpp +++ b/sources/awesomewidgets/abstractextitemaggregator.cpp @@ -129,7 +129,7 @@ QString AbstractExtItemAggregator::getName() } -AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() +AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() const { QListWidgetItem *widgetItem = ui->listWidget->currentItem(); if (!widgetItem) @@ -150,7 +150,7 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() } -void AbstractExtItemAggregator::repaintList() +void AbstractExtItemAggregator::repaintList() const { ui->listWidget->clear(); for (auto &_item : items()) { diff --git a/sources/awesomewidgets/abstractextitemaggregator.h b/sources/awesomewidgets/abstractextitemaggregator.h index 418d386..08da486 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.h +++ b/sources/awesomewidgets/abstractextitemaggregator.h @@ -68,14 +68,14 @@ public: void editItem(); QString getName(); virtual void initItems() = 0; - AbstractExtItem *itemFromWidget(); - void repaintList(); - int uniqNumber() const; + AbstractExtItem *itemFromWidget() const; + void repaintList() const; + [[nodiscard]] int uniqNumber() const; // get methods - QVariant configArgs() const; - QStringList directories() const; - virtual QList items() const = 0; - QString type() const; + [[nodiscard]] QVariant configArgs() const; + [[nodiscard]] QStringList directories() const; + [[nodiscard]] virtual QList items() const = 0; + [[nodiscard]] QString type() const; // set methods void setConfigArgs(const QVariant &_configArgs); diff --git a/sources/awesomewidgets/abstractquotesprovider.h b/sources/awesomewidgets/abstractquotesprovider.h index 53b94ff..26f7586 100644 --- a/sources/awesomewidgets/abstractquotesprovider.h +++ b/sources/awesomewidgets/abstractquotesprovider.h @@ -33,12 +33,13 @@ public: : QObject(_parent){}; ~AbstractQuotesProvider() override = default; virtual void initUrl(const QString &_asset) = 0; - virtual QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const = 0; - QString tag(const QString &_type) const + [[nodiscard]] virtual QVariantHash parse(const QByteArray &_source, + const QVariantHash &_oldValues) const = 0; + [[nodiscard]] QString tag(const QString &_type) const { return dynamic_cast(parent())->tag(_type); }; - virtual QUrl url() const = 0; + [[nodiscard]] virtual QUrl url() const = 0; }; diff --git a/sources/awesomewidgets/abstractweatherprovider.h b/sources/awesomewidgets/abstractweatherprovider.h index 10895a0..ac9d96b 100644 --- a/sources/awesomewidgets/abstractweatherprovider.h +++ b/sources/awesomewidgets/abstractweatherprovider.h @@ -32,9 +32,9 @@ public: explicit AbstractWeatherProvider(QObject *_parent) : QObject(_parent){}; ~AbstractWeatherProvider() override = default; - virtual void initUrl(const QString &_city, const QString &_country, const int _ts) = 0; - virtual QVariantHash parse(const QVariantMap &_json) const = 0; - QString tag(const QString &_type) const + virtual void initUrl(const QString &_city, const QString &_country, int _ts) = 0; + [[nodiscard]] virtual QVariantHash parse(const QVariantMap &_json) const = 0; + [[nodiscard]] QString tag(const QString &_type) const { return dynamic_cast(parent())->tag(_type); }; diff --git a/sources/awesomewidgets/awabstractformatter.h b/sources/awesomewidgets/awabstractformatter.h index b254271..214acec 100644 --- a/sources/awesomewidgets/awabstractformatter.h +++ b/sources/awesomewidgets/awabstractformatter.h @@ -32,14 +32,14 @@ public: explicit AWAbstractFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWAbstractFormatter() override; - virtual QString convert(const QVariant &_value) const = 0; + [[nodiscard]] virtual QString convert(const QVariant &_value) const = 0; void copyDefaults(AbstractExtItem *_other) const override; - QString uniq() const override; + [[nodiscard]] QString uniq() const override; // properties - QString strType() const; - FormatterClass type() const; + [[nodiscard]] QString strType() const; + [[nodiscard]] FormatterClass type() const; void setStrType(const QString &_type); - void setType(const FormatterClass _type); + void setType(FormatterClass _type); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/awdatetimeformatter.cpp b/sources/awesomewidgets/awdatetimeformatter.cpp index b2a18a4..03a34de 100644 --- a/sources/awesomewidgets/awdatetimeformatter.cpp +++ b/sources/awesomewidgets/awdatetimeformatter.cpp @@ -34,9 +34,9 @@ AWDateTimeFormatter::AWDateTimeFormatter(QWidget *_parent, const QString &_fileP qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWDateTimeFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWDateTimeFormatter::translate(); } diff --git a/sources/awesomewidgets/awdatetimeformatter.h b/sources/awesomewidgets/awdatetimeformatter.h index b2e1d78..ef6bca2 100644 --- a/sources/awesomewidgets/awdatetimeformatter.h +++ b/sources/awesomewidgets/awdatetimeformatter.h @@ -37,13 +37,13 @@ class AWDateTimeFormatter : public AWAbstractFormatter public: explicit AWDateTimeFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWDateTimeFormatter() override; - QString convert(const QVariant &_value) const override; - AWDateTimeFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWDateTimeFormatter *copy(const QString &_fileName, int _number) override; // properties - QString format() const; - bool translateString() const; + [[nodiscard]] QString format() const; + [[nodiscard]] bool translateString() const; void setFormat(const QString &_format); - void setTranslateString(const bool _translate); + void setTranslateString(bool _translate); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/awfloatformatter.cpp b/sources/awesomewidgets/awfloatformatter.cpp index 2c51b28..4089711 100644 --- a/sources/awesomewidgets/awfloatformatter.cpp +++ b/sources/awesomewidgets/awfloatformatter.cpp @@ -33,9 +33,9 @@ AWFloatFormatter::AWFloatFormatter(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWFloatFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWFloatFormatter::translate(); } diff --git a/sources/awesomewidgets/awfloatformatter.h b/sources/awesomewidgets/awfloatformatter.h index bbedf22..021d3e7 100644 --- a/sources/awesomewidgets/awfloatformatter.h +++ b/sources/awesomewidgets/awfloatformatter.h @@ -40,23 +40,23 @@ class AWFloatFormatter : public AWAbstractFormatter public: explicit AWFloatFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWFloatFormatter() override; - QString convert(const QVariant &_value) const override; - AWFloatFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWFloatFormatter *copy(const QString &_fileName, int _number) override; // 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); + [[nodiscard]] int count() const; + [[nodiscard]] QChar fillChar() const; + [[nodiscard]] bool forceWidth() const; + [[nodiscard]] char format() const; + [[nodiscard]] double multiplier() const; + [[nodiscard]] int precision() const; + [[nodiscard]] double summand() const; + void setCount(int _count); void setFillChar(const QChar &_fillChar); - void setForceWidth(const bool _forceWidth); + void setForceWidth(bool _forceWidth); void setFormat(char _format); - void setMultiplier(const double _multiplier); - void setPrecision(const int _precision); - void setSummand(const double _summand); + void setMultiplier(double _multiplier); + void setPrecision(int _precision); + void setSummand(double _summand); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/awjsonformatter.cpp b/sources/awesomewidgets/awjsonformatter.cpp index 7d0fc3a..bbdd7ce 100644 --- a/sources/awesomewidgets/awjsonformatter.cpp +++ b/sources/awesomewidgets/awjsonformatter.cpp @@ -34,9 +34,9 @@ AWJsonFormatter::AWJsonFormatter(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWJsonFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWJsonFormatter::translate(); } @@ -144,7 +144,7 @@ void AWJsonFormatter::writeConfiguration() const } -QVariant AWJsonFormatter::getFromJson(const QVariant &_value, const QVariant &_element) const +QVariant AWJsonFormatter::getFromJson(const QVariant &_value, const QVariant &_element) { qCDebug(LOG_LIB) << "Looking for element" << _element << "in" << _value; diff --git a/sources/awesomewidgets/awjsonformatter.h b/sources/awesomewidgets/awjsonformatter.h index bb06f2b..b0dec25 100644 --- a/sources/awesomewidgets/awjsonformatter.h +++ b/sources/awesomewidgets/awjsonformatter.h @@ -34,10 +34,10 @@ class AWJsonFormatter : public AWAbstractFormatter public: explicit AWJsonFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWJsonFormatter() override; - QString convert(const QVariant &_value) const override; - AWJsonFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWJsonFormatter *copy(const QString &_fileName, int _number) override; // properties - QString path() const; + [[nodiscard]] QString path() const; void setPath(const QString &_path); public slots: @@ -47,8 +47,8 @@ public slots: private: Ui::AWJsonFormatter *ui = nullptr; - QVariant getFromJson(const QVariant &_value, const QVariant &_element) const; - static QVariant getFromList(const QVariant &_value, const int _index); + static QVariant getFromJson(const QVariant &_value, const QVariant &_element); + static QVariant getFromList(const QVariant &_value, int _index); static QVariant getFromMap(const QVariant &_value, const QString &_key); void initPath(); void translate() override; diff --git a/sources/awesomewidgets/awlistformatter.cpp b/sources/awesomewidgets/awlistformatter.cpp index 85dbd96..de15406 100644 --- a/sources/awesomewidgets/awlistformatter.cpp +++ b/sources/awesomewidgets/awlistformatter.cpp @@ -33,9 +33,9 @@ AWListFormatter::AWListFormatter(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWListFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWListFormatter::translate(); } diff --git a/sources/awesomewidgets/awlistformatter.h b/sources/awesomewidgets/awlistformatter.h index 888c414..665e54b 100644 --- a/sources/awesomewidgets/awlistformatter.h +++ b/sources/awesomewidgets/awlistformatter.h @@ -36,15 +36,15 @@ class AWListFormatter : public AWAbstractFormatter public: explicit AWListFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWListFormatter() override; - QString convert(const QVariant &_value) const override; - AWListFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWListFormatter *copy(const QString &_fileName, int _number) override; // properties - QString filter() const; - bool isSorted() const; - QString separator() const; + [[nodiscard]] QString filter() const; + [[nodiscard]] bool isSorted() const; + [[nodiscard]] QString separator() const; void setFilter(const QString &_filter); void setSeparator(const QString &_separator); - void setSorted(const bool _sorted); + void setSorted(bool _sorted); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/awnoformatter.cpp b/sources/awesomewidgets/awnoformatter.cpp index 695ffba..3253f1e 100644 --- a/sources/awesomewidgets/awnoformatter.cpp +++ b/sources/awesomewidgets/awnoformatter.cpp @@ -31,9 +31,9 @@ AWNoFormatter::AWNoFormatter(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWNoFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWNoFormatter::translate(); } diff --git a/sources/awesomewidgets/awnoformatter.h b/sources/awesomewidgets/awnoformatter.h index 8e2113f..56f7b40 100644 --- a/sources/awesomewidgets/awnoformatter.h +++ b/sources/awesomewidgets/awnoformatter.h @@ -33,8 +33,8 @@ class AWNoFormatter : public AWAbstractFormatter public: explicit AWNoFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWNoFormatter() override; - QString convert(const QVariant &_value) const override; - AWNoFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWNoFormatter *copy(const QString &_fileName, int _number) override; public slots: int showConfiguration(const QVariant &_args) override; diff --git a/sources/awesomewidgets/awscriptformatter.cpp b/sources/awesomewidgets/awscriptformatter.cpp index 9ba6315..7990983 100644 --- a/sources/awesomewidgets/awscriptformatter.cpp +++ b/sources/awesomewidgets/awscriptformatter.cpp @@ -34,9 +34,9 @@ AWScriptFormatter::AWScriptFormatter(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWScriptFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWScriptFormatter::translate(); } diff --git a/sources/awesomewidgets/awscriptformatter.h b/sources/awesomewidgets/awscriptformatter.h index 71e5967..b3df69c 100644 --- a/sources/awesomewidgets/awscriptformatter.h +++ b/sources/awesomewidgets/awscriptformatter.h @@ -37,16 +37,16 @@ class AWScriptFormatter : public AWAbstractFormatter public: explicit AWScriptFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWScriptFormatter() override; - QString convert(const QVariant &_value) const override; - AWScriptFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWScriptFormatter *copy(const QString &_fileName, int _number) override; // properties - bool appendCode() const; - QString code() const; - bool hasReturn() const; - QString program() const; - void setAppendCode(const bool _appendCode); + [[nodiscard]] bool appendCode() const; + [[nodiscard]] QString code() const; + [[nodiscard]] bool hasReturn() const; + [[nodiscard]] QString program() const; + void setAppendCode(bool _appendCode); void setCode(const QString &_code); - void setHasReturn(const bool _hasReturn); + void setHasReturn(bool _hasReturn); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/awstringformatter.cpp b/sources/awesomewidgets/awstringformatter.cpp index 952238e..b606931 100644 --- a/sources/awesomewidgets/awstringformatter.cpp +++ b/sources/awesomewidgets/awstringformatter.cpp @@ -33,9 +33,9 @@ AWStringFormatter::AWStringFormatter(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + AWStringFormatter::readConfiguration(); ui->setupUi(this); - translate(); + AWStringFormatter::translate(); } diff --git a/sources/awesomewidgets/awstringformatter.h b/sources/awesomewidgets/awstringformatter.h index 7af6516..c634f6e 100644 --- a/sources/awesomewidgets/awstringformatter.h +++ b/sources/awesomewidgets/awstringformatter.h @@ -36,15 +36,15 @@ class AWStringFormatter : public AWAbstractFormatter public: explicit AWStringFormatter(QWidget *_parent = nullptr, const QString &_filePath = ""); ~AWStringFormatter() override; - QString convert(const QVariant &_value) const override; - AWStringFormatter *copy(const QString &_fileName, const int _number) override; + [[nodiscard]] QString convert(const QVariant &_value) const override; + AWStringFormatter *copy(const QString &_fileName, int _number) override; // properties - int count() const; - QChar fillChar() const; - bool forceWidth() const; - void setCount(const int _count); + [[nodiscard]] int count() const; + [[nodiscard]] QChar fillChar() const; + [[nodiscard]] bool forceWidth() const; + void setCount(int _count); void setFillChar(const QChar &_fillChar); - void setForceWidth(const bool _forceWidth); + void setForceWidth(bool _forceWidth); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/extitemaggregator.h b/sources/awesomewidgets/extitemaggregator.h index 6bd106d..0487152 100644 --- a/sources/awesomewidgets/extitemaggregator.h +++ b/sources/awesomewidgets/extitemaggregator.h @@ -41,7 +41,7 @@ public: qCDebug(LOG_LIB) << "Type" << _type; - initItems(); + ExtItemAggregator::initItems(); }; ~ExtItemAggregator() override @@ -117,7 +117,7 @@ public: return found; }; - QList items() const override { return m_items; }; + [[nodiscard]] QList items() const override { return m_items; }; private: QList m_items; diff --git a/sources/awesomewidgets/extnetworkrequest.cpp b/sources/awesomewidgets/extnetworkrequest.cpp index ac23f90..3acd2f4 100644 --- a/sources/awesomewidgets/extnetworkrequest.cpp +++ b/sources/awesomewidgets/extnetworkrequest.cpp @@ -36,9 +36,9 @@ ExtNetworkRequest::ExtNetworkRequest(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + ExtNetworkRequest::readConfiguration(); ui->setupUi(this); - translate(); + ExtNetworkRequest::translate(); m_values[tag("response")] = ""; diff --git a/sources/awesomewidgets/extnetworkrequest.h b/sources/awesomewidgets/extnetworkrequest.h index b55e2a3..fb079a6 100644 --- a/sources/awesomewidgets/extnetworkrequest.h +++ b/sources/awesomewidgets/extnetworkrequest.h @@ -36,10 +36,10 @@ class ExtNetworkRequest : public AbstractExtItem public: explicit ExtNetworkRequest(QWidget *_parent = nullptr, const QString &_filePath = ""); ~ExtNetworkRequest() override; - ExtNetworkRequest *copy(const QString &_fileName, const int _number) override; + ExtNetworkRequest *copy(const QString &_fileName, int _number) override; // get methods - QString stringUrl() const; - QString uniq() const override; + [[nodiscard]] QString stringUrl() const; + [[nodiscard]] QString uniq() const override; // set methods void setStringUrl(const QString &_url); diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 2c9e0d3..a7bfa06 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -36,9 +36,9 @@ ExtQuotes::ExtQuotes(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + ExtQuotes::readConfiguration(); ui->setupUi(this); - translate(); + ExtQuotes::translate(); m_values[tag("price")] = 0.0; m_values[tag("pricechg")] = 0.0; diff --git a/sources/awesomewidgets/extquotes.h b/sources/awesomewidgets/extquotes.h index 439fac6..1acce39 100644 --- a/sources/awesomewidgets/extquotes.h +++ b/sources/awesomewidgets/extquotes.h @@ -37,10 +37,10 @@ class ExtQuotes : public AbstractExtItem public: explicit ExtQuotes(QWidget *_parent = nullptr, const QString &_filePath = ""); ~ExtQuotes() override; - ExtQuotes *copy(const QString &_fileName, const int _number) override; + ExtQuotes *copy(const QString &_fileName, int _number) override; // get methods - QString ticker() const; - QString uniq() const override; + [[nodiscard]] QString ticker() const; + [[nodiscard]] QString uniq() const override; // set methods void setTicker(const QString &_ticker); diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index ba9b909..3017dac 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -36,10 +36,10 @@ ExtScript::ExtScript(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + ExtScript::readConfiguration(); readJsonFilters(); ui->setupUi(this); - translate(); + ExtScript::translate(); m_values[tag("custom")] = ""; @@ -71,7 +71,6 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number) copyDefaults(item); item->setExecutable(executable()); item->setNumber(_number); - item->setPrefix(prefix()); item->setRedirect(redirect()); item->setFilters(filters()); @@ -102,12 +101,6 @@ QStringList ExtScript::filters() const } -QString ExtScript::prefix() const -{ - return m_prefix; -} - - ExtScript::Redirect ExtScript::redirect() const { return m_redirect; @@ -159,14 +152,6 @@ void ExtScript::setFilters(const QStringList &_filters) } -void ExtScript::setPrefix(const QString &_prefix) -{ - qCDebug(LOG_LIB) << "Prefix" << _prefix; - - m_prefix = _prefix; -} - - void ExtScript::setRedirect(const Redirect _redirect) { qCDebug(LOG_LIB) << "Redirect" << static_cast(_redirect); @@ -231,11 +216,9 @@ void ExtScript::readConfiguration() settings.beginGroup("Desktop Entry"); setExecutable(settings.value("Exec", executable()).toString()); - setPrefix(settings.value("X-AW-Prefix", prefix()).toString()); setStrRedirect(settings.value("X-AW-Redirect", strRedirect()).toString()); // api == 3 - setFilters( - settings.value("X-AW-Filters", filters()).toString().split(',', Qt::SkipEmptyParts)); + setFilters(settings.value("X-AW-Filters", filters()).toString().split(',', Qt::SkipEmptyParts)); settings.endGroup(); bumpApi(AW_EXTSCRIPT_API); @@ -283,7 +266,6 @@ int ExtScript::showConfiguration(const QVariant &_args) ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); 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(redirect())); ui->lineEdit_schedule->setText(cron()); @@ -305,7 +287,6 @@ int ExtScript::showConfiguration(const QVariant &_args) setNumber(ui->label_numberValue->text().toInt()); setApiVersion(AW_EXTSCRIPT_API); setExecutable(ui->lineEdit_command->text()); - setPrefix(ui->lineEdit_prefix->text()); setActive(ui->checkBox_active->checkState() == Qt::Checked); setRedirect(static_cast(ui->comboBox_redirect->currentIndex())); setCron(ui->lineEdit_schedule->text()); @@ -330,7 +311,6 @@ void ExtScript::writeConfiguration() const settings.beginGroup("Desktop Entry"); settings.setValue("Exec", executable()); - settings.setValue("X-AW-Prefix", prefix()); settings.setValue("X-AW-Redirect", strRedirect()); settings.setValue("X-AW-Filters", filters().join(',')); settings.endGroup(); @@ -341,12 +321,8 @@ void ExtScript::writeConfiguration() const void ExtScript::startProcess() { - QStringList cmdList; - if (!prefix().isEmpty()) - cmdList.append(prefix()); - cmdList.append(executable()); - qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(' '); - m_process->start("sh", QStringList() << "-c" << cmdList); + qCInfo(LOG_LIB) << "Run cmd" << executable(); + m_process->start("sh", QStringList() << "-c" << executable()); } @@ -387,7 +363,6 @@ void ExtScript::translate() ui->label_comment->setText(i18n("Comment")); ui->label_number->setText(i18n("Tag")); ui->label_command->setText(i18n("Command")); - ui->label_prefix->setText(i18n("Prefix")); ui->checkBox_active->setText(i18n("Active")); ui->label_redirect->setText(i18n("Redirect")); ui->label_schedule->setText(i18n("Schedule")); diff --git a/sources/awesomewidgets/extscript.h b/sources/awesomewidgets/extscript.h index 0f83a10..784a545 100644 --- a/sources/awesomewidgets/extscript.h +++ b/sources/awesomewidgets/extscript.h @@ -33,7 +33,6 @@ class ExtScript : public AbstractExtItem Q_OBJECT Q_PROPERTY(QString executable READ executable WRITE setExecutable) Q_PROPERTY(QStringList filters READ filters WRITE setFilters) - Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect) public: @@ -41,25 +40,23 @@ public: explicit ExtScript(QWidget *_parent = nullptr, const QString &_filePath = ""); ~ExtScript() override; - ExtScript *copy(const QString &_fileName, const int _number) override; + ExtScript *copy(const QString &_fileName, int _number) override; static QString jsonFiltersFile(); // get methods - QString executable() const; - QStringList filters() const; - QString prefix() const; - Redirect redirect() const; - QString uniq() const override; + [[nodiscard]] QString executable() const; + [[nodiscard]] QStringList filters() const; + [[nodiscard]] Redirect redirect() const; + [[nodiscard]] QString uniq() const override; // derivatives - QString strRedirect() const; + [[nodiscard]] QString strRedirect() const; // set methods void setExecutable(const QString &_executable); void setFilters(const QStringList &_filters); - void setPrefix(const QString &_prefix); - void setRedirect(const Redirect _redirect); + void setRedirect(Redirect _redirect); void setStrRedirect(const QString &_redirect); // filters - QString applyFilters(QString _value) const; - void updateFilter(const QString &_filter, const bool _add); + [[nodiscard]] QString applyFilters(QString _value) const; + void updateFilter(const QString &_filter, bool _add); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/extscript.ui b/sources/awesomewidgets/extscript.ui index 8f57e87..700f5db 100644 --- a/sources/awesomewidgets/extscript.ui +++ b/sources/awesomewidgets/extscript.ui @@ -7,7 +7,7 @@ 0 0 420 - 506 + 463
    @@ -104,29 +104,6 @@
    - - - - - - - 0 - 0 - - - - Prefix - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 6673ec2..0195779 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -34,9 +34,9 @@ ExtUpgrade::ExtUpgrade(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + ExtUpgrade::readConfiguration(); ui->setupUi(this); - translate(); + ExtUpgrade::translate(); m_values[tag("pkgcount")] = 0; diff --git a/sources/awesomewidgets/extupgrade.h b/sources/awesomewidgets/extupgrade.h index aedc0dc..62b0edd 100644 --- a/sources/awesomewidgets/extupgrade.h +++ b/sources/awesomewidgets/extupgrade.h @@ -38,16 +38,16 @@ class ExtUpgrade : public AbstractExtItem public: explicit ExtUpgrade(QWidget *_parent = nullptr, const QString &_filePath = ""); ~ExtUpgrade() override; - ExtUpgrade *copy(const QString &_fileName, const int _number) override; + ExtUpgrade *copy(const QString &_fileName, int _number) override; // get methods - QString executable() const; - QString filter() const; - int null() const; - QString uniq() const override; + [[nodiscard]] QString executable() const; + [[nodiscard]] QString filter() const; + [[nodiscard]] int null() const; + [[nodiscard]] QString uniq() const override; // set methods void setExecutable(const QString &_executable); void setFilter(const QString &_filter); - void setNull(const int _null); + void setNull(int _null); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 99232c9..31cd0e4 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -39,10 +39,10 @@ ExtWeather::ExtWeather(QWidget *_parent, const QString &_filePath) qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; if (!_filePath.isEmpty()) - readConfiguration(); + ExtWeather::readConfiguration(); readJsonMap(); ui->setupUi(this); - translate(); + ExtWeather::translate(); m_values[tag("weatherId")] = 0; m_values[tag("weather")] = ""; diff --git a/sources/awesomewidgets/extweather.h b/sources/awesomewidgets/extweather.h index b9ab53c..0ba6c7f 100644 --- a/sources/awesomewidgets/extweather.h +++ b/sources/awesomewidgets/extweather.h @@ -44,24 +44,24 @@ public: explicit ExtWeather(QWidget *_parent = nullptr, const QString &_filePath = ""); ~ExtWeather() override; - ExtWeather *copy(const QString &_fileName, const int _number) override; + ExtWeather *copy(const QString &_fileName, int _number) override; static QString jsonMapFile(); - QString weatherFromInt(const int _id) const; + [[nodiscard]] QString weatherFromInt(int _id) const; // get methods - QString city() const; - QString country() const; - bool image() const; - Provider provider() const; - QString strProvider() const; - int ts() const; - QString uniq() const override; + [[nodiscard]] QString city() const; + [[nodiscard]] QString country() const; + [[nodiscard]] bool image() const; + [[nodiscard]] Provider provider() const; + [[nodiscard]] QString strProvider() const; + [[nodiscard]] int ts() const; + [[nodiscard]] QString uniq() const override; // set methods void setCity(const QString &_city); void setCountry(const QString &_country); - void setImage(const bool _image); - void setProvider(const Provider _provider); + void setImage(bool _image); + void setProvider(Provider _provider); void setStrProvider(const QString &_provider); - void setTs(const int _ts); + void setTs(int _ts); public slots: void readConfiguration() override; diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index 4b9bd6f..fd0ac10 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -52,9 +52,9 @@ GraphicalItem::GraphicalItem(QWidget *_parent, const QString &_filePath) m_helper = new GraphicalItemHelper(this, m_scene); if (!_filePath.isEmpty()) - readConfiguration(); + GraphicalItem::readConfiguration(); ui->setupUi(this); - translate(); + GraphicalItem::translate(); connect(ui->checkBox_custom, SIGNAL(stateChanged(int)), this, SLOT(changeValue(int))); connect(ui->comboBox_type, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCountState(int))); diff --git a/sources/awesomewidgets/graphicalitem.h b/sources/awesomewidgets/graphicalitem.h index 544a193..b7409b1 100644 --- a/sources/awesomewidgets/graphicalitem.h +++ b/sources/awesomewidgets/graphicalitem.h @@ -54,38 +54,38 @@ public: explicit GraphicalItem(QWidget *_parent = nullptr, const QString &_filePath = ""); ~GraphicalItem() override; - GraphicalItem *copy(const QString &_fileName, const int _number) override; + GraphicalItem *copy(const QString &_fileName, int _number) override; QString image(const QVariant &value); void initScene(); // get methods - QString bar() const; - QString activeColor() const; - int count() const; - QString inactiveColor() const; - bool isCustom() const; - int itemHeight() const; - int itemWidth() const; - float minValue() const; - float maxValue() const; - Type type() const; - QString strType() const; - Direction direction() const; - QString strDirection() const; - QStringList usedKeys() const; - QString uniq() const override; + [[nodiscard]] QString bar() const; + [[nodiscard]] QString activeColor() const; + [[nodiscard]] int count() const; + [[nodiscard]] QString inactiveColor() const; + [[nodiscard]] bool isCustom() const; + [[nodiscard]] int itemHeight() const; + [[nodiscard]] int itemWidth() const; + [[nodiscard]] float minValue() const; + [[nodiscard]] float maxValue() const; + [[nodiscard]] Type type() const; + [[nodiscard]] QString strType() const; + [[nodiscard]] Direction direction() const; + [[nodiscard]] QString strDirection() const; + [[nodiscard]] QStringList usedKeys() const; + [[nodiscard]] QString uniq() const override; // set methods void setBar(const QString &_bar); void setActiveColor(const QString &_color); - void setCount(const int _count); - void setCustom(const bool _custom); + void setCount(int _count); + void setCustom(bool _custom); void setInactiveColor(const QString &_color); - void setItemHeight(const int _height); - void setItemWidth(const int _width); - void setMinValue(const float _value); - void setMaxValue(const float _value); - void setType(const Type _type); + void setItemHeight(int _height); + void setItemWidth(int _width); + void setMinValue(float _value); + void setMaxValue(float _value); + void setType(Type _type); void setStrType(const QString &_type); - void setDirection(const Direction _direction); + void setDirection(Direction _direction); void setStrDirection(const QString &_direction); void setUsedKeys(const QStringList &_usedKeys); @@ -97,8 +97,8 @@ public slots: private slots: void changeColor(); - void changeCountState(const int _state); - void changeValue(const int _state); + void changeCountState(int _state); + void changeValue(int _state); private: GraphicalItemHelper *m_helper = nullptr; diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index 5a039d0..1df798f 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -92,7 +92,7 @@ void GraphicalItemHelper::paintBars(const float _value) auto normY = static_cast(m_height - 1); // paint graph for (int i = 0; i < m_values.count(); i++) { - float x = i * normX; + float x = static_cast(i) * normX; float y = 0.5f; float width = normX; float height = m_values.at(i) * normY + 0.5f; @@ -137,9 +137,10 @@ void GraphicalItemHelper::paintGraph(const float _value) // paint graph for (int i = 0; i < m_values.count() - 1; i++) { // some magic here - float x1 = i * normX; + auto value = static_cast(i); + float x1 = value * normX; float y1 = m_values.at(i) * normY + 0.5f; - float x2 = (i + 1) * normX; + float x2 = (value + 1) * normX; float y2 = m_values.at(i + 1) * normY + 0.5f; m_scene->addLine(x1, y1, x2, y2, m_activePen); } @@ -153,10 +154,11 @@ void GraphicalItemHelper::paintHorizontal(const float _percent) m_activePen.setWidth(m_height); m_inactivePen.setWidth(m_height); // inactive - m_scene->addLine(_percent * m_width + 0.5 * m_height, 0.5 * m_height, m_width + 0.5 * m_height, + auto width = static_cast(m_width); + m_scene->addLine(_percent * width + 0.5 * m_height, 0.5 * m_height, m_width + 0.5 * m_height, 0.5 * m_height, m_inactivePen); // active - m_scene->addLine(-0.5 * m_height, 0.5 * m_height, _percent * m_width - 0.5 * m_height, + m_scene->addLine(-0.5 * m_height, 0.5 * m_height, _percent * width - 0.5 * m_height, 0.5 * m_height, m_activePen); } diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index 8cbb1b4..a7dd2d5 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -33,21 +33,21 @@ public: explicit GraphicalItemHelper(QObject *_parent = nullptr, QGraphicsScene *_scene = nullptr); ~GraphicalItemHelper() override; // parameters - void setParameters(const QString &_active, const QString &_inactive, const int _width, - const int _height, const int _count); + void setParameters(const QString &_active, const QString &_inactive, int _width, int _height, + int _count); // paint methods - void paintBars(const float _value); - void paintCircle(const float _percent); - void paintGraph(const float _value); - void paintHorizontal(const float _percent); - void paintVertical(const float _percent); + void paintBars(float _value); + void paintCircle(float _percent); + void paintGraph(float _value); + void paintHorizontal(float _percent); + void paintVertical(float _percent); // additional conversion methods - static float getPercents(const float _value, const float _min, const float _max); + static float getPercents(float _value, float _min, float _max); static bool isColor(const QString &_input); static QColor stringToColor(const QString &_color); private: - void storeValue(const float _value); + void storeValue(float _value); QGraphicsScene *m_scene = nullptr; int m_count = 100; QPen m_activePen; diff --git a/sources/awesomewidgets/owmweatherprovider.h b/sources/awesomewidgets/owmweatherprovider.h index 3222e5c..44612cb 100644 --- a/sources/awesomewidgets/owmweatherprovider.h +++ b/sources/awesomewidgets/owmweatherprovider.h @@ -33,12 +33,12 @@ public: explicit OWMWeatherProvider(QObject *_parent); ~OWMWeatherProvider() override; - void initUrl(const QString &_city, const QString &_country, const int) override; - QVariantHash parse(const QVariantMap &_json) const override; - QUrl url() const override; + void initUrl(const QString &_city, const QString &_country, int) override; + [[nodiscard]] QVariantHash parse(const QVariantMap &_json) const override; + [[nodiscard]] QUrl url() const override; private: - QVariantHash parseSingleJson(const QVariantMap &_json) const; + [[nodiscard]] QVariantHash parseSingleJson(const QVariantMap &_json) const; int m_ts = 0; QUrl m_url; }; diff --git a/sources/awesomewidgets/qcronscheduler.h b/sources/awesomewidgets/qcronscheduler.h index b42c495..5088587 100644 --- a/sources/awesomewidgets/qcronscheduler.h +++ b/sources/awesomewidgets/qcronscheduler.h @@ -39,7 +39,7 @@ public: int minValue = -1; int maxValue = -1; int div = 1; - void fromRange(const QString &_range, const int _min, const int _max); + void fromRange(const QString &_range, int _min, int _max); QList toList(); } QCronField; @@ -56,7 +56,7 @@ private slots: private: QCronRunSchedule m_schedule; QTimer *m_timer = nullptr; - static QList parseField(const QString &_value, const int _min, const int _max); + static QList parseField(const QString &_value, int _min, int _max); }; diff --git a/sources/awesomewidgets/scripts/get-external-ip.desktop b/sources/awesomewidgets/scripts/get-external-ip.desktop index 3e48688..4b3ec25 100644 --- a/sources/awesomewidgets/scripts/get-external-ip.desktop +++ b/sources/awesomewidgets/scripts/get-external-ip.desktop @@ -3,11 +3,10 @@ Encoding=UTF-8 Name=aw-get-external-ip Comment=Custom command to get external IP Exec=curl ip4.telize.com -X-AW-Prefix= X-AW-Active=false X-AW-Redirect=nothing X-AW-Interval=1 -X-AW-ApiVersion=5 +X-AW-ApiVersion=6 X-AW-Number=0 X-AW-Filters= X-AW-Schedule= diff --git a/sources/awesomewidgets/stooqquotesprovider.h b/sources/awesomewidgets/stooqquotesprovider.h index ae232d7..e83ea69 100644 --- a/sources/awesomewidgets/stooqquotesprovider.h +++ b/sources/awesomewidgets/stooqquotesprovider.h @@ -31,8 +31,9 @@ public: explicit StooqQuotesProvider(QObject *_parent); ~StooqQuotesProvider() override; void initUrl(const QString &_asset) override; - QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override; - QUrl url() const override; + [[nodiscard]] QVariantHash parse(const QByteArray &_source, + const QVariantHash &_oldValues) const override; + [[nodiscard]] QUrl url() const override; private: QUrl m_url; diff --git a/sources/awesomewidgets/yahooquotesprovider.h b/sources/awesomewidgets/yahooquotesprovider.h index c63a007..58cc6e0 100644 --- a/sources/awesomewidgets/yahooquotesprovider.h +++ b/sources/awesomewidgets/yahooquotesprovider.h @@ -32,8 +32,9 @@ public: explicit YahooQuotesProvider(QObject *_parent); ~YahooQuotesProvider() override; void initUrl(const QString &_asset) override; - QVariantHash parse(const QByteArray &_source, const QVariantHash &_oldValues) const override; - QUrl url() const override; + [[nodiscard]] QVariantHash parse(const QByteArray &_source, + const QVariantHash &_oldValues) const override; + [[nodiscard]] QUrl url() const override; private: QUrl m_url; diff --git a/sources/awesomewidgets/yahooweatherprovider.h b/sources/awesomewidgets/yahooweatherprovider.h index 20e0eee..cd8c476 100644 --- a/sources/awesomewidgets/yahooweatherprovider.h +++ b/sources/awesomewidgets/yahooweatherprovider.h @@ -33,13 +33,14 @@ public: explicit YahooWeatherProvider(QObject *_parent); ~YahooWeatherProvider() override; - void initUrl(const QString &_city, const QString &_country, const int) override; - QVariantHash parse(const QVariantMap &_json) const override; - QUrl url() const override; + void initUrl(const QString &_city, const QString &_country, int) override; + [[nodiscard]] QVariantHash parse(const QVariantMap &_json) const override; + [[nodiscard]] QUrl url() const override; private: - QVariantHash parseCurrent(const QVariantMap &_json, const QVariantMap &_atmosphere) const; - QVariantHash parseForecast(const QVariantMap &_json) const; + [[nodiscard]] QVariantHash parseCurrent(const QVariantMap &_json, + const QVariantMap &_atmosphere) const; + [[nodiscard]] QVariantHash parseForecast(const QVariantMap &_json) const; int m_ts = 0; QUrl m_url; }; diff --git a/sources/desktop-panel/plugin/dpadds.cpp b/sources/desktop-panel/plugin/dpadds.cpp index 1b53277..434564a 100644 --- a/sources/desktop-panel/plugin/dpadds.cpp +++ b/sources/desktop-panel/plugin/dpadds.cpp @@ -118,34 +118,35 @@ QString DPAdds::toolTipImage(const int _desktop) const toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // update - float margin = 5.0f * info.desktop.width() / 400.0f; - toolTipView->resize(static_cast(info.desktop.width() + 2.0f * margin), - static_cast(info.desktop.height() + 2.0f * margin)); + auto width = static_cast(info.desktop.width()); + auto height = static_cast(info.desktop.height()); + float margin = 5.0f * width / 400.0f; + toolTipView->resize(static_cast(width + 2.0f * margin), + static_cast(height + 2.0f * margin)); toolTipScene->clear(); toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush)); // borders - toolTipScene->addLine(0, 0, 0, info.desktop.height() + 2.0 * margin); - toolTipScene->addLine(0, info.desktop.height() + 2.0 * margin, - info.desktop.width() + 2.0 * margin, - info.desktop.height() + 2.0 * margin); - toolTipScene->addLine(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin, - info.desktop.width() + 2.0 * margin, 0); - toolTipScene->addLine(info.desktop.width() + 2.0 * margin, 0, 0, 0); + toolTipScene->addLine(0, 0, 0, height + 2.0 * margin); + toolTipScene->addLine(0, height + 2.0 * margin, width + 2.0 * margin, height + 2.0 * margin); + toolTipScene->addLine(width + 2.0 * margin, height + 2.0 * margin, width + 2.0 * margin, 0); + toolTipScene->addLine(width + 2.0 * margin, 0, 0, 0); if (m_tooltipType == "contours") { QPen pen = QPen(); - pen.setWidthF(2.0 * info.desktop.width() / 400.0); + pen.setWidthF(2.0 * width / 400.0); pen.setColor(QColor(m_tooltipColor)); for (auto &data : info.windowsData) { QRect rect = data.rect; - toolTipScene->addLine(rect.left() + margin, rect.bottom() + margin, - rect.left() + margin, rect.top() + margin, pen); - toolTipScene->addLine(rect.left() + margin, rect.top() + margin, rect.right() + margin, - rect.top() + margin, pen); - toolTipScene->addLine(rect.right() + margin, rect.top() + margin, rect.right() + margin, - rect.bottom() + margin, pen); - toolTipScene->addLine(rect.right() + margin, rect.bottom() + margin, - rect.left() + margin, rect.bottom() + margin, pen); + auto left = static_cast(rect.left()); + auto right = static_cast(rect.right()); + auto top = static_cast(rect.top()); + auto bottom = static_cast(rect.bottom()); + toolTipScene->addLine(left + margin, bottom + margin, left + margin, top + margin, pen); + toolTipScene->addLine(left + margin, top + margin, right + margin, top + margin, pen); + toolTipScene->addLine(right + margin, top + margin, right + margin, bottom + margin, + pen); + toolTipScene->addLine(right + margin, bottom + margin, left + margin, bottom + margin, + pen); } } else if (m_tooltipType == "clean") { QScreen *screen = QGuiApplication::primaryScreen(); diff --git a/sources/desktop-panel/plugin/dpadds.h b/sources/desktop-panel/plugin/dpadds.h index 8604716..d3f6fa6 100644 --- a/sources/desktop-panel/plugin/dpadds.h +++ b/sources/desktop-panel/plugin/dpadds.h @@ -45,15 +45,15 @@ public: ~DPAdds() override; Q_INVOKABLE static bool isDebugEnabled(); Q_INVOKABLE static int currentDesktop(); - Q_INVOKABLE static QStringList dictKeys(const bool _sorted = true, const QString &_regexp = ""); + Q_INVOKABLE static QStringList dictKeys(bool _sorted = true, const QString &_regexp = ""); Q_INVOKABLE static int numberOfDesktops(); - Q_INVOKABLE QString toolTipImage(const int _desktop) const; - Q_INVOKABLE QString parsePattern(const QString &_pattern, const int _desktop) const; + Q_INVOKABLE [[nodiscard]] QString toolTipImage(int _desktop) const; + Q_INVOKABLE [[nodiscard]] QString parsePattern(const QString &_pattern, int _desktop) const; // values Q_INVOKABLE void setMark(const QString &_newMark); Q_INVOKABLE void setToolTipData(const QVariantMap &_tooltipData); Q_INVOKABLE static QString infoByKey(const QString &_key); - Q_INVOKABLE QString valueByKey(const QString &_key, int _desktop = -1) const; + Q_INVOKABLE [[nodiscard]] QString valueByKey(const QString &_key, int _desktop = -1) const; // configuration slots Q_INVOKABLE static QString getAboutText(const QString &_type); Q_INVOKABLE static QVariantMap getFont(const QVariantMap &_defaultFont); @@ -64,10 +64,10 @@ signals: public slots: Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message); - Q_INVOKABLE static void setCurrentDesktop(const int _desktop); + Q_INVOKABLE static void setCurrentDesktop(int _desktop); private: - static DesktopWindowsInfo getInfoByDesktop(const int _desktop); + static DesktopWindowsInfo getInfoByDesktop(int _desktop); // variables int m_tooltipWidth = 200; QString m_mark = "*"; diff --git a/sources/extsysmon/extsysmon.cpp b/sources/extsysmon/extsysmon.cpp index 17f56fc..88b6e39 100644 --- a/sources/extsysmon/extsysmon.cpp +++ b/sources/extsysmon/extsysmon.cpp @@ -108,8 +108,7 @@ void ExtendedSysMon::readConfiguration() } -QHash -ExtendedSysMon::updateConfiguration(QHash _rawConfig) const +QHash ExtendedSysMon::updateConfiguration(QHash _rawConfig) { qCDebug(LOG_ESM) << "Raw configuration" << _rawConfig; diff --git a/sources/extsysmon/extsysmon.h b/sources/extsysmon/extsysmon.h index c1aded3..6f6b109 100644 --- a/sources/extsysmon/extsysmon.h +++ b/sources/extsysmon/extsysmon.h @@ -32,7 +32,7 @@ public: ~ExtendedSysMon() override; protected: - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; bool sourceRequestEvent(const QString &_source) override; bool updateSourceEvent(const QString &_source) override; @@ -42,7 +42,8 @@ private: QHash m_configuration; // methods void readConfiguration(); - QHash updateConfiguration(QHash _rawConfig) const; + [[nodiscard]] static QHash + updateConfiguration(QHash _rawConfig); }; diff --git a/sources/extsysmon/extsysmonaggregator.h b/sources/extsysmon/extsysmonaggregator.h index 6543fe5..d47d216 100644 --- a/sources/extsysmon/extsysmonaggregator.h +++ b/sources/extsysmon/extsysmonaggregator.h @@ -30,10 +30,10 @@ class ExtSysMonAggregator : public QObject public: explicit ExtSysMonAggregator(QObject *_parent, const QHash &_config); ~ExtSysMonAggregator() override; - QVariant data(const QString &_source) const; - bool hasSource(const QString &_source) const; - QVariantMap initialData(const QString &_source) const; - QStringList sources() const; + [[nodiscard]] QVariant data(const QString &_source) const; + [[nodiscard]] bool hasSource(const QString &_source) const; + [[nodiscard]] QVariantMap initialData(const QString &_source) const; + [[nodiscard]] QStringList sources() const; private: void init(const QHash &_config); diff --git a/sources/extsysmonsources/abstractextsysmonsource.h b/sources/extsysmonsources/abstractextsysmonsource.h index 5b5dcc8..cfe1366 100644 --- a/sources/extsysmonsources/abstractextsysmonsource.h +++ b/sources/extsysmonsources/abstractextsysmonsource.h @@ -32,9 +32,9 @@ public: : QObject(_parent){}; ~AbstractExtSysMonSource() override = default; virtual QVariant data(const QString &_source) = 0; - virtual QVariantMap initialData(const QString &_source) const = 0; + [[nodiscard]] virtual QVariantMap initialData(const QString &_source) const = 0; virtual void run() = 0; - virtual QStringList sources() const = 0; + [[nodiscard]] virtual QStringList sources() const = 0; // used by extensions static int index(const QString &_source) { diff --git a/sources/extsysmonsources/batterysource.cpp b/sources/extsysmonsources/batterysource.cpp index 7472db2..af25bda 100644 --- a/sources/extsysmonsources/batterysource.cpp +++ b/sources/extsysmonsources/batterysource.cpp @@ -241,7 +241,8 @@ void BatterySource::calculateRates() // check time interval auto now = QDateTime::currentDateTimeUtc(); - auto interval = (now.toMSecsSinceEpoch() - m_timestamp.toMSecsSinceEpoch()) / 1000.0f; + auto interval = m_timestamp.secsTo(now); + qCDebug(LOG_AW) << interval; m_timestamp.swap(now); for (int i = 0; i < m_batteriesCount; i++) { diff --git a/sources/extsysmonsources/batterysource.h b/sources/extsysmonsources/batterysource.h index 5de7efd..23b3a34 100644 --- a/sources/extsysmonsources/batterysource.h +++ b/sources/extsysmonsources/batterysource.h @@ -35,9 +35,9 @@ public: ~BatterySource() override; QStringList getSources(); QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: static double approximate(const QList &_trend); diff --git a/sources/extsysmonsources/customsource.h b/sources/extsysmonsources/customsource.h index 290bcd6..c7e921d 100644 --- a/sources/extsysmonsources/customsource.h +++ b/sources/extsysmonsources/customsource.h @@ -34,9 +34,9 @@ public: explicit CustomSource(QObject *_parent, const QStringList &_args); ~CustomSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/desktopsource.h b/sources/extsysmonsources/desktopsource.h index 8a2b235..1de29d1 100644 --- a/sources/extsysmonsources/desktopsource.h +++ b/sources/extsysmonsources/desktopsource.h @@ -31,9 +31,9 @@ public: explicit DesktopSource(QObject *_parent, const QStringList &_args); ~DesktopSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; }; diff --git a/sources/extsysmonsources/gpuloadsource.h b/sources/extsysmonsources/gpuloadsource.h index 8662cca..5787411 100644 --- a/sources/extsysmonsources/gpuloadsource.h +++ b/sources/extsysmonsources/gpuloadsource.h @@ -34,9 +34,9 @@ public: ~GPULoadSource() override; static QString autoGpu(); QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private slots: void updateValue(); diff --git a/sources/extsysmonsources/gputempsource.cpp b/sources/extsysmonsources/gputempsource.cpp index a7edad0..55fbadc 100644 --- a/sources/extsysmonsources/gputempsource.cpp +++ b/sources/extsysmonsources/gputempsource.cpp @@ -84,7 +84,8 @@ void GPUTemperatureSource::run() return; // build cmd QString cmd = m_device == "nvidia" ? "nvidia-smi" : "aticonfig"; - auto args = m_device == "nvidia" ? QStringList({"-q", "-x"}) : QStringList({"--od-gettemperature"}); + auto args + = m_device == "nvidia" ? QStringList({"-q", "-x"}) : QStringList({"--od-gettemperature"}); qCInfo(LOG_ESS) << "cmd" << cmd; m_process->start(cmd, args); diff --git a/sources/extsysmonsources/gputempsource.h b/sources/extsysmonsources/gputempsource.h index cfd7edb..1d88ccf 100644 --- a/sources/extsysmonsources/gputempsource.h +++ b/sources/extsysmonsources/gputempsource.h @@ -33,9 +33,9 @@ public: explicit GPUTemperatureSource(QObject *_parent, const QStringList &_args); ~GPUTemperatureSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private slots: void updateValue(); diff --git a/sources/extsysmonsources/hddtempsource.cpp b/sources/extsysmonsources/hddtempsource.cpp index d434db7..efaae08 100644 --- a/sources/extsysmonsources/hddtempsource.cpp +++ b/sources/extsysmonsources/hddtempsource.cpp @@ -32,7 +32,7 @@ HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, const QStringList & qCDebug(LOG_ESS) << __PRETTY_FUNCTION__; m_devices = _args.at(0).split(',', Qt::SkipEmptyParts); - m_cmd = _args.at(1).split(' '); // lets hope no one put cmd with spaces here lol + m_cmd = _args.at(1).split(' '); // lets hope no one put cmd with spaces here lol m_smartctl = m_cmd.contains("smartctl"); qCInfo(LOG_ESS) << "Parse as smartctl" << m_smartctl; diff --git a/sources/extsysmonsources/hddtempsource.h b/sources/extsysmonsources/hddtempsource.h index 469a67a..4034ab8 100644 --- a/sources/extsysmonsources/hddtempsource.h +++ b/sources/extsysmonsources/hddtempsource.h @@ -34,9 +34,9 @@ public: ~HDDTemperatureSource() override; static QStringList allHdd(); QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private slots: void updateValue(const QString &_device); diff --git a/sources/extsysmonsources/loadsource.h b/sources/extsysmonsources/loadsource.h index e3f68f4..3566d32 100644 --- a/sources/extsysmonsources/loadsource.h +++ b/sources/extsysmonsources/loadsource.h @@ -31,9 +31,9 @@ public: explicit LoadSource(QObject *_parent, const QStringList &_args); ~LoadSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; }; diff --git a/sources/extsysmonsources/networksource.h b/sources/extsysmonsources/networksource.h index 7144543..8e115c6 100644 --- a/sources/extsysmonsources/networksource.h +++ b/sources/extsysmonsources/networksource.h @@ -33,9 +33,9 @@ public: explicit NetworkSource(QObject *_parent, const QStringList &_args); ~NetworkSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private slots: void updateSsid(); diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index 6700138..aaca22f 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -311,7 +311,7 @@ QVariantHash PlayerSource::getPlayerMpdInfo() } -QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) const +QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) { qCDebug(LOG_ESS) << "MPRIS" << _mpris; @@ -338,7 +338,7 @@ QVariantHash PlayerSource::getPlayerMprisInfo(const QString &_mpris) const qCWarning(LOG_ESS) << "Error message" << response.errorMessage(); } else { // another portion of dirty magic - QVariantHash map = qdbus_cast( + auto map = qdbus_cast( response.arguments().first().value().variant().value()); info["player/album"] = map.value("xesam:album", "unknown"); // artist is array diff --git a/sources/extsysmonsources/playersource.h b/sources/extsysmonsources/playersource.h index ec42bce..e5a8449 100644 --- a/sources/extsysmonsources/playersource.h +++ b/sources/extsysmonsources/playersource.h @@ -38,24 +38,24 @@ public: ~PlayerSource() override; QVariant data(const QString &_source) override; static QString getAutoMpris(); - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; // additional method to build dynamic tags - static QString buildString(const QString &_current, const QString &_value, const int _s); - static QString stripString(const QString &_value, const int _s); + static QString buildString(const QString &_current, const QString &_value, int _s); + static QString stripString(const QString &_value, int _s); // additional test method - bool isMpdSocketConnected() const; + [[nodiscard]] bool isMpdSocketConnected() const; private slots: void mpdSocketConnected(); void mpdSocketReadyRead(); - void mpdSocketWritten(const qint64 _bytes); + void mpdSocketWritten(qint64 _bytes); private: static inline QVariantHash defaultInfo(); QVariantHash getPlayerMpdInfo(); - QVariantHash getPlayerMprisInfo(const QString &_mpris) const; + [[nodiscard]] static QVariantHash getPlayerMprisInfo(const QString &_mpris); QTcpSocket m_mpdSocket; // configuration and values QString m_mpdAddress; diff --git a/sources/extsysmonsources/processessource.h b/sources/extsysmonsources/processessource.h index 2f44781..2f4cb6e 100644 --- a/sources/extsysmonsources/processessource.h +++ b/sources/extsysmonsources/processessource.h @@ -31,9 +31,9 @@ public: explicit ProcessesSource(QObject *_parent, const QStringList &_args); ~ProcessesSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: // configuration and values diff --git a/sources/extsysmonsources/quotessource.h b/sources/extsysmonsources/quotessource.h index 21470bc..04fbcba 100644 --- a/sources/extsysmonsources/quotessource.h +++ b/sources/extsysmonsources/quotessource.h @@ -34,9 +34,9 @@ public: explicit QuotesSource(QObject *_parent, const QStringList &_args); ~QuotesSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/requestsource.h b/sources/extsysmonsources/requestsource.h index 6661aa4..4ad16cb 100644 --- a/sources/extsysmonsources/requestsource.h +++ b/sources/extsysmonsources/requestsource.h @@ -34,9 +34,9 @@ public: explicit RequestSource(QObject *_parent, const QStringList &_args); ~RequestSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/systeminfosource.h b/sources/extsysmonsources/systeminfosource.h index 521b025..88b6c10 100644 --- a/sources/extsysmonsources/systeminfosource.h +++ b/sources/extsysmonsources/systeminfosource.h @@ -31,9 +31,9 @@ public: explicit SystemInfoSource(QObject *_parent, const QStringList &_args); ~SystemInfoSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: // configuration and values diff --git a/sources/extsysmonsources/upgradesource.h b/sources/extsysmonsources/upgradesource.h index 21db72c..79a6443 100644 --- a/sources/extsysmonsources/upgradesource.h +++ b/sources/extsysmonsources/upgradesource.h @@ -34,9 +34,9 @@ public: explicit UpgradeSource(QObject *_parent, const QStringList &_args); ~UpgradeSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/extsysmonsources/weathersource.h b/sources/extsysmonsources/weathersource.h index 3ed8cea..b75a1e5 100644 --- a/sources/extsysmonsources/weathersource.h +++ b/sources/extsysmonsources/weathersource.h @@ -34,9 +34,9 @@ public: explicit WeatherSource(QObject *_parent, const QStringList &_args); ~WeatherSource() override; QVariant data(const QString &_source) override; - QVariantMap initialData(const QString &_source) const override; + [[nodiscard]] QVariantMap initialData(const QString &_source) const override; void run() override{}; - QStringList sources() const override; + [[nodiscard]] QStringList sources() const override; private: QStringList getSources(); diff --git a/sources/test/awtestlibrary.cpp b/sources/test/awtestlibrary.cpp index f702381..2413c26 100644 --- a/sources/test/awtestlibrary.cpp +++ b/sources/test/awtestlibrary.cpp @@ -20,15 +20,13 @@ #include #include +#include #include #include -#include #include -void AWTestLibrary::init() -{ -} +void AWTestLibrary::init() {} bool AWTestLibrary::isKWinActive() diff --git a/sources/test/testbatterysource.cpp b/sources/test/testbatterysource.cpp index 893a00d..434cb6d 100644 --- a/sources/test/testbatterysource.cpp +++ b/sources/test/testbatterysource.cpp @@ -52,10 +52,12 @@ void TestBatterySource::test_battery() QSKIP("No battery found, test will be skipped"); QStringList batteries = source->sources(); - std::for_each(batteries.begin(), batteries.end(), [this](const QString bat) { + std::for_each(batteries.begin(), batteries.end(), [this](const QString &bat) { QVariant value = source->data(bat); if (bat == "battery/ac") QCOMPARE(value.type(), QVariant::Bool); + else if (bat.startsWith("battery/batrate") || bat.startsWith("battery/batleft")) + ; else QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat()))); }); diff --git a/sources/test/testextscript.cpp b/sources/test/testextscript.cpp index 1586a83..bd89f00 100644 --- a/sources/test/testextscript.cpp +++ b/sources/test/testextscript.cpp @@ -31,10 +31,9 @@ void TestExtScript::initTestCase() extScript = new ExtScript(nullptr); extScript->setInterval(1); - extScript->setExecutable(randomString); + extScript->setExecutable(QString("echo %1").arg(randomString)); extScript->setNumber(0); extScript->setRedirect(ExtScript::Redirect::stderr2stdout); - extScript->setPrefix("echo"); extScript->run(); } @@ -50,9 +49,8 @@ void TestExtScript::test_values() { QCOMPARE(extScript->interval(), 1); QCOMPARE(extScript->number(), 0); - QCOMPARE(extScript->executable(), randomString); + QCOMPARE(extScript->executable(), QString("echo %1").arg(randomString)); QCOMPARE(extScript->strRedirect(), QString("stderr2stdout")); - QCOMPARE(extScript->prefix(), QString("echo")); } @@ -97,7 +95,6 @@ void TestExtScript::test_copy() QCOMPARE(newExtScript->interval(), extScript->interval()); QCOMPARE(newExtScript->executable(), extScript->executable()); QCOMPARE(newExtScript->strRedirect(), extScript->strRedirect()); - QCOMPARE(newExtScript->prefix(), extScript->prefix()); QCOMPARE(newExtScript->filters(), extScript->filters()); QCOMPARE(newExtScript->number(), 1); diff --git a/sources/test/testfloatformatter.cpp b/sources/test/testfloatformatter.cpp index 24abf6d..fbec11a 100644 --- a/sources/test/testfloatformatter.cpp +++ b/sources/test/testfloatformatter.cpp @@ -18,8 +18,8 @@ #include "testfloatformatter.h" -#include #include +#include #include "awfloatformatter.h" #include "awtestlibrary.h" From 1e0316c4deefb49ae4e88b0b8011b5497efee36d Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 7 Nov 2020 16:45:36 +0300 Subject: [PATCH 33/35] fix warnings --- sources/awdebug.cpp | 2 +- .../package/contents/ui/about.qml | 2 ++ .../package/contents/ui/about.qml | 2 ++ sources/qml/BugReport.qml | 32 +++++++------------ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/sources/awdebug.cpp b/sources/awdebug.cpp index a568db4..7135db6 100644 --- a/sources/awdebug.cpp +++ b/sources/awdebug.cpp @@ -35,7 +35,7 @@ QString AWDebug::getAboutText(const QString &_type) if (_type == "header") { text = NAME; } else if (_type == "version") { - text = i18np("Version %1 (build date %2)", VERSION, BUILD_DATE); + text = i18n("Version %1 (build date %2)", VERSION, BUILD_DATE); if (!QString(COMMIT_SHA).isEmpty()) text += QString(" (%1)").arg(COMMIT_SHA); } else if (_type == "description") { diff --git a/sources/awesome-widget/package/contents/ui/about.qml b/sources/awesome-widget/package/contents/ui/about.qml index 7f39ffe..15ec0de 100644 --- a/sources/awesome-widget/package/contents/ui/about.qml +++ b/sources/awesome-widget/package/contents/ui/about.qml @@ -30,6 +30,8 @@ Item { width: childrenRect.width height: childrenRect.height + property bool debug: awActions.isDebugEnabled() + AboutTab { textProvider: awActions } diff --git a/sources/desktop-panel/package/contents/ui/about.qml b/sources/desktop-panel/package/contents/ui/about.qml index 352cf42..fd6361a 100644 --- a/sources/desktop-panel/package/contents/ui/about.qml +++ b/sources/desktop-panel/package/contents/ui/about.qml @@ -30,6 +30,8 @@ Item { width: childrenRect.width height: childrenRect.height + property bool debug: awActions.isDebugEnabled() + AboutTab { textProvider: dpAdds } diff --git a/sources/qml/BugReport.qml b/sources/qml/BugReport.qml index 1b76e6e..50b80d7 100644 --- a/sources/qml/BugReport.qml +++ b/sources/qml/BugReport.qml @@ -45,17 +45,14 @@ QtDialogs.Dialog { QtControls.TextField { id: title - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true placeholderText: i18n("Report subject") } QtLayouts.ColumnLayout { - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true QtControls.GroupBox { - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true height: parent.height / 5 title: i18n("Description") QtControls.TextArea { @@ -65,8 +62,7 @@ QtDialogs.Dialog { } } QtControls.GroupBox { - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true height: parent.height / 5 title: i18n("Steps to reproduce") QtControls.TextArea { @@ -76,8 +72,7 @@ QtDialogs.Dialog { } } QtControls.GroupBox { - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true height: parent.height / 5 title: i18n("Expected result") QtControls.TextArea { @@ -87,15 +82,14 @@ QtDialogs.Dialog { } } QtControls.GroupBox { - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom + QtLayouts.Layout.fillWidth: true + QtLayouts.Layout.alignment: Qt.AlignBottom title: i18n("Logs") QtLayouts.ColumnLayout { anchors.fill: parent + QtLayouts.Layout.fillWidth: true Row { - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true QtControls.Label { width: parent.width * 2 / 5 horizontalAlignment: Text.AlignJustify @@ -110,16 +104,14 @@ QtDialogs.Dialog { } } QtControls.Button { - anchors.left: parent.left - anchors.right: parent.right + QtLayouts.Layout.fillWidth: true text: i18n("Load log file") onClicked: logPath.open() } QtControls.TextArea { id: logBody - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom + QtLayouts.Layout.fillWidth: true + QtLayouts.Layout.alignment: Qt.AlignBottom textFormat: TextEdit.PlainText } } From e592de9555095d73f1d7151d58ebb576729bc5fc Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sat, 7 Nov 2020 17:05:13 +0300 Subject: [PATCH 34/35] release 3.4.0 --- packages/PKGBUILD | 4 +- sources/CMakeLists.txt | 4 +- .../awesome-widget/package/metadata.desktop | 2 +- .../desktop-panel/package/metadata.desktop | 2 +- sources/translations/en.po | 43 ++++------ sources/translations/es.po | 25 ++---- sources/translations/fr.po | 25 ++---- sources/translations/id_ID.po | 36 +++----- sources/translations/it.po | 83 +++++++++---------- sources/translations/lt.po | 24 ++---- sources/translations/nl_NL.po | 25 ++---- sources/translations/pl.po | 25 ++---- sources/translations/pt_BR.po | 24 ++---- sources/translations/ru.po | 44 ++++------ sources/translations/si.po | 24 ++---- sources/translations/uk.po | 25 ++---- sources/translations/zh.po | 25 ++---- 17 files changed, 158 insertions(+), 282 deletions(-) diff --git a/packages/PKGBUILD b/packages/PKGBUILD index 5ce62ec..7f7e3f7 100644 --- a/packages/PKGBUILD +++ b/packages/PKGBUILD @@ -2,7 +2,7 @@ pkgname=plasma5-applet-awesome-widgets _pkgname=awesome-widgets -pkgver=3.3.3 +pkgver=3.4.0 pkgrel=1 pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)" arch=('i686' 'x86_64') @@ -17,7 +17,7 @@ optdepends=("catalyst: for GPU monitor" makedepends=('cmake' 'extra-cmake-modules' 'python') source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz) install=${pkgname}.install -md5sums=('ce2413868cbb230e358e75a15975a1e5') +md5sums=('8097663d06715e7543643de4c77de6b6') backup=('etc/xdg/plasma-dataengine-extsysmon.conf') prepare() { diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 4dd30a1..3e1b04f 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -15,8 +15,8 @@ set(PROJECT_AUTHOR "Evgeniy Alekseev") set(PROJECT_CONTACT "esalexeev@gmail.com") set(PROJECT_LICENSE "GPL3") set(PROJECT_VERSION_MAJOR "3") -set(PROJECT_VERSION_MINOR "3") -set(PROJECT_VERSION_PATCH "3") +set(PROJECT_VERSION_MINOR "4") +set(PROJECT_VERSION_PATCH "0") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # append git version if any set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "") diff --git a/sources/awesome-widget/package/metadata.desktop b/sources/awesome-widget/package/metadata.desktop index 22a5b57..278d873 100644 --- a/sources/awesome-widget/package/metadata.desktop +++ b/sources/awesome-widget/package/metadata.desktop @@ -19,7 +19,7 @@ X-Plasma-MainScript=ui/main.qml X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget -X-KDE-PluginInfo-Version=3.3.3 +X-KDE-PluginInfo-Version=3.4.0 X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= diff --git a/sources/desktop-panel/package/metadata.desktop b/sources/desktop-panel/package/metadata.desktop index db9fc5c..5bfb750 100644 --- a/sources/desktop-panel/package/metadata.desktop +++ b/sources/desktop-panel/package/metadata.desktop @@ -19,7 +19,7 @@ X-Plasma-MainScript=ui/main.qml X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel -X-KDE-PluginInfo-Version=3.3.3 +X-KDE-PluginInfo-Version=3.4.0 X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= diff --git a/sources/translations/en.po b/sources/translations/en.po index 4ad67ac..e08ebcc 100644 --- a/sources/translations/en.po +++ b/sources/translations/en.po @@ -1,22 +1,22 @@ # Copyright (C) 2014 # This file is distributed under the same license as the PyTextMonitor package. # -# Evgeniy Alekseev , 2014, 2015, 2016, 2017. +# Evgeniy Alekseev , 2014, 2015, 2016, 2017, 2020. msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2017-07-13 17:39+0300\n" -"PO-Revision-Date: 2017-07-13 17:51+0300\n" -"Last-Translator: Evgeniy Alekseev \n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" +"PO-Revision-Date: 2020-11-07 16:47+0300\n" +"Last-Translator: Evgenii 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" -"X-Generator: Lokalize 2.0\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 20.08.2\n" msgid "Version %1 (build date %2)" msgstr "Version %1 (build date %2)" @@ -45,9 +45,6 @@ msgstr "AUR packages" msgid "openSUSE packages" msgstr "openSUSE packages" -msgid "This software is licensed under %1" -msgstr "This software is licensed under %1" - msgid "Translators:" msgstr "Translators:" @@ -382,18 +379,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "Changelog of %1" - msgid "You are using the actual version %1" msgstr "You are using the actual version %1" msgid "No new version found" msgstr "No new version found" -msgid "Current version : %1" -msgstr "Current version : %1" - msgid "New version : %1" msgstr "New version : %1" @@ -497,15 +488,13 @@ msgid "Interval" msgstr "Interval" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgid "Ticker" msgstr "Ticker" @@ -513,9 +502,6 @@ msgstr "Ticker" msgid "Command" msgstr "Command" -msgid "Prefix" -msgstr "Prefix" - msgid "Redirect" msgstr "Redirect" @@ -712,6 +698,9 @@ msgstr "Network request" msgid "Scripts" msgstr "Scripts" +msgid "System" +msgstr "System" + msgid "Time" msgstr "Time" diff --git a/sources/translations/es.po b/sources/translations/es.po index 51c9e87..ff7f54d 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: 2017-07-13 17:39+0300\n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" "PO-Revision-Date: 2016-08-03 15:30+0000\n" "Last-Translator: Ernesto Avilés Vázquez \n" "Language-Team: Spanish (http://www.transifex.com/arcanis/awesome-widgets/" @@ -47,9 +47,6 @@ msgstr "Paquetes AUR" msgid "openSUSE packages" msgstr "Paquetes de openSUSE" -msgid "This software is licensed under %1" -msgstr "Este software está licenciado bajo %1" - #, fuzzy msgid "Translators:" msgstr "Traductores: %1" @@ -392,18 +389,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "Cambios de %1" - msgid "You are using the actual version %1" msgstr "Estás usando al versión actual %1" msgid "No new version found" msgstr "No se encontraron nuevas versiones" -msgid "Current version : %1" -msgstr "Versión actual: %1" - msgid "New version : %1" msgstr "Nueva versión: %1" @@ -506,11 +497,11 @@ msgstr "" msgid "Interval" msgstr "Intervalo" +#, fuzzy msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" "

    Usa el tablero electrónico de YAHOO! para obtener la " "cotización del medio. Dirígete a \n" "Language-Team: French \n" @@ -47,9 +47,6 @@ msgstr "Paquets depuis AUR" msgid "openSUSE packages" msgstr "Paquets openSUSE" -msgid "This software is licensed under %1" -msgstr "Ce programme est publié sous la licence %1" - #, fuzzy msgid "Translators:" msgstr "Traducteurs: %1" @@ -402,9 +399,6 @@ msgstr "" msgid "KB/s" msgstr "" -msgid "Changelog of %1" -msgstr "" - msgid "You are using the actual version %1" msgstr "" @@ -412,10 +406,6 @@ msgstr "" msgid "No new version found" msgstr "Nouvelle version" -#, fuzzy -msgid "Current version : %1" -msgstr "Version actuelle" - #, fuzzy msgid "New version : %1" msgstr "Nouvelle version" @@ -528,10 +518,9 @@ msgid "Interval" msgstr "Intervalle" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" #, fuzzy @@ -542,9 +531,6 @@ msgstr "Ticker: %1" msgid "Command" msgstr "Commande personnalisée" -msgid "Prefix" -msgstr "" - msgid "Redirect" msgstr "" @@ -755,6 +741,9 @@ msgstr "Voisinage réseau" msgid "Scripts" msgstr "Modifier les scripts" +msgid "System" +msgstr "" + #, fuzzy msgid "Time" msgstr "Durée" diff --git a/sources/translations/id_ID.po b/sources/translations/id_ID.po index 0aafca0..98c4c11 100644 --- a/sources/translations/id_ID.po +++ b/sources/translations/id_ID.po @@ -8,11 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2017-07-13 17:39+0300\n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" "PO-Revision-Date: 2016-07-09 08:47+0000\n" "Last-Translator: Heimen Stoffels \n" -"Language-Team: Bahasa (Bahasa Indonesia) (http://www.transifex.com/arcanis/awesome-" -"widgets/language/id_ID/)\n" +"Language-Team: Bahasa (Bahasa Indonesia) (http://www.transifex.com/arcanis/" +"awesome-widgets/language/id_ID/)\n" "Language: id_ID\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -46,9 +46,6 @@ msgstr "Paket AUR" msgid "openSUSE packages" msgstr "paket openSUSE" -msgid "This software is licensed under %1" -msgstr "Perangkat lunak ini berlisensi %1" - #, fuzzy msgid "Translators:" msgstr "Penerjemah: %1" @@ -282,8 +279,8 @@ msgid "" "CPU, CPU clock, memory, swap and network labels support graphical tooltip. " "To enable them just make needed checkbox checked." msgstr "" -"Label CPU, frekuensi CPU, memori, swap, dan jaringan mendukung tooltip grafik" -"Untuk mengaktifkanya, cukup tandai kotak centang." +"Label CPU, frekuensi CPU, memori, swap, dan jaringan mendukung tooltip " +"grafikUntuk mengaktifkanya, cukup tandai kotak centang." msgid "Number of values for tooltips" msgstr "Jumlah nilai untuk tooltip" @@ -390,18 +387,12 @@ msgstr "MB/dtk" msgid "KB/s" msgstr "KB/dtk" -msgid "Changelog of %1" -msgstr "Riwayat ubah dari %1" - msgid "You are using the actual version %1" msgstr "Anda menggunakan versi aktual %1" msgid "No new version found" msgstr "Tidak ada versi baru yang ditemukan" -msgid "Current version : %1" -msgstr "Versi saat ini: %1" - msgid "New version : %1" msgstr "Versi baru: %1" @@ -505,10 +496,9 @@ msgid "Interval" msgstr "Jeda" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" msgid "Ticker" @@ -517,9 +507,6 @@ msgstr "Ticker" msgid "Command" msgstr "Perintah" -msgid "Prefix" -msgstr "Awalan" - msgid "Redirect" msgstr "Pengalihan" @@ -643,8 +630,8 @@ msgid "" "Detailed information may be found on project homepage" msgstr "" -"Informasi mendetail dapat dilihat pada laman situs" +"Informasi mendetail dapat dilihat pada laman situs" msgid "Add" msgstr "Tambah" @@ -721,6 +708,9 @@ msgstr "Jaringan" msgid "Scripts" msgstr "Skrip" +msgid "System" +msgstr "" + msgid "Time" msgstr "Waktu" diff --git a/sources/translations/it.po b/sources/translations/it.po index 5716d28..be74687 100644 --- a/sources/translations/it.po +++ b/sources/translations/it.po @@ -7,16 +7,16 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2017-05-05 18:15+0300\n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" "PO-Revision-Date: 2018-10-02 11:37+0200\n" +"Last-Translator: Antonio Vivace \n" "Language-Team: \n" +"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.1.1\n" -"Last-Translator: Antonio Vivace \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"Language: it\n" msgid "Version %1 (build date %2)" msgstr "Versione %1 (data build %2)" @@ -45,9 +45,6 @@ msgstr "Pacchetti Aur" msgid "openSUSE packages" msgstr "pacchetti openSUSE" -msgid "This software is licensed under %1" -msgstr "Questo software è rilasciato sotto licenza %1" - msgid "Translators:" msgstr "Traduttori:" @@ -274,8 +271,8 @@ msgid "" "CPU, CPU clock, memory, swap and network labels support graphical tooltip. " "To enable them just make needed checkbox checked." msgstr "" -"Le etichette GPU, CPU clock, memoria, swap e rete supportano i tooltip. " -"Per abilitarli, clicca sulle checkbox." +"Le etichette GPU, CPU clock, memoria, swap e rete supportano i tooltip. Per " +"abilitarli, clicca sulle checkbox." msgid "Number of values for tooltips" msgstr "Numero di valori per tooltip" @@ -328,6 +325,9 @@ msgstr "Colore batteria attiva" msgid "Battery inactive color" msgstr "Colore batteria disattiva" +msgid "Edit" +msgstr "Modifica" + msgid "Run %1" msgstr "Esegui %1" @@ -367,9 +367,6 @@ msgstr "Alto carico della GPU" msgid "Network device has been changed to %1" msgstr "Il dispositivo di rete è stato cambiato in %1" -msgid "Edit" -msgstr "Modifica" - msgid "Select type" msgstr "Seleziona tipo" @@ -382,18 +379,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "Lista cambiamenti di %1" - msgid "You are using the actual version %1" msgstr "Stai usando la versione attuale %1" msgid "No new version found" msgstr "Nessuna nuova versione trovata" -msgid "Current version : %1" -msgstr "Versione attuale: %1" - msgid "New version : %1" msgstr "Nuova versione: %1" @@ -496,11 +487,11 @@ msgstr "Socket" msgid "Interval" msgstr "Intervallo" +#, fuzzy msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" "

    Usa YAHOO! finance ticker per ottere quote sullo " "strumento. Vedi \n" "Language-Team: Lithuanian (http://www.transifex.com/arcanis/awesome-widgets/" @@ -47,9 +47,6 @@ msgstr "AUR paketai" msgid "openSUSE packages" msgstr "openSUSE paketai" -msgid "This software is licensed under %1" -msgstr "Ši programinė įranga yra licencijuota pagal %1" - msgid "Translators:" msgstr "" @@ -382,18 +379,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "%1 keitimų žurnalas" - msgid "You are using the actual version %1" msgstr "" msgid "No new version found" msgstr "Nerasta jokios naujos versijos" -msgid "Current version : %1" -msgstr "Dabartinė versija : %1" - msgid "New version : %1" msgstr "Nauja versija : %1" @@ -497,10 +488,9 @@ msgid "Interval" msgstr "" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" msgid "Ticker" @@ -509,9 +499,6 @@ msgstr "" msgid "Command" msgstr "Komanda" -msgid "Prefix" -msgstr "" - msgid "Redirect" msgstr "" @@ -709,6 +696,9 @@ msgstr "Tinklas" msgid "Scripts" msgstr "Scenarijai" +msgid "System" +msgstr "" + msgid "Time" msgstr "Laikas" diff --git a/sources/translations/nl_NL.po b/sources/translations/nl_NL.po index 9379e27..77333f5 100644 --- a/sources/translations/nl_NL.po +++ b/sources/translations/nl_NL.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: 2017-07-13 17:39+0300\n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" "PO-Revision-Date: 2016-07-09 08:47+0000\n" "Last-Translator: Heimen Stoffels \n" "Language-Team: Dutch (Netherlands) (http://www.transifex.com/arcanis/awesome-" @@ -47,9 +47,6 @@ msgstr "AUR-pakketten" msgid "openSUSE packages" msgstr "openSUSE-pakketten" -msgid "This software is licensed under %1" -msgstr "Deze software is gelicenseerd onder %1" - #, fuzzy msgid "Translators:" msgstr "Vertalers: %1" @@ -391,18 +388,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "Wijzigingslog van %1" - msgid "You are using the actual version %1" msgstr "U gebruikt de actuele versie %1" msgid "No new version found" msgstr "Geen nieuwe versie gevonden" -msgid "Current version : %1" -msgstr "Huidige versie: %1" - msgid "New version : %1" msgstr "Nieuwe versie: %1" @@ -505,11 +496,11 @@ msgstr "" msgid "Interval" msgstr "Tussenpozen" +#, fuzzy msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" "

    Gebruik YAHOO! financiën-ticket om citaten te " "verkrijgen voor het instrument. Refereer naar \n" "Language-Team: LANGUAGE \n" @@ -44,9 +44,6 @@ msgstr "Pakiety AUR" msgid "openSUSE packages" msgstr "Pakiety openSUSE" -msgid "This software is licensed under %1" -msgstr "To oprogramowanie jest licencjonowane według %1" - #, fuzzy msgid "Translators:" msgstr "Tłumacze: %1" @@ -390,18 +387,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "" - msgid "You are using the actual version %1" msgstr "Używasz wersji %1" msgid "No new version found" msgstr "Nie znalazłem nowszej wersji" -msgid "Current version : %1" -msgstr "Aktualna wersja: %1" - msgid "New version : %1" msgstr "Nowa wersja: %$1" @@ -507,11 +498,11 @@ msgstr "" msgid "Interval" msgstr "Przedział" +#, fuzzy msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" "

    Użyj usług finansowych YAHOO!Przjdź na \n" "Language-Team: Russian \n" @@ -46,9 +46,6 @@ msgstr "Pacotes AUR" msgid "openSUSE packages" msgstr "Pacotes openSUSE" -msgid "This software is licensed under %1" -msgstr "Este software é licenciado sob %1" - #, fuzzy msgid "Translators:" msgstr "Tradutores: %1" @@ -402,9 +399,6 @@ msgstr "" msgid "KB/s" msgstr "" -msgid "Changelog of %1" -msgstr "" - msgid "You are using the actual version %1" msgstr "" @@ -412,9 +406,6 @@ msgstr "" msgid "No new version found" msgstr "Nova versão: %1" -msgid "Current version : %1" -msgstr "Versão atual: %1" - msgid "New version : %1" msgstr "Nova versão: %1" @@ -521,10 +512,9 @@ msgid "Interval" msgstr "Intervalo de tempo" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" #, fuzzy @@ -534,9 +524,6 @@ msgstr "Relógio: %1" msgid "Command" msgstr "Comentário" -msgid "Prefix" -msgstr "" - msgid "Redirect" msgstr "" @@ -745,6 +732,9 @@ msgstr "Diretório de rede" msgid "Scripts" msgstr "Editar scripts" +msgid "System" +msgstr "" + #, fuzzy msgid "Time" msgstr "Hora" diff --git a/sources/translations/ru.po b/sources/translations/ru.po index 2f6d5d0..8006025 100644 --- a/sources/translations/ru.po +++ b/sources/translations/ru.po @@ -1,22 +1,22 @@ # Copyright (C) 2014 # This file is distributed under the same license as the PyTextMonitor package. # -# Evgeniy Alekseev , 2014, 2015, 2016, 2017. +# Evgeniy Alekseev , 2014, 2015, 2016, 2017, 2020. msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2017-07-13 17:39+0300\n" -"PO-Revision-Date: 2017-07-13 17:52+0300\n" -"Last-Translator: Evgeniy Alekseev \n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" +"PO-Revision-Date: 2020-11-07 16:48+0300\n" +"Last-Translator: Evgenii 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" -"X-Generator: Lokalize 2.0\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 20.08.2\n" msgid "Version %1 (build date %2)" msgstr "Версия %1 (дата сборки %2)" @@ -45,9 +45,6 @@ msgstr "Пакеты в AUR" msgid "openSUSE packages" msgstr "Пакеты для openSUSE" -msgid "This software is licensed under %1" -msgstr "Данное приложение лицензировано под %1" - msgid "Translators:" msgstr "Переводчики:" @@ -382,18 +379,12 @@ msgstr "МБ/с" msgid "KB/s" msgstr "КБ/с" -msgid "Changelog of %1" -msgstr "Список изменений %1" - msgid "You are using the actual version %1" msgstr "Вы используете актуальную версию %1" msgid "No new version found" msgstr "Обновления не найдены" -msgid "Current version : %1" -msgstr "Текущая версия : %1" - msgid "New version : %1" msgstr "Новая версия : %1" @@ -497,15 +488,14 @@ msgid "Interval" msgstr "Интервал" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" -"

    Используйте тикеры YAHOO! finance, чтобы получить " -"котировки по инструменту. См. http://finance.yahoo." -"com/

    " +"

    Используйте тикеры Stooq, чтобы получить " +"котировки по инструменту. См. https://stooq.com/

    " msgid "Ticker" msgstr "Тикер" @@ -513,9 +503,6 @@ msgstr "Тикер" msgid "Command" msgstr "Команда" -msgid "Prefix" -msgstr "Префикс" - msgid "Redirect" msgstr "Перенаправление" @@ -712,6 +699,9 @@ msgstr "Веб-запрос" msgid "Scripts" msgstr "Скрипты" +msgid "System" +msgstr "Системные" + msgid "Time" msgstr "Время" diff --git a/sources/translations/si.po b/sources/translations/si.po index 87108b6..a50bfa0 100644 --- a/sources/translations/si.po +++ b/sources/translations/si.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Awesome widgets\n" "Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n" -"POT-Creation-Date: 2017-07-13 17:39+0300\n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" "PO-Revision-Date: 2017-05-15 17:44+0000\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Sinhala (http://www.transifex.com/arcanis/awesome-widgets/" @@ -45,9 +45,6 @@ msgstr "" msgid "openSUSE packages" msgstr "" -msgid "This software is licensed under %1" -msgstr "" - msgid "Translators:" msgstr "" @@ -380,18 +377,12 @@ msgstr "" msgid "KB/s" msgstr "" -msgid "Changelog of %1" -msgstr "" - msgid "You are using the actual version %1" msgstr "" msgid "No new version found" msgstr "" -msgid "Current version : %1" -msgstr "" - msgid "New version : %1" msgstr "" @@ -495,10 +486,9 @@ msgid "Interval" msgstr "" msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" msgid "Ticker" @@ -507,9 +497,6 @@ msgstr "" msgid "Command" msgstr "" -msgid "Prefix" -msgstr "" - msgid "Redirect" msgstr "" @@ -704,6 +691,9 @@ msgstr "" msgid "Scripts" msgstr "" +msgid "System" +msgstr "" + msgid "Time" msgstr "" diff --git a/sources/translations/uk.po b/sources/translations/uk.po index 204f411..aef2c9c 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: 2017-07-13 17:39+0300\n" +"POT-Creation-Date: 2020-11-07 16:46+0300\n" "PO-Revision-Date: 2016-08-09 22:22+0300\n" "Last-Translator: Evgeniy Alekseev \n" "Language-Team: Ukrainian \n" @@ -45,9 +45,6 @@ msgstr "Пакети в AUR" msgid "openSUSE packages" msgstr "Пакети для openSUSE" -msgid "This software is licensed under %1" -msgstr "Цю програму ліцензовано під %1" - #, fuzzy msgid "Translators:" msgstr "Перекладачі: %1" @@ -393,18 +390,12 @@ msgstr "МБ/с" msgid "KB/s" msgstr "КБ/с" -msgid "Changelog of %1" -msgstr "Список змін %1" - msgid "You are using the actual version %1" msgstr "Ви використовуєте актуальну версію %1" msgid "No new version found" msgstr "Оновлень не знайдено" -msgid "Current version : %1" -msgstr "Поточна версія : %1" - msgid "New version : %1" msgstr "Нова версія : %1" @@ -507,11 +498,11 @@ msgstr "" msgid "Interval" msgstr "Інтервал" +#, fuzzy msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" "

    Використовуйте тікеры YAHOO! finance, щоб отримати " "котирування по інструменту. Див. \n" "Language-Team: Russian \n" @@ -45,9 +45,6 @@ msgstr "AUR 包" msgid "openSUSE packages" msgstr "openSUSE 包" -msgid "This software is licensed under %1" -msgstr "该软件使用以下授权 %1" - #, fuzzy msgid "Translators:" msgstr "翻译: %1" @@ -394,18 +391,12 @@ msgstr "MB/s" msgid "KB/s" msgstr "KB/s" -msgid "Changelog of %1" -msgstr "" - msgid "You are using the actual version %1" msgstr "你正在使用最新版本 %1" msgid "No new version found" msgstr "没有新版本" -msgid "Current version : %1" -msgstr "当前版本 : %1" - msgid "New version : %1" msgstr "新版本 : %1" @@ -511,11 +502,11 @@ msgstr "" msgid "Interval" msgstr "时间周期" +#, fuzzy msgid "" -"

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

    " +"

    Use Stooq ticker to get quotes for the instrument. " +"Refer to https://stooq.com/

    " msgstr "" "

    使用 YAHOO(雅虎)! 获取最新的金融股票行情 . 请点击链" "接 Date: Sat, 7 Nov 2020 17:10:04 +0300 Subject: [PATCH 35/35] release 3.4.1 update translators list --- AUTHORS | 2 ++ packages/PKGBUILD | 4 ++-- sources/CMakeLists.txt | 2 +- sources/awesome-widget/package/metadata.desktop | 2 +- sources/desktop-panel/package/metadata.desktop | 2 +- sources/version.h.in | 10 ++++++---- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4ed4ef5..bb814c0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,3 +11,5 @@ Ernesto Avilés Vzqz (Spanish) Виктор Слободян (Ukrainian) Steve Lemuel (Chinese) Mariusz Kocoń (Polish) +Ibnu Daru Aji (Indonesian) +Antonio Vivace (Italian) diff --git a/packages/PKGBUILD b/packages/PKGBUILD index 7f7e3f7..2d50354 100644 --- a/packages/PKGBUILD +++ b/packages/PKGBUILD @@ -2,7 +2,7 @@ pkgname=plasma5-applet-awesome-widgets _pkgname=awesome-widgets -pkgver=3.4.0 +pkgver=3.4.1 pkgrel=1 pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)" arch=('i686' 'x86_64') @@ -17,7 +17,7 @@ optdepends=("catalyst: for GPU monitor" makedepends=('cmake' 'extra-cmake-modules' 'python') source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz) install=${pkgname}.install -md5sums=('8097663d06715e7543643de4c77de6b6') +md5sums=('772d1b6955ffe20a1e14c4255d04564b') backup=('etc/xdg/plasma-dataengine-extsysmon.conf') prepare() { diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 3e1b04f..3fe9c5e 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -16,7 +16,7 @@ set(PROJECT_CONTACT "esalexeev@gmail.com") set(PROJECT_LICENSE "GPL3") set(PROJECT_VERSION_MAJOR "3") set(PROJECT_VERSION_MINOR "4") -set(PROJECT_VERSION_PATCH "0") +set(PROJECT_VERSION_PATCH "1") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # append git version if any set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "") diff --git a/sources/awesome-widget/package/metadata.desktop b/sources/awesome-widget/package/metadata.desktop index 278d873..3503466 100644 --- a/sources/awesome-widget/package/metadata.desktop +++ b/sources/awesome-widget/package/metadata.desktop @@ -19,7 +19,7 @@ X-Plasma-MainScript=ui/main.qml X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget -X-KDE-PluginInfo-Version=3.4.0 +X-KDE-PluginInfo-Version=3.4.1 X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= diff --git a/sources/desktop-panel/package/metadata.desktop b/sources/desktop-panel/package/metadata.desktop index 5bfb750..9f95b1b 100644 --- a/sources/desktop-panel/package/metadata.desktop +++ b/sources/desktop-panel/package/metadata.desktop @@ -19,7 +19,7 @@ X-Plasma-MainScript=ui/main.qml X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel -X-KDE-PluginInfo-Version=3.4.0 +X-KDE-PluginInfo-Version=3.4.1 X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= diff --git a/sources/version.h.in b/sources/version.h.in index e96897f..05e080e 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -7,10 +7,12 @@ const char NAME[] = "Awesome Widgets"; const char VERSION[] = "@PROJECT_VERSION@"; const char COMMIT_SHA[] = "@PROJECT_COMMIT_SHA@"; const char AUTHOR[] = "@PROJECT_AUTHOR@"; -const char TRANSLATORS[] = "Ernesto Aviles Vzqz (Spanish),Mermouy " - "(French),underr (Brazillian Portuguese),Viktor " - "Slobodyan (Ukrainian),Lemueler (Chinese),Heimen " - "Stoffels (Dutch),Mariusz Kocoń (Polish)"; +const char TRANSLATORS[] + = "Ernesto Aviles Vzqz (Spanish),Mermouy " + "(French),underr (Brazillian Portuguese),Viktor " + "Slobodyan (Ukrainian),Lemueler (Chinese),Heimen " + "Stoffels (Dutch),Mariusz Kocoń (Polish),Ibnu " + "Daru Aji (Indonesian),Antonio Vivace (Italian)"; const char EMAIL[] = "@PROJECT_CONTACT@"; const char LICENSE[] = "@PROJECT_LICENSE@"; const char TRDPARTY_LICENSE[] = "QReplyTimeout "