MythTV master
playersettings.cpp
Go to the documentation of this file.
1// Qt
2#include <QString>
3
4// MythTV
7
8// MythMusic
9#include "musicplayer.h"
10#include "playersettings.h"
11
13{
14 bool err = false;
15
16 // Load the theme for this screen
17 if (!LoadWindowFromXML("musicsettings-ui.xml", "playersettings", this))
18 return false;
19
20 UIUtilE::Assign(this, m_resumeMode, "resumemode", &err);
21 UIUtilE::Assign(this, m_resumeModeEditor, "resumemodeeditor", &err);
22 UIUtilE::Assign(this, m_resumeModeRadio, "resumemoderadio", &err);
23 UIUtilE::Assign(this, m_exitAction, "exitaction", &err);
24 UIUtilE::Assign(this, m_jumpAction, "jumpaction", &err);
25 UIUtilE::Assign(this, m_autoLookupCD, "autolookupcd", &err);
26 UIUtilE::Assign(this, m_autoPlayCD, "autoplaycd", &err);
27 UIUtilE::Assign(this, m_saveButton, "save", &err);
28 UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
29
30 if (err)
31 {
32 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'playersettings'");
33 return false;
34 }
35
36 new MythUIButtonListItem(m_resumeMode, tr("Off"), QVariant::fromValue((int)MusicPlayer::RESUME_OFF));
37 new MythUIButtonListItem(m_resumeMode, tr("First"), QVariant::fromValue((int)MusicPlayer::RESUME_FIRST));
38 new MythUIButtonListItem(m_resumeMode, tr("Track"), QVariant::fromValue((int)MusicPlayer::RESUME_TRACK));
39 new MythUIButtonListItem(m_resumeMode, tr("Exact"), QVariant::fromValue((int)MusicPlayer::RESUME_EXACT));
41
42 new MythUIButtonListItem(m_resumeModeEditor, tr("Off"), QVariant::fromValue((int)MusicPlayer::RESUME_OFF));
43 new MythUIButtonListItem(m_resumeModeEditor, tr("First"), QVariant::fromValue((int)MusicPlayer::RESUME_FIRST));
44 new MythUIButtonListItem(m_resumeModeEditor, tr("Track"), QVariant::fromValue((int)MusicPlayer::RESUME_TRACK));
45 new MythUIButtonListItem(m_resumeModeEditor, tr("Exact"), QVariant::fromValue((int)MusicPlayer::RESUME_EXACT));
47
48 new MythUIButtonListItem(m_resumeModeRadio, tr("Off"), QVariant::fromValue((int)MusicPlayer::RESUME_OFF));
49 new MythUIButtonListItem(m_resumeModeRadio, tr("On"), QVariant::fromValue((int)MusicPlayer::RESUME_TRACK));
51
52 new MythUIButtonListItem(m_exitAction, tr("Prompt"), QVariant::fromValue(QString("prompt")));
53 new MythUIButtonListItem(m_exitAction, tr("Stop playing"), QVariant::fromValue(QString("stop")));
54 new MythUIButtonListItem(m_exitAction, tr("Continue Playing"), QVariant::fromValue(QString("play")));
55 m_exitAction->SetValueByData(gCoreContext->GetSetting("MusicExitAction", "prompt"));
56
57 new MythUIButtonListItem(m_jumpAction, tr("Stop playing"), QVariant::fromValue(QString("stop")));
58 new MythUIButtonListItem(m_jumpAction, tr("Continue Playing"), QVariant::fromValue(QString("play")));
59 m_jumpAction->SetValueByData(gCoreContext->GetSetting("MusicJumpPointAction", "stop"));
60
61 int loadAutoLookupCD = gCoreContext->GetNumSetting("AutoLookupCD", 0);
62 if (loadAutoLookupCD == 1)
64 int loadAutoPlayCD = gCoreContext->GetNumSetting("AutoPlayCD", 0);
65 if (loadAutoPlayCD == 1)
67
68 m_resumeMode->SetHelpText(tr("Playback screen - Resume playback at either the beginning of the "
69 "active play queue, the beginning of the last track played, "
70 "or an exact point within the last track played or not at all."));
71 m_resumeModeEditor->SetHelpText(tr("Playlist Editor screen - Resume playback at either the beginning of the "
72 "active play queue, the beginning of the last track played, "
73 "or an exact point within the last track played or not at all."));
74 m_resumeModeRadio->SetHelpText(tr("Radio screen - Resume playback at the previous station or not at all"));
75 m_exitAction->SetHelpText(tr("Specify what action to take when exiting MythMusic plugin."));
76 m_jumpAction->SetHelpText(tr("Specify what action to take when exiting MythMusic plugin due to a jumppoint being executed."));
77 m_autoLookupCD->SetHelpText(tr("Automatically lookup an audio CD if it is "
78 "present and show its information in the "
79 "Music Selection Tree."));
80 m_autoPlayCD->SetHelpText(tr("Automatically put a new CD on the "
81 "playlist and start playing the CD."));
82 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
83 m_saveButton->SetHelpText(tr("Save settings and Exit"));
84
87
89
90 return true;
91}
92
94{
95 gCoreContext->SaveSetting("ResumeModePlayback", m_resumeMode->GetDataValue().toInt());
96 gCoreContext->SaveSetting("ResumeModeEditor", m_resumeModeEditor->GetDataValue().toInt());
97 gCoreContext->SaveSetting("ResumeModeRadio", m_resumeModeRadio->GetDataValue().toInt());
98 gCoreContext->SaveSetting("MusicExitAction", m_exitAction->GetDataValue().toString());
99 gCoreContext->SaveSetting("MusicJumpPointAction", m_jumpAction->GetDataValue().toString());
100
101 int saveAutoLookupCD = (m_autoLookupCD->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
102 gCoreContext->SaveSetting("AutoLookupCD", saveAutoLookupCD);
103 int saveAutoPlayCD = (m_autoPlayCD->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
104 gCoreContext->SaveSetting("AutoPlayCD", saveAutoPlayCD);
105
106 gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED PLAYER_SETTINGS")));
107
108 Close();
109}
110
void SaveSetting(const QString &key, int newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
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 SetValueByData(const QVariant &data)
QVariant GetDataValue() const
void Clicked()
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
void SetHelpText(const QString &text)
Definition: mythuitype.h:177
MythUIButton * m_cancelButton
MythUIButtonList * m_resumeMode
bool Create(void) override
MythUIButtonList * m_resumeModeEditor
MythUIButtonList * m_jumpAction
MythUICheckBox * m_autoPlayCD
MythUIButton * m_saveButton
MythUIButtonList * m_resumeModeRadio
MythUICheckBox * m_autoLookupCD
MythUIButtonList * m_exitAction
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