kdeplasma-addons: adjust to Plasma::SpinBox changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-20 12:24:11 +03:00
parent b9161e7987
commit d6f1e450e8
2 changed files with 16 additions and 16 deletions

View file

@ -117,14 +117,14 @@ void UnitConverter::sltUnitChanged(int index)
} }
} }
void UnitConverter::sltValueChanged(const int iNewValue) void UnitConverter::sltValueChanged(const double iNewValue)
{ {
Q_UNUSED(iNewValue); Q_UNUSED(iNewValue);
m_bCalculateReverse = false; // store calculation direction m_bCalculateReverse = false; // store calculation direction
calculate(); calculate();
} }
void UnitConverter::sltValueChangedReverse(const int iNewValue) void UnitConverter::sltValueChangedReverse(const double iNewValue)
{ {
Q_UNUSED(iNewValue); Q_UNUSED(iNewValue);
m_bCalculateReverse = true; // store calculation direction m_bCalculateReverse = true; // store calculation direction
@ -139,22 +139,22 @@ void UnitConverter::calculate()
switch (m_pCmbCategory->nativeWidget()->currentIndex()) { switch (m_pCmbCategory->nativeWidget()->currentIndex()) {
case 0: { case 0: {
KTemperature temp(m_pSpnValue1->value(), static_cast<KTemperature::KTempUnit>(fromindex)); KTemperature temp(m_pSpnValue1->value(), static_cast<KTemperature::KTempUnit>(fromindex));
m_pSpnValue2->setValue(qRound(temp.convertTo(static_cast<KTemperature::KTempUnit>(toindex)))); m_pSpnValue2->setValue(temp.convertTo(static_cast<KTemperature::KTempUnit>(toindex)));
break; break;
} }
case 1: { case 1: {
KVelocity velo(m_pSpnValue1->value(), static_cast<KVelocity::KVeloUnit>(fromindex)); KVelocity velo(m_pSpnValue1->value(), static_cast<KVelocity::KVeloUnit>(fromindex));
m_pSpnValue2->setValue(qRound(velo.convertTo(static_cast<KVelocity::KVeloUnit>(toindex)))); m_pSpnValue2->setValue(velo.convertTo(static_cast<KVelocity::KVeloUnit>(toindex)));
break; break;
} }
case 2: { case 2: {
KPressure pres(m_pSpnValue1->value(), static_cast<KPressure::KPresUnit>(fromindex)); KPressure pres(m_pSpnValue1->value(), static_cast<KPressure::KPresUnit>(fromindex));
m_pSpnValue2->setValue(qRound(pres.convertTo(static_cast<KPressure::KPresUnit>(toindex)))); m_pSpnValue2->setValue(pres.convertTo(static_cast<KPressure::KPresUnit>(toindex)));
break; break;
} }
case 3: { case 3: {
KLength leng(m_pSpnValue1->value(), static_cast<KLength::KLengUnit>(fromindex)); KLength leng(m_pSpnValue1->value(), static_cast<KLength::KLengUnit>(fromindex));
m_pSpnValue2->setValue(qRound(leng.convertTo(static_cast<KLength::KLengUnit>(toindex)))); m_pSpnValue2->setValue(leng.convertTo(static_cast<KLength::KLengUnit>(toindex)));
break; break;
} }
} }
@ -168,22 +168,22 @@ void UnitConverter::calculateReverse()
switch (m_pCmbCategory->nativeWidget()->currentIndex()) { switch (m_pCmbCategory->nativeWidget()->currentIndex()) {
case 0: { case 0: {
KTemperature temp(m_pSpnValue2->value(), static_cast<KTemperature::KTempUnit>(fromindex)); KTemperature temp(m_pSpnValue2->value(), static_cast<KTemperature::KTempUnit>(fromindex));
m_pSpnValue1->setValue(qRound(temp.convertTo(static_cast<KTemperature::KTempUnit>(toindex)))); m_pSpnValue1->setValue(temp.convertTo(static_cast<KTemperature::KTempUnit>(toindex)));
break; break;
} }
case 1: { case 1: {
KVelocity velo(m_pSpnValue2->value(), static_cast<KVelocity::KVeloUnit>(fromindex)); KVelocity velo(m_pSpnValue2->value(), static_cast<KVelocity::KVeloUnit>(fromindex));
m_pSpnValue1->setValue(qRound(velo.convertTo(static_cast<KVelocity::KVeloUnit>(toindex)))); m_pSpnValue1->setValue(velo.convertTo(static_cast<KVelocity::KVeloUnit>(toindex)));
break; break;
} }
case 2: { case 2: {
KPressure pres(m_pSpnValue2->value(), static_cast<KPressure::KPresUnit>(fromindex)); KPressure pres(m_pSpnValue2->value(), static_cast<KPressure::KPresUnit>(fromindex));
m_pSpnValue1->setValue(qRound(pres.convertTo(static_cast<KPressure::KPresUnit>(toindex)))); m_pSpnValue1->setValue(pres.convertTo(static_cast<KPressure::KPresUnit>(toindex)));
break; break;
} }
case 3: { case 3: {
KLength leng(m_pSpnValue2->value(), static_cast<KLength::KLengUnit>(fromindex)); KLength leng(m_pSpnValue2->value(), static_cast<KLength::KLengUnit>(fromindex));
m_pSpnValue1->setValue(qRound(leng.convertTo(static_cast<KLength::KLengUnit>(toindex)))); m_pSpnValue1->setValue(leng.convertTo(static_cast<KLength::KLengUnit>(toindex)));
break; break;
} }
} }
@ -230,10 +230,10 @@ QGraphicsWidget *UnitConverter::graphicsWidget()
m_pCmbCategory->nativeWidget()->addItem(KPressure::description(), QVariant::fromValue(2)); m_pCmbCategory->nativeWidget()->addItem(KPressure::description(), QVariant::fromValue(2));
m_pCmbCategory->nativeWidget()->addItem(KLength::description(), QVariant::fromValue(3)); m_pCmbCategory->nativeWidget()->addItem(KLength::description(), QVariant::fromValue(3));
connect(m_pSpnValue1, SIGNAL(valueChanged(int)), connect(m_pSpnValue1, SIGNAL(valueChanged(double)),
this, SLOT(sltValueChanged(int))); this, SLOT(sltValueChanged(double)));
connect(m_pSpnValue2, SIGNAL(valueChanged(int)), connect(m_pSpnValue2, SIGNAL(valueChanged(double)),
this, SLOT(sltValueChangedReverse(int))); this, SLOT(sltValueChangedReverse(double)));
connect(m_pCmbCategory->nativeWidget(), SIGNAL(currentIndexChanged(int)), connect(m_pCmbCategory->nativeWidget(), SIGNAL(currentIndexChanged(int)),
this, SLOT(sltCategoryChanged(int))); this, SLOT(sltCategoryChanged(int)));
connect(m_pCmbUnit1->nativeWidget(), SIGNAL(currentIndexChanged(int)), connect(m_pCmbUnit1->nativeWidget(), SIGNAL(currentIndexChanged(int)),

View file

@ -53,8 +53,8 @@ class UnitConverter : public Plasma::PopupApplet
void configChanged(); void configChanged();
private slots: private slots:
void sltValueChanged(const int iNewValue); void sltValueChanged(const double iNewValue);
void sltValueChangedReverse(const int iNewValue); void sltValueChangedReverse(const double iNewValue);
void sltUnitChanged(int index); void sltUnitChanged(int index);
void sltCategoryChanged(int index); void sltCategoryChanged(int index);