confgui: shared change: add str defautls

This commit is contained in:
Jean-Francois Dockes 2021-11-11 18:46:09 +01:00
parent 9e2e73a995
commit 43f2692d1d
2 changed files with 18 additions and 4 deletions

View File

@ -475,7 +475,9 @@ void ConfParamStrW::storeValue()
void ConfParamStrW::loadValue()
{
string s;
m_cflink->get(s);
if (!m_cflink->get(s)) {
s = m_strdefault;
}
if (m_fsencoding) {
#ifdef _WIN32
m_le->setText(m_origvalue = QString::fromUtf8(s.c_str()));
@ -529,7 +531,9 @@ void ConfParamCStrW::storeValue()
void ConfParamCStrW::loadValue()
{
string s;
m_cflink->get(s);
if (!m_cflink->get(s)) {
s = m_strdefault;
}
QString cs;
if (m_fsencoding) {
#ifdef _WIN32
@ -640,7 +644,9 @@ void ConfParamFNW::storeValue()
void ConfParamFNW::loadValue()
{
string s;
m_cflink->get(s);
if (!m_cflink->get(s)) {
s = m_strdefault;
}
#ifdef _WIN32
m_le->setText(m_origvalue = QString::fromUtf8(s.c_str()));
#else
@ -784,7 +790,9 @@ void ConfParamSLW::storeValue()
void ConfParamSLW::loadValue()
{
m_origvalue.clear();
m_cflink->get(m_origvalue);
if (!m_cflink->get(m_origvalue)) {
m_origvalue = m_strdefault;
}
vector<string> ls;
stringToStrings(m_origvalue, ls);
QStringList qls;

View File

@ -235,6 +235,10 @@ public:
const QString& getVarName() {
return m_varname;
}
void setStrDefault(const std::string& value) {
m_strdefault = value;
}
public slots:
virtual void setEnabled(bool) = 0;
virtual void storeValue() = 0;
@ -251,6 +255,8 @@ protected:
// File names are encoded as local8bit in the config files. Other
// are encoded as utf-8
bool m_fsencoding;
// Bool and Int have constructor parameters for the default value. Others may use this
std::string m_strdefault;
virtual bool createCommon(const QString& lbltxt, const QString& tltptxt);
};