From 575fc065605c962d800ecd9daa26e9ae3b2809df Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Tue, 30 Apr 2024 21:52:39 +0300 Subject: [PATCH] Split formatters and matchers into separated singleton classes (#166) * split formatter into separated singleton classes * split data engine matchers to classes * nodiscard attribute for formatter methods * small refactoring in matchers * fix codefactor warnings * fix test building --- sources/awesome-widget/plugin/CMakeLists.txt | 2 +- sources/awesome-widget/plugin/awbugreporter.h | 2 +- .../awesome-widget/plugin/awconfighelper.h | 2 +- .../plugin/awdataenginemapper.cpp | 414 ++---------------- .../plugin/awdataenginemapper.h | 10 +- sources/awesome-widget/plugin/awkeycache.cpp | 55 +-- sources/awesome-widget/plugin/awkeycache.h | 5 +- .../awesome-widget/plugin/awkeyoperations.cpp | 28 +- .../awesome-widget/plugin/awkeyoperations.h | 6 +- sources/awesome-widget/plugin/awkeys.cpp | 24 +- sources/awesome-widget/plugin/awkeys.h | 2 +- .../plugin/awkeysaggregator.cpp | 205 ++------- .../awesome-widget/plugin/awkeysaggregator.h | 68 +-- .../plugin/awpairconfigfactory.h | 2 - .../plugin/awpatternfunctions.h | 2 +- .../plugin/awtelemetryhandler.h | 2 +- .../awesome-widget/plugin/awupdatehelper.h | 2 +- .../formatters/awpluginformatsettings.h | 37 ++ .../plugin/formatters/awpluginformatter.h | 69 +++ .../plugin/formatters/awpluginformatterac.cpp | 25 ++ .../plugin/formatters/awpluginformatterac.h | 28 ++ .../formatters/awpluginformattercustom.cpp | 29 ++ .../formatters/awpluginformattercustom.h | 28 ++ .../formatters/awpluginformatterdouble.cpp | 25 ++ .../formatters/awpluginformatterdouble.h | 28 ++ .../formatters/awpluginformatterfloat.cpp | 24 + .../formatters/awpluginformatterfloat.h | 28 ++ .../awpluginformatterfloatprecise.cpp | 25 ++ .../awpluginformatterfloatprecise.h | 28 ++ .../formatters/awpluginformatterinteger.cpp | 24 + .../formatters/awpluginformatterinteger.h | 28 ++ .../awpluginformatterintegershort.cpp | 25 ++ .../awpluginformatterintegershort.h | 28 ++ .../awpluginformatterintegerwide.cpp | 25 ++ .../formatters/awpluginformatterintegerwide.h | 28 ++ .../formatters/awpluginformatterlist.cpp | 24 + .../plugin/formatters/awpluginformatterlist.h | 28 ++ .../formatters/awpluginformattermemory.cpp | 24 + .../formatters/awpluginformattermemory.h | 28 ++ .../formatters/awpluginformattermemorygb.cpp | 24 + .../formatters/awpluginformattermemorygb.h | 28 ++ .../formatters/awpluginformattermemorymb.cpp | 24 + .../formatters/awpluginformattermemorymb.h | 28 ++ .../formatters/awpluginformatternet.cpp | 37 ++ .../plugin/formatters/awpluginformatternet.h | 32 ++ .../formatters/awpluginformatternetunits.cpp | 40 ++ .../formatters/awpluginformatternetunits.h | 32 ++ .../formatters/awpluginformatternoformat.cpp | 24 + .../formatters/awpluginformatternoformat.h | 28 ++ .../awpluginformattertemperature.cpp | 48 ++ .../formatters/awpluginformattertemperature.h | 31 ++ .../formatters/awpluginformattertime.cpp | 26 ++ .../plugin/formatters/awpluginformattertime.h | 28 ++ .../awpluginformattertimecustom.cpp | 46 ++ .../formatters/awpluginformattertimecustom.h | 35 ++ .../formatters/awpluginformattertimeiso.cpp | 26 ++ .../formatters/awpluginformattertimeiso.h | 28 ++ .../formatters/awpluginformattertimelong.cpp | 27 ++ .../formatters/awpluginformattertimelong.h | 28 ++ .../formatters/awpluginformattertimeshort.cpp | 27 ++ .../formatters/awpluginformattertimeshort.h | 28 ++ .../formatters/awpluginformatteruptime.cpp | 44 ++ .../formatters/awpluginformatteruptime.h | 31 ++ .../plugin/formatters/formatters.h | 39 ++ .../plugin/matchers/awpluginmatcher.h | 63 +++ .../plugin/matchers/awpluginmatcherac.cpp | 33 ++ .../plugin/matchers/awpluginmatcherac.h | 29 ++ .../matchers/awpluginmatcherbattery.cpp | 38 ++ .../plugin/matchers/awpluginmatcherbattery.h | 29 ++ .../matchers/awpluginmatcherbrightness.cpp | 33 ++ .../matchers/awpluginmatcherbrightness.h | 29 ++ .../plugin/matchers/awpluginmatchercpu.cpp | 33 ++ .../plugin/matchers/awpluginmatchercpu.h | 29 ++ .../matchers/awpluginmatchercpucore.cpp | 38 ++ .../plugin/matchers/awpluginmatchercpucore.h | 29 ++ .../matchers/awpluginmatchercpufrequency.cpp | 33 ++ .../matchers/awpluginmatchercpufrequency.h | 29 ++ .../awpluginmatchercpufrequencycore.cpp | 39 ++ .../awpluginmatchercpufrequencycore.h | 29 ++ .../plugin/matchers/awpluginmatchercustom.cpp | 35 ++ .../plugin/matchers/awpluginmatchercustom.h | 29 ++ .../matchers/awpluginmatcherdesktop.cpp | 33 ++ .../plugin/matchers/awpluginmatcherdesktop.h | 29 ++ .../matchers/awpluginmatcherdesktopcount.cpp | 33 ++ .../matchers/awpluginmatcherdesktopcount.h | 29 ++ .../matchers/awpluginmatcherdesktopnumber.cpp | 33 ++ .../matchers/awpluginmatcherdesktopnumber.h | 29 ++ .../plugin/matchers/awpluginmatchergpu.cpp | 33 ++ .../plugin/matchers/awpluginmatchergpu.h | 29 ++ .../matchers/awpluginmatchergpucore.cpp | 40 ++ .../plugin/matchers/awpluginmatchergpucore.h | 29 ++ .../awpluginmatchergputemperature.cpp | 41 ++ .../matchers/awpluginmatchergputemperature.h | 29 ++ .../plugin/matchers/awpluginmatcherhdd.cpp | 40 ++ .../plugin/matchers/awpluginmatcherhdd.h | 29 ++ .../matchers/awpluginmatcherhddfree.cpp | 43 ++ .../plugin/matchers/awpluginmatcherhddfree.h | 29 ++ .../matchers/awpluginmatcherhddread.cpp | 40 ++ .../plugin/matchers/awpluginmatcherhddread.h | 29 ++ .../matchers/awpluginmatcherhddtotal.cpp | 44 ++ .../plugin/matchers/awpluginmatcherhddtotal.h | 29 ++ .../matchers/awpluginmatcherhddused.cpp | 43 ++ .../plugin/matchers/awpluginmatcherhddused.h | 29 ++ .../matchers/awpluginmatcherhddwrite.cpp | 41 ++ .../plugin/matchers/awpluginmatcherhddwrite.h | 29 ++ .../plugin/matchers/awpluginmatcherload.cpp | 35 ++ .../plugin/matchers/awpluginmatcherload.h | 29 ++ .../matchers/awpluginmatcherloadaverage.cpp | 35 ++ .../matchers/awpluginmatcherloadaverage.h | 29 ++ .../plugin/matchers/awpluginmatchermemory.cpp | 33 ++ .../plugin/matchers/awpluginmatchermemory.h | 29 ++ .../awpluginmatchermemoryapplication.cpp | 36 ++ .../awpluginmatchermemoryapplication.h | 29 ++ .../matchers/awpluginmatchermemoryfree.cpp | 36 ++ .../matchers/awpluginmatchermemoryfree.h | 29 ++ .../matchers/awpluginmatchermemorytotal.cpp | 36 ++ .../matchers/awpluginmatchermemorytotal.h | 29 ++ .../matchers/awpluginmatchermemoryused.cpp | 36 ++ .../matchers/awpluginmatchermemoryused.h | 29 ++ .../matchers/awpluginmatchernetwork.cpp | 45 ++ .../plugin/matchers/awpluginmatchernetwork.h | 29 ++ .../matchers/awpluginmatchernetworkdevice.cpp | 33 ++ .../matchers/awpluginmatchernetworkdevice.h | 29 ++ .../matchers/awpluginmatchernetworkssid.cpp | 33 ++ .../matchers/awpluginmatchernetworkssid.h | 29 ++ .../matchers/awpluginmatchernetworktotal.cpp | 45 ++ .../matchers/awpluginmatchernetworktotal.h | 29 ++ .../plugin/matchers/awpluginmatcherplayer.cpp | 35 ++ .../plugin/matchers/awpluginmatcherplayer.h | 29 ++ .../plugin/matchers/awpluginmatcherps.cpp | 33 ++ .../plugin/matchers/awpluginmatcherps.h | 29 ++ .../matchers/awpluginmatcherpsprocesses.cpp | 33 ++ .../matchers/awpluginmatcherpsprocesses.h | 29 ++ .../matchers/awpluginmatcherpstotal.cpp | 33 ++ .../plugin/matchers/awpluginmatcherpstotal.h | 29 ++ .../plugin/matchers/awpluginmatcherquotes.cpp | 35 ++ .../plugin/matchers/awpluginmatcherquotes.h | 29 ++ .../matchers/awpluginmatcherrequest.cpp | 35 ++ .../plugin/matchers/awpluginmatcherrequest.h | 29 ++ .../matchers/awpluginmatchersensors.cpp | 44 ++ .../plugin/matchers/awpluginmatchersensors.h | 29 ++ .../plugin/matchers/awpluginmatchersettings.h | 30 ++ .../plugin/matchers/awpluginmatcherswap.cpp | 33 ++ .../plugin/matchers/awpluginmatcherswap.h | 29 ++ .../matchers/awpluginmatcherswapfree.cpp | 36 ++ .../plugin/matchers/awpluginmatcherswapfree.h | 29 ++ .../matchers/awpluginmatcherswaptotal.cpp | 36 ++ .../matchers/awpluginmatcherswaptotal.h | 29 ++ .../matchers/awpluginmatcherswapused.cpp | 36 ++ .../plugin/matchers/awpluginmatcherswapused.h | 29 ++ .../plugin/matchers/awpluginmatchertime.cpp | 37 ++ .../plugin/matchers/awpluginmatchertime.h | 29 ++ .../matchers/awpluginmatcherupgrade.cpp | 35 ++ .../plugin/matchers/awpluginmatcherupgrade.h | 29 ++ .../plugin/matchers/awpluginmatcheruptime.cpp | 33 ++ .../plugin/matchers/awpluginmatcheruptime.h | 29 ++ .../plugin/matchers/awpluginmatchervolume.cpp | 33 ++ .../plugin/matchers/awpluginmatchervolume.h | 29 ++ .../matchers/awpluginmatcherweather.cpp | 38 ++ .../plugin/matchers/awpluginmatcherweather.h | 29 ++ .../awesome-widget/plugin/matchers/matchers.h | 118 +++++ .../configs/aw-example-standalonerc | 2 +- sources/awesomewidgets/extitemaggregator.h | 4 +- sources/desktop-panel/plugin/dpadds.h | 2 +- .../abstractextsysmonsource.h | 12 +- sources/extsysmonsources/batterysource.h | 2 +- sources/extsysmonsources/customsource.h | 2 +- sources/extsysmonsources/desktopsource.h | 2 +- sources/extsysmonsources/loadsource.h | 2 +- sources/extsysmonsources/networksource.h | 2 +- sources/extsysmonsources/playersource.h | 14 +- sources/extsysmonsources/processessource.h | 2 +- sources/extsysmonsources/quotessource.h | 2 +- sources/extsysmonsources/requestsource.h | 2 +- sources/extsysmonsources/systeminfosource.h | 13 +- sources/extsysmonsources/timesource.h | 2 +- sources/extsysmonsources/upgradesource.h | 2 +- sources/extsysmonsources/weathersource.h | 2 +- sources/test/CMakeLists.txt | 78 ++-- sources/test/awtestlibrary.cpp | 1 - sources/test/testawbugreporter.cpp | 1 - sources/version.h.in | 1 - 182 files changed, 4928 insertions(+), 766 deletions(-) create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatsettings.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatter.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterac.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattercustom.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterdouble.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterfloat.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterinteger.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterlist.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatterlist.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattermemory.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattermemory.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatternet.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatternet.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatternoformat.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertime.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertime.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp create mode 100644 sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h create mode 100644 sources/awesome-widget/plugin/formatters/formatters.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcher.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherac.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherload.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherload.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemory.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemory.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherps.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherps.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchersensors.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswap.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswap.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchertime.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchertime.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchervolume.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatchervolume.h create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherweather.cpp create mode 100644 sources/awesome-widget/plugin/matchers/awpluginmatcherweather.h create mode 100644 sources/awesome-widget/plugin/matchers/matchers.h diff --git a/sources/awesome-widget/plugin/CMakeLists.txt b/sources/awesome-widget/plugin/CMakeLists.txt index b33c698b..3532b0ba 100644 --- a/sources/awesome-widget/plugin/CMakeLists.txt +++ b/sources/awesome-widget/plugin/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories( ${Kf6_INCLUDE} ) -file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp) +file(GLOB SUBPROJECT_SOURCE *.cpp formatters/*.cpp matchers/*.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp) file(GLOB SUBPROJECT_UI *.ui) file(GLOB SUBPROJECT_NOTIFY *.notifyrc) diff --git a/sources/awesome-widget/plugin/awbugreporter.h b/sources/awesome-widget/plugin/awbugreporter.h index 7f793217..e17f0804 100644 --- a/sources/awesome-widget/plugin/awbugreporter.h +++ b/sources/awesome-widget/plugin/awbugreporter.h @@ -23,7 +23,7 @@ class QNetworkAccessManager; class QNetworkReply; -class AWBugReporter : public QObject +class __attribute__((visibility("default"))) AWBugReporter : public QObject { Q_OBJECT diff --git a/sources/awesome-widget/plugin/awconfighelper.h b/sources/awesome-widget/plugin/awconfighelper.h index a4f16a52..9730292b 100644 --- a/sources/awesome-widget/plugin/awconfighelper.h +++ b/sources/awesome-widget/plugin/awconfighelper.h @@ -23,7 +23,7 @@ class QSettings; -class AWConfigHelper : public QObject +class __attribute__((visibility("default"))) AWConfigHelper : public QObject { Q_OBJECT diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index fa2b3710..92b2d464 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -21,6 +21,8 @@ #include "awdebug.h" #include "awformatterhelper.h" +#include "formatters/formatters.h" +#include "matchers/matchers.h" AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_custom) @@ -30,33 +32,25 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus qCDebug(LOG_AW) << __PRETTY_FUNCTION__; // default formatters - // memory - m_formatter["mem"] = AWKeysAggregator::FormatterType::Float; - m_formatter["memtotmb"] = AWKeysAggregator::FormatterType::MemMBFormat; - m_formatter["memtotgb"] = AWKeysAggregator::FormatterType::MemGBFormat; // network - m_formatter["down"] = AWKeysAggregator::FormatterType::NetSmartFormat; - m_formatter["downkb"] = AWKeysAggregator::FormatterType::Integer; - m_formatter["downtot"] = AWKeysAggregator::FormatterType::MemMBFormat; - m_formatter["downtotkb"] = AWKeysAggregator::FormatterType::Integer; - m_formatter["downunits"] = AWKeysAggregator::FormatterType::NetSmartUnits; - m_formatter["up"] = AWKeysAggregator::FormatterType::NetSmartFormat; - m_formatter["upkb"] = AWKeysAggregator::FormatterType::Integer; - m_formatter["uptot"] = AWKeysAggregator::FormatterType::MemMBFormat; - m_formatter["uptotkb"] = AWKeysAggregator::FormatterType::Integer; - m_formatter["upunits"] = AWKeysAggregator::FormatterType::NetSmartUnits; - // swap - m_formatter["swap"] = AWKeysAggregator::FormatterType::Float; - m_formatter["swaptotmb"] = AWKeysAggregator::FormatterType::MemMBFormat; - m_formatter["swaptotgb"] = AWKeysAggregator::FormatterType::MemGBFormat; + m_formatter["down"] = AWPluginFormatterNet::instance(); + m_formatter["downkb"] = AWPluginFormatterMemory::instance(); + m_formatter["downtot"] = AWPluginFormatterMemoryMB::instance(); + m_formatter["downtotkb"] = AWPluginFormatterMemory::instance(); + m_formatter["downunits"] = AWPluginFormatterNetUnits::instance(); + m_formatter["up"] = AWPluginFormatterNet::instance(); + m_formatter["upkb"] = AWPluginFormatterMemory::instance(); + m_formatter["uptot"] = AWPluginFormatterMemoryMB::instance(); + m_formatter["uptotkb"] = AWPluginFormatterMemory::instance(); + m_formatter["upunits"] = AWPluginFormatterNetUnits::instance(); } -AWKeysAggregator::FormatterType AWDataEngineMapper::formatter(const QString &_key) const +AWPluginFormaterInterface *AWDataEngineMapper::formatter(const QString &_key) const { qCDebug(LOG_AW) << "Get formatter for key" << _key; - return m_formatter.value(_key, AWKeysAggregator::FormatterType::NoFormat); + return m_formatter.value(_key, AWPluginFormatterNoFormat::instance()); } @@ -75,376 +69,44 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy { qCDebug(LOG_AW) << "Source" << _source << "with units" << _units; - // regular expressions - static auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$"); - static auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$"); - static auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$"); - static auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$"); - static auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$"); - static auto hddrRegExp = QRegularExpression("^disk/.*/read$"); - static auto hddwRegExp = QRegularExpression("^disk/.*/write$"); - static auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$"); - static auto mountFreeRegExp = QRegularExpression("^disk/.*/free$"); - static auto mountUsedRegExp = QRegularExpression("^disk/.*/used$"); - static auto netRegExp = QRegularExpression("^network/.*/(download|upload)$"); - static auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$"); + auto matchers = AWPluginMatchers::matchers; + auto matcher = std::find_if(matchers.cbegin(), matchers.cend(), + [&_source](auto matcher) { return matcher->matches(_source); }); + if (matcher == matchers.cend()) + return {}; - if (_source == "extsysmon/battery/ac") { - // AC - m_map.insert(_source, "ac"); - m_formatter["ac"] = AWKeysAggregator::FormatterType::ACFormat; - } else if (_source.startsWith("extsysmon/battery/")) { - // battery stats - auto key = _source; - key.remove("extsysmon/battery/"); - m_map.insert(_source, key); - m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float - : AWKeysAggregator::FormatterType::IntegerThree; - } else if (_source == "cpu/all/usage") { - // cpu - m_map.insert(_source, "cpu"); - m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float; - } else if (_source.contains(cpuRegExp)) { - // cpus - auto key = _source; - key.remove("cpu/").remove("/usage"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Float; - } else if (_source == "cpu/all/averageFrequency") { - // cpucl - m_map.insert(_source, "cpucl"); - m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer; - } else if (_source.contains(cpuclRegExp)) { - // cpucls - auto key = _source; - key.remove("cpu/cpu").remove("/frequency"); - key = QString("cpucl%1").arg(key); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Integer; - } else if (_source.startsWith("extsysmon/custom")) { - // custom - auto key = _source; - key.remove("extsysmon/custom/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source == "extsysmon/desktop/name") { - // current desktop name - m_map.insert(_source, "desktop"); - m_formatter["desktop"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source == "extsysmon/desktop/number") { - // current desktop number - m_map.insert(_source, "ndesktop"); - m_formatter["ndesktop"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source == "extsysmon/desktop/count") { - // desktop count - m_map.insert(_source, "tdesktops"); - m_formatter["tdesktops"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source.contains(hddrRegExp)) { - // read speed - auto device = _source; - device.remove("disk/").remove("/read"); - auto index = m_devices["disk"].indexOf(device); - if (index > -1) { - QString key = QString("hddr%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat; - } - } else if (_source.contains(hddwRegExp)) { - // write speed - auto device = _source; - device.remove("disk/").remove("/write"); - auto index = m_devices["disk"].indexOf(device); - if (index > -1) { - QString key = QString("hddw%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat; - } - } else if (_source == "gpu/all/usage") { - // gpu load - m_map.insert(_source, "gpu"); - m_formatter["gpu"] = AWKeysAggregator::FormatterType::Float; - } else if (_source.contains(gpuRegExp)) { - // gpus - auto device = _source; - device.remove("gpu/").remove("/usage"); - auto index = m_devices["gpu"].indexOf(device); - if (index > -1) { - auto key = QString("gpu%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Float; - } - } else if (_source.contains(gpuTempRegExp)) { - // gpus temps - auto device = _source; - device.remove("gpu/").remove("/temperature"); - auto index = m_devices["gpu"].indexOf(device); - if (index > -1) { - auto key = QString("gputemp%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; - } - } else if (_source.contains(mountFillRegExp)) { - // fill level - auto device = _source; - device.remove("disk/").remove("/usedPercent"); - auto index = m_devices["mount"].indexOf(device); - if (index > -1) { - auto key = QString("hdd%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Float; - // additional keys - m_formatter[QString("hddtotmb%1").arg(index)] = AWKeysAggregator::FormatterType::MemMBFormat; - m_formatter[QString("hddtotgb%1").arg(index)] = AWKeysAggregator::FormatterType::MemGBFormat; - } - } else if (_source.contains(mountFreeRegExp)) { - // free space - auto device = _source; - device.remove("disk/").remove("/free"); - auto index = m_devices["mount"].indexOf(device); - if (index > -1) { - // mb - auto key = QString("hddfreemb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - key = QString("hddfreegb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat; - } - } else if (_source.contains(mountUsedRegExp)) { - // used - auto device = _source; - device.remove("disk/").remove("/used"); - auto index = m_devices["mount"].indexOf(device); - if (index > -1) { - // mb - auto key = QString("hddmb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - key = QString("hddgb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat; - } - } else if (_source.startsWith("cpu/loadaverages/loadaverage")) { - // load average - auto time = _source; - time.remove("cpu/loadaverages/loadaverage"); - auto key = QString("la%1").arg(time); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols; - } else if (_source == "memory/physical/application") { - // app memory - // mb - m_map.insert(_source, "memmb"); - m_formatter["memmb"] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - m_map.insert(_source, "memgb"); - m_formatter["memgb"] = AWKeysAggregator::FormatterType::MemGBFormat; - } else if (_source == "memory/physical/free") { - // free memory - // mb - m_map.insert(_source, "memfreemb"); - m_formatter["memfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - m_map.insert(_source, "memfreegb"); - m_formatter["memfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat; - } else if (_source == "memory/physical/used") { - // used memory - // mb - m_map.insert(_source, "memusedmb"); - m_formatter["memusedmb"] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - m_map.insert(_source, "memusedgb"); - m_formatter["memusedgb"] = AWKeysAggregator::FormatterType::MemGBFormat; - } else if (_source == "extsysmon/network/device") { - // network device - m_map.insert(_source, "netdev"); - m_formatter["netdev"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source == "extsysmon/network/ssid") { - // current ssid - m_map.insert(_source, "ssid"); - m_formatter["ssid"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source.startsWith("extsysmon/requests/response")) { - // network response - auto key = _source; - key.remove("extsysmon/requests/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source.contains(netRegExp)) { - // network speed - auto type = _source.endsWith("download") ? "down" : "up"; - auto index = m_devices["net"].indexOf(_source.split('/')[1]); - if (index > -1) { - // kb - auto key = QString("%1kb%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat; - // smart - key = QString("%1%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::NetSmartFormat; - // units - key = QString("%1units%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::NetSmartUnits; - } - } else if (_source.contains(netTotalRegExp)) { - // network data total - auto type = _source.endsWith("Download") ? "down" : "up"; - auto index = m_devices["net"].indexOf(_source.split('/')[1]); - if (index > -1) { - // kb - auto key = QString("%1totkb%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat; - // mb - key = QString("%1tot%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::MemMBFormat; - } - } else if (_source.startsWith("extsysmon/upgrade")) { - // package manager - auto key = _source; - key.remove("extsysmon/upgrade/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::IntegerThree; - } else if (_source.startsWith("extsysmon/player")) { - // player - auto key = _source; - key.remove("extsysmon/player/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source == "extsysmon/ps/running") { - // running processes count - m_map.insert(_source, "pscount"); - m_formatter["pscount"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source == "extsysmon/ps/list") { - // list of running processes - m_map.insert(_source, "ps"); - m_formatter["ps"] = AWKeysAggregator::FormatterType::List; - } else if (_source == "extsysmon/ps/count") { - // total processes count - m_map.insert(_source, "pstot"); - m_formatter["pstot"] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source.startsWith("extsysmon/quotes")) { - // quotes - auto key = _source; - key.remove("extsysmon/quotes/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Quotes; - } else if (_source == "memory/swap/free") { - // free swap - // mb - m_map.insert(_source, "swapfreemb"); - m_formatter["swapfreemb"] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - m_map.insert(_source, "swapfreegb"); - m_formatter["swapfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat; - } else if (_source == "memory/swap/used") { - // used swap - // mb - m_map.insert(_source, "swapmb"); - m_formatter["swapmb"] = AWKeysAggregator::FormatterType::MemMBFormat; - // gb - m_map.insert(_source, "swapgb"); - m_formatter["swapgb"] = AWKeysAggregator::FormatterType::MemGBFormat; - } else if (_source.startsWith("lmsensors/") || _source.contains(cpuTempRegExp) - || _source == "cpu/all/averageTemperature") { - // temperature - auto index = m_devices["temp"].indexOf(_source); - // HACK on DE initialization there are no units key - if (_units == KSysGuard::UnitInvalid) - return QStringList({QString("temp%1").arg(index)}); - if (index > -1) { - auto key = QString("temp%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature - : AWKeysAggregator::FormatterType::Integer; - } - } else if (_source == "extsysmon/time/now") { - // time - m_map.insert(_source, "time"); - m_formatter["time"] = AWKeysAggregator::FormatterType::Time; - // custom time - m_map.insert(_source, "ctime"); - m_formatter["ctime"] = AWKeysAggregator::FormatterType::TimeCustom; - // ISO time - m_map.insert(_source, "isotime"); - m_formatter["isotime"] = AWKeysAggregator::FormatterType::TimeISO; - // long time - m_map.insert(_source, "longtime"); - m_formatter["longtime"] = AWKeysAggregator::FormatterType::TimeLong; - // short time - m_map.insert(_source, "shorttime"); - m_formatter["shorttime"] = AWKeysAggregator::FormatterType::TimeShort; - // timestamp - m_map.insert(_source, "tstime"); - m_formatter["tstime"] = AWKeysAggregator::FormatterType::Timestamp; - } else if (_source == "extsysmon/system/brightness") { - m_map.insert(_source, "brightness"); - m_formatter["brightness"] = AWKeysAggregator::FormatterType::IntegerThree; - } else if (_source == "extsysmon/system/volume") { - m_map.insert(_source, "volume"); - m_formatter["volume"] = AWKeysAggregator::FormatterType::IntegerThree; - } else if (_source == "os/system/uptime") { - // uptime - m_map.insert(_source, "uptime"); - m_formatter["uptime"] = AWKeysAggregator::FormatterType::Uptime; - // custom uptime - m_map.insert(_source, "cuptime"); - m_formatter["cuptime"] = AWKeysAggregator::FormatterType::UptimeCustom; - } else if (_source.startsWith("extsysmon/weather/temperature")) { - // temperature - auto key = _source; - key.remove("extsysmon/weather/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; - } else if (_source.startsWith("extsysmon/weather/")) { - // other weather - auto key = _source; - key.remove("extsysmon/weather/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat; - } else if (_source.startsWith("extsysmon/load/load")) { - // load source - auto key = _source; - key.remove("extsysmon/load/"); - m_map.insert(_source, key); - m_formatter[key] = AWKeysAggregator::FormatterType::Temperature; - } - - auto foundKeys = keysFromSource(_source); + auto foundKeys = (*matcher)->keys(_source, _units, m_settings); + auto keys = foundKeys.keys(); // speedup a little bit // rewrite formatters for custom ones QStringList customFormattersKeys; if (m_customFormatters) customFormattersKeys = m_customFormatters->definedFormatters(); - qCInfo(LOG_AW) << "Looking for formatters" << foundKeys << "in" << customFormattersKeys; - for (auto &key : foundKeys) { + qCInfo(LOG_AW) << "Looking for formatters" << keys << "in" << customFormattersKeys; + for (auto &key : keys) { if (!customFormattersKeys.contains(key)) continue; - m_formatter[key] = AWKeysAggregator::FormatterType::Custom; + foundKeys[key] = AWPluginFormatterCustom::instance(); } - // drop key from dictionary if no one user requested key required it - qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys; - auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](auto &key) { - return _keys.contains(key); - }); - if (!required) { - m_map.remove(_source); - for (auto &key : foundKeys) - m_formatter.remove(key); + // check if keys were actually requested + qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys; + auto required = _keys.isEmpty() + || std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { return _keys.contains(key); }); + if (!required) + return {}; + + // insert keys into memory + for (auto [key, formatter] : foundKeys.asKeyValueRange()) { + m_map.insert(_source, key); + m_formatter[key] = formatter; } - return keysFromSource(_source); + return keys; } -void AWDataEngineMapper::setDevices(const QHash &_devices) +void AWDataEngineMapper::setDevices(const AWPluginMatcherSettings &_settings) { - qCDebug(LOG_AW) << "Devices" << _devices; - - m_devices = _devices; + m_settings = _settings; } diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index 6f88af34..8a069e13 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -22,7 +22,8 @@ #include #include -#include "awkeysaggregator.h" +#include "formatters/awpluginformatter.h" +#include "matchers/awpluginmatchersettings.h" class AWFormatterHelper; @@ -35,16 +36,17 @@ class AWDataEngineMapper : public QObject explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr); ~AWDataEngineMapper() override = default; // get methods - [[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const; + [[nodiscard]] AWPluginFormaterInterface *formatter(const QString &_key) const; [[nodiscard]] QStringList keysFromSource(const QString &_source) const; // set methods QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); - void setDevices(const QHash &_devices); + void setDevices(const AWPluginMatcherSettings &_settings); private: AWFormatterHelper *m_customFormatters = nullptr; + AWPluginMatcherSettings m_settings; // variables QHash m_devices; - QHash m_formatter; + QHash m_formatter; QMultiHash m_map; }; diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp index 0ac191c5..491928f6 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -82,47 +82,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL } } - // insert depending keys, refer to AWKeys::calculateValues() - // hddtotmb* - for (auto &key : _allKeys.filter(QRegularExpression("^hddtotmb"))) { - if (!used.contains(key)) - continue; - key.remove("hddtotmb"); - auto index = key.toInt(); - used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index); - } - // hddtotgb* - for (auto &key : _allKeys.filter(QRegularExpression("^hddtotgb"))) { - if (!used.contains(key)) - continue; - key.remove("hddtotgb"); - auto index = key.toInt(); - used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index); - } - // mem - if (used.contains("mem")) - used << "memmb" - << "memtotmb"; - // memtotmb - if (used.contains("memtotmb")) - used << "memusedmb" - << "memfreemb"; - // memtotgb - if (used.contains("memtotgb")) - used << "memusedgb" - << "memfreegb"; - // swap - if (used.contains("swap")) - used << "swapmb" - << "swaptotmb"; - // swaptotmb - if (used.contains("swaptotmb")) - used << "swapmb" - << "swapfreemb"; - // memtotgb - if (used.contains("swaptotgb")) - used << "swapgb" - << "swapfreegb"; + // insert keys which depend on others, refer to AWKeys::calculateValues() // network keys QStringList netKeys( {"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"}); @@ -146,18 +106,23 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL } -QHash AWKeyCache::loadKeysFromCache() +AWPluginMatcherSettings AWKeyCache::loadKeysFromCache() { auto fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); qCInfo(LOG_AW) << "Cache file" << fileName; QSettings cache(fileName, QSettings::IniFormat); - QHash devices; - for (auto &group : cache.childGroups()) { + AWPluginMatcherSettings devices; + QHash groups = { + {"disk", &devices.disk}, {"gpu", &devices.gpu}, {"mount", &devices.mount}, + {"net", &devices.network}, {"temp", &devices.sensors}, + }; + + for (auto [group, list] : groups.asKeyValueRange()) { cache.beginGroup(group); for (auto &key : cache.allKeys()) - devices[group].append(cache.value(key).toString()); + list->append(cache.value(key).toString()); cache.endGroup(); } diff --git a/sources/awesome-widget/plugin/awkeycache.h b/sources/awesome-widget/plugin/awkeycache.h index bd323887..099639d5 100644 --- a/sources/awesome-widget/plugin/awkeycache.h +++ b/sources/awesome-widget/plugin/awkeycache.h @@ -17,15 +17,16 @@ #pragma once -#include #include #include +#include + 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 QStringList &_allKeys); -QHash loadKeysFromCache(); +AWPluginMatcherSettings loadKeysFromCache(); } // namespace AWKeyCache diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index bb60147f..33e34ac4 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -49,15 +49,7 @@ AWKeyOperations::AWKeyOperations(QObject *_parent) } -QStringList AWKeyOperations::devices(const QString &_type) const -{ - qCDebug(LOG_AW) << "Looking for type" << _type; - - return m_devices[_type]; -} - - -QHash AWKeyOperations::devices() const +AWPluginMatcherSettings AWKeyOperations::devices() const { return m_devices; } @@ -88,15 +80,15 @@ QStringList AWKeyOperations::dictKeys() const allKeys.append(QString("cpu%1").arg(i)); } // temperature - for (auto i = 0; i < m_devices["temp"].count(); ++i) + for (auto i = 0; i < m_devices.sensors.count(); ++i) allKeys.append(QString("temp%1").arg(i)); // gpu - for (auto i = 0; i < m_devices["gpu"].count(); ++i) { + for (auto i = 0; i < m_devices.gpu.count(); ++i) { allKeys.append(QString("gpu%1").arg(i)); allKeys.append(QString("gputemp%1").arg(i)); } // hdd - for (auto i = 0; i < m_devices["mount"].count(); ++i) { + for (auto i = 0; i < m_devices.mount.count(); ++i) { allKeys.append(QString("hddmb%1").arg(i)); allKeys.append(QString("hddgb%1").arg(i)); allKeys.append(QString("hddfreemb%1").arg(i)); @@ -106,12 +98,12 @@ QStringList AWKeyOperations::dictKeys() const allKeys.append(QString("hdd%1").arg(i)); } // hdd speed - for (auto i = 0; i < m_devices["disk"].count(); ++i) { + for (auto i = 0; i < m_devices.disk.count(); ++i) { allKeys.append(QString("hddr%1").arg(i)); allKeys.append(QString("hddw%1").arg(i)); } // network - for (auto i = 0; i < m_devices["net"].count(); ++i) { + for (auto i = 0; i < m_devices.network.count(); ++i) { allKeys.append(QString("downunits%1").arg(i)); allKeys.append(QString("upunits%1").arg(i)); allKeys.append(QString("downtotkb%1").arg(i)); @@ -224,15 +216,15 @@ QString AWKeyOperations::infoByKey(const QString &_key) const } else if (_key.contains(hddrwRegExp)) { auto index = _key; index.remove(hddrwRegExp); - output = m_devices["disk"][index.toInt()]; + output = m_devices.disk[index.toInt()]; } else if (_key.contains(hddMatchRegExp)) { auto index = _key; index.remove(hddRegExp); - output = m_devices["mount"][index.toInt()]; + output = m_devices.mount[index.toInt()]; } else if (_key.contains(netMatchRegExp)) { auto index = _key; index.remove(netRegExp); - output = m_devices["net"][index.toInt()]; + output = m_devices.network[index.toInt()]; } else if (_key.startsWith("pkgcount")) { auto item = m_extUpgrade->itemByTag(_key, stripped); if (item) @@ -248,7 +240,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const } else if (_key.startsWith("temp")) { auto index = _key; index.remove("temp"); - output = m_devices["temp"][index.toInt()]; + output = m_devices.sensors[index.toInt()]; } else if (_key.startsWith("response")) { auto item = m_extNetRequest->itemByTag(_key, stripped); if (item) diff --git a/sources/awesome-widget/plugin/awkeyoperations.h b/sources/awesome-widget/plugin/awkeyoperations.h index c9b028ca..f239f2ef 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.h +++ b/sources/awesome-widget/plugin/awkeyoperations.h @@ -20,6 +20,7 @@ #include #include "extitemaggregator.h" +#include "matchers/awpluginmatchersettings.h" class AWCustomKeysHelper; @@ -38,8 +39,7 @@ class AWKeyOperations : public QObject public: explicit AWKeyOperations(QObject *_parent = nullptr); ~AWKeyOperations() override = default; - [[nodiscard]] QStringList devices(const QString &_type) const; - [[nodiscard]] QHash devices() const; + [[nodiscard]] AWPluginMatcherSettings devices() const; void updateCache(); // keys [[nodiscard]] QStringList dictKeys() const; @@ -73,6 +73,6 @@ public slots: ExtItemAggregator *m_extUpgrade = nullptr; ExtItemAggregator *m_extWeather = nullptr; // variables - QHash m_devices; + AWPluginMatcherSettings m_devices; QString m_pattern; }; diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index dfe270fa..18bedf99 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -231,24 +231,10 @@ void AWKeys::updateTextData() // specified pattern. Usually they are values which depend on several others void AWKeys::calculateValues() { - // hddtot* - auto mountDevices = m_keyOperator->devices("mount"); - for (auto &device : mountDevices) { - auto index = mountDevices.indexOf(device); - m_values[QString("hddtotmb%1").arg(index)] = m_values[QString("hddfreemb%1").arg(index)].toDouble() - + m_values[QString("hddmb%1").arg(index)].toDouble(); - m_values[QString("hddtotgb%1").arg(index)] = m_values[QString("hddfreegb%1").arg(index)].toDouble() - + m_values[QString("hddgb%1").arg(index)].toDouble(); - } - - // memtot* - m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong(); - m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble(); - // mem - m_values["mem"] = 100.0 * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble(); + auto devices = m_keyOperator->devices(); // up, down, upkb, downkb, upunits, downunits - auto netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString()); + auto netIndex = devices.network.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)]; @@ -260,12 +246,6 @@ void AWKeys::calculateValues() m_values["uptotkb"] = m_values[QString("uptotkb%1").arg(netIndex)]; m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)]; - // swaptot* - m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong(); - m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble(); - // swap - m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble(); - // user defined keys for (auto &key : m_keyOperator->userKeys()) m_values[key] = m_values[m_keyOperator->userKeySource(key)]; diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index 2a1322ea..e7f137e5 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -28,7 +28,7 @@ class AWKeyOperations; class AWKeysAggregator; class QTimer; -class AWKeys : public QObject +class __attribute__((visibility("default"))) AWKeys : public QObject { Q_OBJECT diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index 95629936..3a02fce8 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -17,15 +17,9 @@ #include "awkeysaggregator.h" -#include - -#include -#include - #include "awdataenginemapper.h" #include "awdebug.h" #include "awformatterhelper.h" -#include "version.h" AWKeysAggregator::AWKeysAggregator(QObject *_parent) @@ -33,19 +27,38 @@ AWKeysAggregator::AWKeysAggregator(QObject *_parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; - m_customFormatters = new AWFormatterHelper(this); - m_mapper = new AWDataEngineMapper(this, m_customFormatters); - - // sort time keys - m_timeKeys = QString(TIME_KEYS).split(','); - m_timeKeys.sort(); - std::reverse(m_timeKeys.begin(), m_timeKeys.end()); + m_settings.customFormatters = new AWFormatterHelper(this); + m_mapper = new AWDataEngineMapper(this, m_settings.customFormatters); } void AWKeysAggregator::initFormatters() { - m_customFormatters->initItems(); + m_settings.customFormatters->initItems(); +} + + +QString AWKeysAggregator::acOffline() const +{ + return m_settings.acOffline; +} + + +QString AWKeysAggregator::acOnline() const +{ + return m_settings.acOnline; +} + + +QString AWKeysAggregator::customTime() const +{ + return m_settings.customTime; +} + + +QString AWKeysAggregator::customUptime() const +{ + return m_settings.customUptime; } @@ -53,113 +66,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key, { qCDebug(LOG_AW) << "Data" << _data << "for key" << _key; - QString output; - QLocale loc = m_translate ? QLocale::system() : QLocale::c(); - // case block - switch (m_mapper->formatter(_key)) { - case FormatterType::Float: - output = QString("%1").arg(_data.toDouble(), 5, 'f', 1); - break; - case FormatterType::FloatTwoSymbols: - output = QString("%1").arg(_data.toDouble(), 5, 'f', 2); - break; - case FormatterType::Integer: - output = QString("%1").arg(_data.toDouble(), 4, 'f', 0); - break; - case FormatterType::IntegerFive: - output = QString("%1").arg(_data.toDouble(), 5, 'f', 0); - break; - case FormatterType::IntegerThree: - output = QString("%1").arg(_data.toDouble(), 3, 'f', 0); - break; - case FormatterType::List: - output = _data.toStringList().join(','); - break; - case FormatterType::ACFormat: - output = _data.toBool() ? m_acOnline : m_acOffline; - break; - case FormatterType::MemGBFormat: - output = QString("%1").arg(_data.toDouble() / GBinBytes, 5, 'f', 1); - break; - case FormatterType::MemMBFormat: - output = QString("%1").arg(_data.toDouble() / MBinBytes, 5, 'f', 0); - break; - case FormatterType::MemKBFormat: - output = QString("%1").arg(_data.toDouble() / KBinBytes, 5, 'f', 0); - break; - case FormatterType::NetSmartFormat: - output = [](const double value) { - if (value > MBinBytes) - return QString("%1").arg(value / MBinBytes, 4, 'f', 1); - else - return QString("%1").arg(value / KBinBytes, 4, 'f', 0); - }(_data.toDouble()); - break; - case FormatterType::NetSmartUnits: - if (_data.toDouble() > MBinBytes) - output = m_translate ? i18n("MB/s") : "MB/s"; - else - output = m_translate ? i18n("KB/s") : "KB/s"; - break; - case FormatterType::Quotes: - // first cast - output = QString("%1").arg(_data.toDouble(), 0, 'f'); - output = output.rightJustified(8, QLatin1Char(' '), true); - break; - case FormatterType::Temperature: - output = QString("%1").arg(temperature(_data.toDouble()), 5, 'f', 1); - break; - case FormatterType::Time: - output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString(); - break; - case FormatterType::TimeCustom: - output = m_customTime; - [&output, loc, this](const QDateTime &dt) { - for (auto &key : m_timeKeys) - output.replace(QString("$%1").arg(key), loc.toString(dt, key)); - }(QDateTime::fromSecsSinceEpoch(_data.toLongLong())); - break; - case FormatterType::TimeISO: - output = QDateTime::fromSecsSinceEpoch(_data.toLongLong()).toString(Qt::ISODate); - break; - case FormatterType::TimeLong: - output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::LongFormat); - break; - case FormatterType::TimeShort: - output = loc.toString(QDateTime::fromSecsSinceEpoch(_data.toLongLong()), QLocale::ShortFormat); - break; - case FormatterType::Timestamp: - output = _data.toString(); - break; - case FormatterType::Uptime: - case FormatterType::UptimeCustom: - output = - [](auto source, auto uptime) { - auto seconds = uptime - uptime % 60; - auto minutes = seconds / 60 % 60; - auto hours = ((seconds / 60) - minutes) / 60 % 24; - auto days = (((seconds / 60) - minutes) / 60 - hours) / 24; - - 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("$h", QString("%1").arg(hours)); - 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, - static_cast(_data.toDouble())); - break; - case FormatterType::NoFormat: - output = _data.toString(); - break; - case FormatterType::Custom: - if (m_customFormatters) - output = m_customFormatters->convert(_data, _key); - break; - } - + auto output = m_mapper->formatter(_key)->format(_data, _key, m_settings); // replace spaces to non-breakable ones replaceSpace &= (!_key.startsWith("custom") && (!_key.startsWith("weather"))); if (replaceSpace) @@ -177,11 +84,23 @@ QStringList AWKeysAggregator::keysFromSource(const QString &_source) const } +QString AWKeysAggregator::tempUnits() const +{ + return m_settings.tempUnits; +} + + +bool AWKeysAggregator::translate() const +{ + return m_settings.translate; +} + + void AWKeysAggregator::setAcOffline(const QString &_inactive) { qCDebug(LOG_AW) << "Inactive AC string" << _inactive; - m_acOffline = _inactive; + m_settings.acOffline = _inactive; } @@ -189,7 +108,7 @@ void AWKeysAggregator::setAcOnline(const QString &_active) { qCDebug(LOG_AW) << "Active AC string" << _active; - m_acOnline = _active; + m_settings.acOnline = _active; } @@ -197,7 +116,7 @@ void AWKeysAggregator::setCustomTime(const QString &_customTime) { qCDebug(LOG_AW) << "Format" << _customTime; - m_customTime = _customTime; + m_settings.customTime = _customTime; } @@ -205,15 +124,13 @@ void AWKeysAggregator::setCustomUptime(const QString &_customUptime) { qCDebug(LOG_AW) << "Format" << _customUptime; - m_customUptime = _customUptime; + m_settings.customUptime = _customUptime; } -void AWKeysAggregator::setDevices(const QHash &_devices) +void AWKeysAggregator::setDevices(const AWPluginMatcherSettings &_settings) { - qCDebug(LOG_AW) << "Devices" << _devices; - - m_mapper->setDevices(_devices); + m_mapper->setDevices(_settings); } @@ -221,7 +138,7 @@ void AWKeysAggregator::setTempUnits(const QString &_units) { qCDebug(LOG_AW) << "Units" << _units; - m_tempUnits = _units; + m_settings.tempUnits = _units; } @@ -229,7 +146,7 @@ void AWKeysAggregator::setTranslate(const bool _translate) { qCDebug(LOG_AW) << "Translate" << _translate; - m_translate = _translate; + m_settings.translate = _translate; } @@ -240,29 +157,3 @@ QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysG return m_mapper->registerSource(_source, _units, _keys); } - - -double AWKeysAggregator::temperature(const double temp) const -{ - qCDebug(LOG_AW) << "Temperature value" << temp; - - auto converted = temp; - if (m_tempUnits == "Celsius") { - } else if (m_tempUnits == "Fahrenheit") { - converted = temp * 9.0f / 5.0 + 32.0; - } else if (m_tempUnits == "Kelvin") { - converted = temp + 273.15; - } else if (m_tempUnits == "Reaumur") { - converted = temp * 0.8; - } else if (m_tempUnits == "cm^-1") { - converted = (temp + 273.15) * 0.695; - } else if (m_tempUnits == "kJ/mol") { - converted = (temp + 273.15) * 8.31; - } else if (m_tempUnits == "kcal/mol") { - converted = (temp + 273.15) * 1.98; - } else { - qCWarning(LOG_AW) << "Invalid units" << m_tempUnits; - } - - return converted; -} diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index e6fbca11..95d81a1c 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -22,66 +22,41 @@ #include #include +#include "formatters/awpluginformatsettings.h" +#include "matchers/awpluginmatchersettings.h" + -class AWFormatterHelper; class AWDataEngineMapper; class AWKeysAggregator : public QObject { Q_OBJECT - 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 tempUnits MEMBER m_tempUnits WRITE setTempUnits); - Q_PROPERTY(bool translate MEMBER m_translate WRITE setTranslate); + Q_PROPERTY(QString acOffline READ acOffline WRITE setAcOffline); + Q_PROPERTY(QString acOnline READ acOnline WRITE setAcOnline); + Q_PROPERTY(QString customTime READ customTime WRITE setCustomTime); + Q_PROPERTY(QString customUptime READ customUptime WRITE setCustomUptime); + Q_PROPERTY(QString tempUnits READ tempUnits WRITE setTempUnits); + Q_PROPERTY(bool translate READ translate WRITE setTranslate); public: - enum class FormatterType { - // general formatters - Custom, - NoFormat, - Float, - FloatTwoSymbols, - Integer, - IntegerFive, - IntegerThree, - List, - // unit specific formatters - ACFormat, - MemGBFormat, - MemMBFormat, - MemKBFormat, - NetSmartFormat, - NetSmartUnits, - Quotes, - Temperature, - Time, - TimeCustom, - TimeISO, - TimeLong, - TimeShort, - Timestamp, - Uptime, - UptimeCustom - }; - - static constexpr double KBinBytes = 1024.0; - static constexpr double MBinBytes = 1024.0 * KBinBytes; - static constexpr double GBinBytes = 1024.0 * MBinBytes; - explicit AWKeysAggregator(QObject *_parent = nullptr); ~AWKeysAggregator() override = default; void initFormatters(); // get methods + [[nodiscard]] QString acOffline() const; + [[nodiscard]] QString acOnline() const; + [[nodiscard]] QString customTime() const; + [[nodiscard]] QString customUptime() const; [[nodiscard]] QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const; [[nodiscard]] QStringList keysFromSource(const QString &_source) const; + [[nodiscard]] QString tempUnits() const; + [[nodiscard]] bool translate() const; // set methods void setAcOffline(const QString &_inactive); void setAcOnline(const QString &_active); void setCustomTime(const QString &_customTime); void setCustomUptime(const QString &_customUptime); - void setDevices(const QHash &_devices); + void setDevices(const AWPluginMatcherSettings &_settings); void setTempUnits(const QString &_units); void setTranslate(bool _translate); @@ -89,15 +64,6 @@ public slots: QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); private: - [[nodiscard]] double temperature(double temp) const; - AWFormatterHelper *m_customFormatters = nullptr; + AWPluginFormatSettings m_settings; AWDataEngineMapper *m_mapper = nullptr; - QStringList m_timeKeys; - // variables - QString m_acOffline; - QString m_acOnline; - QString m_customTime; - QString m_customUptime; - QString m_tempUnits; - bool m_translate = false; }; diff --git a/sources/awesome-widget/plugin/awpairconfigfactory.h b/sources/awesome-widget/plugin/awpairconfigfactory.h index 8df7e391..2614011c 100644 --- a/sources/awesome-widget/plugin/awpairconfigfactory.h +++ b/sources/awesome-widget/plugin/awpairconfigfactory.h @@ -29,6 +29,4 @@ class AWPairConfigFactory : public QObject ~AWPairConfigFactory() override = default; 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.h b/sources/awesome-widget/plugin/awpatternfunctions.h index 2d3f2a4f..1b1a6607 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.h +++ b/sources/awesome-widget/plugin/awpatternfunctions.h @@ -23,7 +23,7 @@ class AWKeysAggregator; -namespace AWPatternFunctions +namespace __attribute__((visibility("default"))) AWPatternFunctions { typedef struct { QStringList args; diff --git a/sources/awesome-widget/plugin/awtelemetryhandler.h b/sources/awesome-widget/plugin/awtelemetryhandler.h index dd202d45..7c750fed 100644 --- a/sources/awesome-widget/plugin/awtelemetryhandler.h +++ b/sources/awesome-widget/plugin/awtelemetryhandler.h @@ -20,7 +20,7 @@ #include -class AWTelemetryHandler : public QObject +class __attribute__((visibility("default"))) AWTelemetryHandler : public QObject { Q_OBJECT diff --git a/sources/awesome-widget/plugin/awupdatehelper.h b/sources/awesome-widget/plugin/awupdatehelper.h index e5dba9da..be619e20 100644 --- a/sources/awesome-widget/plugin/awupdatehelper.h +++ b/sources/awesome-widget/plugin/awupdatehelper.h @@ -24,7 +24,7 @@ class KNotification; class QNetworkReply; -class AWUpdateHelper : public QObject +class __attribute__((visibility("default"))) AWUpdateHelper : public QObject { Q_OBJECT diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatsettings.h b/sources/awesome-widget/plugin/formatters/awpluginformatsettings.h new file mode 100644 index 00000000..e3e76dd5 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatsettings.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#pragma once + +#include + + +class AWFormatterHelper; + +struct AWPluginFormatSettings { + QString acOffline; + QString acOnline; + + QString customTime; + QString customUptime; + + QString tempUnits; + + bool translate = false; + + AWFormatterHelper *customFormatters = nullptr; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatter.h b/sources/awesome-widget/plugin/formatters/awpluginformatter.h new file mode 100644 index 00000000..57b47897 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatter.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include +#include + +#include + +#include "awpluginformatsettings.h" + + +class AWPluginFormaterInterface +{ +public: + virtual ~AWPluginFormaterInterface() = default; + [[nodiscard]] virtual QString format(const QVariant &_value, const QString &_key, + const AWPluginFormatSettings &_settings) const + = 0; + virtual void load(){}; +}; + + +template class AWPluginFormatter : public AWPluginFormaterInterface +{ +public: + static constexpr double KBinBytes = 1024.0; + static constexpr double MBinBytes = 1024.0 * KBinBytes; + static constexpr double GBinBytes = 1024.0 * MBinBytes; + + AWPluginFormatter(AWPluginFormatter &) = delete; + void operator=(const AWPluginFormatter &) = delete; + + [[nodiscard]] static Formatter *instance() + { + static auto instance = loadInstance(); + return instance.get(); + }; + + [[nodiscard]] static QLocale locale(const AWPluginFormatSettings &_settings) + { + return _settings.translate ? QLocale::system() : QLocale::c(); + }; + +protected: + AWPluginFormatter() = default; + + [[nodiscard]] static std::unique_ptr loadInstance() + { + auto instance = std::make_unique(); + instance->load(); + return instance; + }; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp new file mode 100644 index 00000000..9ddbcec1 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * 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 "awpluginformatterac.h" + + +QString AWPluginFormatterAC::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + return _value.toBool() ? _settings.acOnline : _settings.acOffline; +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterac.h b/sources/awesome-widget/plugin/formatters/awpluginformatterac.h new file mode 100644 index 00000000..e4ffe2aa --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterac.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterAC : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp new file mode 100644 index 00000000..42b03e03 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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 "awpluginformattercustom.h" + +#include "awformatterhelper.h" + + +QString AWPluginFormatterCustom::format(const QVariant &_value, const QString &_key, + const AWPluginFormatSettings &_settings) const +{ + if (_settings.customFormatters) + return _settings.customFormatters->convert(_value, _key); + return _value.toString(); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h new file mode 100644 index 00000000..3a8a3152 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterCustom : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &_key, + const AWPluginFormatSettings &_settings) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.cpp new file mode 100644 index 00000000..ef31c470 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * 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 "awpluginformatterdouble.h" + + +QString AWPluginFormatterDouble::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + auto output = QString("%1").arg(_value.toDouble(), 0, 'f'); + return output.rightJustified(8, QLatin1Char(' '), true); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h b/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h new file mode 100644 index 00000000..61cecff3 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterDouble : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.cpp new file mode 100644 index 00000000..231cba31 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformatterfloat.h" + + +QString AWPluginFormatterFloat::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble(), 5, 'f', 1); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h b/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h new file mode 100644 index 00000000..c4506b87 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterFloat : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp new file mode 100644 index 00000000..90bab4a6 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * 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 "awpluginformatterfloatprecise.h" + + +QString AWPluginFormatterFloatPrecise::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble(), 5, 'f', 2); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h new file mode 100644 index 00000000..585239eb --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterFloatPrecise : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.cpp new file mode 100644 index 00000000..411bd2d8 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformatterinteger.h" + + +QString AWPluginFormatterInteger::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble(), 4, 'f', 0); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h b/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h new file mode 100644 index 00000000..3ecdf247 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterInteger : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp new file mode 100644 index 00000000..93da1be5 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * 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 "awpluginformatterintegershort.h" + + +QString AWPluginFormatterIntegerShort::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble(), 3, 'f', 0); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h new file mode 100644 index 00000000..c610601a --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterIntegerShort : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp new file mode 100644 index 00000000..f0a36050 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * 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 "awpluginformatterintegerwide.h" + + +QString AWPluginFormatterIntegerWide::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble(), 5, 'f', 0); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h new file mode 100644 index 00000000..f701e117 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterIntegerWide : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterlist.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterlist.cpp new file mode 100644 index 00000000..d998bdb1 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterlist.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformatterlist.h" + + +QString AWPluginFormatterList::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return _value.toStringList().join(","); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h b/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h new file mode 100644 index 00000000..f9498a76 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterList : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemory.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattermemory.cpp new file mode 100644 index 00000000..de334931 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemory.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformattermemory.h" + + +QString AWPluginFormatterMemory::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble() / KBinBytes, 5, 'f', 0); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h b/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h new file mode 100644 index 00000000..c3b8cadc --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterMemory : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.cpp new file mode 100644 index 00000000..aea5064c --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformattermemorygb.h" + + +QString AWPluginFormatterMemoryGB::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble() / GBinBytes, 5, 'f', 1); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h b/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h new file mode 100644 index 00000000..b316882b --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterMemoryGB : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.cpp new file mode 100644 index 00000000..7ad05c7d --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformattermemorymb.h" + + +QString AWPluginFormatterMemoryMB::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QString("%1").arg(_value.toDouble() / MBinBytes, 5, 'f', 0); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h b/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h new file mode 100644 index 00000000..a114fbfe --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterMemoryMB : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternet.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatternet.cpp new file mode 100644 index 00000000..fe684b87 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternet.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginformatternet.h" + + +QString AWPluginFormatterNet::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + auto value = _value.toDouble(); + return (value > MBinBytes) ? formatMB(value) : formatKB(value); +} + + +QString AWPluginFormatterNet::formatKB(const double &_value) +{ + return QString("%1").arg(_value / KBinBytes, 4, 'f', 0); +} + + +QString AWPluginFormatterNet::formatMB(const double &_value) +{ + return QString("%1").arg(_value / MBinBytes, 4, 'f', 1); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternet.h b/sources/awesome-widget/plugin/formatters/awpluginformatternet.h new file mode 100644 index 00000000..dfd891a7 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternet.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterNet : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; + +private: + [[nodiscard]] static QString formatKB(const double &_value); + [[nodiscard]] static QString formatMB(const double &_value); +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp new file mode 100644 index 00000000..f6416548 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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 "awpluginformatternetunits.h" + +#include + + +QString AWPluginFormatterNetUnits::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + auto value = _value.toDouble(); + return (value > MBinBytes) ? formatMB(_settings) : formatKB(_settings); +} + + +QString AWPluginFormatterNetUnits::formatKB(const AWPluginFormatSettings &_settings) +{ + return _settings.translate ? i18n("KB/s") : "KB/s"; +} + + +QString AWPluginFormatterNetUnits::formatMB(const AWPluginFormatSettings &_settings) +{ + return _settings.translate ? i18n("MB/s") : "MB/s"; +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h new file mode 100644 index 00000000..fd0d1496 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterNetUnits : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; + +private: + [[nodiscard]] static QString formatKB(const AWPluginFormatSettings &_settings); + [[nodiscard]] static QString formatMB(const AWPluginFormatSettings &_settings); +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.cpp new file mode 100644 index 00000000..56572ed9 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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 "awpluginformatternoformat.h" + + +QString AWPluginFormatterNoFormat::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return _value.toString(); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h b/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h new file mode 100644 index 00000000..f74872a0 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterNoFormat : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp new file mode 100644 index 00000000..a5e72a8d --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp @@ -0,0 +1,48 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginformattertemperature.h" + + +QString AWPluginFormatterTemperature::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + auto converted = convert(_value.toDouble(), _settings.tempUnits); + return QString("%1").arg(converted, 5, 'f', 1); +} + + +double AWPluginFormatterTemperature::convert(const double &_value, const QString &_units) +{ + auto converted = _value; + if (_units == "Celsius") { + } else if (_units == "Fahrenheit") { + converted = _value * 9.0f / 5.0 + 32.0; + } else if (_units == "Kelvin") { + converted = _value + 273.15; + } else if (_units == "Reaumur") { + converted = _value * 0.8; + } else if (_units == "cm^-1") { + converted = (_value + 273.15) * 0.695; + } else if (_units == "kJ/mol") { + converted = (_value + 273.15) * 8.31; + } else if (_units == "kcal/mol") { + converted = (_value + 273.15) * 1.98; + } + + return converted; +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h new file mode 100644 index 00000000..9360c6a7 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterTemperature : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; + +private: + [[nodiscard]] static double convert(const double &_value, const QString &_units); +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertime.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertime.cpp new file mode 100644 index 00000000..8a9c1942 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertime.cpp @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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 "awpluginformattertime.h" + +#include + + +QString AWPluginFormatterTime::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QDateTime::fromSecsSinceEpoch(_value.toLongLong()).toString(); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertime.h b/sources/awesome-widget/plugin/formatters/awpluginformattertime.h new file mode 100644 index 00000000..8b19a507 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertime.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterTime : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp new file mode 100644 index 00000000..2aa6600f --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginformattertimecustom.h" + +#include "awdebug.h" + + +QString AWPluginFormatterTimeCustom::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + auto value = QDateTime::fromSecsSinceEpoch(_value.toLongLong()); + return format(value, _settings.customTime, locale(_settings)); +} + + +void AWPluginFormatterTimeCustom::load() +{ + m_timeKeys = QString(TIME_KEYS).split(','); + m_timeKeys.sort(); + std::reverse(m_timeKeys.begin(), m_timeKeys.end()); +} + + +QString AWPluginFormatterTimeCustom::format(const QDateTime &_value, QString _formatString, + const QLocale &_locale) const +{ + for (auto &key : m_timeKeys) + _formatString.replace(QString("$%1").arg(key), _locale.toString(_value, key)); + + return _formatString; +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h new file mode 100644 index 00000000..6a6e9781 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include + +#include "awpluginformatter.h" + + +class AWPluginFormatterTimeCustom : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; + void load() override; + +private: + [[nodiscard]] QString format(const QDateTime &_value, QString _formatString, const QLocale &_locale) const; + QStringList m_timeKeys; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.cpp new file mode 100644 index 00000000..abc9f649 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.cpp @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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 "awpluginformattertimeiso.h" + +#include + + +QString AWPluginFormatterTimeISO::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +{ + return QDateTime::fromSecsSinceEpoch(_value.toLongLong()).toString(Qt::ISODate); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h new file mode 100644 index 00000000..a03aba0e --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterTimeISO : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp new file mode 100644 index 00000000..bcb64c0f --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp @@ -0,0 +1,27 @@ +/*************************************************************************** + * 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 "awpluginformattertimelong.h" + +#include + + +QString AWPluginFormatterTimeLong::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::LongFormat); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h new file mode 100644 index 00000000..12849a06 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterTimeLong : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp new file mode 100644 index 00000000..9bd0840f --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp @@ -0,0 +1,27 @@ +/*************************************************************************** + * 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 "awpluginformattertimeshort.h" + +#include + + +QString AWPluginFormatterTimeShort::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::ShortFormat); +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h new file mode 100644 index 00000000..32b161a6 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterTimeShort : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; +}; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp new file mode 100644 index 00000000..9b614e29 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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 "awpluginformatteruptime.h" + + +QString AWPluginFormatterUptime::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const +{ + auto value = static_cast(_value.toDouble()); + return format(value, _settings.customUptime); +} + + +QString AWPluginFormatterUptime::format(const long &_value, QString _formatString) +{ + auto seconds = _value - _value % 60; + auto minutes = seconds / 60 % 60; + auto hours = ((seconds / 60) - minutes) / 60 % 24; + auto days = (((seconds / 60) - minutes) / 60 - hours) / 24; + + _formatString.replace("$dd", QString("%1").arg(days, 3, 10, QChar('0'))); + _formatString.replace("$d", QString("%1").arg(days)); + _formatString.replace("$hh", QString("%1").arg(hours, 2, 10, QChar('0'))); + _formatString.replace("$h", QString("%1").arg(hours)); + _formatString.replace("$mm", QString("%1").arg(minutes, 2, 10, QChar('0'))); + _formatString.replace("$m", QString("%1").arg(minutes)); + + return _formatString; +} diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h new file mode 100644 index 00000000..a4a26730 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginformatter.h" + + +class AWPluginFormatterUptime : public AWPluginFormatter +{ +public: + [[nodiscard]] QString format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const override; + +private: + [[nodiscard]] static QString format(const long &_value, QString _formatString); +}; diff --git a/sources/awesome-widget/plugin/formatters/formatters.h b/sources/awesome-widget/plugin/formatters/formatters.h new file mode 100644 index 00000000..06153a51 --- /dev/null +++ b/sources/awesome-widget/plugin/formatters/formatters.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginformatterac.h" +#include "awpluginformattercustom.h" +#include "awpluginformatterdouble.h" +#include "awpluginformatterfloat.h" +#include "awpluginformatterfloatprecise.h" +#include "awpluginformatterinteger.h" +#include "awpluginformatterintegershort.h" +#include "awpluginformatterintegerwide.h" +#include "awpluginformatterlist.h" +#include "awpluginformattermemory.h" +#include "awpluginformattermemorygb.h" +#include "awpluginformattermemorymb.h" +#include "awpluginformatternet.h" +#include "awpluginformatternetunits.h" +#include "awpluginformatternoformat.h" +#include "awpluginformattertemperature.h" +#include "awpluginformattertime.h" +#include "awpluginformattertimecustom.h" +#include "awpluginformattertimeiso.h" +#include "awpluginformattertimelong.h" +#include "awpluginformattertimeshort.h" +#include "awpluginformatteruptime.h" diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcher.h b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h new file mode 100644 index 00000000..3b5bfeb5 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include + +#include + +#include + +#include "awpluginmatchersettings.h" + + +class AWPluginFormaterInterface; + +class AWPluginMatcherInterface +{ +public: + virtual ~AWPluginMatcherInterface() = default; + [[nodiscard]] virtual QHash + keys(const QString &_source, KSysGuard::Unit _units, const AWPluginMatcherSettings &_settings) const = 0; + [[nodiscard]] virtual bool matches(const QString &_source) const = 0; +}; + + +template class AWPluginMatcher : public AWPluginMatcherInterface +{ +public: + AWPluginMatcher(AWPluginMatcher &) = delete; + void operator=(const AWPluginMatcher &) = delete; + + [[nodiscard]] static Matcher *instance() + { + static auto instance = std::make_unique(); + return instance.get(); + }; + + [[nodiscard]] static QString device(const QString &_source) { return _source.split('/')[1]; }; + + [[nodiscard]] static qsizetype index(const QString &_source, const QStringList &_devices) + { + auto device = AWPluginMatcher::device(_source); + return _devices.indexOf(device); + } + +protected: + AWPluginMatcher() = default; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp new file mode 100644 index 00000000..672a2d60 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherac.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherAC::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"ac", AWPluginFormatterAC::instance()}}; +} + + +bool AWPluginMatcherAC::matches(const QString &_source) const +{ + return _source == "extsysmon/battery/ac"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherac.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.h new file mode 100644 index 00000000..c4b01472 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherAC : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp new file mode 100644 index 00000000..d51ebb70 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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 "awpluginmatcherbattery.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherBattery::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/battery/"); + + if (key.contains("rate")) + return {{key, AWPluginFormatterFloat::instance()}}; + return {{key, AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherBattery::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/battery/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h new file mode 100644 index 00000000..15a17364 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherBattery : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.cpp new file mode 100644 index 00000000..f9494aae --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherbrightness.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherBrightness::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"brightness", AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherBrightness::matches(const QString &_source) const +{ + return _source == "extsysmon/system/brightness"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.h new file mode 100644 index 00000000..a93f7b77 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherBrightness : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp new file mode 100644 index 00000000..9e125fc1 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchercpu.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPU::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"cpu", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherCPU::matches(const QString &_source) const +{ + return _source == "cpu/all/usage"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h new file mode 100644 index 00000000..60e87001 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherCPU : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp new file mode 100644 index 00000000..90086a27 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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 "awpluginmatchercpucore.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPUCore::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("cpu/").remove("/usage"); + return {{key, AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherCPUCore::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^cpu/cpu.*/usage$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h new file mode 100644 index 00000000..ef3d483f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherCPUCore : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp new file mode 100644 index 00000000..585a17a1 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchercpufrequency.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPUFrequency::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"cpucl", AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherCPUFrequency::matches(const QString &_source) const +{ + return _source == "cpu/all/averageFrequency"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h new file mode 100644 index 00000000..86720bb6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherCPUFrequency : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp new file mode 100644 index 00000000..0f6d1182 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatchercpufrequencycore.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPUFrequencyCore::keys(const QString &_source, + const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto index = _source; + index.remove("cpu/cpu").remove("/frequency"); + return {{QString("cpucl%1").arg(index), AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherCPUFrequencyCore::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^cpu/cpu.*/frequency$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h new file mode 100644 index 00000000..88d5ea2e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherCPUFrequencyCore : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp new file mode 100644 index 00000000..79ac8439 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatchercustom.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCustom::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/custom/"); + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherCustom::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/custom/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h new file mode 100644 index 00000000..b02aa012 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherCustom : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp new file mode 100644 index 00000000..ab3a5ab2 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherdesktop.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherDesktop::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"desktop", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherDesktop::matches(const QString &_source) const +{ + return _source == "extsysmon/desktop/name"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h new file mode 100644 index 00000000..66fe7cce --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherDesktop : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp new file mode 100644 index 00000000..c7c00d23 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherdesktopcount.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherDesktopCount::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"tdesktops", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherDesktopCount::matches(const QString &_source) const +{ + return _source == "extsysmon/desktop/count"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h new file mode 100644 index 00000000..09e48078 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherDesktopCount : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp new file mode 100644 index 00000000..e09873cb --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherdesktopnumber.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherDesktopNumber::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"ndesktop", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherDesktopNumber::matches(const QString &_source) const +{ + return _source == "extsysmon/desktop/number"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h new file mode 100644 index 00000000..59144b91 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherDesktopNumber : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp new file mode 100644 index 00000000..e46afa33 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchergpu.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherGPU::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"gpu", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherGPU::matches(const QString &_source) const +{ + return _source == "gpu/all/usage"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h new file mode 100644 index 00000000..e4ba8673 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherGPU : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp new file mode 100644 index 00000000..6479bd41 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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 "awpluginmatchergpucore.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherGPUCore::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.gpu); + if (index == -1) + return {}; + + return {{QString("gpu%1").arg(index), AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherGPUCore::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^gpu/gpu.*/usage$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h new file mode 100644 index 00000000..1d6ce6fd --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherGPUCore : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp new file mode 100644 index 00000000..7f7120b4 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatchergputemperature.h" + +#include + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherGPUTemperature::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.gpu); + if (index == -1) + return {}; + + return {{QString("gputemp%1").arg(index), AWPluginFormatterTemperature::instance()}}; +} + + +bool AWPluginMatcherGPUTemperature::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^gpu/gpu.*/temperature$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h new file mode 100644 index 00000000..f5f4baf0 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherGPUTemperature : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp new file mode 100644 index 00000000..2575e0a6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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 "awpluginmatcherhdd.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDD::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.disk); + if (index == -1) + return {}; + + return {{QString("hdd%1").arg(index), AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherHDD::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/usedPercent$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h new file mode 100644 index 00000000..6c6b4000 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherHDD : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp new file mode 100644 index 00000000..92750f28 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp @@ -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/ * + ***************************************************************************/ + +#include "awpluginmatcherhddfree.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDFree::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.disk); + if (index == -1) + return {}; + + return { + {QString("hddfreemb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("hddfreegb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherHDDFree::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/free$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.h new file mode 100644 index 00000000..46f146dc --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherHDDFree : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp new file mode 100644 index 00000000..353e5e4e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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 "awpluginmatcherhddread.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDRead::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.disk); + if (index == -1) + return {}; + + return {{QString("hddr%1").arg(index), AWPluginFormatterMemory::instance()}}; +} + + +bool AWPluginMatcherHDDRead::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/read$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h new file mode 100644 index 00000000..69ebc803 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherHDDRead : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp new file mode 100644 index 00000000..cd60859d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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 "awpluginmatcherhddtotal.h" + +#include + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherHDDTotal::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.disk); + if (index == -1) + return {}; + + return { + {QString("hddtotmb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("hddtotgb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherHDDTotal::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/total$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.h new file mode 100644 index 00000000..e6bacbc8 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherHDDTotal : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp new file mode 100644 index 00000000..0b4dc3e2 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp @@ -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/ * + ***************************************************************************/ + +#include "awpluginmatcherhddused.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDUsed::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.disk); + if (index == -1) + return {}; + + return { + {QString("hddmb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("hddgb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherHDDUsed::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/used$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.h new file mode 100644 index 00000000..489c0c47 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherHDDUsed : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp new file mode 100644 index 00000000..b57939e8 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherhddwrite.h" + +#include + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherHDDWrite::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.disk); + if (index == -1) + return {}; + + return {{QString("hddw%1").arg(index), AWPluginFormatterMemory::instance()}}; +} + + +bool AWPluginMatcherHDDWrite::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/write$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h new file mode 100644 index 00000000..5ed23cb5 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherHDDWrite : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherload.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.cpp new file mode 100644 index 00000000..e00e03ae --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatcherload.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherLoad::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/load/"); + return {{key, AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherLoad::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/load/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherload.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.h new file mode 100644 index 00000000..293f662f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherLoad : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp new file mode 100644 index 00000000..b7e9c773 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatcherloadaverage.h" + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherLoadAverage::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + auto time = _source; + time.remove("cpu/loadaverages/loadaverage"); + return {{QString("la%1").arg(time), AWPluginFormatterFloatPrecise::instance()}}; +} + + +bool AWPluginMatcherLoadAverage::matches(const QString &_source) const +{ + return _source.startsWith("cpu/loadaverages/loadaverage"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h new file mode 100644 index 00000000..ada9571d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherLoadAverage : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.cpp new file mode 100644 index 00000000..18b0f4c2 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchermemory.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemory::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"mem", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherMemory::matches(const QString &_source) const +{ + return _source == "memory/physical/usedPercent"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.h new file mode 100644 index 00000000..6ff91912 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherMemory : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp new file mode 100644 index 00000000..18ba95fc --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatchermemoryapplication.h" + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherMemoryApplication::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return { + {"memmb", AWPluginFormatterMemoryMB::instance()}, + {"memgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryApplication::matches(const QString &_source) const +{ + return _source == "memory/physical/application"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h new file mode 100644 index 00000000..873c6ad9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherMemoryApplication : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp new file mode 100644 index 00000000..61073311 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatchermemoryfree.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryFree::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"memfreemb", AWPluginFormatterMemoryMB::instance()}, + {"memfreegb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryFree::matches(const QString &_source) const +{ + return _source == "memory/physical/free"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h new file mode 100644 index 00000000..4051fe41 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherMemoryFree : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.cpp new file mode 100644 index 00000000..6fa0e823 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatchermemorytotal.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryTotal::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"memtotmb", AWPluginFormatterMemoryMB::instance()}, + {"memtotgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryTotal::matches(const QString &_source) const +{ + return _source == "memory/physical/total"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.h new file mode 100644 index 00000000..7e0a2fd9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherMemoryTotal : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp new file mode 100644 index 00000000..a7dae15b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatchermemoryused.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryUsed::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"memusedmb", AWPluginFormatterMemoryMB::instance()}, + {"memusedgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryUsed::matches(const QString &_source) const +{ + return _source == "memory/physical/used"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h new file mode 100644 index 00000000..d6f7d97e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherMemoryUsed : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp new file mode 100644 index 00000000..c8187510 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatchernetwork.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherNetwork::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.network); + if (index == -1) + return {}; + + auto type = _source.endsWith("download") ? "down" : "up"; + return { + {QString("%1%2").arg(type).arg(index), AWPluginFormatterNet::instance()}, + {QString("%1kb%2").arg(type).arg(index), AWPluginFormatterMemory::instance()}, + {QString("%1units%2").arg(type).arg(index), AWPluginFormatterNetUnits::instance()}, + }; +} + + +bool AWPluginMatcherNetwork::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^network/.*/(download|upload)$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.h new file mode 100644 index 00000000..a7ec5bbb --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherNetwork : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp new file mode 100644 index 00000000..c1675bde --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchernetworkdevice.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherNetworkDevice::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"netdev", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherNetworkDevice::matches(const QString &_source) const +{ + return _source == "extsysmon/network/device"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h new file mode 100644 index 00000000..03bfd998 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherNetworkDevice : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp new file mode 100644 index 00000000..be60d372 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchernetworkssid.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherNetworkSSID::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"ssid", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherNetworkSSID::matches(const QString &_source) const +{ + return _source == "extsysmon/network/ssid"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h new file mode 100644 index 00000000..369ce8eb --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherNetworkSSID : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp new file mode 100644 index 00000000..d26acd42 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatchernetworktotal.h" + +#include + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherNetworkTotal::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto index = AWPluginMatcher::index(_source, _settings.network); + if (index == -1) + return {}; + + auto type = _source.endsWith("Download") ? "down" : "up"; + return { + {QString("%1tot%2").arg(type).arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("%1totkb%2").arg(type).arg(index), AWPluginFormatterMemory::instance()}, + }; +} + + +bool AWPluginMatcherNetworkTotal::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.h new file mode 100644 index 00000000..e7603ff6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherNetworkTotal : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.cpp new file mode 100644 index 00000000..886d2863 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatcherplayer.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPlayer::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/player/"); + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherPlayer::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/player/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.h new file mode 100644 index 00000000..418d8bf5 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherPlayer : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherps.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.cpp new file mode 100644 index 00000000..ed51258b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherps.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPS::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"pscount", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherPS::matches(const QString &_source) const +{ + return _source == "extsysmon/ps/running"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherps.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.h new file mode 100644 index 00000000..4c90424d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherPS : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.cpp new file mode 100644 index 00000000..195955cc --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherpsprocesses.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPSProcesses::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"ps", AWPluginFormatterList::instance()}}; +} + + +bool AWPluginMatcherPSProcesses::matches(const QString &_source) const +{ + return _source == "extsysmon/ps/list"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.h new file mode 100644 index 00000000..228595e4 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherPSProcesses : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.cpp new file mode 100644 index 00000000..ab924c65 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherpstotal.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPSTotal::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"count", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherPSTotal::matches(const QString &_source) const +{ + return _source == "extsysmon/ps/count"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.h new file mode 100644 index 00000000..0b0a8967 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherPSTotal : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.cpp new file mode 100644 index 00000000..e999597e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatcherquotes.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherQuotes::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/quotes/"); + return {{key, AWPluginFormatterDouble::instance()}}; +} + + +bool AWPluginMatcherQuotes::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/quotes/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.h new file mode 100644 index 00000000..a39d778e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherQuotes : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.cpp new file mode 100644 index 00000000..f1d1932e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatcherrequest.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherRequest::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/requests/"); + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherRequest::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/requests/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.h new file mode 100644 index 00000000..2d10b315 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherRequest : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp new file mode 100644 index 00000000..651d4ba8 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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 "awpluginmatchersensors.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSensors::keys(const QString &_source, KSysGuard::Unit _units, + const AWPluginMatcherSettings &_settings) const +{ + // temperature + auto index = _settings.sensors.indexOf(_source); + auto key = QString("temp%1").arg(index); + if (index == -1) + return {}; + + if (_units == KSysGuard::UnitCelsius) + return {{key, AWPluginFormatterTemperature::instance()}}; + return {{key, AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherSensors::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^cpu/cpu.*/temperature$"); + return _source.startsWith("lmsensors/") || _source == "cpu/all/averageTemperature" || _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.h b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.h new file mode 100644 index 00000000..74470965 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherSensors : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit _units, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h b/sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h new file mode 100644 index 00000000..b16c1fe0 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include + + +struct AWPluginMatcherSettings { + // devices + QStringList disk; + QStringList gpu; + QStringList mount; + QStringList network; + QStringList sensors; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.cpp new file mode 100644 index 00000000..218013d9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherswap.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwap::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"swap", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherSwap::matches(const QString &_source) const +{ + return _source == "memory/swap/usedPercent"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.h new file mode 100644 index 00000000..7e81429e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherSwap : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.cpp new file mode 100644 index 00000000..a5871116 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatcherswapfree.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwapFree::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"swapfreemb", AWPluginFormatterMemoryMB::instance()}, + {"swapfreegb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherSwapFree::matches(const QString &_source) const +{ + return _source == "memory/swap/free"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.h new file mode 100644 index 00000000..61988229 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherSwapFree : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.cpp new file mode 100644 index 00000000..23198daa --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatcherswaptotal.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwapTotal::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"swaptotmb", AWPluginFormatterMemoryMB::instance()}, + {"swaptotgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherSwapTotal::matches(const QString &_source) const +{ + return _source == "memory/swap/total"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.h new file mode 100644 index 00000000..dd9ce585 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherSwapTotal : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.cpp new file mode 100644 index 00000000..6c2430c3 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 "awpluginmatcherswapused.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwapUsed::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"swapmb", AWPluginFormatterMemoryMB::instance()}, + {"swapgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherSwapUsed::matches(const QString &_source) const +{ + return _source == "memory/swap/used"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.h new file mode 100644 index 00000000..dfe0a52b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherSwapUsed : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchertime.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.cpp new file mode 100644 index 00000000..60764e0a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatchertime.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherTime::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"time", AWPluginFormatterTime::instance()}, {"ctime", AWPluginFormatterTimeCustom::instance()}, + {"isotime", AWPluginFormatterTimeISO::instance()}, {"longtime", AWPluginFormatterTimeLong::instance()}, + {"shorttime", AWPluginFormatterTimeShort::instance()}, {"tstime", AWPluginFormatterNoFormat::instance()}, + }; +} + + +bool AWPluginMatcherTime::matches(const QString &_source) const +{ + return _source == "extsysmon/time/now"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchertime.h b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.h new file mode 100644 index 00000000..188ded0d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherTime : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.cpp new file mode 100644 index 00000000..6e4985a1 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatcherupgrade.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherUpgrade::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/upgrade/"); + return {{key, AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherUpgrade::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/upgrade/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.h new file mode 100644 index 00000000..2520c290 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherUpgrade : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.cpp new file mode 100644 index 00000000..15b2561d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcheruptime.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherUptime::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"uptime", AWPluginFormatterUptime::instance()}}; +} + + +bool AWPluginMatcherUptime::matches(const QString &_source) const +{ + return _source == "os/system/uptime"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.h b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.h new file mode 100644 index 00000000..1d872821 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherUptime : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.cpp new file mode 100644 index 00000000..6d92a1ea --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchervolume.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherVolume::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"volume", AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherVolume::matches(const QString &_source) const +{ + return _source == "extsysmon/system/volume"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.h b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.h new file mode 100644 index 00000000..9415f0ff --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherVolume : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.cpp new file mode 100644 index 00000000..5ac70447 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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 "awpluginmatcherweather.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherWeather::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/weather/"); + + if (key.startsWith("temperature")) + return {{key, AWPluginFormatterTemperature::instance()}}; + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherWeather::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/weather/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.h new file mode 100644 index 00000000..34d01031 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * 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/ * + ***************************************************************************/ + +#pragma once + +#include "awpluginmatcher.h" + + +class AWPluginMatcherWeather : public AWPluginMatcher +{ +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, + const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/matchers.h b/sources/awesome-widget/plugin/matchers/matchers.h new file mode 100644 index 00000000..4545cd32 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/matchers.h @@ -0,0 +1,118 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherac.h" +#include "awpluginmatcherbattery.h" +#include "awpluginmatcherbrightness.h" +#include "awpluginmatchercpu.h" +#include "awpluginmatchercpucore.h" +#include "awpluginmatchercpufrequency.h" +#include "awpluginmatchercpufrequencycore.h" +#include "awpluginmatchercustom.h" +#include "awpluginmatcherdesktop.h" +#include "awpluginmatcherdesktopcount.h" +#include "awpluginmatcherdesktopnumber.h" +#include "awpluginmatchergpu.h" +#include "awpluginmatchergpucore.h" +#include "awpluginmatchergputemperature.h" +#include "awpluginmatcherhdd.h" +#include "awpluginmatcherhddfree.h" +#include "awpluginmatcherhddread.h" +#include "awpluginmatcherhddtotal.h" +#include "awpluginmatcherhddused.h" +#include "awpluginmatcherhddwrite.h" +#include "awpluginmatcherload.h" +#include "awpluginmatcherloadaverage.h" +#include "awpluginmatchermemory.h" +#include "awpluginmatchermemoryapplication.h" +#include "awpluginmatchermemoryfree.h" +#include "awpluginmatchermemorytotal.h" +#include "awpluginmatchermemoryused.h" +#include "awpluginmatchernetwork.h" +#include "awpluginmatchernetworkdevice.h" +#include "awpluginmatchernetworkssid.h" +#include "awpluginmatchernetworktotal.h" +#include "awpluginmatcherplayer.h" +#include "awpluginmatcherps.h" +#include "awpluginmatcherpsprocesses.h" +#include "awpluginmatcherpstotal.h" +#include "awpluginmatcherquotes.h" +#include "awpluginmatcherrequest.h" +#include "awpluginmatchersensors.h" +#include "awpluginmatcherswap.h" +#include "awpluginmatcherswapfree.h" +#include "awpluginmatcherswaptotal.h" +#include "awpluginmatcherswapused.h" +#include "awpluginmatchertime.h" +#include "awpluginmatcherupgrade.h" +#include "awpluginmatcheruptime.h" +#include "awpluginmatchervolume.h" +#include "awpluginmatcherweather.h" + + +namespace AWPluginMatchers +{ +static QList matchers = { + AWPluginMatcherAC::instance(), + AWPluginMatcherBattery::instance(), + AWPluginMatcherBrightness::instance(), + AWPluginMatcherCPU::instance(), + AWPluginMatcherCPUCore::instance(), + AWPluginMatcherCPUFrequency::instance(), + AWPluginMatcherCPUFrequencyCore::instance(), + AWPluginMatcherCustom::instance(), + AWPluginMatcherDesktop::instance(), + AWPluginMatcherDesktopCount::instance(), + AWPluginMatcherDesktopNumber::instance(), + AWPluginMatcherGPU::instance(), + AWPluginMatcherGPUCore::instance(), + AWPluginMatcherGPUTemperature::instance(), + AWPluginMatcherHDD::instance(), + AWPluginMatcherHDDFree::instance(), + AWPluginMatcherHDDRead::instance(), + AWPluginMatcherHDDTotal::instance(), + AWPluginMatcherHDDUsed::instance(), + AWPluginMatcherHDDWrite::instance(), + AWPluginMatcherLoad::instance(), + AWPluginMatcherLoadAverage::instance(), + AWPluginMatcherMemory::instance(), + AWPluginMatcherMemoryApplication::instance(), + AWPluginMatcherMemoryFree::instance(), + AWPluginMatcherMemoryTotal::instance(), + AWPluginMatcherMemoryUsed::instance(), + AWPluginMatcherNetwork::instance(), + AWPluginMatcherNetworkDevice::instance(), + AWPluginMatcherNetworkSSID::instance(), + AWPluginMatcherNetworkTotal::instance(), + AWPluginMatcherPlayer::instance(), + AWPluginMatcherPS::instance(), + AWPluginMatcherPSProcesses::instance(), + AWPluginMatcherPSTotal::instance(), + AWPluginMatcherQuotes::instance(), + AWPluginMatcherRequest::instance(), + AWPluginMatcherSensors::instance(), + AWPluginMatcherSwap::instance(), + AWPluginMatcherSwapFree::instance(), + AWPluginMatcherSwapTotal::instance(), + AWPluginMatcherSwapUsed::instance(), + AWPluginMatcherTime::instance(), + AWPluginMatcherUpgrade::instance(), + AWPluginMatcherUptime::instance(), + AWPluginMatcherVolume::instance(), + AWPluginMatcherWeather::instance(), +}; +}; diff --git a/sources/awesomewidgets/configs/aw-example-standalonerc b/sources/awesomewidgets/configs/aw-example-standalonerc index 666c91ec..bb494cbc 100644 --- a/sources/awesomewidgets/configs/aw-example-standalonerc +++ b/sources/awesomewidgets/configs/aw-example-standalonerc @@ -121,7 +121,7 @@ queueLimit=0 swapTooltip=true swapTooltipColor=#ffff00 tempUnits=Celsius -text="\n

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

\n\n" +text="\n

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

\n\n" textAlign=center tooltipBackground=#ffffff tooltipNumber=100 diff --git a/sources/awesomewidgets/extitemaggregator.h b/sources/awesomewidgets/extitemaggregator.h index d315171d..04da7d27 100644 --- a/sources/awesomewidgets/extitemaggregator.h +++ b/sources/awesomewidgets/extitemaggregator.h @@ -85,7 +85,7 @@ template class ExtItemAggregator : public AbstractExtItemAggregator auto found = std::find_if(m_items.cbegin(), m_items.cend(), [&_tag, &_type](auto item) { return item->tag(_type) == _tag; }); - if (found == std::end(m_items)) { + if (found == m_items.cend()) { qCWarning(LOG_LIB) << "Could not find item by tag" << _tag; return nullptr; } @@ -99,7 +99,7 @@ template class ExtItemAggregator : public AbstractExtItemAggregator auto found = std::find_if(m_items.cbegin(), m_items.cend(), [_number](auto item) { return item->number() == _number; }); - if (found == std::end(m_items)) { + if (found == m_items.cend()) { qCWarning(LOG_LIB) << "Could not find item by number" << _number; return nullptr; } diff --git a/sources/desktop-panel/plugin/dpadds.h b/sources/desktop-panel/plugin/dpadds.h index eeddb176..c2d3a3ed 100644 --- a/sources/desktop-panel/plugin/dpadds.h +++ b/sources/desktop-panel/plugin/dpadds.h @@ -28,7 +28,7 @@ class VirtualDesktopInfo; class WindowTasksModel; } // namespace TaskManager -class DPAdds : public QObject +class __attribute__((visibility("default"))) DPAdds : public QObject { Q_OBJECT diff --git a/sources/extsysmonsources/abstractextsysmonsource.h b/sources/extsysmonsources/abstractextsysmonsource.h index 69895f6c..a0404546 100644 --- a/sources/extsysmonsources/abstractextsysmonsource.h +++ b/sources/extsysmonsources/abstractextsysmonsource.h @@ -32,11 +32,11 @@ class AbstractExtSysMonSource : public QObject explicit AbstractExtSysMonSource(QObject *_parent); ~AbstractExtSysMonSource() override = default; - virtual QVariant data(const QString &_source) = 0; + [[nodiscard]] virtual QVariant data(const QString &_source) = 0; [[nodiscard]] virtual QHash sources() const = 0; - static int index(const QString &_source); + [[nodiscard]] static int index(const QString &_source); // safe value extractor - template static QVariantHash dataByItem(T *_extension, const QString &_source) + template [[nodiscard]] static QVariantHash dataByItem(T *_extension, const QString &_source) { auto idx = index(_source); if (idx == -1) @@ -45,9 +45,9 @@ class AbstractExtSysMonSource : public QObject auto item = _extension->itemByTagNumber(idx); return item ? item->run() : QVariantHash(); } - static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, QMetaType::Type _type, - KSysGuard::Unit _unit = KSysGuard::UnitNone, - double _min = 0, double _max = 0); + [[nodiscard]] static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, QMetaType::Type _type, + KSysGuard::Unit _unit = KSysGuard::UnitNone, + double _min = 0, double _max = 0); signals: void dataReceived(const QVariantHash &); diff --git a/sources/extsysmonsources/batterysource.h b/sources/extsysmonsources/batterysource.h index cf474c73..b4cacacd 100644 --- a/sources/extsysmonsources/batterysource.h +++ b/sources/extsysmonsources/batterysource.h @@ -32,7 +32,7 @@ class BatterySource : public AbstractExtSysMonSource explicit BatterySource(QObject *_parent, QString _acpiPath); ~BatterySource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; void run(); [[nodiscard]] QHash sources() const override; diff --git a/sources/extsysmonsources/customsource.h b/sources/extsysmonsources/customsource.h index e4d59ad6..c4a5ae0e 100644 --- a/sources/extsysmonsources/customsource.h +++ b/sources/extsysmonsources/customsource.h @@ -32,7 +32,7 @@ class CustomSource : public AbstractExtSysMonSource public: explicit CustomSource(QObject *_parent); ~CustomSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: diff --git a/sources/extsysmonsources/desktopsource.h b/sources/extsysmonsources/desktopsource.h index 2f8404fb..43baeeeb 100644 --- a/sources/extsysmonsources/desktopsource.h +++ b/sources/extsysmonsources/desktopsource.h @@ -35,7 +35,7 @@ class DesktopSource : public AbstractExtSysMonSource explicit DesktopSource(QObject *_parent); ~DesktopSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: diff --git a/sources/extsysmonsources/loadsource.h b/sources/extsysmonsources/loadsource.h index ca3b0e08..cf3aae9c 100644 --- a/sources/extsysmonsources/loadsource.h +++ b/sources/extsysmonsources/loadsource.h @@ -29,6 +29,6 @@ class LoadSource : public AbstractExtSysMonSource public: explicit LoadSource(QObject *_parent); ~LoadSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; }; diff --git a/sources/extsysmonsources/networksource.h b/sources/extsysmonsources/networksource.h index 43da6ed0..f4c52c43 100644 --- a/sources/extsysmonsources/networksource.h +++ b/sources/extsysmonsources/networksource.h @@ -31,7 +31,7 @@ class NetworkSource : public AbstractExtSysMonSource public: explicit NetworkSource(QObject *_parent); ~NetworkSource() override; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private slots: diff --git a/sources/extsysmonsources/playersource.h b/sources/extsysmonsources/playersource.h index 4642e9c4..06c1ce15 100644 --- a/sources/extsysmonsources/playersource.h +++ b/sources/extsysmonsources/playersource.h @@ -36,13 +36,13 @@ class PlayerSource : public AbstractExtSysMonSource explicit PlayerSource(QObject *_parent, QString _player, QString _mpdAddress, int _mpdPort, QString _mpris, int _symbols); ~PlayerSource() override; - QVariant data(const QString &_source) override; - static QString getAutoMpris(); + [[nodiscard]] QVariant data(const QString &_source) override; + [[nodiscard]] static QString getAutoMpris(); void run(); [[nodiscard]] QHash sources() const override; // additional method to build dynamic tags - static QString buildString(const QString &_current, const QString &_value, int _s); - static QString stripString(const QString &_value, int _s); + [[nodiscard]] static QString buildString(const QString &_current, const QString &_value, int _s); + [[nodiscard]] static QString stripString(const QString &_value, int _s); // additional test method [[nodiscard]] bool isMpdSocketConnected() const; @@ -52,8 +52,8 @@ private slots: void mpdSocketWritten(qint64 _bytes); private: - static inline QVariantHash defaultInfo(); - QVariantHash getPlayerMpdInfo(); + [[nodiscard]] static inline QVariantHash defaultInfo(); + [[nodiscard]] QVariantHash getPlayerMpdInfo(); [[nodiscard]] static QVariantHash getPlayerMprisInfo(const QString &_mpris); QTcpSocket m_mpdSocket; // configuration and values @@ -64,6 +64,6 @@ private slots: QMutex m_dbusMutex; QString m_player; int m_symbols; - QStringList m_metadata = QStringList({"album", "artist", "title"}); + QStringList m_metadata = {"album", "artist", "title"}; QVariantHash m_values; }; diff --git a/sources/extsysmonsources/processessource.h b/sources/extsysmonsources/processessource.h index 3fb05fa6..3e9c1746 100644 --- a/sources/extsysmonsources/processessource.h +++ b/sources/extsysmonsources/processessource.h @@ -29,7 +29,7 @@ class ProcessesSource : public AbstractExtSysMonSource public: explicit ProcessesSource(QObject *_parent); ~ProcessesSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; void run(); [[nodiscard]] QHash sources() const override; diff --git a/sources/extsysmonsources/quotessource.h b/sources/extsysmonsources/quotessource.h index b3376518..7b09969f 100644 --- a/sources/extsysmonsources/quotessource.h +++ b/sources/extsysmonsources/quotessource.h @@ -32,7 +32,7 @@ class QuotesSource : public AbstractExtSysMonSource public: explicit QuotesSource(QObject *_parent); ~QuotesSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: diff --git a/sources/extsysmonsources/requestsource.h b/sources/extsysmonsources/requestsource.h index 08f4977e..2ac624d3 100644 --- a/sources/extsysmonsources/requestsource.h +++ b/sources/extsysmonsources/requestsource.h @@ -32,7 +32,7 @@ class RequestSource : public AbstractExtSysMonSource public: explicit RequestSource(QObject *_parent); ~RequestSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: diff --git a/sources/extsysmonsources/systeminfosource.h b/sources/extsysmonsources/systeminfosource.h index 2d58dce7..f8cf0c53 100644 --- a/sources/extsysmonsources/systeminfosource.h +++ b/sources/extsysmonsources/systeminfosource.h @@ -29,14 +29,15 @@ class SystemInfoSource : public AbstractExtSysMonSource public: explicit SystemInfoSource(QObject *_parent); ~SystemInfoSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: // configuration and values - static QVariant fromDBusVariant(const QVariant &_value); - static double getCurrentBrightness(); - static double getCurrentVolume(); - static QVariant sendDBusRequest(const QString &_destination, const QString &_path, const QString &_interface, - const QString &_method, const QVariantList &_args = {}); + [[nodiscard]] static QVariant fromDBusVariant(const QVariant &_value); + [[nodiscard]] static double getCurrentBrightness(); + [[nodiscard]] static double getCurrentVolume(); + [[nodiscard]] static QVariant sendDBusRequest(const QString &_destination, const QString &_path, + const QString &_interface, const QString &_method, + const QVariantList &_args = {}); }; diff --git a/sources/extsysmonsources/timesource.h b/sources/extsysmonsources/timesource.h index dbbd80a5..3e8e939e 100644 --- a/sources/extsysmonsources/timesource.h +++ b/sources/extsysmonsources/timesource.h @@ -29,6 +29,6 @@ class TimeSource : public AbstractExtSysMonSource public: explicit TimeSource(QObject *_parent); ~TimeSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; }; diff --git a/sources/extsysmonsources/upgradesource.h b/sources/extsysmonsources/upgradesource.h index c80955dc..ed9c6249 100644 --- a/sources/extsysmonsources/upgradesource.h +++ b/sources/extsysmonsources/upgradesource.h @@ -32,7 +32,7 @@ class UpgradeSource : public AbstractExtSysMonSource public: explicit UpgradeSource(QObject *_parent); ~UpgradeSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: diff --git a/sources/extsysmonsources/weathersource.h b/sources/extsysmonsources/weathersource.h index e69d4d8b..73d903b7 100644 --- a/sources/extsysmonsources/weathersource.h +++ b/sources/extsysmonsources/weathersource.h @@ -32,7 +32,7 @@ class WeatherSource : public AbstractExtSysMonSource public: explicit WeatherSource(QObject *_parent); ~WeatherSource() override = default; - QVariant data(const QString &_source) override; + [[nodiscard]] QVariant data(const QString &_source) override; [[nodiscard]] QHash sources() const override; private: diff --git a/sources/test/CMakeLists.txt b/sources/test/CMakeLists.txt index 3903a3ab..a058f32a 100644 --- a/sources/test/CMakeLists.txt +++ b/sources/test/CMakeLists.txt @@ -21,59 +21,53 @@ set(AWTESTLIBRARY_HEADERS awtestlibrary.h) set(AWTESTLIBRARY_SOURCES awtestlibrary.cpp) add_library(${SUBPROJECT}-awtest STATIC ${AWTESTLIBRARY_SOURCES} ${AWTESTLIBRARY_HEADERS}) target_link_libraries(${SUBPROJECT}-awtest ${Qt_LIBRARIES} ${Qt6Test_LIBRARIES} ${Kf6_LIBRARIES}) -set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSOURCES} +set(LIBRARY_TEST_SET ${SUBPROJECT}-awtest ${PROJECT_LIBRARY} ${PROJECT_MONITORSOURCES} awplugin dpplugin ${Qt_LIBRARIES} ${Kf6_LIBRARIES} ${Qt6Test_LIBRARIES}) # modules set(TEST_MODULES - abstractextitem extquotes extscript extupgrade extweather - abstractformatter datetimeformatter floatformatter jsonformatter listformatter noformatter scriptformatter stringformatter + abstractextitem + extquotes + extscript + extupgrade + extweather + + abstractformatter + datetimeformatter + floatformatter + jsonformatter + listformatter + noformatter + scriptformatter + stringformatter + extitemaggregator - batterysource desktopsource networksource playersource processessource - awbugreporter awconfighelper awkeycache awkeys awpatternfunctions awtelemetryhandler awupdatehelper - dpplugin) + + batterysource + desktopsource + networksource + playersource + processessource + + awbugreporter + awconfighelper + awkeycache + awkeys + awpatternfunctions + awtelemetryhandler + awupdatehelper + + dpplugin +) + foreach (TEST_MODULE ${TEST_MODULES}) set(${TEST_MODULE}_HEADERS test${TEST_MODULE}.h) set(${TEST_MODULE}_SOURCES test${TEST_MODULE}.cpp) - if (TEST_MODULE MATCHES "awbugreporter") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awbugreporter.cpp) - elseif (TEST_MODULE MATCHES "awconfighelper") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awconfighelper.cpp) - elseif (TEST_MODULE MATCHES "awkeycache") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp) - elseif (TEST_MODULE MATCHES "awkeys") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awabstractpairhelper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awactions.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awcustomkeyshelper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataaggregator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataengineaggregator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataenginemapper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdbusadaptor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeycache.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeyoperations.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeys.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp - ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) - elseif (TEST_MODULE MATCHES "awpatternfunctions") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awabstractpairhelper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awdataenginemapper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awformatterhelper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awkeysaggregator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awpatternfunctions.cpp) - elseif (TEST_MODULE MATCHES "awtelemetryhandler") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awtelemetryhandler.cpp) - elseif (TEST_MODULE MATCHES "awupdatehelper") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../awesome-widget/plugin/awupdatehelper.cpp) - elseif (TEST_MODULE MATCHES "dpplugin") - set(${TEST_MODULE}_SOURCES ${${TEST_MODULE}_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/../desktop-panel/plugin/dpadds.cpp - ${PROJECT_TRDPARTY_DIR}/fontdialog/fontdialog.cpp) - endif (TEST_MODULE MATCHES "awbugreporter") add_executable(${SUBPROJECT}-${TEST_MODULE} ${${TEST_MODULE}_HEADERS} ${${TEST_MODULE}_SOURCES}) + target_link_libraries(${SUBPROJECT}-${TEST_MODULE} ${LIBRARY_TEST_SET}) set_target_properties(${SUBPROJECT}-${TEST_MODULE} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if (NOT TEST_MODULE MATCHES "awbugreporter") add_test(NAME ${TEST_MODULE} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-${TEST_MODULE}) endif (NOT TEST_MODULE MATCHES "awbugreporter") diff --git a/sources/test/awtestlibrary.cpp b/sources/test/awtestlibrary.cpp index f2805113..c664fa35 100644 --- a/sources/test/awtestlibrary.cpp +++ b/sources/test/awtestlibrary.cpp @@ -15,7 +15,6 @@ * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ - #include "awtestlibrary.h" #include diff --git a/sources/test/testawbugreporter.cpp b/sources/test/testawbugreporter.cpp index 4dc19f75..81dd5760 100644 --- a/sources/test/testawbugreporter.cpp +++ b/sources/test/testawbugreporter.cpp @@ -15,7 +15,6 @@ * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * ***************************************************************************/ - #include "testawbugreporter.h" #include diff --git a/sources/version.h.in b/sources/version.h.in index d974b404..9d834ac8 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -67,7 +67,6 @@ static const char STATIC_KEYS[] = "time," "tstime," "ctime," "uptime," - "cuptime," "cpucl," "cpu," "gpu,"