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
41
42 int loadNoWhitespace = gCoreContext->GetNumSetting("NoWhitespace", 0);
43 if (loadNoWhitespace == 1)
45
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
98bool 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}
MythUITextEdit * m_postCDRipScript
MythUITextEdit * m_filenameTemplate
void slotSave(void)
MythUIButtonList * m_paranoiaLevel
MythUIButtonList * m_encoderType
MythUIButton * m_cancelButton
MythUICheckBox * m_noWhitespace
bool Create(void) override
MythUICheckBox * m_ejectCD
MythUIButtonList * m_defaultRipQuality
MythUIButton * m_saveButton
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUICheckBox * m_mp3UseVBR
void SaveSetting(const QString &key, int newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
void dispatch(const MythEvent &event)
int GetNumSetting(const QString &key, int defaultval=0)
This class is used as a container for messages.
Definition: mythevent.h:17
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
virtual void Close()
void SetValueByData(const QVariant &data)
QVariant GetDataValue() const
void Clicked()
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
void SetHelpText(const QString &text)
Definition: mythuitype.h:177
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27