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

Add Emacs navigation key-bindings support #2829

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

janmejay
Copy link

Rebase and address review-comments on a very old abandoned change (PR#1039)

  • add emacs-style navigation keymap support (similar to existing Vi keymap support)
  • convert the checkboxes to a set of radio-buttons (one of the open review comments)

@janmejay janmejay requested a review from hluk as a code owner August 30, 2024 18:56
@janmejay
Copy link
Author

@hluk did you have a chance to look at this?

@hluk
Copy link
Owner

hluk commented Sep 19, 2024

@hluk did you have a chance to look at this?

Not yet. Thanks for the patch! Checking now.

src/common/common.cpp Outdated Show resolved Hide resolved
src/common/common.cpp Outdated Show resolved Hide resolved
src/common/common.cpp Outdated Show resolved Hide resolved
src/gui/mainwindow.cpp Outdated Show resolved Hide resolved
Comment on lines 88 to +89
bool m_viMode;
bool m_emacsMode;
Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

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").

Copy link
Owner

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>
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