00001
00002 #include <QString>
00003
00004
00005 #include <mythcorecontext.h>
00006
00007 #include "playersettings.h"
00008
00009 PlayerSettings::PlayerSettings(MythScreenStack *parent, const char *name)
00010 : MythScreenType(parent, name),
00011 m_resumeMode(NULL),
00012 m_exitAction(NULL),
00013 m_autoLookupCD(NULL),
00014 m_autoPlayCD(NULL),
00015 m_saveButton(NULL),
00016 m_cancelButton(NULL)
00017 {
00018 }
00019
00020 PlayerSettings::~PlayerSettings()
00021 {
00022
00023 }
00024
00025 bool PlayerSettings::Create()
00026 {
00027 bool err = false;
00028
00029
00030 if (!LoadWindowFromXML("musicsettings-ui.xml", "playersettings", this))
00031 return false;
00032
00033 UIUtilE::Assign(this, m_resumeMode, "resumemode", &err);
00034 UIUtilE::Assign(this, m_exitAction, "exitaction", &err);
00035 UIUtilE::Assign(this, m_autoLookupCD, "autolookupcd", &err);
00036 UIUtilE::Assign(this, m_autoPlayCD, "autoplaycd", &err);
00037 UIUtilE::Assign(this, m_saveButton, "save", &err);
00038 UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
00039
00040 if (err)
00041 {
00042 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'playersettings'");
00043 return false;
00044 }
00045
00046 new MythUIButtonListItem(m_resumeMode, tr("Off"), qVariantFromValue(QString("off")));
00047 new MythUIButtonListItem(m_resumeMode, tr("Track"), qVariantFromValue(QString("track")));
00048 new MythUIButtonListItem(m_resumeMode, tr("Exact"), qVariantFromValue(QString("exact")));
00049 m_resumeMode->SetValueByData(gCoreContext->GetSetting("ResumeMode"));
00050
00051 new MythUIButtonListItem(m_exitAction, tr("Prompt"), qVariantFromValue(QString("prompt")));
00052 new MythUIButtonListItem(m_exitAction, tr("Stop playing"), qVariantFromValue(QString("stop")));
00053 new MythUIButtonListItem(m_exitAction, tr("Continue Playing"), qVariantFromValue(QString("play")));
00054 m_exitAction->SetValueByData(gCoreContext->GetSetting("MusicExitAction"));
00055
00056 int loadAutoLookupCD = gCoreContext->GetNumSetting("AutoLookupCD", 0);
00057 if (loadAutoLookupCD == 1)
00058 m_autoLookupCD->SetCheckState(MythUIStateType::Full);
00059 int loadAutoPlayCD = gCoreContext->GetNumSetting("AutoPlayCD", 0);
00060 if (loadAutoPlayCD == 1)
00061 m_autoLookupCD->SetCheckState(MythUIStateType::Full);
00062
00063 m_resumeMode->SetHelpText(tr("Resume playback at either the beginning of the "
00064 "active play queue, the beginning of the last track, "
00065 "or an exact point within the last track."));
00066 m_exitAction->SetHelpText(tr("Specify what action to take when exiting MythMusic plugin."));
00067 m_autoLookupCD->SetHelpText(tr("Automatically lookup an audio CD if it is "
00068 "present and show its information in the "
00069 "Music Selection Tree."));
00070 m_autoPlayCD->SetHelpText(tr("Automatically put a new CD on the "
00071 "playlist and start playing the CD."));
00072 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
00073 m_saveButton->SetHelpText(tr("Save settings and Exit"));
00074
00075 connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
00076 connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
00077
00078 BuildFocusList();
00079
00080 return true;
00081 }
00082
00083 void PlayerSettings::slotSave(void)
00084 {
00085 gCoreContext->SaveSetting("ResumeMode", m_resumeMode->GetDataValue().toString());
00086 gCoreContext->SaveSetting("MusicExitAction", m_exitAction->GetDataValue().toString());
00087
00088 int saveAutoLookupCD = (m_autoLookupCD->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00089 gCoreContext->SaveSetting("AutoLookupCD", saveAutoLookupCD);
00090 int saveAutoPlayCD = (m_autoPlayCD->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00091 gCoreContext->SaveSetting("AutoPlayCD", saveAutoPlayCD);
00092
00093 gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED PLAYER_SETTINGS")));
00094
00095 Close();
00096 }
00097