Separate processcore/{formatter,unit} into its own library
ClosedPublic

Authored by ahiemstra on Mar 5 2020, 1:58 PM.

Details

Summary

This moves Formatter and Unit out of ProcessCore and into its own Formatter library.
This allows us to reuse them in other places, like a new sensor library that will be
posted later.

It includes a declarative plugin that makes things available to QML.

It also contains a small unit test for Formatter.

Test Plan
  • The new unit test passes.
  • KSysGuard still runs correctly.

Diff Detail

Repository
R111 KSysguard Library
Branch
formatter_lib
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 23322
Build 23340: arc lint + arc unit
ahiemstra created this revision.Mar 5 2020, 1:58 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 5 2020, 1:58 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
ahiemstra requested review of this revision.Mar 5 2020, 1:58 PM
ahiemstra updated this revision to Diff 77025.Mar 5 2020, 2:00 PM
  • Correct comment
ahiemstra updated this revision to Diff 77027.Mar 5 2020, 2:03 PM
  • More minor corrections
ngraham added a subscriber: ngraham.Mar 5 2020, 2:07 PM
ngraham added inline comments.
processcore/unit.h
81

No Fahrenheit for us poor Americans? :)

ahiemstra updated this revision to Diff 77038.Mar 5 2020, 2:59 PM
  • Fix qmldir file
  • Also register meta type of MetricPrefix so it can actually be used
  • Add a manual test to test how Formatter works from QML
ahiemstra added a subscriber: zzag.Mar 5 2020, 3:08 PM
ahiemstra added inline comments.
processcore/unit.h
81

Blame @zzag for that who wrote the original code. :P

That said, we probably should consider how to deal with localization issues like that at some point in the future.

zzag added inline comments.Mar 5 2020, 3:14 PM
processcore/unit.h
81

Oops, sorry.

davidedmundson accepted this revision.Mar 19 2020, 10:36 AM
This revision is now accepted and ready to land.Mar 19 2020, 10:36 AM
This revision was automatically updated to reflect the committed changes.

cmake fails with:

...
-- Configuring done
CMake Error at formatter/declarative/CMakeLists.txt:3 (add_library):
  Target "FormatterPlugin" links to target "Qt5::Qml" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

(Qt 5.14.*)

I guess that top-level CMakeLists.txt needs:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@
 include(FeatureSummary)
 include(GenerateExportHeader)
 
-find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS DBus Network Widgets)
+find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS DBus Network Qml Widgets)
 find_package(Qt5WebEngineWidgets ${QT_MIN_VERSION} CONFIG)
 set_package_properties(Qt5WebEngineWidgets PROPERTIES
                        URL "git://code.qt.org/qt/qtwebenginewidgets.git"