MythTV  master
importsettings.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QString>
3 
4 // MythTV
7 
8 // MythMusic
9 #include "importsettings.h"
10 
12 {
13  bool err = false;
14 
15  // Load the theme for this screen
16  if (!LoadWindowFromXML("musicsettings-ui.xml", "importsettings", this))
17  return false;
18 
19  UIUtilE::Assign(this, m_paranoiaLevel, "paranoialevel", &err);
20  UIUtilE::Assign(this, m_filenameTemplate, "filenametemplate", &err);
21  UIUtilE::Assign(this, m_noWhitespace, "nowhitespace", &err);
22  UIUtilE::Assign(this, m_postCDRipScript, "postcdripscript", &err);
23  UIUtilE::Assign(this, m_ejectCD, "ejectcd", &err);
24  UIUtilE::Assign(this, m_encoderType, "encodertype", &err);
25  UIUtilE::Assign(this, m_defaultRipQuality, "defaultripquality", &err);
26  UIUtilE::Assign(this, m_mp3UseVBR, "mp3usevbr", &err);
27  UIUtilE::Assign(this, m_saveButton, "save", &err);
28  UIUtilE::Assign(this, m_cancelButton, "cancel", &err);
29 
30  if (err)
31  {
32  LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'importsettings'");
33  return false;
34  }
35 
36  new MythUIButtonListItem(m_paranoiaLevel, tr("Full"), QVariant::fromValue(QString("Full")));
37  new MythUIButtonListItem(m_paranoiaLevel, tr("Faster"), QVariant::fromValue(QString("Faster")));
39 
40  m_filenameTemplate->SetText(gCoreContext->GetSetting("FilenameTemplate"));
41 
42  int loadNoWhitespace = gCoreContext->GetNumSetting("NoWhitespace", 0);
43  if (loadNoWhitespace == 1)
45 
46  m_postCDRipScript->SetText(gCoreContext->GetSetting("PostCDRipScript"));
47 
48  int loadEjectCD = gCoreContext->GetNumSetting("EjectCDAfterRipping", 0);
49  if (loadEjectCD == 1)
51 
52  new MythUIButtonListItem(m_encoderType, tr("Ogg Vorbis"), QVariant::fromValue(QString("ogg")));
53  new MythUIButtonListItem(m_encoderType, tr("Lame (MP3)"), QVariant::fromValue(QString("mp3")));
55 
56  new MythUIButtonListItem(m_defaultRipQuality, tr("Low"), QVariant::fromValue(0));
57  new MythUIButtonListItem(m_defaultRipQuality, tr("Medium"), QVariant::fromValue(1));
58  new MythUIButtonListItem(m_defaultRipQuality, tr("High"), QVariant::fromValue(2));
59  new MythUIButtonListItem(m_defaultRipQuality, tr("Perfect"), QVariant::fromValue(3));
61 
62  int loadMp3UseVBR = gCoreContext->GetNumSetting("Mp3UseVBR", 0);
63  if (loadMp3UseVBR == 1)
65 
68 
69  m_paranoiaLevel->SetHelpText(tr("Paranoia level of the CD ripper. Set to "
70  "faster if you're not concerned about "
71  "possible errors in the audio."));
72  m_filenameTemplate->SetHelpText(tr("Defines the location/name for new "
73  "songs. Valid tokens are:\n"
74  "GENRE, ARTIST, ALBUM, TRACK, TITLE, YEAR"));
75  m_noWhitespace->SetHelpText(tr("If set, whitespace characters in filenames "
76  "will be replaced with underscore characters."));
77  m_postCDRipScript->SetHelpText(tr("If present this script will be executed "
78  "after a CD Rip is completed."));
79  m_ejectCD->SetHelpText(tr("If set, the CD tray will automatically open "
80  "after the CD has been ripped."));
81  m_encoderType->SetHelpText(tr("Audio encoder to use for CD ripping. "
82  "Note that the quality level 'Perfect' "
83  "will use the FLAC encoder."));
84  m_defaultRipQuality->SetHelpText(tr("Default quality for new CD rips."));
85  m_mp3UseVBR->SetHelpText(tr("If set, the MP3 encoder will use variable "
86  "bitrates (VBR) except for the low quality setting. "
87  "The Ogg encoder will always use variable bitrates."));
88  m_cancelButton->SetHelpText(tr("Exit without saving settings"));
89  m_saveButton->SetHelpText(tr("Save settings and Exit"));
90 
92 
94 
95  return true;
96 }
97 
98 bool ImportSettings::keyPressEvent(QKeyEvent *event)
99 {
100  if (GetFocusWidget()->keyPressEvent(event))
101  return true;
102 
103  return MythScreenType::keyPressEvent(event);
104 }
105 
107 {
108  gCoreContext->SaveSetting("ParanoiaLevel", m_paranoiaLevel->GetDataValue().toString());
109  gCoreContext->SaveSetting("FilenameTemplate", m_filenameTemplate->GetText());
110  gCoreContext->SaveSetting("PostCDRipScript", m_postCDRipScript->GetText());
111  gCoreContext->SaveSetting("EncoderType", m_encoderType->GetDataValue().toString());
112  gCoreContext->SaveSetting("DefaultRipQuality", m_defaultRipQuality->GetDataValue().toString());
113 
114  int saveNoWhitespace = (m_noWhitespace->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
115  gCoreContext->SaveSetting("Ignore_ID3", saveNoWhitespace);
116 
117  int saveEjectCD = (m_ejectCD->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
118  gCoreContext->SaveSetting("EjectCDAfterRipping", saveEjectCD);
119 
120  int saveMp3UseVBR = (m_mp3UseVBR->GetCheckState() == MythUIStateType::Full) ? 1 : 0;
121  gCoreContext->SaveSetting("Mp3UseVBR", saveMp3UseVBR);
122 
123  gCoreContext->dispatch(MythEvent(QString("MUSIC_SETTINGS_CHANGED IMPORT_SETTINGS")));
124 
125  Close();
126 }
MythUIButton::Clicked
void Clicked()
ImportSettings::m_saveButton
MythUIButton * m_saveButton
Definition: importsettings.h:31
MythUIButtonList::SetValueByData
void SetValueByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1566
ImportSettings::m_encoderType
MythUIButtonList * m_encoderType
Definition: importsettings.h:28
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:384
ImportSettings::m_postCDRipScript
MythUITextEdit * m_postCDRipScript
Definition: importsettings.h:26
ImportSettings::m_cancelButton
MythUIButton * m_cancelButton
Definition: importsettings.h:32
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
ImportSettings::m_noWhitespace
MythUICheckBox * m_noWhitespace
Definition: importsettings.h:25
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythUITextEdit::GetText
QString GetText(void) const
Definition: mythuitextedit.h:50
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:111
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:198
ImportSettings::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: importsettings.cpp:98
mythlogging.h
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:116
MythUIType::SetHelpText
void SetHelpText(const QString &text)
Definition: mythuitype.h:175
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:204
MythUIButtonList::GetDataValue
QVariant GetDataValue() const
Definition: mythuibuttonlist.cpp:1643
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:57
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:918
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:402
ImportSettings::m_ejectCD
MythUICheckBox * m_ejectCD
Definition: importsettings.h:27
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
ImportSettings::Create
bool Create(void) override
Definition: importsettings.cpp:11
ImportSettings::slotSave
void slotSave(void)
Definition: importsettings.cpp:106
MythUIStateType::Full
@ Full
Definition: mythuistatetype.h:27
ImportSettings::m_filenameTemplate
MythUITextEdit * m_filenameTemplate
Definition: importsettings.h:24
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:887
MythUICheckBox::GetCheckState
MythUIStateType::StateType GetCheckState() const
Definition: mythuicheckbox.cpp:98
ImportSettings::m_defaultRipQuality
MythUIButtonList * m_defaultRipQuality
Definition: importsettings.h:29
ImportSettings::m_mp3UseVBR
MythUICheckBox * m_mp3UseVBR
Definition: importsettings.h:30
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1729
ImportSettings::m_paranoiaLevel
MythUIButtonList * m_paranoiaLevel
Definition: importsettings.h:23
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:904
importsettings.h