MythTV  master
ratingsettings.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QString>
3 
4 // MythTV
6 
7 #include "ratingsettings.h"
8 
10 {
11  // Load the theme for this screen
12  if (!LoadWindowFromXML("musicsettings-ui.xml", "ratingsettings", this))
13  return false;
14 
15  bool err = false;
16 
17  UIUtilE::Assign(this, m_ratingWeight, "ratingweight", &err);
18  UIUtilE::Assign(this, m_playCountWeight, "playcountweight", &err);
19  UIUtilE::Assign(this, m_lastPlayWeight, "lastplayweight", &err);
20  UIUtilE::Assign(this, m_randomWeight, "randomweight", &err);
21  UIUtilE::Assign(this, m_saveButton, "save", &err);
22  UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
23 
24  if (err)
25  {
26  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'ratingsettings'");
27  return false;
28  }
29 
30  m_ratingWeight->SetRange(0,100,1);
31  m_ratingWeight->SetValue(gCoreContext->GetNumSetting("IntelliRatingWeight"));
32  m_playCountWeight->SetRange(0,100,1);
33  m_playCountWeight->SetValue(gCoreContext->GetNumSetting("IntelliPlayCountWeight"));
34  m_lastPlayWeight->SetRange(0,100,1);
35  m_lastPlayWeight->SetValue(gCoreContext->GetNumSetting("IntelliLastPlayWeight"));
36  m_randomWeight->SetRange(0,100,1);
37  m_randomWeight->SetValue(gCoreContext->GetNumSetting("IntelliRandomWeight"));
38 
39  m_ratingWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
40  "This weighting affects how much strength is "
41  "given to your rating of a given track when "
42  "ordering a group of songs."));
43  m_playCountWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
44  "This weighting affects how much strength is "
45  "given to how many times a given track has been "
46  "played when ordering a group of songs."));
47  m_lastPlayWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
48  "This weighting affects how much strength is "
49  "given to how long it has been since a given "
50  "track was played when ordering a group of songs."));
51  m_randomWeight->SetHelpText(tr("Used in \"Smart\" Shuffle mode. "
52  "This weighting affects how much strength is "
53  "given to good old (pseudo-)randomness "
54  "when ordering a group of songs."));
55  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
56  m_saveButton->SetHelpText(tr("Save settings and Exit"));
57 
60 
62 
63  return true;
64 }
65 
67 {
68  gCoreContext->SaveSetting("IntelliRatingWeight", m_ratingWeight->GetValue());
69  gCoreContext->SaveSetting("IntelliPlayCountWeight", m_playCountWeight->GetValue());
70  gCoreContext->SaveSetting("IntelliLastPlayWeight", m_lastPlayWeight->GetValue());
71  gCoreContext->SaveSetting("IntelliRandomWeight", m_randomWeight->GetValue());
72 
73  gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED RATING_SETTINGS")));
74 
75  Close();
76 }
77 
78 
MythUIButton::Clicked
void Clicked()
MythUISpinBox::GetValue
QString GetValue(void) const override
Definition: mythuispinbox.h:31
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:383
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
RatingSettings::m_ratingWeight
MythUISpinBox * m_ratingWeight
Definition: ratingsettings.h:20
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythUISpinBox::SetRange
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
Definition: mythuispinbox.cpp:26
MythUISpinBox::SetValue
void SetValue(int val) override
Definition: mythuispinbox.h:26
ratingsettings.h
RatingSettings::m_saveButton
MythUIButton * m_saveButton
Definition: ratingsettings.h:24
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:203
RatingSettings::m_randomWeight
MythUISpinBox * m_randomWeight
Definition: ratingsettings.h:23
RatingSettings::Create
bool Create(void) override
Definition: ratingsettings.cpp:9
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
RatingSettings::slotSave
void slotSave(void)
Definition: ratingsettings.cpp:66
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
mythcorecontext.h
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:701
RatingSettings::m_playCountWeight
MythUISpinBox * m_playCountWeight
Definition: ratingsettings.h:21
RatingSettings::m_lastPlayWeight
MythUISpinBox * m_lastPlayWeight
Definition: ratingsettings.h:22
RatingSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: ratingsettings.h:25
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:885
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1727