00001
00002 #include <QString>
00003
00004
00005 #include <mythcorecontext.h>
00006
00007 #include "ratingsettings.h"
00008
00009 RatingSettings::RatingSettings(MythScreenStack *parent, const char *name)
00010 : MythScreenType(parent, name),
00011 m_ratingWeight(NULL), m_playCountWeight(NULL),
00012 m_lastPlayWeight(NULL), m_randomWeight(NULL),
00013 m_saveButton(NULL), m_cancelButton(NULL)
00014 {
00015 }
00016
00017 RatingSettings::~RatingSettings()
00018 {
00019
00020 }
00021
00022 bool RatingSettings::Create()
00023 {
00024 bool err = false;
00025
00026
00027 if (!LoadWindowFromXML("musicsettings-ui.xml", "ratingsettings", this))
00028 return false;
00029
00030 m_ratingWeight = dynamic_cast<MythUISpinBox *> (GetChild("ratingweight"));
00031 m_playCountWeight = dynamic_cast<MythUISpinBox *> (GetChild("playcountweight"));
00032 m_lastPlayWeight = dynamic_cast<MythUISpinBox *> (GetChild("lastplayweight"));
00033 m_randomWeight = dynamic_cast<MythUISpinBox *> (GetChild("randomweight"));
00034 m_saveButton = dynamic_cast<MythUIButton *> (GetChild("save"));
00035 m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
00036
00037 if (err)
00038 {
00039 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'ratingsettings'");
00040 return false;
00041 }
00042
00043 m_ratingWeight->SetRange(0,100,1);
00044 m_ratingWeight->SetValue(gCoreContext->GetNumSetting("IntelliRatingWeight"));
00045 m_playCountWeight->SetRange(0,100,1);
00046 m_playCountWeight->SetValue(gCoreContext->GetNumSetting("IntelliPlayCountWeight"));
00047 m_lastPlayWeight->SetRange(0,100,1);
00048 m_lastPlayWeight->SetValue(gCoreContext->GetNumSetting("IntelliLastPlayWeight"));
00049 m_randomWeight->SetRange(0,100,1);
00050 m_randomWeight->SetValue(gCoreContext->GetNumSetting("IntelliRandomWeight"));
00051
00052 m_ratingWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
00053 "This weighting affects how much strength is "
00054 "given to your rating of a given track when "
00055 "ordering a group of songs."));
00056 m_playCountWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
00057 "This weighting affects how much strength is "
00058 "given to how many times a given track has been "
00059 "played when ordering a group of songs."));
00060 m_lastPlayWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
00061 "This weighting affects how much strength is "
00062 "given to how long it has been since a given "
00063 "track was played when ordering a group of songs."));
00064 m_randomWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
00065 "This weighting affects how much strength is "
00066 "given to good old (pseudo-)randomness "
00067 "when ordering a group of songs."));
00068 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
00069 m_saveButton->SetHelpText(tr("Save settings and Exit"));
00070
00071 connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
00072 connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
00073
00074 BuildFocusList();
00075
00076 return true;
00077 }
00078
00079 void RatingSettings::slotSave(void)
00080 {
00081 gCoreContext->SaveSetting("IntelliRatingWeight", m_ratingWeight->GetValue());
00082 gCoreContext->SaveSetting("IntelliPlayCountWeight", m_playCountWeight->GetValue());
00083 gCoreContext->SaveSetting("IntelliLastPlayWeight", m_lastPlayWeight->GetValue());
00084 gCoreContext->SaveSetting("IntelliRandomWeight", m_randomWeight->GetValue());
00085
00086 gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED RATING_SETTINGS")));
00087
00088 Close();
00089 }
00090
00091