00001 #include <iostream>
00002 using namespace std;
00003
00004
00005 #include <QString>
00006
00007
00008 #include "mythcontext.h"
00009 #include "mythdbcon.h"
00010 #include "mythdirs.h"
00011
00012 #include "videoplayersettings.h"
00013
00014
00015
00016 PlayerSettings::PlayerSettings(MythScreenStack *parent, const char *name)
00017 : MythScreenType(parent, name),
00018 m_defaultPlayerEdit(NULL), m_dvdPlayerEdit(NULL),
00019 m_dvdDriveEdit(NULL), m_blurayMountEdit(NULL),
00020 m_altPlayerEdit(NULL), m_blurayRegionList(NULL),
00021 m_altCheck(NULL), m_okButton(NULL),
00022 m_cancelButton(NULL)
00023 {
00024 }
00025
00026 bool PlayerSettings::Create()
00027 {
00028 bool foundtheme = false;
00029
00030
00031 foundtheme = LoadWindowFromXML("video-ui.xml", "playersettings", this);
00032
00033 if (!foundtheme)
00034 return false;
00035
00036 m_defaultPlayerEdit =
00037 dynamic_cast<MythUITextEdit *> (GetChild("defaultplayer"));
00038 m_dvdPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvdplayer"));
00039 m_dvdDriveEdit = dynamic_cast<MythUITextEdit *> (GetChild("dvddrive"));
00040 m_blurayMountEdit =
00041 dynamic_cast<MythUITextEdit *> (GetChild("bluraymount"));
00042 m_altPlayerEdit = dynamic_cast<MythUITextEdit *> (GetChild("altplayer"));
00043
00044 m_blurayRegionList =
00045 dynamic_cast<MythUIButtonList *> (GetChild("blurayregionlist"));
00046
00047 m_altCheck = dynamic_cast<MythUICheckBox *> (GetChild("altcheck"));
00048
00049 m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
00050 m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
00051
00052 if (!m_defaultPlayerEdit || !m_dvdPlayerEdit || !m_blurayRegionList ||
00053 !m_altCheck || !m_altPlayerEdit || !m_dvdDriveEdit ||
00054 !m_blurayMountEdit || !m_okButton || !m_cancelButton)
00055 {
00056 LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
00057 return false;
00058 }
00059
00060 int setting =
00061 gCoreContext->GetNumSetting("mythvideo.EnableAlternatePlayer", 0);
00062 if (setting == 1)
00063 m_altCheck->SetCheckState(MythUIStateType::Full);
00064
00065 m_defaultPlayerEdit->SetText(gCoreContext->GetSetting("VideoDefaultPlayer",
00066 "Internal"));
00067 m_dvdPlayerEdit->SetText(gCoreContext->
00068 GetSetting("mythdvd.DVDPlayerCommand", "Internal"));
00069 m_dvdDriveEdit->SetText(gCoreContext->GetSetting("DVDDeviceLocation",
00070 "default"));
00071 m_blurayMountEdit->SetText(gCoreContext->GetSetting("BluRayMountpoint",
00072 "/media/cdrom"));
00073 m_altPlayerEdit->SetText(gCoreContext->GetSetting(
00074 "mythvideo.VideoAlternatePlayer", "Internal"));
00075
00076 if (m_altCheck->GetCheckState() == MythUIStateType::Full)
00077 m_altPlayerEdit->SetVisible(true);
00078 else
00079 m_altPlayerEdit->SetVisible(false);
00080
00081 connect(m_okButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
00082 connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
00083
00084 connect(m_altCheck, SIGNAL(valueChanged()), SLOT(toggleAlt()));
00085
00086 m_defaultPlayerEdit->SetHelpText(
00087 tr("This is the command used for any file "
00088 "whose extension is not specifically defined. "
00089 "You may also enter the name of one of the playback "
00090 "plugins such as 'Internal'."));
00091 m_dvdPlayerEdit->SetHelpText(
00092 tr("This can be any command to launch a DVD "
00093 " player. Internal is the default. For other players, %d "
00094 "will be substituted for the DVD device (e.g. /dev/dvd)."));
00095 m_dvdDriveEdit->SetHelpText(
00096 tr("This device must exist, and the user "
00097 "playing the DVD needs to have read permission "
00098 "on the device. 'default' will let the "
00099 "MediaMonitor choose a device."));
00100 m_blurayMountEdit->SetHelpText(
00101 tr("This path is the location your "
00102 "operating system mounts Blu-ray discs."));
00103 m_altPlayerEdit->SetHelpText(
00104 tr("If for some reason the default player "
00105 "doesn't play a video, you can play it in an alternate "
00106 "player by selecting 'Play in Alternate Player.'"));
00107 m_blurayRegionList->SetHelpText(
00108 tr("Some Blu-ray discs require that a player region be "
00109 "explicitly set. Only change the value from "
00110 "'No Region' if you encounter a disc which "
00111 "fails to play citing a region mismatch."));
00112 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
00113 m_okButton->SetHelpText(tr("Save settings and Exit"));
00114
00115 fillRegionList();
00116
00117 BuildFocusList();
00118
00119 return true;
00120 }
00121
00122 PlayerSettings::~PlayerSettings()
00123 {
00124 }
00125
00126 void PlayerSettings::slotSave(void)
00127 {
00128 gCoreContext->SaveSetting("VideoDefaultPlayer", m_defaultPlayerEdit->GetText());
00129 gCoreContext->SaveSetting("mythdvd.DVDPlayerCommand", m_dvdPlayerEdit->GetText());
00130 gCoreContext->SaveSetting("DVDDeviceLocation", m_dvdDriveEdit->GetText());
00131 gCoreContext->SaveSetting("BluRayMountpoint", m_blurayMountEdit->GetText());
00132 gCoreContext->SaveSetting("mythvideo.VideoAlternatePlayer", m_altPlayerEdit->GetText());
00133
00134 gCoreContext->SaveSetting("BlurayRegionCode",
00135 m_blurayRegionList->GetItemCurrent()->GetData().toInt());
00136
00137 int checkstate = 0;
00138 if (m_altCheck->GetCheckState() == MythUIStateType::Full)
00139 checkstate = 1;
00140 gCoreContext->SaveSetting("mythvideo.EnableAlternatePlayer", checkstate);
00141
00142 Close();
00143 }
00144
00145 bool PlayerSettings::keyPressEvent(QKeyEvent *event)
00146 {
00147 if (GetFocusWidget()->keyPressEvent(event))
00148 return true;
00149
00150 bool handled = false;
00151
00152 if (!handled && MythScreenType::keyPressEvent(event))
00153 handled = true;
00154
00155 return handled;
00156 }
00157
00158 void PlayerSettings::toggleAlt()
00159 {
00160 int checkstate = 0;
00161 if (m_altCheck->GetCheckState() == MythUIStateType::Full)
00162 checkstate = 1;
00163
00164 m_altPlayerEdit->SetVisible(checkstate);
00165 }
00166
00167 void PlayerSettings::fillRegionList()
00168 {
00169 MythUIButtonListItem *noRegion =
00170 new MythUIButtonListItem(m_blurayRegionList, QString("No Region"));
00171 noRegion->SetData(0);
00172
00173 MythUIButtonListItem *regionA =
00174 new MythUIButtonListItem(m_blurayRegionList, QString("Region A: "
00175 "The Americas, Southeast Asia, Japan"));
00176 regionA->SetData(1);
00177
00178 MythUIButtonListItem *regionB =
00179 new MythUIButtonListItem(m_blurayRegionList, QString("Region B: "
00180 "Europe, Middle East, Africa, Oceania"));
00181 regionB->SetData(2);
00182
00183 MythUIButtonListItem *regionC =
00184 new MythUIButtonListItem(m_blurayRegionList, QString("Region C: "
00185 "Eastern Europe, Central and South Asia"));
00186 regionC->SetData(4);
00187
00188 int region = gCoreContext->GetNumSetting("BlurayRegionCode", 0);
00189
00190 MythUIButtonListItem *item = m_blurayRegionList->GetItemByData(region);
00191
00192 if (item)
00193 m_blurayRegionList->SetItemCurrent(item);
00194 }
00195