MythTV  master
visualizationsettings.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QString>
3 
4 // MythTV
5 #include <mythcorecontext.h>
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 
55  connect(m_saveButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
56  connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
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 }
bool Create(void) override
MythUIStateType::StateType GetCheckState() const
void SaveSetting(const QString &key, int newValue)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void SetValue(int val) override
Definition: mythuispinbox.h:26
void BuildFocusList(void)
int GetIntValue(void) const override
Definition: mythuispinbox.h:33
virtual void Close()
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.
This class is used as a container for messages.
Definition: mythevent.h:16
void SetHelpText(const QString &text)
Definition: mythuitype.h:150
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void dispatch(const MythEvent &event)
MythUICheckBox * m_randomizeOrder
int GetNumSetting(const QString &key, int defaultval=0)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
void SetCheckState(MythUIStateType::StateType state)
MythUICheckBox * m_changeOnSongChange
bool SetFocusWidget(MythUIType *widget=nullptr)