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 
93 void PlayerSettings::slotSave(void)
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 
MythUIButton::Clicked
void Clicked()
PlayerSettings::m_autoLookupCD
MythUICheckBox * m_autoLookupCD
Definition: playersettings.h:25
MusicPlayer::RESUME_OFF
@ RESUME_OFF
Definition: musicplayer.h:184
MythUIButtonList::SetValueByData
void SetValueByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1566
PlayerSettings::slotSave
void slotSave(void)
Definition: videoplayersettings.cpp:111
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:384
PlayerSettings::m_resumeModeRadio
MythUIButtonList * m_resumeModeRadio
Definition: playersettings.h:22
PlayerSettings::m_saveButton
MythUIButton * m_saveButton
Definition: playersettings.h:27
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MusicPlayer::RESUME_FIRST
@ RESUME_FIRST
Definition: musicplayer.h:185
MusicPlayer::RESUME_TRACK
@ RESUME_TRACK
Definition: musicplayer.h:186
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
PlayerSettings::Create
bool Create(void) override
Definition: videoplayersettings.cpp:18
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
MusicPlayer::RESUME_EXACT
@ RESUME_EXACT
Definition: musicplayer.h:187
mythlogging.h
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:204
MythUIButtonList::GetDataValue
QVariant GetDataValue() const
Definition: mythuibuttonlist.cpp:1643
PlayerSettings::m_exitAction
MythUIButtonList * m_exitAction
Definition: playersettings.h:23
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:57
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:918
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
PlayerSettings::m_resumeMode
MythUIButtonList * m_resumeMode
Definition: playersettings.h:20
PlayerSettings::m_resumeModeEditor
MythUIButtonList * m_resumeModeEditor
Definition: playersettings.h:21
mythcorecontext.h
MythUICheckBox::SetCheckState
void SetCheckState(MythUIStateType::StateType state)
Definition: mythuicheckbox.cpp:66
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:701
PlayerSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: videoplayersettings.h:36
PlayerSettings::m_jumpAction
MythUIButtonList * m_jumpAction
Definition: playersettings.h:24
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:27
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:887
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1729
playersettings.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:904
musicplayer.h
PlayerSettings::m_autoPlayCD
MythUICheckBox * m_autoPlayCD
Definition: playersettings.h:26