mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
plasma: disallow calculator operators for zero
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
771aa0ae06
commit
b261835f4d
1 changed files with 14 additions and 1 deletions
|
@ -27,10 +27,11 @@
|
|||
#include <KDebug>
|
||||
|
||||
static const QString s_decimal = QString::fromLatin1(".");
|
||||
static const QLatin1String s_zero = QLatin1String("0");
|
||||
|
||||
static QString kAddNumber(const QString &string, const ushort number)
|
||||
{
|
||||
if (string == QString::fromLatin1("0")) {
|
||||
if (string == s_zero) {
|
||||
return QString::number(number);
|
||||
}
|
||||
return string + QString::number(number);
|
||||
|
@ -295,6 +296,9 @@ void CalculatorAppletWidget::slotClear()
|
|||
|
||||
void CalculatorAppletWidget::slotDiv()
|
||||
{
|
||||
if (m_label->text() == s_zero) {
|
||||
return;
|
||||
}
|
||||
m_savednumber = m_label->text().toFloat();
|
||||
m_operator = CalculatorAppletWidget::OperatorDiv;
|
||||
slotClear();
|
||||
|
@ -302,6 +306,9 @@ void CalculatorAppletWidget::slotDiv()
|
|||
|
||||
void CalculatorAppletWidget::slotMul()
|
||||
{
|
||||
if (m_label->text() == s_zero) {
|
||||
return;
|
||||
}
|
||||
m_savednumber = m_label->text().toFloat();
|
||||
m_operator = CalculatorAppletWidget::OperatorMul;
|
||||
slotClear();
|
||||
|
@ -331,6 +338,9 @@ void CalculatorAppletWidget::slot9()
|
|||
|
||||
void CalculatorAppletWidget::slotMinus()
|
||||
{
|
||||
if (m_label->text() == s_zero) {
|
||||
return;
|
||||
}
|
||||
m_savednumber = m_label->text().toFloat();
|
||||
m_operator = CalculatorAppletWidget::OperatorMinus;
|
||||
slotClear();
|
||||
|
@ -353,6 +363,9 @@ void CalculatorAppletWidget::slot6()
|
|||
|
||||
void CalculatorAppletWidget::slotPlus()
|
||||
{
|
||||
if (m_label->text() == s_zero) {
|
||||
return;
|
||||
}
|
||||
m_savednumber = m_label->text().toFloat();
|
||||
m_operator = CalculatorAppletWidget::OperatorPlus;
|
||||
slotClear();
|
||||
|
|
Loading…
Add table
Reference in a new issue