From d6f1e450e88556b0949dcc9816b4b9a0b8639dcf Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 20 May 2024 12:24:11 +0300 Subject: [PATCH] kdeplasma-addons: adjust to Plasma::SpinBox changes Signed-off-by: Ivailo Monev --- .../applets/unitconverter/unitconverter.cpp | 28 +++++++++---------- .../applets/unitconverter/unitconverter.h | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/kdeplasma-addons/applets/unitconverter/unitconverter.cpp b/kdeplasma-addons/applets/unitconverter/unitconverter.cpp index 5eb4f147..31f0d38a 100644 --- a/kdeplasma-addons/applets/unitconverter/unitconverter.cpp +++ b/kdeplasma-addons/applets/unitconverter/unitconverter.cpp @@ -117,14 +117,14 @@ void UnitConverter::sltUnitChanged(int index) } } -void UnitConverter::sltValueChanged(const int iNewValue) +void UnitConverter::sltValueChanged(const double iNewValue) { Q_UNUSED(iNewValue); m_bCalculateReverse = false; // store calculation direction calculate(); } -void UnitConverter::sltValueChangedReverse(const int iNewValue) +void UnitConverter::sltValueChangedReverse(const double iNewValue) { Q_UNUSED(iNewValue); m_bCalculateReverse = true; // store calculation direction @@ -139,22 +139,22 @@ void UnitConverter::calculate() switch (m_pCmbCategory->nativeWidget()->currentIndex()) { case 0: { KTemperature temp(m_pSpnValue1->value(), static_cast(fromindex)); - m_pSpnValue2->setValue(qRound(temp.convertTo(static_cast(toindex)))); + m_pSpnValue2->setValue(temp.convertTo(static_cast(toindex))); break; } case 1: { KVelocity velo(m_pSpnValue1->value(), static_cast(fromindex)); - m_pSpnValue2->setValue(qRound(velo.convertTo(static_cast(toindex)))); + m_pSpnValue2->setValue(velo.convertTo(static_cast(toindex))); break; } case 2: { KPressure pres(m_pSpnValue1->value(), static_cast(fromindex)); - m_pSpnValue2->setValue(qRound(pres.convertTo(static_cast(toindex)))); + m_pSpnValue2->setValue(pres.convertTo(static_cast(toindex))); break; } case 3: { KLength leng(m_pSpnValue1->value(), static_cast(fromindex)); - m_pSpnValue2->setValue(qRound(leng.convertTo(static_cast(toindex)))); + m_pSpnValue2->setValue(leng.convertTo(static_cast(toindex))); break; } } @@ -168,22 +168,22 @@ void UnitConverter::calculateReverse() switch (m_pCmbCategory->nativeWidget()->currentIndex()) { case 0: { KTemperature temp(m_pSpnValue2->value(), static_cast(fromindex)); - m_pSpnValue1->setValue(qRound(temp.convertTo(static_cast(toindex)))); + m_pSpnValue1->setValue(temp.convertTo(static_cast(toindex))); break; } case 1: { KVelocity velo(m_pSpnValue2->value(), static_cast(fromindex)); - m_pSpnValue1->setValue(qRound(velo.convertTo(static_cast(toindex)))); + m_pSpnValue1->setValue(velo.convertTo(static_cast(toindex))); break; } case 2: { KPressure pres(m_pSpnValue2->value(), static_cast(fromindex)); - m_pSpnValue1->setValue(qRound(pres.convertTo(static_cast(toindex)))); + m_pSpnValue1->setValue(pres.convertTo(static_cast(toindex))); break; } case 3: { KLength leng(m_pSpnValue2->value(), static_cast(fromindex)); - m_pSpnValue1->setValue(qRound(leng.convertTo(static_cast(toindex)))); + m_pSpnValue1->setValue(leng.convertTo(static_cast(toindex))); break; } } @@ -230,10 +230,10 @@ QGraphicsWidget *UnitConverter::graphicsWidget() m_pCmbCategory->nativeWidget()->addItem(KPressure::description(), QVariant::fromValue(2)); m_pCmbCategory->nativeWidget()->addItem(KLength::description(), QVariant::fromValue(3)); - connect(m_pSpnValue1, SIGNAL(valueChanged(int)), - this, SLOT(sltValueChanged(int))); - connect(m_pSpnValue2, SIGNAL(valueChanged(int)), - this, SLOT(sltValueChangedReverse(int))); + connect(m_pSpnValue1, SIGNAL(valueChanged(double)), + this, SLOT(sltValueChanged(double))); + connect(m_pSpnValue2, SIGNAL(valueChanged(double)), + this, SLOT(sltValueChangedReverse(double))); connect(m_pCmbCategory->nativeWidget(), SIGNAL(currentIndexChanged(int)), this, SLOT(sltCategoryChanged(int))); connect(m_pCmbUnit1->nativeWidget(), SIGNAL(currentIndexChanged(int)), diff --git a/kdeplasma-addons/applets/unitconverter/unitconverter.h b/kdeplasma-addons/applets/unitconverter/unitconverter.h index e329c886..bdb25558 100644 --- a/kdeplasma-addons/applets/unitconverter/unitconverter.h +++ b/kdeplasma-addons/applets/unitconverter/unitconverter.h @@ -53,8 +53,8 @@ class UnitConverter : public Plasma::PopupApplet void configChanged(); private slots: - void sltValueChanged(const int iNewValue); - void sltValueChangedReverse(const int iNewValue); + void sltValueChanged(const double iNewValue); + void sltValueChangedReverse(const double iNewValue); void sltUnitChanged(int index); void sltCategoryChanged(int index);