Ticket #953: Ticket#953_v2.patch

File Ticket#953_v2.patch, 2.5 KB (added by Bogdan Lazic, 12 years ago)
  • ps/ConfigDB.cpp

     
    284284            ret.push_back(std::make_pair(it->first, it->second));
    285285    }
    286286
     287    bool isKeyAlreadyPresent = false;
    287288    for (int search_ns = ns; search_ns >= 0; search_ns--)
    288289    {
    289290        for (TConfigMap::iterator it = m_Map[search_ns].begin(); it != m_Map[search_ns].end(); ++it)
    290291        {
    291292            if (boost::algorithm::starts_with(it->first, prefix))
    292                 ret.push_back(std::make_pair(it->first, it->second));
     293            {
     294                isKeyAlreadyPresent = false;
     295                for (int i = 0; i < ret.size(); i++)
     296                {
     297                    if (ret[i].first == it->first)
     298                    {
     299                        isKeyAlreadyPresent = true;
     300                        break;
     301                    }
     302                }
     303
     304                if (!isKeyAlreadyPresent)
     305                {
     306                    ret.push_back(std::make_pair(it->first, it->second));
     307                }
     308            }
    293309        }
    294310    }
    295311
  • ps/Hotkey.cpp

     
    5858// The current pressed status of hotkeys
    5959std::map<std::string, bool> g_HotkeyStatus;
    6060
     61// Delete multiple hotkey for same key combination
     62// Compare all keys require in requires if there is same combination already in use, delete other one
     63static void RemoveOverlapingHotKeys()
     64{   
     65    for (std::map<int, KeyMapping>::iterator itHkm = g_HotkeyMap.begin(); itHkm != g_HotkeyMap.end(); ++itHkm)
     66    {
     67        for (unsigned int kmi = 0; kmi < itHkm->second.size(); kmi++)
     68        {
     69            for (unsigned int kmj = 0; kmj < kmi; kmj++)
     70            {
     71                if (itHkm->second[kmi].requires.size() > 0 &&
     72                    itHkm->second[kmi].requires.size() == itHkm->second[kmj].requires.size())
     73                {
     74                    bool match = false;
     75                    for (unsigned int i = 0; i < itHkm->second[kmi].requires.size(); i++)
     76                    {
     77                        for (unsigned int j = 0; j < itHkm->second[kmj].requires.size(); j++)
     78                        {
     79                            if (itHkm->second[kmi].requires[i].code == itHkm->second[kmj].requires[j].code)
     80                            {
     81                                match = true;
     82                                break;
     83                            }
     84                        }
     85
     86                        if (!match)
     87                        {
     88                            break;
     89                        }
     90                    }
     91
     92                    if (match)
     93                    {
     94                        itHkm->second.erase(itHkm->second.begin() + kmi);
     95                        kmi--;
     96                        break;
     97                    }
     98                }
     99            }
     100        }
     101    }
     102}
     103
    61104// Look up each key binding in the config file and set the mappings for
    62105// all key combinations that trigger it.
    63106static void LoadConfigBindings()
     
    140183            }
    141184        }
    142185    }
     186
     187    RemoveOverlapingHotKeys();
    143188}
    144189
    145190void LoadHotkeys()