-
Notifications
You must be signed in to change notification settings - Fork 23
Start calculator also on numbers #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
providers.cpp
Outdated
| s.chop(1); | ||
| } | ||
|
|
||
| QRegularExpression mathPattern(QStringLiteral("^[0-9+\\-*/ ]+$")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I personally don't agree, that the calculator should be triggered w/o the equal sign (either at the beginning or at the end).
- Constructing (and compiling) the regex on each call is not resource friendly.
- The regexp is really a simple one and doesn't cover all possible equations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points (except 1. as I dislike = as it's not handy on my keyboard) . What about something like this
if (s.at(0).isDigit())
{
is_math = true;
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's up to you, but with this I would also go safe side and check the s.empty()-ness before accessing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
I don't agree with the idea behind this (if I have understood it correctly). Redundant computations aren't good in general, and it solves no problem. |
It's years that I search for an easier method than hitting always = for showing the result or starting the calculator (which I learned only looking at the code now). Actually I wanted to use enter or KP_Enter for showing the result first, but that's way more complicated. Just being able to start typing something like |
|
A KDE or GNOME dev may not care about these things. But keeping an app lightweight isn't something that's done automatically; it consists of small steps of avoiding extra resource usage. In addition, it may seem good in an elementary case like |
That's more than enough for me ;) |
|
It was you who said time ago its coredump analysis was really correct. Ignore the messenger of the unwanted truth? |
|
Yes, that case was an exception. It has no "idea" what we're doing here, let alone a perspective, because it has no intelligence but an algorithm to satisfy the questioner. |
|
So you would say it's wrong and the computation is indeed measurable and we'll loose therefore lightweight in the runner? Getting tired here. |
|
I don't intend to convince you. I just told my opinion and my reasons for it, as @palinek did. |

While looking if it would be possible to show results also on
KP_EnterandReturn(which seems quite hard to implement) I noticed that the calculator shows results in realtime by entering "="before, afaik that is undocumented (for all the years I had to press = (shift+0) which wasn't convenient).With this PR the calculator will start also when entering numbers and an operator and act the same as when "=" is inserted.