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