Bug 281484

Summary: Calculator plasmoid does not accept entries with more than 4 digits
Product: [Unmaintained] plasma4 Reporter: Sergio <sergio.callegari>
Component: widget-miscAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal CC: agostinelli, annma, dweeble01103, joanmaspons, lightningstrike35, rshah0385
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Sergio 2011-09-06 15:54:35 UTC
Version:           unspecified (using KDE 4.7.0) 
OS:                Linux

You cannot enter numbers larger than 9999 in the calculator (either with the mouse or with the keyboard). Calculator shows "0" after the fourth digit.

Can this be related to the use of a latin (italian) locale?

Reproducible: Didn't try

Steps to Reproduce:
Try entering 12345+1

Type 1 > On screen you get "1"
Type 2 > On screen you get "12"
Type 3 > On screen you get "123"
Type 4 > On screen you get "1.234"
Type 5 > On screen you get "0"




Actual Results:  
See steps to reproduce

Expected Results:  
The obvious one
Comment 1 Sergio 2011-09-26 20:39:24 UTC
Still present in 4.7.1
Comment 2 Matteo Agostinelli 2011-10-02 20:55:23 UTC
Confirmed in 4.7.1, Archlinux binaries.
Comment 3 Matteo Agostinelli 2011-10-02 20:57:23 UTC
On further inspection, the bug can be also reproduced with US english locale
Comment 4 jmaspons 2011-10-20 10:01:27 UTC
Same problem in Kubuntu 11.10 (4.7.1)
Comment 5 Sergio 2011-10-23 22:48:55 UTC
Still buggy in 4.7.2. Please, consider removing the plasmoid altogether from the software compilation and readding when eventually fixed. Plasmoid has already remained broken through 3 point releases. Having broken stuff just creates confusion and kalgebra is a valid substitute anyway.
Comment 6 Thorsteinn A. Malmjursson 2011-12-10 16:45:20 UTC
Seems to hasve an additional bug as well (4.7.2) - it doesn't like any numbers (even 4 digit ones) which have a 5 or a 6 in them - I'd agree with sergio, if this has been buggy since back at 4.7.1 or earlier, I'd go with "remove the entire plasmoid."  We don't even need a calculator widget, this is why we have kcalc :)
Comment 7 Reza 2011-12-14 13:45:08 UTC
I tried adding some kDebug lines like below.
The result of currentValue is 0, may be something wrong at readNumber.

void CalculatorApplet::slotDigitClicked()
{
    Plasma::PushButton *clickedButton = qobject_cast<Plasma::PushButton *>(sender());
    int newDigit = clickedButton->text().toInt();

    if (inputText == QLatin1String( "0" ) && newDigit == 0.0)
        return;

    if (inputText.length() >= MaxInputLength)
        return;

    if (waitingForDigit) {
        inputText.clear();
        waitingForDigit = false;
    }

    inputText += QString::number(newDigit);

    if (!inputText.contains(KGlobal::locale()->decimalSymbol())) {
      //If there is no decimal, then we need to reformat the number
      inputText = "1234567";
      kDebug() << "Input =" << inputText;
      double currentValue = KGlobal::locale()->readNumber(inputText);
      kDebug() << "Current value=" << currentValue;
      QString localizedString = KGlobal::locale()->formatNumber(currentValue, 0);
      mOutputDisplay->setText(localizedString);
    } else {
      //Once we have a decimal, then all we have to do is append the number
      mOutputDisplay->setText(mOutputDisplay->text()+QString::number(newDigit));
    }
}
Comment 8 bill p. (aka google01103) 2011-12-15 23:34:04 UTC
+1 to remove it if it's not going to be fixed
Comment 9 Anne-Marie Mahfouf 2011-12-16 09:05:51 UTC
This bug is a duplicate of 288963 and the bug is not in the Calculator widget code but in kdelibs. I tracked down the faulty code but I am not sure I can fix it, this code is tricky. I'll do my best to have this fixed before 4.8 is out.

*** This bug has been marked as a duplicate of bug 288963 ***