refs #233 Keyboard key/key list

* helper methods for keylist (key for function)
* new Hotkey function (toggle window on top)
* improved comparisons for key
* unit tests
This commit is contained in:
Klaus Basan
2014-05-07 23:16:28 +02:00
parent 17f617f418
commit 421d2d5411
5 changed files with 89 additions and 6 deletions

View File

@@ -30,6 +30,16 @@ namespace BlackMisc
return CSequence::contains(&CKeyboardKey::getFunction, function);
}
/*
* Key for function
*/
CKeyboardKey CKeyboardKeyList::keyForFunction(CKeyboardKey::HotkeyFunction function) const
{
CKeyboardKeyList keys = this->findBy(&CKeyboardKey::getFunction, function);
if (keys.isEmpty())
return CKeyboardKey(CKeyboardKey::HotkeyNone);
else
return keys[0];
}
/*
@@ -56,6 +66,7 @@ namespace BlackMisc
if (!this->containsFunction(CKeyboardKey::HotkeyOpacity100)) this->push_back(CKeyboardKey(CKeyboardKey::HotkeyOpacity100));
if (!this->containsFunction(CKeyboardKey::HotkeyToggleCom1)) this->push_back(CKeyboardKey(CKeyboardKey::HotkeyToggleCom1));
if (!this->containsFunction(CKeyboardKey::HotkeyToggleCom2)) this->push_back(CKeyboardKey(CKeyboardKey::HotkeyToggleCom2));
if (!this->containsFunction(CKeyboardKey::HotkeyToogleWindowsStayOnTop)) this->push_back(CKeyboardKey(CKeyboardKey::HotkeyToogleWindowsStayOnTop));
}
} // namespace