aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpsettingswindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-07 23:58:52 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-07 23:58:52 +0800
commitf0d2584fdad44703f3966eb0b1e695341a4ca01c (patch)
tree354a6f8a961a07a14a8b7f1887e66986e558d303 /qmidiplayer-desktop/qmpsettingswindow.cpp
parent909cfe195ae2f6058a03875123f1e80f2a3fa0fa (diff)
downloadQMidiPlayer-f0d2584fdad44703f3966eb0b1e695341a4ca01c.tar.xz
Added two new options.
Fixed several crashes related to options without a description. Sanitise deinitialize order again. Fixed several memory leaks.
Diffstat (limited to 'qmidiplayer-desktop/qmpsettingswindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp
index 45f84c3..81ac364 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.cpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.cpp
@@ -330,24 +330,25 @@ void qmpSettingsWindow::updateCustomOptions()
{
case 0:case 1:
{
- QSpinBox* sb=(QSpinBox*)i->second.widget;
+ QSpinBox* sb=(QSpinBox*)i->second.widget;if(!i->second.widget)break;
settings->setValue(QString(i->first.c_str()),sb->value());
break;
}
case 2:
{
+ if(!i->second.widget)break;
settings->setValue(QString(i->first.c_str()),((QCheckBox*)i->second.widget)->isChecked()?1:0);
break;
}
case 3:
{
- QDoubleSpinBox* sb=(QDoubleSpinBox*)i->second.widget;
+ QDoubleSpinBox* sb=(QDoubleSpinBox*)i->second.widget;if(!i->second.widget)break;
settings->setValue(QString(i->first.c_str()),sb->value());
break;
}
case 4:
{
- QLineEdit* te=(QLineEdit*)i->second.widget;
+ QLineEdit* te=(QLineEdit*)i->second.widget;if(!i->second.widget)break;
settings->setValue(QString(i->first.c_str()),te->text());
}
}
@@ -393,6 +394,7 @@ int qmpSettingsWindow::getOptionInt(std::string key)
void qmpSettingsWindow::setOptionInt(std::string key,int val)
{
settings->setValue(QString(key.c_str()),val);
+ if(customOptions[key].widget)
((QSpinBox*)customOptions[key].widget)->setValue(val);
}
@@ -436,6 +438,7 @@ unsigned qmpSettingsWindow::getOptionUint(std::string key)
void qmpSettingsWindow::setOptionUint(std::string key,unsigned val)
{
settings->setValue(QString(key.c_str()),val);
+ if(customOptions[key].widget)
((QSpinBox*)customOptions[key].widget)->setValue(val);
}
@@ -472,6 +475,7 @@ bool qmpSettingsWindow::getOptionBool(std::string key)
void qmpSettingsWindow::setOptionBool(std::string key,bool val)
{
settings->setValue(QString(key.c_str()),val?1:0);
+ if(customOptions[key].widget)
((QCheckBox*)customOptions[key].widget)->setChecked(val);
}
@@ -515,6 +519,7 @@ double qmpSettingsWindow::getOptionDouble(std::string key)
void qmpSettingsWindow::setOptionDouble(std::string key,double val)
{
settings->setValue(QString(key.c_str()),val);
+ if(customOptions[key].widget)
((QDoubleSpinBox*)customOptions[key].widget)->setValue(val);
}
@@ -554,5 +559,6 @@ std::string qmpSettingsWindow::getOptionString(std::string key)
void qmpSettingsWindow::setOptionString(std::string key,std::string val)
{
settings->setValue(QString(key.c_str()),QString(val.c_str()));
+ if(customOptions[key].widget)
((QLineEdit*)customOptions[key].widget)->setText(val.c_str());
}