Skip to content

Commit

Permalink
STYLE: Mark translatable strings in Base/QTGUI
Browse files Browse the repository at this point in the history
Separation of SliceOrientationMarkerTypeComboBox item text and data so that to ease translations
See Slicer/SlicerLanguagePacks#12
  • Loading branch information
mhdiop committed Dec 19, 2022
1 parent a4cc0f2 commit 052dec1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
23 changes: 1 addition & 22 deletions Base/QTGUI/Resources/UI/qSlicerSettingsViewsPanel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,7 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="ctkComboBox" name="SliceOrientationMarkerTypeComboBox">
<item>
<property name="text">
<string>none</string>
</property>
</item>
<item>
<property name="text">
<string>cube</string>
</property>
</item>
<item>
<property name="text">
<string>human</string>
</property>
</item>
<item>
<property name="text">
<string>axes</string>
</property>
</item>
</widget>
<widget class="ctkComboBox" name="SliceOrientationMarkerTypeComboBox"/>
</item>
<item>
<widget class="ctkComboBox" name="SliceOrientationMarkerSizeComboBox">
Expand Down
10 changes: 8 additions & 2 deletions Base/QTGUI/qSlicerSettingsViewsPanel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ void qSlicerSettingsViewsPanelPrivate::init()
qSlicerSettingsViewsPanel::tr("Multisampling (MSAA)"),
ctkSettingsPanel::OptionRequireRestart);

this->SliceOrientationMarkerTypeComboBox->addItem(qSlicerSettingsViewsPanel::tr("none"), QString(/*no tr*/"none"));
this->SliceOrientationMarkerTypeComboBox->addItem(qSlicerSettingsViewsPanel::tr("cube"), QString(/*no tr*/"cube"));
this->SliceOrientationMarkerTypeComboBox->addItem(qSlicerSettingsViewsPanel::tr("human"), QString(/*no tr*/"human"));
this->SliceOrientationMarkerTypeComboBox->addItem(qSlicerSettingsViewsPanel::tr("axes"), QString(/*no tr*/"axes"));

QObject::connect(this->SliceOrientationMarkerTypeComboBox, SIGNAL(currentIndexChanged(QString)),
q, SIGNAL(currentSliceOrientationMarkerTypeChanged(QString)));
q->registerProperty("DefaultSliceView/OrientationMarkerType", q,
Expand Down Expand Up @@ -292,11 +297,12 @@ void qSlicerSettingsViewsPanel::sliceViewOrientationChangedByUser()
Q_D(qSlicerSettingsViewsPanel);
if (d->SliceViewOrientationComboBox->currentUserDataAsString() == "PatientRightIsScreenRight")
{
if (d->SliceOrientationMarkerTypeComboBox->currentText() == tr("none"))
if (d->SliceOrientationMarkerTypeComboBox->currentData() == /*no tr*/"none")
{
// Non-default orientation is chosen and no orientation marker is displayed.
// To ensure that there is no accidental mixup of orientations, show the orientation marker.
d->SliceOrientationMarkerTypeComboBox->setCurrentText(tr("axes"));
int index = d->SliceOrientationMarkerTypeComboBox->findData(/*no tr*/"axes");
d->SliceOrientationMarkerTypeComboBox->setCurrentIndex(index);
}
}
}

0 comments on commit 052dec1

Please sign in to comment.