00001
00002 #include <QString>
00003
00004
00005 #include <mythcorecontext.h>
00006
00007 #include "importsettings.h"
00008
00009 ImportSettings::ImportSettings(MythScreenStack *parent, const char *name)
00010 : MythScreenType(parent, name),
00011 m_paranoiaLevel(NULL),
00012 m_filenameTemplate(NULL),
00013 m_noWhitespace(NULL),
00014 m_postCDRipScript(NULL),
00015 m_ejectCD(NULL),
00016 m_encoderType(NULL),
00017 m_defaultRipQuality(NULL),
00018 m_mp3UseVBR(NULL),
00019 m_saveButton(NULL),
00020 m_cancelButton(NULL)
00021 {
00022 }
00023
00024 ImportSettings::~ImportSettings()
00025 {
00026
00027 }
00028
00029 bool ImportSettings::Create()
00030 {
00031 bool err = false;
00032
00033
00034 if (!LoadWindowFromXML("musicsettings-ui.xml", "importsettings", this))
00035 return false;
00036
00037 UIUtilE::Assign(this, m_paranoiaLevel, "paranoialevel", &err);
00038 UIUtilE::Assign(this, m_filenameTemplate, "filenametemplate", &err);
00039 UIUtilE::Assign(this, m_noWhitespace, "nowhitespace", &err);
00040 UIUtilE::Assign(this, m_postCDRipScript, "postcdripscript", &err);
00041 UIUtilE::Assign(this, m_ejectCD, "ejectcd", &err);
00042 UIUtilE::Assign(this, m_encoderType, "encodertype", &err);
00043 UIUtilE::Assign(this, m_defaultRipQuality, "defaultripquality", &err);
00044 UIUtilE::Assign(this, m_mp3UseVBR, "mp3usevbr", &err);
00045 UIUtilE::Assign(this, m_saveButton, "save", &err);
00046 UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
00047
00048 if (err)
00049 {
00050 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'importsettings'");
00051 return false;
00052 }
00053
00054 new MythUIButtonListItem(m_paranoiaLevel, tr("Full"), qVariantFromValue(QString("Full")));
00055 new MythUIButtonListItem(m_paranoiaLevel, tr("Faster"), qVariantFromValue(QString("Faster")));
00056 m_paranoiaLevel->SetValueByData(gCoreContext->GetSetting("ParanoiaLevel"));
00057
00058 m_filenameTemplate->SetText(gCoreContext->GetSetting("FilenameTemplate"));
00059
00060 int loadNoWhitespace = gCoreContext->GetNumSetting("NoWhitespace", 0);
00061 if (loadNoWhitespace == 1)
00062 m_noWhitespace->SetCheckState(MythUIStateType::Full);
00063
00064 m_postCDRipScript->SetText(gCoreContext->GetSetting("PostCDRipScript"));
00065
00066 int loadEjectCD = gCoreContext->GetNumSetting("EjectCDAfterRipping", 0);
00067 if (loadEjectCD == 1)
00068 m_ejectCD->SetCheckState(MythUIStateType::Full);
00069
00070 new MythUIButtonListItem(m_encoderType, tr("Ogg Vorbis"), qVariantFromValue(QString("ogg")));
00071 new MythUIButtonListItem(m_encoderType, tr("Lame (MP3)"), qVariantFromValue(QString("mp3")));
00072 m_encoderType->SetValueByData(gCoreContext->GetSetting("EncoderType"));
00073
00074 new MythUIButtonListItem(m_defaultRipQuality, tr("Low"), qVariantFromValue(0));
00075 new MythUIButtonListItem(m_defaultRipQuality, tr("Medium"), qVariantFromValue(1));
00076 new MythUIButtonListItem(m_defaultRipQuality, tr("High"), qVariantFromValue(2));
00077 new MythUIButtonListItem(m_defaultRipQuality, tr("Perfect"), qVariantFromValue(3));
00078 m_defaultRipQuality->SetValueByData(gCoreContext->GetSetting("DefaultRipQuality"));
00079
00080 int loadMp3UseVBR = gCoreContext->GetNumSetting("Mp3UseVBR", 0);
00081 if (loadMp3UseVBR == 1)
00082 m_mp3UseVBR->SetCheckState(MythUIStateType::Full);
00083
00084 connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
00085 connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
00086
00087 m_paranoiaLevel->SetHelpText(tr("Paranoia level of the CD ripper. Set to "
00088 "faster if you're not concerned about "
00089 "possible errors in the audio."));
00090 m_filenameTemplate->SetHelpText(tr("Defines the location/name for new "
00091 "songs. Valid tokens are:\n"
00092 "GENRE, ARTIST, ALBUM, TRACK, TITLE, YEAR"));
00093 m_noWhitespace->SetHelpText(tr("If set, whitespace characters in filenames "
00094 "will be replaced with underscore characters."));
00095 m_postCDRipScript->SetHelpText(tr("If present this script will be executed "
00096 "after a CD Rip is completed."));
00097 m_ejectCD->SetHelpText(tr("If set, the CD tray will automatically open "
00098 "after the CD has been ripped."));
00099 m_encoderType->SetHelpText(tr("Audio encoder to use for CD ripping. "
00100 "Note that the quality level 'Perfect' "
00101 "will use the FLAC encoder."));
00102 m_defaultRipQuality->SetHelpText(tr("Default quality for new CD rips."));
00103 m_mp3UseVBR->SetHelpText(tr("If set, the MP3 encoder will use variable "
00104 "bitrates (VBR) except for the low quality setting. "
00105 "The Ogg encoder will always use variable bitrates."));
00106 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
00107 m_saveButton->SetHelpText(tr("Save settings and Exit"));
00108
00109 BuildFocusList();
00110
00111 SetFocusWidget(m_paranoiaLevel);
00112
00113 return true;
00114 }
00115
00116 bool ImportSettings::keyPressEvent(QKeyEvent *event)
00117 {
00118 if (GetFocusWidget()->keyPressEvent(event))
00119 return true;
00120
00121 bool handled = false;
00122
00123 if (!handled && MythScreenType::keyPressEvent(event))
00124 handled = true;
00125
00126 return handled;
00127 }
00128
00129 void ImportSettings::slotSave(void)
00130 {
00131 gCoreContext->SaveSetting("ParanoiaLevel", m_paranoiaLevel->GetDataValue().toString());
00132 gCoreContext->SaveSetting("FilenameTemplate", m_filenameTemplate->GetText());
00133 gCoreContext->SaveSetting("PostCDRipScript", m_postCDRipScript->GetText());
00134 gCoreContext->SaveSetting("EncoderType", m_encoderType->GetDataValue().toString());
00135 gCoreContext->SaveSetting("DefaultRipQuality", m_defaultRipQuality->GetDataValue().toString());
00136
00137 int saveNoWhitespace = (m_noWhitespace->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00138 gCoreContext->SaveSetting("Ignore_ID3", saveNoWhitespace);
00139
00140 int saveEjectCD = (m_ejectCD->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00141 gCoreContext->SaveSetting("EjectCDAfterRipping", saveEjectCD);
00142
00143 int saveMp3UseVBR = (m_mp3UseVBR->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00144 gCoreContext->SaveSetting("Mp3UseVBR", saveMp3UseVBR);
00145
00146 gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED IMPORT_SETTINGS")));
00147
00148 Close();
00149 }