aboutsummaryrefslogtreecommitdiff
path: root/visualization/renderer/qmpsettingsro.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-01 01:31:45 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-01 01:31:45 +0800
commit893bec26cd1bc83fd85bb7dfdfd6225d9f6ee5b5 (patch)
tree3b7e7a4f772c8f8de93d61b549599b22902e83fc /visualization/renderer/qmpsettingsro.cpp
parentbd165c0254b9095bb9e5ea54def56b6404033ebe (diff)
downloadQMidiPlayer-893bec26cd1bc83fd85bb7dfdfd6225d9f6ee5b5.tar.xz
Visualization renderer now understands command line arguments.
Fixed wrong tick calculation in render mode. Fixed most of the hangs and crashes associated with the renderer. Do not write pixel data in the visualization thread.
Diffstat (limited to 'visualization/renderer/qmpsettingsro.cpp')
-rw-r--r--visualization/renderer/qmpsettingsro.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/visualization/renderer/qmpsettingsro.cpp b/visualization/renderer/qmpsettingsro.cpp
index cc6e0bf..a66943b 100644
--- a/visualization/renderer/qmpsettingsro.cpp
+++ b/visualization/renderer/qmpsettingsro.cpp
@@ -165,3 +165,62 @@ void qmpSettingsRO::load(const char *path)
settings.insert(k,qsettings->value(k));
}
}
+
+void qmpSettingsRO::setopt(std::string key, std::string val)
+{
+ if(options.find(key)==options.end())
+ {
+ std::string nkey="Visualization/"+key;
+ if(options.find(nkey)==options.end())
+ {
+ qDebug("invalid option key %s",key.c_str());
+ return;
+ }
+ else key=nkey;
+ }
+ char *rptr;
+ switch(options[key].type)
+ {
+ case qmpOptionR::ParameterType::parameter_int:
+ {
+ long long v=strtoll(val.c_str(),&rptr,10);
+ if(rptr==val.c_str()||v>INT_MAX||v<INT_MIN)
+ qDebug("invalid value for option %s",key.c_str());
+ setOptionInt(key,static_cast<int>(v));
+ }
+ break;
+ case qmpOptionR::ParameterType::parameter_uint:
+ {
+ long long v=strtoll(val.c_str(),&rptr,10);
+ if(rptr==val.c_str()||v>UINT32_MAX||v<0)
+ qDebug("invalid value for option %s",key.c_str());
+ setOptionUint(key,static_cast<uint32_t>(v));
+ }
+ break;
+ case qmpOptionR::ParameterType::parameter_double:
+ {
+ errno=0;
+ double v=strtod(val.c_str(),&rptr);
+ if(rptr==val.c_str()||errno)
+ qDebug("invalid value for option %s",key.c_str());
+ setOptionDouble(key,v);
+ }
+ break;
+ case qmpOptionR::ParameterType::parameter_bool:
+ {
+ if(val!="true"&&val!="false")
+ qDebug("invalid value for option %s",key.c_str());
+ setOptionBool(key,val=="true");
+ }
+ break;
+ case qmpOptionR::ParameterType::parameter_str:
+ case qmpOptionR::ParameterType::parameter_url:
+ setOptionString(key,val);
+ break;
+ case qmpOptionR::ParameterType::parameter_enum:
+ setOptionEnumIntOptName(key,val);
+ break;
+ default:
+ break;
+ }
+}