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
8 #include "libmyth/mythcontext.h"
10 #include "libmythbase/mythdirs.h"
11 
12 // MythFrontend
13 #include "videoplayersettings.h"
14 
15 // ---------------------------------------------------
16 
18 {
19  // Load the theme for this screen
20  bool foundtheme = LoadWindowFromXML("video-ui.xml", "playersettings", this);
21  if (!foundtheme)
22  return false;
23 
25  dynamic_cast<MythUITextEdit *> (GetChild("defaultplayer"));
26  m_dvdPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvdplayer"));
27  m_dvdDriveEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvddrive"));
29  dynamic_cast<MythUITextEdit *> (GetChild("bluraymount"));
30  m_altPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("altplayer"));
31 
33  dynamic_cast<MythUIButtonList *> (GetChild("blurayregionlist"));
34 
35  m_altCheck = dynamic_cast<MythUICheckBox *> (GetChild("altcheck"));
36 
37  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
38  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
39 
43  {
44  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
45  return false;
46  }
47 
48  int setting =
49  gCoreContext->GetNumSetting("mythvideo.EnableAlternatePlayer", 0);
50  if (setting == 1)
52 
53  m_defaultPlayerEdit->SetText(gCoreContext->GetSetting("VideoDefaultPlayer",
54  "Internal"));
56  GetSetting("mythdvd.DVDPlayerCommand", "Internal"));
57  m_dvdDriveEdit->SetText(gCoreContext->GetSetting("DVDDeviceLocation",
58  "default"));
59  m_blurayMountEdit->SetText(gCoreContext->GetSetting("BluRayMountpoint",
60  "/media/cdrom"));
62  "mythvideo.VideoAlternatePlayer", "Internal"));
63 
66  else
68 
71 
73 
75  tr("This is the command used for any file "
76  "whose extension is not specifically defined. "
77  "You may also enter the name of one of the playback "
78  "plugins such as 'Internal'."));
80  tr("This can be any command to launch a DVD "
81  " player. Internal is the default. For other players, %d "
82  "will be substituted for the DVD device (e.g. /dev/dvd)."));
84  tr("This device must exist, and the user "
85  "playing the DVD needs to have read permission "
86  "on the device. 'default' will let the "
87  "MediaMonitor choose a device."));
89  tr("This path is the location your "
90  "operating system mounts Blu-ray discs."));
92  tr("If for some reason the default player "
93  "doesn't play a video, you can play it in an alternate "
94  "player by selecting 'Play in Alternate Player.'"));
96  tr("Some Blu-ray discs require that a player region be "
97  "explicitly set. Only change the value from "
98  "'No Region' if you encounter a disc which "
99  "fails to play citing a region mismatch."));
100  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
101  m_okButton->SetHelpText(tr("Save settings and Exit"));
102 
103  fillRegionList();
104 
105  BuildFocusList();
106 
107  return true;
108 }
109 
111 {
112  gCoreContext->SaveSetting("VideoDefaultPlayer", m_defaultPlayerEdit->GetText());
113  gCoreContext->SaveSetting("mythdvd.DVDPlayerCommand", m_dvdPlayerEdit->GetText());
114  gCoreContext->SaveSetting("DVDDeviceLocation", m_dvdDriveEdit->GetText());
115  gCoreContext->SaveSetting("BluRayMountpoint", m_blurayMountEdit->GetText());
116  gCoreContext->SaveSetting("mythvideo.VideoAlternatePlayer", m_altPlayerEdit->GetText());
117 
118  gCoreContext->SaveSetting("BlurayRegionCode",
120 
121  int checkstate = 0;
123  checkstate = 1;
124  gCoreContext->SaveSetting("mythvideo.EnableAlternatePlayer", checkstate);
125 
126  Close();
127 }
128 
129 bool PlayerSettings::keyPressEvent(QKeyEvent *event)
130 {
131  if (GetFocusWidget()->keyPressEvent(event))
132  return true;
133 
134  return MythScreenType::keyPressEvent(event);
135 }
136 
138 {
139  int checkstate = 0;
141  checkstate = 1;
142 
143  m_altPlayerEdit->SetVisible(checkstate != 0);
144 }
145 
147 {
148  auto *noRegion =
149  new MythUIButtonListItem(m_blurayRegionList, tr("No Region"));
150  noRegion->SetData(0);
151 
152  auto *regionA =
153  new MythUIButtonListItem(m_blurayRegionList, tr("Region A: "
154  "The Americas, Southeast Asia, Japan"));
155  regionA->SetData(1);
156 
157  auto *regionB =
158  new MythUIButtonListItem(m_blurayRegionList, tr("Region B: "
159  "Europe, Middle East, Africa, Oceania"));
160  regionB->SetData(2);
161 
162  auto *regionC =
163  new MythUIButtonListItem(m_blurayRegionList, tr("Region C: "
164  "Eastern Europe, Central and South Asia"));
165  regionC->SetData(4);
166 
167  int region = gCoreContext->GetNumSetting("BlurayRegionCode", 0);
168 
170 
171  if (item)
173 }
MythUIButton::Clicked
void Clicked()
PlayerSettings::fillRegionList
void fillRegionList(void)
Definition: videoplayersettings.cpp:146
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1614
PlayerSettings::slotSave
void slotSave(void)
Definition: videoplayersettings.cpp:110
PlayerSettings::m_altPlayerEdit
MythUITextEdit * m_altPlayerEdit
Definition: videoplayersettings.h:29
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:383
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:129
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:17
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:110
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()
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:203
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:55
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:916
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:401
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
mythcontext.h
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:885
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:137
videoplayersettings.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:902