There is now hardcoded hex= command handling for converting to hexadecimal, however this is not consistance with other base unit convertion syntax. Currently in krunner if you use the syntax oct=, bin=, or dec=. You get get a reference to qalculate functions oct(), bin(), dec(), which all return a decimal number for the given input. (and do not function using name= syntax.) Desired results: handling of oct=, bin=, dec= to be in line with the hex= syntax.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2222
Git commit 8ea36e077a80a39aa3fec2260f217548f054953d by Fushan Wen, on behalf of Max Ramanouski. Committed on 19/10/2022 at 14:27. Pushed by fusionfuture into branch 'master'. runners/calculator: Improve output base handling Reimplement krunner base conversion through libqalculate PrintOptions.base instead of parsing decimal output and converting it to hex. This approach allows for correct display of multiple solutions converted to different base, for example: `hex= x * x = 4` will output `x = 0x2 || x = -0x2`. Also, this makes it possible to easily implement more bases like bin, oct, time, roman, etc. To detect required base findPrefix function was implemented in QalculateEngine, this function checks are there any common bases like hex, oct, bin, roman, time, pi and if there is it sets PrintOptions.base to corresponding base, this common base mappings were taken from libqalculate/src/qalc.cc set_option function (lines from 747 to 776, libqalcualate commit d767c71). To handle non-common bases prefix base was implemented, examples: `base 42=64` results to `1M`, `base 2**16=123456789` results to `\1883\52501`. When findPrefix function encounters base keyword in prefix, it sets base to BASE_CUSTOM, then at QalculateEngine::evaluate if base is set to BASE_CUSTOM everything in prefix after base keyword is calculated and set as custom base for main calculation via CALCULATOR->setCustomOutputBase. M +15 -11 runners/calculator/calculatorrunner.cpp M +1 -1 runners/calculator/calculatorrunner.h M +77 -1 runners/calculator/qalculate_engine.cpp M +3 -1 runners/calculator/qalculate_engine.h https://invent.kde.org/plasma/plasma-workspace/commit/8ea36e077a80a39aa3fec2260f217548f054953d