refs #198 , changed keyboardkey classes so they can be initialized either by read settings or default values

This commit is contained in:
Klaus Basan
2014-04-01 12:18:11 +02:00
parent 6327c3a1cb
commit f3148fdd49
3 changed files with 27 additions and 10 deletions

View File

@@ -22,6 +22,14 @@ namespace BlackMisc
CSequence<CKeyboardKey>(baseClass)
{ }
/*
* Contains this hotkey function?
*/
bool CKeyboardKeyList::containsFunction(CKeyboardKey::HotkeyFunction key)
{
return CSequence::contains(&CKeyboardKey::getFunction, key);
}
/*
* Register metadata
*/
@@ -35,14 +43,17 @@ namespace BlackMisc
qDBusRegisterMetaType<CKeyboardKeyList>();
}
void CKeyboardKeyList::initAsHotkeyList()
/*
* Hotkey list
*/
void CKeyboardKeyList::initAsHotkeyList(bool reset)
{
this->clear();
this->push_back(CKeyboardKey(CKeyboardKey::HotkeyPtt));
this->push_back(CKeyboardKey(CKeyboardKey::HotkeyOpacity50));
this->push_back(CKeyboardKey(CKeyboardKey::HotkeyOpacity100));
this->push_back(CKeyboardKey(CKeyboardKey::HotkeyToggleCom1));
this->push_back(CKeyboardKey(CKeyboardKey::HotkeyToggleCom2));
if (reset) this->clear();
if (!this->containsFunction(CKeyboardKey::HotkeyPtt)) this->push_back(CKeyboardKey(CKeyboardKey::HotkeyPtt));
if (!this->containsFunction(CKeyboardKey::HotkeyOpacity50)) this->push_back(CKeyboardKey(CKeyboardKey::HotkeyOpacity50));
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));
}
} // namespace