00001
00002 #include <QString>
00003
00004
00005 #include <mythcorecontext.h>
00006
00007 #include "visualizationsettings.h"
00008
00009 VisualizationSettings::VisualizationSettings(MythScreenStack *parent, const char *name)
00010 : MythScreenType(parent, name),
00011 m_changeOnSongChange(NULL),
00012 m_randomizeOrder(NULL),
00013 m_scaleWidth(NULL),
00014 m_scaleHeight(NULL),
00015 m_saveButton(NULL),
00016 m_cancelButton(NULL)
00017 {
00018 }
00019
00020 VisualizationSettings::~VisualizationSettings()
00021 {
00022
00023 }
00024
00025 bool VisualizationSettings::Create()
00026 {
00027 bool err = false;
00028
00029
00030 if (!LoadWindowFromXML("musicsettings-ui.xml", "visualizationsettings", this))
00031 return false;
00032
00033 UIUtilE::Assign(this, m_changeOnSongChange, "cycleonsongchange", &err);
00034 UIUtilE::Assign(this, m_randomizeOrder, "randomizeorder", &err);
00035 UIUtilE::Assign(this, m_scaleWidth, "scalewidth", &err);
00036 UIUtilE::Assign(this, m_scaleHeight, "scaleheight", &err);
00037 UIUtilE::Assign(this, m_saveButton, "save", &err);
00038 UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
00039
00040 int changeOnSongChange = gCoreContext->GetNumSetting("VisualCycleOnSongChange", 0);
00041 if (changeOnSongChange == 1)
00042 m_changeOnSongChange->SetCheckState(MythUIStateType::Full);
00043 int randomizeorder = gCoreContext->GetNumSetting("VisualRandomize", 0);
00044 if (randomizeorder == 1)
00045 m_randomizeOrder->SetCheckState(MythUIStateType::Full);
00046
00047 m_scaleWidth->SetRange(1,2,1);
00048 m_scaleWidth->SetValue(gCoreContext->GetNumSetting("VisualScaleWidth"));
00049 m_scaleHeight->SetRange(1,2,1);
00050 m_scaleHeight->SetValue(gCoreContext->GetNumSetting("VisualScaleHeight"));
00051
00052 m_changeOnSongChange->SetHelpText(tr("Change the visualizer when the song changes."));
00053 m_randomizeOrder->SetHelpText(tr("On changing the visualizer pick a new one at random."));
00054 m_scaleWidth->SetHelpText(tr("If set to \"2\", visualizations will be "
00055 "scaled in half. Currently only used by "
00056 "the goom visualization. Reduces CPU load "
00057 "on slower machines."));
00058 m_scaleHeight->SetHelpText(tr("If set to \"2\", visualizations will be "
00059 "scaled in half. Currently only used by "
00060 "the goom visualization. Reduces CPU load "
00061 "on slower machines."));
00062 m_cancelButton->SetHelpText(tr("Exit without saving settings"));
00063 m_saveButton->SetHelpText(tr("Save settings and Exit"));
00064
00065 connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
00066 connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
00067
00068 BuildFocusList();
00069
00070 SetFocusWidget(m_cancelButton);
00071
00072 return true;
00073 }
00074
00075 void VisualizationSettings::slotSave(void)
00076 {
00077 int changeOnSongChange = (m_changeOnSongChange->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00078 gCoreContext->SaveSetting("VisualCycleOnSongChange", changeOnSongChange);
00079 int randomizeorder = (m_randomizeOrder->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
00080 gCoreContext->SaveSetting("VisualRandomize", randomizeorder);
00081
00082 gCoreContext->SaveSetting("VisualScaleWidth", m_scaleWidth->GetIntValue());
00083 gCoreContext->SaveSetting("VisualScaleHeight", m_scaleHeight->GetIntValue());
00084
00085 gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED VISUALIZATION_SETTINGS")));
00086
00087 Close();
00088 }