MythTV  master
visualizationsettings.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QString>
3 
4 // MythTV
6 
8 
10 {
11  bool err = false;
12 
13  // Load the theme for this screen
14  if (!LoadWindowFromXML("musicsettings-ui.xml", "visualizationsettings", this))
15  return false;
16 
17  UIUtilE::Assign(this, m_changeOnSongChange, "cycleonsongchange", &err);
18  UIUtilE::Assign(this, m_randomizeOrder, "randomizeorder", &err);
19  UIUtilE::Assign(this, m_scaleWidth, "scalewidth", &err);
20  UIUtilE::Assign(this, m_scaleHeight, "scaleheight", &err);
21  UIUtilE::Assign(this, m_saveButton, "save", &err);
22  UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
23 
24  if (err)
25  {
26  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'visualizationsettings'");
27  return false;
28  }
29 
30  int changeOnSongChange = gCoreContext->GetNumSetting("VisualCycleOnSongChange", 0);
31  if (changeOnSongChange == 1)
33  int randomizeorder = gCoreContext->GetNumSetting("VisualRandomize", 0);
34  if (randomizeorder == 1)
36 
37  m_scaleWidth->SetRange(1,4,1);
38  m_scaleWidth->SetValue(gCoreContext->GetNumSetting("VisualScaleWidth"));
39  m_scaleHeight->SetRange(1,4,1);
40  m_scaleHeight->SetValue(gCoreContext->GetNumSetting("VisualScaleHeight"));
41 
42  m_changeOnSongChange->SetHelpText(tr("Change the visualizer when the song changes."));
43  m_randomizeOrder->SetHelpText(tr("On changing the visualizer pick a new one at random."));
44  m_scaleWidth->SetHelpText(tr("If set to \"2\", visualizations will be "
45  "scaled in half. Currently only used by "
46  "the goom visualization. Reduces CPU load "
47  "on slower machines."));
48  m_scaleHeight->SetHelpText(tr("If set to \"2\", visualizations will be "
49  "scaled in half. Currently only used by "
50  "the goom visualization. Reduces CPU load "
51  "on slower machines."));
52  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
53  m_saveButton->SetHelpText(tr("Save settings and Exit"));
54 
57 
59 
61 
62  return true;
63 }
64 
66 {
67  int changeOnSongChange = (m_changeOnSongChange->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
68  gCoreContext->SaveSetting("VisualCycleOnSongChange", changeOnSongChange);
69  int randomizeorder = (m_randomizeOrder->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
70  gCoreContext->SaveSetting("VisualRandomize", randomizeorder);
71 
72  gCoreContext->SaveSetting("VisualScaleWidth", m_scaleWidth->GetIntValue());
73  gCoreContext->SaveSetting("VisualScaleHeight", m_scaleHeight->GetIntValue());
74 
75  gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED VISUALIZATION_SETTINGS")));
76 
77  Close();
78 }
MythUIButton::Clicked
void Clicked()
VisualizationSettings::m_scaleHeight
MythUISpinBox * m_scaleHeight
Definition: visualizationsettings.h:23
VisualizationSettings::slotSave
void slotSave(void)
Definition: visualizationsettings.cpp:65
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:383
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
VisualizationSettings::m_randomizeOrder
MythUICheckBox * m_randomizeOrder
Definition: visualizationsettings.h:21
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythUISpinBox::SetRange
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
Definition: mythuispinbox.cpp:26
VisualizationSettings::Create
bool Create(void) override
Definition: visualizationsettings.cpp:9
MythUISpinBox::SetValue
void SetValue(int val) override
Definition: mythuispinbox.h:26
VisualizationSettings::m_changeOnSongChange
MythUICheckBox * m_changeOnSongChange
Definition: visualizationsettings.h:20
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:115
MythUISpinBox::GetIntValue
int GetIntValue(void) const override
Definition: mythuispinbox.h:33
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:203
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
VisualizationSettings::m_saveButton
MythUIButton * m_saveButton
Definition: visualizationsettings.h:24
mythcorecontext.h
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:701
visualizationsettings.h
VisualizationSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: visualizationsettings.h:25
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:27
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:885
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1727
VisualizationSettings::m_scaleWidth
MythUISpinBox * m_scaleWidth
Definition: visualizationsettings.h:22