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

Keyboard shortcuts not persisting #53

Closed
hafner opened this issue Feb 2, 2022 · 8 comments
Closed

Keyboard shortcuts not persisting #53

hafner opened this issue Feb 2, 2022 · 8 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@hafner
Copy link

hafner commented Feb 2, 2022

Bug Description

If you set a custom keyboard shortcut the next time you open the application it is reverted back to default

Device information

  • Operating System: Windows 10
  • QPrompt Version:1.0.0
@Cuperino
Copy link
Owner

Cuperino commented Feb 2, 2022

Haven't gotten around to making shortcuts persistent... I'll make this a priority.

@Cuperino Cuperino added the enhancement New feature or request label Feb 2, 2022
@Cuperino Cuperino added this to the 1.x milestone Feb 2, 2022
@Cuperino Cuperino added the bug Something isn't working label Feb 2, 2022
@Cuperino
Copy link
Owner

Cuperino commented Feb 3, 2022

Out of curiosity @hafner: What values are you customizing your keyboard inputs to and why?

@hafner
Copy link
Author

hafner commented Feb 3, 2022 via email

@Cuperino
Copy link
Owner

Cuperino commented Feb 3, 2022

I see... Thanks for the feedback!

@DrJPK
Copy link

DrJPK commented Mar 1, 2022

Hi @Cuperino I would also greatly appreciate this enhancement. I am using a stream deck as a controller so am mapping the shortcuts to F13-F24 range so that it doesn't clash with anything else I'm using in Windows.

If you know where in the source code they are actually defined/initialised, I might be able to find some time to work out some way of writing them out to / reading them in from a text .conf file that might work across platforms. I'm thinking something in a ~/.qprompt/ directory???

@Cuperino
Copy link
Owner

Cuperino commented Mar 1, 2022

Hello @DrJPK,

My apologies I haven't been able to work on this yet. It's been a busy month and the hardware I used to develop QPrompt broke, but I've worked around it. (You can find more details about this in the project's Telegram chat.)

Adding persistence should be quite easy. The challenging part is having the program show the correct values on the key mapping UI when a new session starts; some tweaks or rewriting of the UI might be required.

Key mapping code

Key mapping is split across 3 files:

How data is saved to disk

Configurations are saved to disk using the Qt.labs.settings module. This module is an API to access the QSettings from QML without the need to add additional C++ backend. Since The Qt Company does not guarantee the Qt.labs module will remain compatible in future versions of the software, if support for it is dropped the QSettings Class should be used instead, ideally through the creation of a shim layer.

The advantage in using either Settings or QSettings is this layer provides a cross-platform abstraction to save simple configurations to disk. You can see where data is stored for each platform over at https://doc.qt.io/qt-5/qsettings.html#platform-specific-notes

Prior knowledge

This is not an exhaustive list. Understanding how the following things work will ease the development process:

Good practice

Please note that a declarative programming approach should always preferred over imperative programming when developing QPrompt. You may watch KDAB's video tutorial on the topic for reference.

Things that may need to occur for key mappings to be preserved

  1. The keys JavaScript object at Prompter.qml (lines 162-171) may need to be replaced with an instance of Settings QML type. Use of the Settings type would allow for a more declarative style of programming to be used for this feature.
  2. See how the current default button labels are hard coded at lines 53-60 of InputsOverlay.qml? The button's getKeyText method could be triggered from the Component.onCompleted slot to dynamically choose which text will be shown on the InputsOverlay UI upon loading.
  3. The onSetKey slot of each KeyInputButton component (currently located at lines: 64, 69, 74, 79, 84, 89 of InputsOverlay.qml) could trigger saving the respective button setting to disk. The use of this imperative style of programming may not be necessary were the keys object replaced with a Settings object.

@Cuperino
Copy link
Owner

@DrJPK, just checking, have you been able to get acquainted with the code?

Cuperino added a commit that referenced this issue Mar 18, 2022
…#53 and #75. Made next and previous anchor shortcut customization independent from move backwards and move forwards shortcuts, solving issue #65. Re-implemented Prompter's keyboard input management to enable using modifier keys as part of shortcuts, multiplying number of possible input combinations.
@Cuperino
Copy link
Owner

Quick update, I've finished implementing persistent shortcuts. The fix will be available in the next release.

@Cuperino Cuperino moved this to Done in QPrompt Feb 25, 2023
@Cuperino Cuperino added this to QPrompt Feb 25, 2023
@Cuperino Cuperino modified the milestones: 2.x, 1.x Nov 17, 2024
Cuperino added a commit that referenced this issue Dec 1, 2024
…#53 and #75. Made next and previous anchor shortcut customization independent from move backwards and move forwards shortcuts, solving issue #65. Re-implemented Prompter's keyboard input management to enable using modifier keys as part of shortcuts, multiplying number of possible input combinations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

3 participants