-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Add support to use mouse buttons (including X1 & X2) as shortcuts (fix #598) #4927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: beta
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
return os::Shortcut( | ||
(accel.unicodeChar() ? accel.unicodeChar() : from_scancode_to_unicode(accel.scancode())), | ||
accel.modifiers()); | ||
return os::Shortcut((shortcut.unicodeChar() ? shortcut.unicodeChar() : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
return os::Shortcut((shortcut.unicodeChar() ? shortcut.unicodeChar() : | |
return os::Shortcut(((shortcut.unicodeChar() != 0) ? shortcut.unicodeChar() : |
{ | ||
LockButtons lock(this); | ||
ui::Accelerator accel; | ||
SelectAccelerator window(accel, m_key ? m_key->keycontext() : KeyContext::Any, m_keys); | ||
ui::Shortcut shortcut; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'shortcut' of type 'ui::Shortcut' can be declared 'const' [misc-const-correctness]
ui::Shortcut shortcut; | |
ui::Shortcut const shortcut; |
int y = bounds.y; | ||
int dh = textSize().h + 4 * guiscale(); | ||
int maxi = (accels && accels->size() > 1 ? accels->size() : 1); | ||
int maxi = (shortcuts && shortcuts->size() > 1 ? shortcuts->size() : 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'maxi' of type 'int' can be declared 'const' [misc-const-correctness]
int maxi = (shortcuts && shortcuts->size() > 1 ? shortcuts->size() : 1); | |
int const maxi = (shortcuts && shortcuts->size() > 1 ? shortcuts->size() : 1); |
} | ||
|
||
std::string getAccelText(const Accelerator& accel) const | ||
std::string getShortcutText(const Shortcut& shortcut) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'getShortcutText' can be made static [readability-convert-member-functions-to-static]
std::string getShortcutText(const Shortcut& shortcut) const | |
static std::string getShortcutText(const Shortcut& shortcut) |
const ui::Accelerator* isPressed(const ui::Message* msg, | ||
const KeyboardShortcuts& globalKeys) const; | ||
const ui::Shortcuts& shortcuts() const; | ||
const KeySourceShortcutList addsKeys() const { return m_adds; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: return type 'const KeySourceShortcutList' (aka 'const vector<std::pair<KeySource, ui::Shortcut>>') is 'const'-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]
const KeySourceShortcutList addsKeys() const { return m_adds; } | |
KeySourceShortcutList addsKeys() const { return m_adds; } |
const KeyboardShortcuts& globalKeys, | ||
const KeyContext keyContext) const | ||
const ui::Shortcut* Key::isPressed(const Message* msg, | ||
const KeyboardShortcuts& globalKeys, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'globalKeys' is unused [misc-unused-parameters]
const KeyboardShortcuts& globalKeys, | |
const KeyboardShortcuts& /*globalKeys*/, |
} | ||
|
||
bool Key::hasUserDefinedAccels() const | ||
bool Key::hasUserDefinedShortcuts() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'hasUserDefinedShortcuts' can be made static [readability-convert-member-functions-to-static]
src/app/ui/key.h:135:
- bool hasUserDefinedShortcuts() const;
+ static bool hasUserDefinedShortcuts() ;
bool Key::hasUserDefinedShortcuts() const | |
bool Key::hasUserDefinedShortcuts() |
const Key* key, | ||
const ui::Accelerator& accel, | ||
bool removed) | ||
void KeyboardShortcuts::exportShortcut(XMLElement* parent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'exportShortcut' can be made static [readability-convert-member-functions-to-static]
src/app/ui/keyboard_shortcuts.h:79:
- void exportShortcut(tinyxml2::XMLElement* parent,
+ static void exportShortcut(tinyxml2::XMLElement* parent,
const KeyContext keyContext, | ||
const Key* newKey); | ||
void disableShortcut(const ui::Shortcut& shortcut, | ||
const KeySource source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'source' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
const KeySource source, | |
KeySource source, |
const Key* newKey); | ||
void disableShortcut(const ui::Shortcut& shortcut, | ||
const KeySource source, | ||
const KeyContext keyContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'keyContext' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
const KeyContext keyContext, | |
KeyContext keyContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@@ -1753,6 +1757,11 @@ void Manager::onNewDisplayConfiguration(Display* display) | |||
container->flushRedraw(); | |||
} | |||
|
|||
bool Manager::onEnqueueMouseDown(MouseMessage* mouseMsg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'mouseMsg' is unused [misc-unused-parameters]
bool Manager::onEnqueueMouseDown(MouseMessage* mouseMsg) | |
bool Manager::onEnqueueMouseDown(MouseMessage* /*mouseMsg*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
updateText(); | ||
} | ||
|
||
obs::signal<void(const ui::Shortcut*)> ShortcutChange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member variable 'ShortcutChange' has public visibility [misc-non-private-member-variables-in-classes]
obs::signal<void(const ui::Shortcut*)> ShortcutChange;
^
case kKeyDownMessage: | ||
if (hasFocus() && !isReadOnly()) { | ||
KeyMessage* keymsg = static_cast<KeyMessage*>(msg); | ||
if (!keymsg->scancode() && keymsg->unicodeChar() < 32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'KeyScancode' (aka 'os::KeyScancode') -> 'bool' [readability-implicit-bool-conversion]
if (!keymsg->scancode() && keymsg->unicodeChar() < 32) | |
if ((keymsg->scancode() == 0u) && keymsg->unicodeChar() < 32) |
setText(tmp.toString()); | ||
} | ||
|
||
Shortcut m_shortcut; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member variable 'm_shortcut' has protected visibility [misc-non-private-member-variables-in-classes]
Shortcut m_shortcut;
^
addChild(&m_tooltipManager); | ||
} | ||
|
||
void SelectShortcut::onModifierChange(KeyModifiers modifier, CheckBox* checkbox) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: pointer parameter 'checkbox' can be pointer to const [readability-non-const-parameter]
void SelectShortcut::onModifierChange(KeyModifiers modifier, CheckBox* checkbox) | |
void SelectShortcut::onModifierChange(KeyModifiers modifier, const CheckBox* checkbox) |
{ | ||
bool state = (checkbox->isSelected()); | ||
KeyModifiers modifiers = m_shortcut.modifiers(); | ||
KeyScancode scancode = m_shortcut.scancode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'scancode' of type 'KeyScancode' (aka 'os::KeyScancode') can be declared 'const' [misc-const-correctness]
KeyScancode scancode = m_shortcut.scancode(); | |
KeyScancode const scancode = m_shortcut.scancode(); |
alt()->setSelected(m_shortcut.modifiers() & kKeyAltModifier ? true : false); | ||
ctrl()->setSelected(m_shortcut.modifiers() & kKeyCtrlModifier ? true : false); | ||
shift()->setSelected(m_shortcut.modifiers() & kKeyShiftModifier ? true : false); | ||
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false);
^
this fix will not be applied because it overlaps with another fix
alt()->setSelected(m_shortcut.modifiers() & kKeyAltModifier ? true : false); | ||
ctrl()->setSelected(m_shortcut.modifiers() & kKeyCtrlModifier ? true : false); | ||
shift()->setSelected(m_shortcut.modifiers() & kKeyShiftModifier ? true : false); | ||
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: redundant boolean literal in ternary expression result [readability-simplify-boolean-expr]
space()->setSelected(m_shortcut.modifiers() & kKeySpaceModifier ? true : false); | |
space()->setSelected((m_shortcut.modifiers() & kKeySpaceModifier) != 0); |
"Also known as Windows key, logo key,\ncommand key, or system key.", | ||
TOP); | ||
#endif | ||
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false);
^
this fix will not be applied because it overlaps with another fix
"Also known as Windows key, logo key,\ncommand key, or system key.", | ||
TOP); | ||
#endif | ||
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: redundant boolean literal in ternary expression result [readability-simplify-boolean-expr]
win()->setSelected(m_shortcut.modifiers() & kKeyWinModifier ? true : false); | |
win()->setSelected((m_shortcut.modifiers() & kKeyWinModifier) != 0); |
#endif | ||
} | ||
|
||
void SelectShortcut::updateAssignedTo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'updateAssignedTo' can be made static [readability-convert-member-functions-to-static]
src/app/ui/select_shortcut.h:37:
- void updateAssignedTo();
+ static void updateAssignedTo();
This was a pending refactor, where "user.aseprite-keys" files were already using the "shortcut" attribute (instead of "accelerator").
This is a work-in-progress to fix #598