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