UGlobalHotkey
UGlobalHotkey copied to clipboard
Cannot define multiple actions for multiple hotkeys
This great add-on, exactly what I need, except for the fact that I don't seem to be able to define multiple hotkeys using below code:
hotkeyOne = new UGlobalHotkeys();
hotkeyOne->registerHotkey("Ctrl+Shift+B");
connect(hotkeyOne, SIGNAL(activated(size_t)), this, SLOT(actionOne()));
hotkeyTwo = new UGlobalHotkeys();
hotkeyTwo->registerHotkey("Ctrl+Shift+L");
connect(hotkeyTwo, SIGNAL(activated(size_t)), this, SLOT(actionTwo()));
Whenever I use try to define it like this both hotkeys get registered, BUT both of them trigger actionTwo
only. actionOne
never gets executed.
Meantime this approach works, but it is not inline with Qt5 style:
hotkeyOne = new UGlobalHotkeys();
hotkeyOne->registerHotkey("Ctrl+Shift+B", 1);
hotkeyOne->registerHotkey("Ctrl+Shift+L", 2);
connect(hotkeyOne, &UGlobalHotkeys::activated, [=](size_t id){
switch (id) {
case 1:
actionOne();
break;
case 2:
actionTwo();
break;
}
});
Hello! I'm sorry, but I do not actively support this repo. The second approach is exactly what was intended upon creation of this add-on.
Then I think it would be good to have an example of how to use it added to readme.