Mercurial > hg > sonic-visualiser
comparison main/PreferencesDialog.cpp @ 658:86d1f640ae1e
Add choice of interface language to the prefs dialog (in case user is unhappy with system locale)
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 10:35:55 +0000 |
parents | e5e6625deb85 |
children | 9d6eadfd390e |
comparison
equal
deleted
inserted
replaced
657:1938702bb3bf | 658:86d1f640ae1e |
---|---|
140 QSettings settings; | 140 QSettings settings; |
141 settings.beginGroup("Preferences"); | 141 settings.beginGroup("Preferences"); |
142 QString targetName = settings.value("audio-target", "").toString(); | 142 QString targetName = settings.value("audio-target", "").toString(); |
143 settings.endGroup(); | 143 settings.endGroup(); |
144 | 144 |
145 for (int i = 0; i < devices.size(); ++i) { | 145 for (int i = 0; i < (int)devices.size(); ++i) { |
146 audioDevice->addItem(AudioTargetFactory::getInstance() | 146 audioDevice->addItem(AudioTargetFactory::getInstance() |
147 ->getCallbackTargetDescription(devices[i])); | 147 ->getCallbackTargetDescription(devices[i])); |
148 if (targetName == devices[i]) audioDevice->setCurrentIndex(i); | 148 if (targetName == devices[i]) audioDevice->setCurrentIndex(i); |
149 } | 149 } |
150 | 150 |
203 | 203 |
204 connect(bgMode, SIGNAL(currentIndexChanged(int)), | 204 connect(bgMode, SIGNAL(currentIndexChanged(int)), |
205 this, SLOT(backgroundModeChanged(int))); | 205 this, SLOT(backgroundModeChanged(int))); |
206 #endif | 206 #endif |
207 | 207 |
208 settings.beginGroup("Preferences"); | |
209 QString userLocale = settings.value("locale", "").toString(); | |
210 m_currentLocale = userLocale; | |
211 settings.endGroup(); | |
212 | |
213 QComboBox *locale = new QComboBox; | |
214 QStringList localeFiles = QDir(":i18n").entryList(QStringList() << "*.qm"); | |
215 locale->addItem(tr("Follow system locale")); | |
216 m_locales.push_back(""); | |
217 if (userLocale == "") { | |
218 locale->setCurrentIndex(0); | |
219 } | |
220 foreach (QString f, localeFiles) { | |
221 QString f0 = f; | |
222 f.replace("sonic-visualiser_", "").replace(".qm", ""); | |
223 if (f == f0) { // our expectations about filename format were not met | |
224 std::cerr << "INFO: Unexpected filename " << f << " in i18n resource directory" << std::endl; | |
225 } else { | |
226 m_locales.push_back(f); | |
227 QString displayText; | |
228 // Add new translations here | |
229 if (f == "ru") displayText = tr("Russian"); | |
230 else if (f == "en_GB") displayText = tr("British English"); | |
231 else if (f == "en_US") displayText = tr("American English"); | |
232 else if (f == "cs_CZ") displayText = tr("Czech"); | |
233 else displayText = f; | |
234 locale->addItem(QString("%1 [%2]").arg(displayText).arg(f)); | |
235 if (userLocale == f) { | |
236 locale->setCurrentIndex(locale->count() - 1); | |
237 } | |
238 } | |
239 } | |
240 connect(locale, SIGNAL(currentIndexChanged(int)), | |
241 this, SLOT(localeChanged(int))); | |
242 | |
208 QSpinBox *fontSize = new QSpinBox; | 243 QSpinBox *fontSize = new QSpinBox; |
209 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max, | 244 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max, |
210 &deflt); | 245 &deflt); |
211 m_viewFontSize = fs; | 246 m_viewFontSize = fs; |
212 fontSize->setMinimum(min); | 247 fontSize->setMinimum(min); |
237 QGridLayout *subgrid = new QGridLayout; | 272 QGridLayout *subgrid = new QGridLayout; |
238 frame->setLayout(subgrid); | 273 frame->setLayout(subgrid); |
239 | 274 |
240 int row = 0; | 275 int row = 0; |
241 | 276 |
277 subgrid->addWidget(new QLabel(tr("%1:").arg(tr("User interface language"))), | |
278 row, 0); | |
279 subgrid->addWidget(locale, row++, 1, 1, 1); | |
280 | |
242 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel | 281 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel |
243 ("Temporary Directory Root"))), | 282 ("Temporary Directory Root"))), |
244 row, 0); | 283 row, 0); |
245 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1); | 284 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1); |
246 subgrid->addWidget(tempDirButton, row, 2, 1, 1); | 285 subgrid->addWidget(tempDirButton, row, 2, 1, 1); |
479 void | 518 void |
480 PreferencesDialog::defaultTemplateChanged(int i) | 519 PreferencesDialog::defaultTemplateChanged(int i) |
481 { | 520 { |
482 m_currentTemplate = m_templates[i]; | 521 m_currentTemplate = m_templates[i]; |
483 m_applyButton->setEnabled(true); | 522 m_applyButton->setEnabled(true); |
523 } | |
524 | |
525 void | |
526 PreferencesDialog::localeChanged(int i) | |
527 { | |
528 m_currentLocale = m_locales[i]; | |
529 m_applyButton->setEnabled(true); | |
530 m_changesOnRestart = true; | |
484 } | 531 } |
485 | 532 |
486 void | 533 void |
487 PreferencesDialog::tempDirRootChanged(QString r) | 534 PreferencesDialog::tempDirRootChanged(QString r) |
488 { | 535 { |
562 | 609 |
563 settings.beginGroup("MainWindow"); | 610 settings.beginGroup("MainWindow"); |
564 settings.setValue("sessiontemplate", m_currentTemplate); | 611 settings.setValue("sessiontemplate", m_currentTemplate); |
565 settings.endGroup(); | 612 settings.endGroup(); |
566 | 613 |
614 settings.beginGroup("Preferences"); | |
615 settings.setValue("locale", m_currentLocale); | |
616 settings.endGroup(); | |
617 | |
567 m_applyButton->setEnabled(false); | 618 m_applyButton->setEnabled(false); |
568 | 619 |
569 if (m_changesOnRestart) { | 620 if (m_changesOnRestart) { |
570 QMessageBox::information(this, tr("Preferences"), | 621 QMessageBox::information(this, tr("Preferences"), |
571 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>")); | 622 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>")); |