Move app::Key to its own key.cpp file#5407
Conversation
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
| app::KeyContext context; | ||
| }; | ||
|
|
||
| static std::vector<KeyShortcutAction> g_actions; |
There was a problem hiding this comment.
warning: 'g_actions' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
| static std::vector<KeyShortcutAction> g_actions; | |
| std::vector<KeyShortcutAction> g_actions; |
|
|
||
| static std::vector<KeyShortcutAction> g_actions; | ||
|
|
||
| static const std::vector<KeyShortcutAction>& actions() |
There was a problem hiding this comment.
warning: 'actions' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
| static const std::vector<KeyShortcutAction>& actions() | |
| const std::vector<KeyShortcutAction>& actions() |
| static struct { | ||
| const char* name; | ||
| app::KeyContext context; | ||
| } g_contexts[] = { |
There was a problem hiding this comment.
warning: 'g_contexts' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
src/app/ui/key.cpp:125:
- static struct {
+ struct {| Vec vector; | ||
| }; | ||
|
|
||
| static std::vector<KeyShortcutWheelAction> g_wheel_actions; |
There was a problem hiding this comment.
warning: 'g_wheel_actions' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
| static std::vector<KeyShortcutWheelAction> g_wheel_actions; | |
| std::vector<KeyShortcutWheelAction> g_wheel_actions; |
|
|
||
| static std::vector<KeyShortcutWheelAction> g_wheel_actions; | ||
|
|
||
| static const std::vector<KeyShortcutWheelAction>& wheel_actions() |
There was a problem hiding this comment.
warning: 'wheel_actions' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
| static const std::vector<KeyShortcutWheelAction>& wheel_actions() | |
| const std::vector<KeyShortcutWheelAction>& wheel_actions() |
| template<> | ||
| std::string convert_to(const app::WheelAction& from) | ||
| { | ||
| int c = int(from); |
There was a problem hiding this comment.
warning: variable 'c' of type 'int' can be declared 'const' [misc-const-correctness]
| int c = int(from); | |
| int const c = int(from); |
| case KeyAction::SquareAspect: | ||
| case KeyAction::DrawFromCenter: | ||
| case KeyAction::RotateShape: m_keycontext = KeyContext::ShapeTool; break; | ||
| case KeyAction::LeftMouseButton: m_keycontext = KeyContext::Any; break; |
There was a problem hiding this comment.
warning: switch has 2 consecutive identical branches [bugprone-branch-clone]
case KeyAction::LeftMouseButton: m_keycontext = KeyContext::Any; break;
^Additional context
src/app/ui/key.cpp:373: last of these clones ends here
case KeyAction::RightMouseButton: m_keycontext = KeyContext::Any; break;
^| } | ||
| } | ||
|
|
||
| const ui::Shortcut* Key::isPressed(const Message* msg, const KeyContext keyContext) const |
There was a problem hiding this comment.
warning: method 'isPressed' can be made static [readability-convert-member-functions-to-static]
src/app/ui/key.h:126:
- const ui::Shortcut* isPressed(const ui::Message* msg, KeyContext keyContext) const;
+ static const ui::Shortcut* isPressed(const ui::Message* msg, KeyContext keyContext) ;| const ui::Shortcut* Key::isPressed(const Message* msg, const KeyContext keyContext) const | |
| const ui::Shortcut* Key::isPressed(const Message* msg, const KeyContext keyContext) |
|
|
||
| const ui::Shortcut* Key::isPressed(const Message* msg, const KeyContext keyContext) const | ||
| { | ||
| if (const auto* keyMsg = dynamic_cast<const KeyMessage*>(msg)) { |
There was a problem hiding this comment.
warning: repeated branch body in conditional chain [bugprone-branch-clone]
if (const auto* keyMsg = dynamic_cast<const KeyMessage*>(msg)) {
^Additional context
src/app/ui/key.cpp:454: end of the original
}
^src/app/ui/key.cpp:455: clone 1 starts here
else if (const auto* mouseMsg = dynamic_cast<const MouseMessage*>(msg)) {
^| { | ||
| switch (keyctx) { | ||
| case KeyContext::Any: return std::string(); | ||
| case KeyContext::Normal: return I18N_KEY(key_context_normal); |
There was a problem hiding this comment.
warning: switch has 10 consecutive identical branches [bugprone-branch-clone]
case KeyContext::Normal: return I18N_KEY(key_context_normal);
^Additional context
src/app/ui/key.cpp:591: last of these clones ends here
case KeyContext::Transformation: return I18N_KEY(key_context_transformation);
^0af057e to
21ad78c
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
|
|
||
| const ui::Shortcut* Key::isPressed(const Message* msg, const KeyContext keyContext) const | ||
| { | ||
| if (const auto* keyMsg = dynamic_cast<const KeyMessage*>(msg)) { |
There was a problem hiding this comment.
warning: repeated branch body in conditional chain [bugprone-branch-clone]
if (const auto* keyMsg = dynamic_cast<const KeyMessage*>(msg)) {
^Additional context
src/app/ui/key.cpp:450: end of the original
}
^src/app/ui/key.cpp:451: clone 1 starts here
else if (const auto* mouseMsg = dynamic_cast<const MouseMessage*>(msg)) {
^| { | ||
| switch (keyctx) { | ||
| case KeyContext::Any: return {}; | ||
| case KeyContext::Normal: return I18N_KEY(key_context_normal); |
There was a problem hiding this comment.
warning: switch has 10 consecutive identical branches [bugprone-branch-clone]
case KeyContext::Normal: return I18N_KEY(key_context_normal);
^Additional context
src/app/ui/key.cpp:587: last of these clones ends here
case KeyContext::Transformation: return I18N_KEY(key_context_transformation);
^
No description provided.