MythTV  master
videoplayersettings.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 // Qt
4 #include <QString>
5 
6 // MythTV
7 #include "mythcontext.h"
8 #include "mythdbcon.h"
9 #include "mythdirs.h"
10 
11 #include "videoplayersettings.h"
12 
13 // ---------------------------------------------------
14 
16 {
17  // Load the theme for this screen
18  bool foundtheme = LoadWindowFromXML("video-ui.xml", "playersettings", this);
19  if (!foundtheme)
20  return false;
21 
23  dynamic_cast<MythUITextEdit *> (GetChild("defaultplayer"));
24  m_dvdPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvdplayer"));
25  m_dvdDriveEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvddrive"));
27  dynamic_cast<MythUITextEdit *> (GetChild("bluraymount"));
28  m_altPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("altplayer"));
29 
31  dynamic_cast<MythUIButtonList *> (GetChild("blurayregionlist"));
32 
33  m_altCheck = dynamic_cast<MythUICheckBox *> (GetChild("altcheck"));
34 
35  m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
36  m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
37 
41  {
42  LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
43  return false;
44  }
45 
46  int setting =
47  gCoreContext->GetNumSetting("mythvideo.EnableAlternatePlayer", 0);
48  if (setting == 1)
50 
51  m_defaultPlayerEdit->SetText(gCoreContext->GetSetting("VideoDefaultPlayer",
52  "Internal"));
54  GetSetting("mythdvd.DVDPlayerCommand", "Internal"));
55  m_dvdDriveEdit->SetText(gCoreContext->GetSetting("DVDDeviceLocation",
56  "default"));
57  m_blurayMountEdit->SetText(gCoreContext->GetSetting("BluRayMountpoint",
58  "/media/cdrom"));
60  "mythvideo.VideoAlternatePlayer", "Internal"));
61 
64  else
66 
69 
71 
73  tr("This is the command used for any file "
74  "whose extension is not specifically defined. "
75  "You may also enter the name of one of the playback "
76  "plugins such as 'Internal'."));
78  tr("This can be any command to launch a DVD "
79  " player. Internal is the default. For other players, %d "
80  "will be substituted for the DVD device (e.g. /dev/dvd)."));
82  tr("This device must exist, and the user "
83  "playing the DVD needs to have read permission "
84  "on the device. 'default' will let the "
85  "MediaMonitor choose a device."));
87  tr("This path is the location your "
88  "operating system mounts Blu-ray discs."));
90  tr("If for some reason the default player "
91  "doesn't play a video, you can play it in an alternate "
92  "player by selecting 'Play in Alternate Player.'"));
94  tr("Some Blu-ray discs require that a player region be "
95  "explicitly set. Only change the value from "
96  "'No Region' if you encounter a disc which "
97  "fails to play citing a region mismatch."));
98  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
99  m_okButton->SetHelpText(tr("Save settings and Exit"));
100 
101  fillRegionList();
102 
103  BuildFocusList();
104 
105  return true;
106 }
107 
109 {
110  gCoreContext->SaveSetting("VideoDefaultPlayer", m_defaultPlayerEdit->GetText());
111  gCoreContext->SaveSetting("mythdvd.DVDPlayerCommand", m_dvdPlayerEdit->GetText());
112  gCoreContext->SaveSetting("DVDDeviceLocation", m_dvdDriveEdit->GetText());
113  gCoreContext->SaveSetting("BluRayMountpoint", m_blurayMountEdit->GetText());
114  gCoreContext->SaveSetting("mythvideo.VideoAlternatePlayer", m_altPlayerEdit->GetText());
115 
116  gCoreContext->SaveSetting("BlurayRegionCode",
118 
119  int checkstate = 0;
121  checkstate = 1;
122  gCoreContext->SaveSetting("mythvideo.EnableAlternatePlayer", checkstate);
123 
124  Close();
125 }
126 
127 bool PlayerSettings::keyPressEvent(QKeyEvent *event)
128 {
129  if (GetFocusWidget()->keyPressEvent(event))
130  return true;
131 
132  return MythScreenType::keyPressEvent(event);
133 }
134 
136 {
137  int checkstate = 0;
139  checkstate = 1;
140 
141  m_altPlayerEdit->SetVisible(checkstate != 0);
142 }
143 
145 {
146  auto *noRegion =
147  new MythUIButtonListItem(m_blurayRegionList, tr("No Region"));
148  noRegion->SetData(0);
149 
150  auto *regionA =
151  new MythUIButtonListItem(m_blurayRegionList, tr("Region A: "
152  "The Americas, Southeast Asia, Japan"));
153  regionA->SetData(1);
154 
155  auto *regionB =
156  new MythUIButtonListItem(m_blurayRegionList, tr("Region B: "
157  "Europe, Middle East, Africa, Oceania"));
158  regionB->SetData(2);
159 
160  auto *regionC =
161  new MythUIButtonListItem(m_blurayRegionList, tr("Region C: "
162  "Eastern Europe, Central and South Asia"));
163  regionC->SetData(4);
164 
165  int region = gCoreContext->GetNumSetting("BlurayRegionCode", 0);
166 
168 
169  if (item)
171 }
MythUIButton::Clicked
void Clicked()
PlayerSettings::fillRegionList
void fillRegionList(void)
Definition: videoplayersettings.cpp:144
MythUIButtonList::GetItemCurrent
MythUIButtonListItem * GetItemCurrent() const
Definition: mythuibuttonlist.cpp:1590
PlayerSettings::slotSave
void slotSave(void)
Definition: videoplayersettings.cpp:108
PlayerSettings::m_altPlayerEdit
MythUITextEdit * m_altPlayerEdit
Definition: videoplayersettings.h:29
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:402
MythUIType::GetChild
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:131
mythdbcon.h
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:33
PlayerSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: videoplayersettings.cpp:127
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythUITextEdit::GetText
QString GetText(void) const
Definition: mythuitextedit.h:47
PlayerSettings::Create
bool Create(void) override
Definition: videoplayersettings.cpp:15
mythdirs.h
PlayerSettings::m_altCheck
MythUICheckBox * m_altCheck
Definition: videoplayersettings.h:33
MythUIButtonList::GetItemByData
MythUIButtonListItem * GetItemByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1684
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
PlayerSettings::m_blurayRegionList
MythUIButtonList * m_blurayRegionList
Definition: videoplayersettings.h:31
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:216
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:172
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
PlayerSettings::m_dvdDriveEdit
MythUITextEdit * m_dvdDriveEdit
Definition: videoplayersettings.h:27
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
GetSetting
t<< doc.toString(4);f.close();LOG(VB_JOBQUEUE, LOG_INFO, "Copying video file");bool res=copyFile(filename, saveDirectory+title+"/"+baseName);if(!res) return 0;if(QFile::exists(filename+".png")) { LOG(VB_JOBQUEUE, LOG_INFO, "Copying preview image");res=copyFile(filename+".png", saveDirectory+title+"/"+baseName+".png");if(!res) return 0;} LOG(VB_JOBQUEUE, LOG_INFO, "Item Archived OK");return 1;}int NativeArchive::exportVideo(QDomElement &itemNode, const QString &saveDirectory){ QString dbVersion=gCoreContext-> GetSetting("DBSchemaVer", "")
PlayerSettings::m_okButton
MythUIButton * m_okButton
Definition: videoplayersettings.h:35
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:25
MythUIButtonListItem::GetData
QVariant GetData()
Definition: mythuibuttonlist.cpp:3580
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:60
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:16
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:933
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
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
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1086
mythcontext.h
MythUIButtonList::SetItemCurrent
void SetItemCurrent(MythUIButtonListItem *item)
Definition: mythuibuttonlist.cpp:1557
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:902
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:152
PlayerSettings::toggleAlt
void toggleAlt(void)
Definition: videoplayersettings.cpp:135
videoplayersettings.h
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:919