MythTV  master
ratingsettings.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QString>
3 
4 // MythTV
5 #include <mythcorecontext.h>
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 
58  connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
59  connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
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 * m_cancelButton
void SaveSetting(const QString &key, int newValue)
QString GetValue(void) const override
Definition: mythuispinbox.h:31
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void SetValue(int val) override
Definition: mythuispinbox.h:26
bool Create(void) override
MythUISpinBox * m_ratingWeight
void BuildFocusList(void)
virtual void Close()
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.
This class is used as a container for messages.
Definition: mythevent.h:16
void SetHelpText(const QString &text)
Definition: mythuitype.h:150
MythUIButton * m_saveButton
void slotSave(void)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
MythUISpinBox * m_lastPlayWeight
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void dispatch(const MythEvent &event)
int GetNumSetting(const QString &key, int defaultval=0)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
MythUISpinBox * m_randomWeight
MythUISpinBox * m_playCountWeight