Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

lxqt-runner provides a GUI that comes up on the desktop and allows for launching applications or shutting down the system. A calculator function is implemented too.
lxqt-runner provides a desktop GUI for launching applications or shutting down the system. It also includes a calculator, which is triggered by entering = or a sequence of numbers and operators.

![lxqt-runner](lxqt-runner.png)

Expand Down
5 changes: 5 additions & 0 deletions providers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,11 @@ bool MathItem::compare(const QRegularExpression &regExp) const
s.chop(1);
}

QRegularExpression mathPattern(QStringLiteral("^[0-9+\\-*/ ]+$"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I personally don't agree, that the calculator should be triggered w/o the equal sign (either at the beginning or at the end).
  2. Constructing (and compiling) the regex on each call is not resource friendly.
  3. The regexp is really a simple one and doesn't cover all possible equations.

Copy link
Member Author

@stefonarch stefonarch Jan 21, 2026

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;
    }

?

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (mathPattern.match(s).hasMatch()) {
is_math = true;
}

if (is_math)
{
if (s != mCachedInput)
Expand Down