-
Notifications
You must be signed in to change notification settings - Fork 441
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
Add Emacs navigation key-bindings support #2829
base: master
Are you sure you want to change the base?
Conversation
@hluk did you have a chance to look at this? |
Not yet. Thanks for the patch! Checking now. |
bool m_viMode; | ||
bool m_emacsMode; |
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.
Can you change this to use an enum? Something like:
enum class NavigationStyle {
Default,
Vi,
Emacs
};
It would also mean that there is single method to set the navigation void setNavigationStyle(NavigationStyle style)
.
It would be best if the configuration value in appconfig.h
has this type, but that might require some more refactoring. I could look into this later.
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.
@hluk I looked into this today. One way I can see of making this change (let me know if this is not really what you had in mind) is to make NavigationStyle
a QVariant
and then bind QGroupBox
instead of individual QRadioButtons
.
I'd have to overload the Option
constructor to allow me to pass getter and setter lambdas because checkedId
is not available as a property. This overload would be used for Option<NavigationStyle>
instance.
The main problem is this is backwards incompatible with persisted settings. For anyone that has vi
mode enabled at the moment would reset to Default
when they upgrade.
We can try to migrate settings, but unless we introduce a new concept (say SettingsMigrator
) the implementation won't be clean.
Let me know if this isn't what you had in mind.
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.
I would prefer to keep the code simpler. I tried writing some conversion function for new enum option, but it did not work well and was unnecessarily complex (custom QMetaType conversion function).
Here is a simple solution: 2810029
The UI uses QComboBox with fixed values instead of a group of radio buttons - enum values and the items in the combo box must match.
It reuses the Config::vi
option because I thought that it would convert the old false
/true
values so it would stay backwards-compatible. Unfortunately, that does not work. It would be good to figure this out, but I would avoid any complex migration code.
Another downside is that from CLI (copyq config vi ...
) you would need to use values 0,1,2 instead of more reasonable strings (e.g. "vi"/"emacs").
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.
I've solved the backwards-compatibility issue in: aba654f
But I'm not sure if I like the complexity of the solution 🙂 (diff from the previous version).
Co-authored-by: Lukas Holecek <ruling.worlds@gmail.com>
Rebase and address review-comments on a very old abandoned change (PR#1039)