@@ -392,40 +392,28 @@ using namespace std;
392392#pragma endregion
393393
394394#pragma region Setters
395- void CSFParser::SetHotkey (const string& input, const wchar_t & wchLetter)
395+ void CSFParser::SetHotkey (const string& input, const wchar_t & wchLetter) { SetHotkey (QString::fromStdString (input), wchLetter); }
396+ void CSFParser::SetHotkey (const char * strName, const wchar_t & wchLetter) { SetHotkey (string (strName), wchLetter); }
397+ void CSFParser::SetHotkey (const QString& strName, const wchar_t & wchLetter)
396398 {
397- LOGSTM << " Changing for string \" " << input << " \" hotkey assingment to letter \" " << (const char )wchLetter << " \" " << endl;
399+ if (wchLetter == L' ' ) return ;
400+
401+ LOGSTM << " Changing for string \" " << strName.toStdString () << " \" hotkey assingment to letter \" " << (const char )wchLetter << " \" " << endl;
398402
399- QString strName = QString::fromStdString (input);
400-
401403 for (auto & elem : Table)
402404 {
403- if (elem.Name == strName)
404- {
405- int index = 0 ;
405+ if (elem.Name != strName)
406+ continue ;
406407
407- index = elem.Value .indexOf (L' &' );
408+ if (!elem.Value .contains (L' &' ) || elem.Value .size () <= 4 ) // if not "[&F]"
409+ elem.Value = QString (" [&" ) + QChar (wchLetter) + " ] " + elem.Value ;
410+ else
411+ elem.Value [elem.Value .indexOf (L' &' ) + 1 ] = wchLetter;
408412
409- if (index <= elem.Value .size ())
410- {
411- // If we could find something like [&F], then we just replace the letter
412- if (elem.Value [index - 1 ] == L' [' && elem.Value [index + 2 ] == L' ]' )
413- {
414- elem.Value [index + 1 ] = wchLetter;
415- }
416- // If no, then we add [&wch] to begin of the value and delete & in text
417- else
418- {
419- elem.Value = elem.Value .remove (index, 1 );
420- }
421- }
422- }
413+ break ;
423414 }
424415 }
425416
426- void CSFParser::SetHotkey (const char * strName, const wchar_t & wchLetter) { SetHotkey (string (strName), wchLetter); }
427- void CSFParser::SetHotkey (const QString& strName, const wchar_t & wchLetter) { SetHotkey (strName.toStdString (), wchLetter); }
428-
429417 void CSFParser::SetStringValue (const string& strName, const wstring& wstrValue)
430418 {
431419 LOGSTM << " Changing value for string \" " << strName << " \" " << endl;
0 commit comments