MythTV  master
videoplayersettings.cpp
Go to the documentation of this file.
1 // C++
2 #include <iostream>
3 
4 // Qt
5 #include <QString>
6 
7 // MythTV
10 #include "libmythbase/mythdirs.h"
12 
13 // MythFrontend
14 #include "videoplayersettings.h"
15 
16 // ---------------------------------------------------
17 
19 {
20  // Load the theme for this screen
21  bool foundtheme = LoadWindowFromXML("video-ui.xml", "playersettings", this);
22  if (!foundtheme)
23  return false;
24 
26  dynamic_cast<MythUITextEdit *> (GetChild("defaultplayer"));
27  m_dvdPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvdplayer"));
28  m_dvdDriveEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvddrive"));
30  dynamic_cast<MythUITextEdit *> (GetChild("bluraymount"));
31  m_altPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("altplayer"));
32 
34  dynamic_cast<MythUIButtonList *> (GetChild("blurayregionlist"));
35 
36  m_altCheck = dynamic_cast<MythUICheckBox *> (GetChild("altcheck"));
37 
38  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
39  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
40 
44  {
45  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
46  return false;
47  }
48 
49  int setting =
50  gCoreContext->GetNumSetting("mythvideo.EnableAlternatePlayer", 0);
51  if (setting == 1)
53 
54  m_defaultPlayerEdit->SetText(gCoreContext->GetSetting("VideoDefaultPlayer",
55  "Internal"));
57  GetSetting("mythdvd.DVDPlayerCommand", "Internal"));
58  m_dvdDriveEdit->SetText(gCoreContext->GetSetting("DVDDeviceLocation",
59  "default"));
60  m_blurayMountEdit->SetText(gCoreContext->GetSetting("BluRayMountpoint",
61  "/media/cdrom"));
63  "mythvideo.VideoAlternatePlayer", "Internal"));
64 
67  else
69 
72 
74 
76  tr("This is the command used for any file "
77  "whose extension is not specifically defined. "
78  "You may also enter the name of one of the playback "
79  "plugins such as 'Internal'."));
81  tr("This can be any command to launch a DVD "
82  " player. Internal is the default. For other players, %d "
83  "will be substituted for the DVD device (e.g. /dev/dvd)."));
85  tr("This device must exist, and the user "
86  "playing the DVD needs to have read permission "
87  "on the device. 'default' will let the "
88  "MediaMonitor choose a device."));
90  tr("This path is the location your "
91  "operating system mounts Blu-ray discs."));
93  tr("If for some reason the default player "
94  "doesn't play a video, you can play it in an alternate "
95  "player by selecting 'Play in Alternate Player.'"));
97  tr("Some Blu-ray discs require that a player region be "
98  "explicitly set. Only change the value from "
99  "'No Region' if you encounter a disc which "
100  "fails to play citing a region mismatch."));
101  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
102  m_okButton->SetHelpText(tr("Save settings and Exit"));
103 
104  fillRegionList();
105 
106  BuildFocusList();
107 
108  return true;
109 }
110 
112 {
113  gCoreContext->SaveSetting("VideoDefaultPlayer", m_defaultPlayerEdit->GetText());
114  gCoreContext->SaveSetting("mythdvd.DVDPlayerCommand", m_dvdPlayerEdit->GetText());
115  gCoreContext->SaveSetting("DVDDeviceLocation", m_dvdDriveEdit->GetText());
116  gCoreContext->SaveSetting("BluRayMountpoint", m_blurayMountEdit->GetText());
117  gCoreContext->SaveSetting("mythvideo.VideoAlternatePlayer", m_altPlayerEdit->GetText());
118 
119  gCoreContext->SaveSetting("BlurayRegionCode",
121 
122  int checkstate = 0;
124  checkstate = 1;
125  gCoreContext->SaveSetting("mythvideo.EnableAlternatePlayer", checkstate);
126 
127  Close();
128 }
129 
130 bool PlayerSettings::keyPressEvent(QKeyEvent *event)
131 {
132  if (GetFocusWidget()->keyPressEvent(event))
133  return true;
134 
135  return MythScreenType::keyPressEvent(event);
136 }
137 
139 {
140  int checkstate = 0;
142  checkstate = 1;
143 
144  m_altPlayerEdit->SetVisible(checkstate != 0);
145 }
146 
148 {
149  auto *noRegion =
150  new MythUIButtonListItem(m_blurayRegionList, tr("No Region"));
151  noRegion->SetData(0);
152 
153  auto *regionA =
154  new MythUIButtonListItem(m_blurayRegionList, tr("Region A: "
155  "The Americas, Southeast Asia, Japan"));
156  regionA->SetData(1);
157 
158  auto *regionB =
159  new MythUIButtonListItem(m_blurayRegionList, tr("Region B: "
160  "Europe, Middle East, Africa, Oceania"));
161  regionB->SetData(2);
162 
163  auto *regionC =
164  new MythUIButtonListItem(m_blurayRegionList, tr("Region C: "
165  "Eastern Europe, Central and South Asia"));
166  regionC->SetData(4);
167 
168  int region = gCoreContext->GetNumSetting("BlurayRegionCode", 0);
169 
171 
172  if (item)
174 }
MythUIButton::Clicked
void Clicked()
PlayerSettings::fillRegionList
void fillRegionList(void)
Definition: videoplayersettings.cpp:147
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1614
PlayerSettings::slotSave
void slotSave(void)
Definition: videoplayersettings.cpp:111
PlayerSettings::m_altPlayerEdit
MythUITextEdit * m_altPlayerEdit
Definition: videoplayersettings.h:29
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:384
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:138
mythdbcon.h
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:34
PlayerSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: videoplayersettings.cpp:130
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythUITextEdit::GetText
QString GetText(void) const
Definition: mythuitextedit.h:50
PlayerSettings::Create
bool Create(void) override
Definition: videoplayersettings.cpp:18
mythdirs.h
PlayerSettings::m_altCheck
MythUICheckBox * m_altCheck
Definition: videoplayersettings.h:33
MythUIButtonList::GetItemByData
MythUIButtonListItem * GetItemByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1708
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:111
PlayerSettings::m_blurayRegionList
MythUIButtonList * m_blurayRegionList
Definition: videoplayersettings.h:31
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:198
PlayerSettings::m_blurayMountEdit
MythUITextEdit * m_blurayMountEdit
Definition: videoplayersettings.h:28
MythUICheckBox::valueChanged
void valueChanged()
mythlogging.h
PlayerSettings::m_defaultPlayerEdit
MythUITextEdit * m_defaultPlayerEdit
Definition: videoplayersettings.h:25
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:204
PlayerSettings::m_dvdDriveEdit
MythUITextEdit * m_dvdDriveEdit
Definition: videoplayersettings.h:27
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
PlayerSettings::m_okButton
MythUIButton * m_okButton
Definition: videoplayersettings.h:35
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3715
PlayerSettings::m_dvdPlayerEdit
MythUITextEdit * m_dvdPlayerEdit
Definition: videoplayersettings.h:26
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:57
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:15
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:918
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:402
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
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1105
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1581
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
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:191
PlayerSettings::toggleAlt
void toggleAlt(void)
Definition: videoplayersettings.cpp:138
videoplayersettings.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:904