| 426 | } |
| 427 | |
| 428 | void LabelWidget::updateUnits() { |
| 429 | const KConfigGroup group = Settings::group(QStringLiteral("Settings_General")); |
| 430 | BaseDock::Units units = (BaseDock::Units)group.readEntry("Units", (int)BaseDock::Units::Metric); |
| 431 | if (units == m_units) |
| 432 | return; |
| 433 | |
| 434 | m_units = units; |
| 435 | CONDITIONAL_LOCK_RETURN; |
| 436 | QString suffix; |
| 437 | auto xPosition = ui.cbPositionX->currentIndex(); |
| 438 | auto yPosition = ui.cbPositionY->currentIndex(); |
| 439 | if (m_units == BaseDock::Units::Metric) { |
| 440 | // convert from imperial to metric |
| 441 | m_worksheetUnit = Worksheet::Unit::Centimeter; |
| 442 | suffix = QLatin1String(" cm"); |
| 443 | if (xPosition != static_cast<int>(WorksheetElement::HorizontalPosition::Relative)) |
| 444 | ui.sbPositionX->setValue(roundValue(ui.sbPositionX->value() * GSL_CONST_CGS_INCH)); |
| 445 | if (yPosition != static_cast<int>(WorksheetElement::VerticalPosition::Relative)) |
| 446 | ui.sbPositionY->setValue(roundValue(ui.sbPositionY->value() * GSL_CONST_CGS_INCH)); |
| 447 | } else { |
| 448 | // convert from metric to imperial |
| 449 | m_worksheetUnit = Worksheet::Unit::Inch; |
| 450 | suffix = QLatin1String(" in"); |
| 451 | if (xPosition != static_cast<int>(WorksheetElement::HorizontalPosition::Relative)) |
| 452 | ui.sbPositionX->setValue(roundValue(ui.sbPositionX->value() / GSL_CONST_CGS_INCH)); |
| 453 | if (yPosition != static_cast<int>(WorksheetElement::VerticalPosition::Relative)) |
| 454 | ui.sbPositionY->setValue(roundValue(ui.sbPositionY->value() / GSL_CONST_CGS_INCH)); |
| 455 | } |
| 456 | |
| 457 | if (xPosition != static_cast<int>(WorksheetElement::HorizontalPosition::Relative)) |
| 458 | ui.sbPositionX->setSuffix(suffix); |
| 459 | if (yPosition != static_cast<int>(WorksheetElement::VerticalPosition::Relative)) |
| 460 | ui.sbPositionY->setSuffix(suffix); |
| 461 | } |
| 462 | |
| 463 | void LabelWidget::updateLocale() { |
| 464 | const auto numberLocale = QLocale(); |
no test coverage detected