00001 #include <iostream>
00002
00003
00004 #include <QString>
00005
00006
00007 #include "mythcontext.h"
00008 #include "mythdbcon.h"
00009 #include "mythdirs.h"
00010 #include "mythprogressdialog.h"
00011
00012 #include "videometadatasettings.h"
00013
00014 using namespace std;
00015
00016
00017
00018 MetadataSettings::MetadataSettings(MythScreenStack *parent, const char *name)
00019 : MythScreenType(parent, name),
00020 m_trailerSpin(NULL),
00021 m_unknownFileCheck(NULL), m_autoMetaUpdateCheck(NULL),
00022 m_treeLoadsMetaCheck(NULL), m_randomTrailerCheck(NULL),
00023 m_okButton(NULL), m_cancelButton(NULL)
00024 {
00025 }
00026
00027 bool MetadataSettings::Create()
00028 {
00029 bool foundtheme = false;
00030
00031
00032 foundtheme = LoadWindowFromXML("video-ui.xml", "metadatasettings", this);
00033
00034 if (!foundtheme)
00035 return false;
00036
00037 m_trailerSpin =
00038 dynamic_cast<MythUISpinBox *> (GetChild("trailernum"));
00039
00040 m_unknownFileCheck =
00041 dynamic_cast<MythUICheckBox *> (GetChild("unknownfilecheck"));
00042 m_autoMetaUpdateCheck =
00043 dynamic_cast<MythUICheckBox *> (GetChild("autometaupdatecheck"));
00044 m_treeLoadsMetaCheck =
00045 dynamic_cast<MythUICheckBox *> (GetChild("treeloadsmetacheck"));
00046 m_randomTrailerCheck =
00047 dynamic_cast<MythUICheckBox *> (GetChild("randomtrailercheck"));
00048
00049 m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
00050 m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
00051
00052 if (!m_trailerSpin || !m_autoMetaUpdateCheck ||
00053 !m_unknownFileCheck || !m_treeLoadsMetaCheck ||
00054 !m_randomTrailerCheck ||!m_okButton || !m_cancelButton)
00055 {
00056 LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
00057 return false;
00058 }
00059
00060 int unknownSetting =
00061 gCoreContext->GetNumSetting("VideoListUnknownFiletypes", 0);
00062 if (unknownSetting == 1)
00063 m_unknownFileCheck->SetCheckState(MythUIStateType::Full);
00064
00065 int autoMetaSetting =
00066 gCoreContext->GetNumSetting("mythvideo.AutoMetaDataScan", 1);
00067 if (autoMetaSetting == 1)
00068 m_autoMetaUpdateCheck->SetCheckState(MythUIStateType::Full);
00069
00070 int loadMetaSetting =
00071 gCoreContext->GetNumSetting("VideoTreeLoadMetaData", 1);
00072 if (loadMetaSetting == 1)
00073 m_treeLoadsMetaCheck->SetCheckState(MythUIStateType::Full);
00074
00075 int trailerSetting =
00076 gCoreContext->GetNumSetting("mythvideo.TrailersRandomEnabled", 0);
00077 if (trailerSetting == 1)
00078 m_randomTrailerCheck->SetCheckState(MythUIStateType::Full);
00079
00080 m_trailerSpin->SetRange(0,100,1);
00081 m_trailerSpin->SetValue(gCoreContext->GetNumSetting(
00082 "mythvideo.TrailersRandomCount"));
00083
00084 if (m_randomTrailerCheck->GetCheckState() == MythUIStateType::Full)
00085 m_trailerSpin->SetVisible(true);
00086 else
00087 m_trailerSpin->SetVisible(false);
00088
00089 connect(m_okButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
00090 connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
00091
00092 connect(m_randomTrailerCheck, SIGNAL(valueChanged()),
00093 SLOT(toggleTrailers()));
00094
00095 m_randomTrailerCheck->SetHelpText(
00096 tr("If set, this will enable a button "
00097 "called \"Watch With Trailers\" which will "
00098 "play a user-specified number of trailers "
00099 "before the movie."));
00100 m_trailerSpin->SetHelpText(tr("Number of trailers to play before a film."));
00101 m_unknownFileCheck->SetHelpText(
00102 tr("If set, all files below the MythVideo "
00103 "directory will be displayed unless their "
00104 "extension is explicitly set to be ignored."));
00105 m_autoMetaUpdateCheck->SetHelpText(
00106 tr("If set, every time a scan for new videos "
00107 "is performed, a mass metadata update of the "
00108 "collection will also occur."));
00109 m_treeLoadsMetaCheck->SetHelpText(
00110 tr("If set along with Browse Files, this "
00111 "will cause the Video List to load any known video meta"
00112 "data from the database. Turning this off can greatly "
00113 "speed up how long it takes to load the Video List tree."));
00114 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
00115 m_okButton->SetHelpText(tr("Save settings and Exit"));
00116
00117 BuildFocusList();
00118
00119 return true;
00120 }
00121
00122 MetadataSettings::~MetadataSettings()
00123 {
00124 }
00125
00126 void MetadataSettings::slotSave(void)
00127 {
00128 gCoreContext->SaveSetting("mythvideo.TrailersRandomCount",
00129 m_trailerSpin->GetValue());
00130
00131 int listUnknownState = 0;
00132 if (m_unknownFileCheck->GetCheckState() == MythUIStateType::Full)
00133 listUnknownState = 1;
00134 gCoreContext->SaveSetting("VideoListUnknownFiletypes", listUnknownState);
00135
00136 int autoMetaState = 0;
00137 if (m_autoMetaUpdateCheck->GetCheckState() == MythUIStateType::Full)
00138 autoMetaState = 1;
00139 gCoreContext->SaveSetting("mythvideo.AutoMetaDataScan", autoMetaState);
00140
00141 int loadMetaState = 0;
00142 if (m_treeLoadsMetaCheck->GetCheckState() == MythUIStateType::Full)
00143 loadMetaState = 1;
00144 gCoreContext->SaveSetting("VideoTreeLoadMetaData", loadMetaState);
00145
00146 int trailerState = 0;
00147 if (m_randomTrailerCheck->GetCheckState() == MythUIStateType::Full)
00148 trailerState = 1;
00149 gCoreContext->SaveSetting("mythvideo.TrailersRandomEnabled", trailerState);
00150
00151 Close();
00152 }
00153
00154 bool MetadataSettings::keyPressEvent(QKeyEvent *event)
00155 {
00156 if (GetFocusWidget()->keyPressEvent(event))
00157 return true;
00158
00159 bool handled = false;
00160
00161 if (!handled && MythScreenType::keyPressEvent(event))
00162 handled = true;
00163
00164 return handled;
00165 }
00166
00167 void MetadataSettings::toggleTrailers()
00168 {
00169 int checkstate = 0;
00170 if (m_randomTrailerCheck->GetCheckState() == MythUIStateType::Full)
00171 checkstate = 1;
00172
00173 m_trailerSpin->SetVisible(checkstate);
00174 }