Bug 466468 - Implement a spinbox for byte values respecting BinaryUnitDialect
Summary: Implement a spinbox for byte values respecting BinaryUnitDialect
Status: CONFIRMED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-26 12:00 UTC by Karl Ove Hufthammer
Modified: 2023-02-27 15:15 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Ove Hufthammer 2023-02-26 12:00:42 UTC
There is a need for a QSpinBox for byte values (bytes, KiB, kB, MiB, MB etc.) that supports BinaryUnitDialect (see bug 364321) and localisation (KFormat does supoprt localisation, https://api.kde.org/frameworks/kcoreaddons/html/classKFormat.html). Suggested name: KByteSpinBox

The idea is that it would hold a byte value, but it would be formatted as either bytes, KiB, kB, MiB, MB etc. depending on the user’s BinaryUnitDialect and language/locale settings. In other words, when displaying the byte value, it would be divided 1000, 1024 etc., and the suffix would be set to kB/KB/KiB.

This is needed in Dolphin (bug 453853), Konqueror (bug 466257) and probably other applications too.

It should be possible to specify a fixed ‘major’ unit (e.g., *always* shows the value as KiB/kB/KB, even for very large values) or have the widget (by default) automatically choose the unit based on the value (bytes for values < 1000 or 1024, kB/KiB for larger values, MB/MiB for even larger values), cf. the AutoAdjust feature in KFormat::UnitPrefix.

Advantages:
* BinaryUnitDialect would be respected (bug 364321)
* The unit suffix would be automatically localised
* The implementation of byte value widgets in applications would be simpler:
  * No need for manually dividing by 1000, 1024 etc. in various functions
  * No need for manually handling large ranges (e.g., from bytes to GiB)
  * No need for manually formatting the values when getting/setting byte values, adding/stripping suffixes