X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsettingsform.cpp;h=530ed28a677b0a179390e4921ce4026313d289d2;hb=ce3d82f849347cbd48890fc2cad2f90137d2d982;hp=0e336877879cf929be12127227fe7a060d7856d2;hpb=071bd14235584b29b9b3311fc9814a24f240782d;p=someplayer diff --git a/src/settingsform.cpp b/src/settingsform.cpp index 0e33687..530ed28 100644 --- a/src/settingsform.cpp +++ b/src/settingsform.cpp @@ -33,6 +33,11 @@ SettingsForm::SettingsForm(QWidget *parent) : { ui->setupUi(this); Config config; + + _color_map << "blue" << "magenta" << "red" << "yellow" << + "white" << "black" << "light" << "dark"; + _lang_map << "en" << "ru" << "cn"; + QString albumSorting = config.getValue("ui/albumsorting").toString(); QString showTrackLenght = config.getValue("ui/showtracklenght").toString(); QString orientation = config.getValue("ui/orientation").toString(); @@ -45,8 +50,8 @@ SettingsForm::SettingsForm(QWidget *parent) : ui->orientationLButton->setChecked(true); ui->iconsWButton->setChecked(true); ui->gradientYButton->setChecked(true); - ui->engLangButton->setChecked(true); - ui->cBlueButton->setChecked(true); + ui->langComboBox->setCurrentIndex(_lang_map.indexOf(language)); + ui->colorComboBox->setCurrentIndex(_color_map.indexOf(track_color)); ui->pauseHPNoButton->setChecked(true); ui->hwKeysBox->setChecked(false); ui->hwkeysLabel->setEnabled(false); @@ -70,27 +75,6 @@ SettingsForm::SettingsForm(QWidget *parent) : if (gradient == "no") { ui->gradientNButton->setChecked(true); } - if (language == "ru") { - ui->ruLangButton->setChecked(true); - } - if (language == "cn") { - ui->cnLangButton->setChecked(true); - } - if (track_color == "black") { - ui->cBlackButton->setChecked(true); - } else if (track_color == "magenta") { - ui->cMagentaButton->setChecked(true); - } else if (track_color == "Red") { - ui->cRedButton->setChecked(true); - } else if (track_color == "yellow") { - ui->cYellowButton->setChecked(true); - } else if (track_color == "white") { - ui->cWhiteButton->setChecked(true); - } else if (track_color == "dark") { - ui->cDarkButton->setChecked(true); - } else if (track_color == "light") { - ui->cLightButton->setChecked(true); - } if (config.getValue("hw/hpautopause").toString() == "yes") { ui->pauseHPYesButton->setChecked(true); } @@ -127,17 +111,6 @@ SettingsForm::SettingsForm(QWidget *parent) : connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool))); connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool))); connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool))); - connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool))); - connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool))); - connect (ui->cnLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_cn(bool))); - connect (ui->cBlackButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_black(bool))); - connect (ui->cBlueButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_blue(bool))); - connect (ui->cDarkButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_dark(bool))); - connect (ui->cLightButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_light(bool))); - connect (ui->cMagentaButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_magenta(bool))); - connect (ui->cRedButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_red(bool))); - connect (ui->cWhiteButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_white(bool))); - connect (ui->cYellowButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_yellow(bool))); connect (ui->pauseHPNoButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_no(bool))); connect (ui->pauseHPYesButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_yes(bool))); connect (ui->hwKeysBox, SIGNAL(toggled(bool)), this, SLOT(_toggle_hw_settings(bool))); @@ -148,6 +121,8 @@ SettingsForm::SettingsForm(QWidget *parent) : connect (ui->libraryButton, SIGNAL(clicked()), this, SLOT(_toggle_view_lib())); connect (ui->fmtxSettingsButton, SIGNAL(clicked()), this, SLOT(_open_fmtx_settings())); connect (ui->fmtxGroupBox, SIGNAL(toggled(bool)), this, SLOT(_toggle_fmtx_settings(bool))); + connect (ui->colorComboBox, SIGNAL(activated(int)), this, SLOT(_set_color(int))); + connect (ui->langComboBox, SIGNAL(activated(int)), this, SLOT(_set_language(int))); _toggle_view_ui(); setAttribute(Qt::WA_Maemo5StackedWindow); setWindowFlags(Qt::Window | windowFlags()); @@ -235,80 +210,15 @@ void SettingsForm::_set_gradient_yes(bool checked) { emit gradientChanged(); } -void SettingsForm::_set_color_black(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/trackcolor", "black"); - emit trackColorChanged(); -} - -void SettingsForm::_set_color_blue(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/trackcolor", "blue"); - emit trackColorChanged(); -} - -void SettingsForm::_set_color_dark(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/trackcolor", "dark"); - emit trackColorChanged(); -} - -void SettingsForm::_set_color_light(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/trackcolor", "light"); - emit trackColorChanged(); -} - -void SettingsForm::_set_color_magenta(bool checked) { - if (!checked) return; +void SettingsForm::_set_color(int code) { Config config; - config.setValue("ui/trackcolor", "magenta"); + config.setValue("ui/trackcolor", _color_map[code]); emit trackColorChanged(); } -void SettingsForm::_set_color_red(bool checked) { - if (!checked) return; +void SettingsForm::_set_language(int code) { Config config; - config.setValue("ui/trackcolor", "red"); - emit trackColorChanged(); -} - -void SettingsForm::_set_color_white(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/trackcolor", "white"); - emit trackColorChanged(); -} - -void SettingsForm::_set_color_yellow(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/trackcolor", "yellow"); - emit trackColorChanged(); -} - -void SettingsForm::_set_lang_en(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/language", "en"); - emit translationChanged(); -} - -void SettingsForm::_set_lang_ru(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/language", "ru"); - emit translationChanged(); -} - -void SettingsForm::_set_lang_cn(bool checked) { - if (!checked) return; - Config config; - config.setValue("ui/language", "cn"); + config.setValue("ui/language", _lang_map[code]); emit translationChanged(); } @@ -367,27 +277,13 @@ void SettingsForm::_toggle_view_hw() { } void SettingsForm::updateTranslations() { + Config config; ui->retranslateUi(this); + ui->langComboBox->setCurrentIndex(_lang_map.indexOf(config.getValue("ui/language").toString())); + ui->colorComboBox->setCurrentIndex(_color_map.indexOf(config.getValue("ui/trackcolor").toString())); } void SettingsForm::landscapeMode() { - ui->cButtonsLayout->removeWidget(ui->cBlueButton); - ui->cButtonsLayout->removeWidget(ui->cMagentaButton); - ui->cButtonsLayout->removeWidget(ui->cRedButton); - ui->cButtonsLayout->removeWidget(ui->cYellowButton); - ui->cButtonsLayout->removeWidget(ui->cWhiteButton); - ui->cButtonsLayout->removeWidget(ui->cBlackButton); - ui->cButtonsLayout->removeWidget(ui->cLightButton); - ui->cButtonsLayout->removeWidget(ui->cDarkButton); - ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0); - ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1); - ui->cButtonsLayout->addWidget(ui->cRedButton, 0, 2); - ui->cButtonsLayout->addWidget(ui->cYellowButton, 0, 3); - ui->cButtonsLayout->addWidget(ui->cWhiteButton, 1, 0); - ui->cButtonsLayout->addWidget(ui->cBlackButton, 1, 1); - ui->cButtonsLayout->addWidget(ui->cLightButton, 1, 2); - ui->cButtonsLayout->addWidget(ui->cDarkButton, 1, 3); - ui->orientationGridLayout->removeWidget(ui->orientationAButton); ui->orientationGridLayout->removeWidget(ui->orientationLButton); ui->orientationGridLayout->removeWidget(ui->orientationPButton); @@ -397,23 +293,6 @@ void SettingsForm::landscapeMode() { } void SettingsForm::portraitMode() { - ui->cButtonsLayout->removeWidget(ui->cBlueButton); - ui->cButtonsLayout->removeWidget(ui->cMagentaButton); - ui->cButtonsLayout->removeWidget(ui->cRedButton); - ui->cButtonsLayout->removeWidget(ui->cYellowButton); - ui->cButtonsLayout->removeWidget(ui->cWhiteButton); - ui->cButtonsLayout->removeWidget(ui->cBlackButton); - ui->cButtonsLayout->removeWidget(ui->cLightButton); - ui->cButtonsLayout->removeWidget(ui->cDarkButton); - ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0); - ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1); - ui->cButtonsLayout->addWidget(ui->cRedButton, 1, 0); - ui->cButtonsLayout->addWidget(ui->cYellowButton, 1, 1); - ui->cButtonsLayout->addWidget(ui->cWhiteButton, 2, 0); - ui->cButtonsLayout->addWidget(ui->cBlackButton, 2, 1); - ui->cButtonsLayout->addWidget(ui->cLightButton, 3, 0); - ui->cButtonsLayout->addWidget(ui->cDarkButton, 3, 1); - ui->orientationGridLayout->removeWidget(ui->orientationAButton); ui->orientationGridLayout->removeWidget(ui->orientationLButton); ui->orientationGridLayout->removeWidget(ui->orientationPButton);