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