Skip to content

Commit

Permalink
Use QCoreApplication::translate() not tr()
Browse files Browse the repository at this point in the history
  • Loading branch information
danferns committed Jul 26, 2024
1 parent a1b0976 commit 06528bc
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions src/preferences/dialog/dlgprefcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ void DlgPrefColors::slotUpdate() {
BaseTrackTableModel::kKeyColorsEnabledDefault));
for (const auto& palette : std::as_const(mixxx::PredefinedColorPalettes::kPalettes)) {
QString paletteName = palette.getName();
QString translatedName = QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(paletteName));
QIcon paletteIcon = drawPalettePreview(paletteName);
comboBoxHotcueColors->addItem(tr(qPrintable(paletteName)), paletteName);
comboBoxHotcueColors->addItem(translatedName, paletteName);
comboBoxHotcueColors->setItemIcon(
comboBoxHotcueColors->count() - 1,
paletteIcon);

comboBoxTrackColors->addItem(tr(qPrintable(paletteName)), paletteName);
comboBoxTrackColors->addItem(translatedName, paletteName);
comboBoxTrackColors->setItemIcon(
comboBoxTrackColors->count() - 1,
paletteIcon);

if (palette.size() == 12) {
comboBoxKeyColors->addItem(tr(qPrintable(paletteName)), paletteName);
comboBoxKeyColors->addItem(translatedName, paletteName);
comboBoxKeyColors->setItemIcon(
comboBoxKeyColors->count() - 1,
paletteIcon);
Expand All @@ -117,32 +119,34 @@ void DlgPrefColors::slotUpdate() {

const QSet<QString> colorPaletteNames = m_colorPaletteSettings.getColorPaletteNames();
for (const auto& paletteName : colorPaletteNames) {
QString translatedName = QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(paletteName));
QIcon paletteIcon = drawPalettePreview(paletteName);
comboBoxHotcueColors->addItem(tr(qPrintable(paletteName)), paletteName);
comboBoxHotcueColors->addItem(translatedName, paletteName);
comboBoxHotcueColors->setItemIcon(
comboBoxHotcueColors->count() - 1,
paletteIcon);
comboBoxTrackColors->addItem(tr(qPrintable(paletteName)), paletteName);
comboBoxTrackColors->addItem(translatedName, paletteName);
comboBoxTrackColors->setItemIcon(
comboBoxHotcueColors->count() - 1,
paletteIcon);
}

const ColorPalette trackPalette =
m_colorPaletteSettings.getTrackColorPalette();
comboBoxTrackColors->setCurrentText(
tr(qPrintable(trackPalette.getName())));
comboBoxTrackColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(trackPalette.getName())));

const ColorPalette hotcuePalette =
m_colorPaletteSettings.getHotcueColorPalette();
comboBoxHotcueColors->setCurrentText(
tr(qPrintable(hotcuePalette.getName())));
comboBoxHotcueColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(hotcuePalette.getName())));
slotHotcuePaletteIndexChanged(comboBoxHotcueColors->currentIndex());

const ColorPalette keyPalette =
m_colorPaletteSettings.getKeyColorPalette();
comboBoxKeyColors->setCurrentText(
tr(qPrintable(keyPalette.getName())));
comboBoxKeyColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(keyPalette.getName())));

bool autoHotcueColors = m_pConfig->getValue(kAutoHotcueColorsConfigKey, false);
if (autoHotcueColors) {
Expand Down Expand Up @@ -180,15 +184,19 @@ void DlgPrefColors::slotUpdate() {

// Set the default values for all the widgets
void DlgPrefColors::slotResetToDefaults() {
comboBoxHotcueColors->setCurrentText(
tr(qPrintable(mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette
.getName())));
comboBoxTrackColors->setCurrentText(
tr(qPrintable(mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette
.getName())));
comboBoxKeyColors->setCurrentText(
tr(qPrintable(mixxx::PredefinedColorPalettes::kDefaultKeyColorPalette
.getName())));
comboBoxHotcueColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes",
qPrintable(
mixxx::PredefinedColorPalettes::kDefaultHotcueColorPalette
.getName())));
comboBoxTrackColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes",
qPrintable(mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette
.getName())));
comboBoxKeyColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes",
qPrintable(mixxx::PredefinedColorPalettes::kDefaultKeyColorPalette
.getName())));
comboBoxHotcueDefaultColor->setCurrentIndex(
mixxx::PredefinedColorPalettes::kDefaultTrackColorPalette.size());
comboBoxLoopDefaultColor->setCurrentIndex(
Expand Down Expand Up @@ -465,8 +473,10 @@ void DlgPrefColors::restoreComboBoxes(
const QString& trackColors,
int defaultHotcueColor,
int defaultLoopColor) {
comboBoxHotcueColors->setCurrentText(tr(qPrintable(hotcueColors)));
comboBoxTrackColors->setCurrentText(tr(qPrintable(trackColors)));
comboBoxHotcueColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(hotcueColors)));
comboBoxTrackColors->setCurrentText(QCoreApplication::translate(
"PredefinedColorPalettes", qPrintable(trackColors)));
if (comboBoxHotcueDefaultColor->count() > defaultHotcueColor) {
comboBoxHotcueDefaultColor->setCurrentIndex(defaultHotcueColor);
} else {
Expand Down

0 comments on commit 06528bc

Please sign in to comment.