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