Skip to content
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

feat: Alt hotkeys [Feedback wanted] #5875

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

apa420
Copy link
Collaborator

@apa420 apa420 commented Jan 30, 2025

#5872
I would appreciate feedback on this (not on the code rn). This would basically add the possiblity of a alternate keybind to an already existing action. This would make creating more keybinds for the same action easier and also allow us to set multiple keybinds for the same default action more intuitavely (see shift+enter and ctrl+shift+enter).

Copy link
Contributor

@github-actions github-actions bot left a 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

@@ -7,20 +7,32 @@
namespace chatterino {

Hotkey::Hotkey(HotkeyCategory category, QKeySequence keySequence,
QString action, std::vector<QString> arguments, QString name)
QKeySequence *keySequenceAlt, QString action,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: pass by value and use std::move [modernize-pass-by-value]

src/controllers/hotkeys/Hotkey.cpp:1:

+ 
+ #include <utility>

src/controllers/hotkeys/Hotkey.cpp:14:

-     , action_(action)
+     , action_(std::move(action))

@@ -7,20 +7,32 @@
namespace chatterino {

Hotkey::Hotkey(HotkeyCategory category, QKeySequence keySequence,
QString action, std::vector<QString> arguments, QString name)
QKeySequence *keySequenceAlt, QString action,
std::vector<QString> arguments, QString name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: pass by value and use std::move [modernize-pass-by-value]

src/controllers/hotkeys/Hotkey.cpp:15:

-     , arguments_(arguments)
+     , arguments_(std::move(arguments))

@@ -7,20 +7,32 @@
namespace chatterino {

Hotkey::Hotkey(HotkeyCategory category, QKeySequence keySequence,
QString action, std::vector<QString> arguments, QString name)
QKeySequence *keySequenceAlt, QString action,
std::vector<QString> arguments, QString name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: pass by value and use std::move [modernize-pass-by-value]

src/controllers/hotkeys/Hotkey.cpp:16:

-     , name_(name)
+     , name_(std::move(name))

@@ -560,7 +554,8 @@ void HotkeyController::clearRemovedDefaults()
void HotkeyController::tryAddDefault(std::set<QString> &addedHotkeys,
HotkeyCategory category,
QKeySequence keySequence, QString action,
std::vector<QString> args, QString name)
std::vector<QString> args, QString name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'args' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

src/controllers/hotkeys/HotkeyController.hpp:131:

-                        std::vector<QString> args, QString name,
+                        const std::vector<QString>& args, QString name,
Suggested change
std::vector<QString> args, QString name,
const std::vector<QString>& args, QString name,

@@ -560,7 +554,8 @@
void HotkeyController::tryAddDefault(std::set<QString> &addedHotkeys,
HotkeyCategory category,
QKeySequence keySequence, QString action,
std::vector<QString> args, QString name)
std::vector<QString> args, QString name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'name' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

src/controllers/hotkeys/HotkeyController.hpp:131:

-                        std::vector<QString> args, QString name,
+                        std::vector<QString> args, const QString& name,
Suggested change
std::vector<QString> args, QString name,
std::vector<QString> args, const QString& name,

@Felanbird
Copy link
Collaborator

nitpick nothing to do with the code: user-facing references to alternative/alternate should not be shortened, since alt is a valid key press

@apa420 apa420 changed the title Alt hotkeys [Feedback wanted] feat: Alt hotkeys [Feedback wanted] Jan 31, 2025
@apa420
Copy link
Collaborator Author

apa420 commented Jan 31, 2025

Is there a need to have infinite keybinds per hotkey action or is just 2 enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants