fix(energy): show correct date and value in graph

Summary

Hovering on graph in "Charge percentage" and "Energy consumption" was showing wrong datetime and battery value.

Description

a future datetime of ~57 years was being shown on hover, and value for battery was shown whatever it was when kinfocenter was opened at (or so I think).

X axis ticks would show local time but hover would show future (I was confused if it's battery serial number or something, only printing to console did I realize 83 is 2083 😄 ).

fix by removing time offset logic and directly using X value under cursor, which already is the correct datetime. same for getting battery percentage, provide value.x which shows % at the correct datetime.

Notes

  • literally first contribution to KDE. I haven't made an issue on bug tracker for this. I don't know if this is the correct fix (no prior C++/Qt experience) but it has fixed the issue for me and I naively believe it to be correct
  • While recording, I noticed that the energy consumption graph got stuck at one value when it should've been going down with line
  • My local timezone is UTC +05:00 and I only tested it on this timezone (perhaps breaks for others?). I see some commits on this file indicating work done for local timezone support. This code maybe was supposed to be cleaned up then?
  • I see !276 is for moving this module to another repo, but MR is 10m old. If any plans to move, this change if merged will have to go there too.
  • installed kde-builder today, and got to work. This bullet point is only here as a thank you for such a great onboarding flow for something as complex as KDE, to be built by someone with no prior experience with the toolchain

EDIT: Forgot to add screencasts. Added below.

before.webm

after.webm

Edited by Shehriyar Qureshi

Merge request reports

Loading
Loading