Cuperino / QPrompt-Teleprompter

Teleprompter software for all video creators. Built with ease of use, productivity, control accuracy, and smooth performance in mind.
https://qprompt.app
GNU General Public License v3.0
361 stars 24 forks source link

Keyboard shortcuts not persisting #53

Closed hafner closed 2 years ago

hafner commented 2 years ago

Bug Description

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

Device information

Cuperino commented 2 years ago

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

Cuperino commented 2 years ago

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

hafner commented 2 years ago

I have a wireless usb pointer that acts as a keyboard wedge(normally used for PowerPoint) and it doesn't allow you to change the keys. So I have start/stop mapped to enter instead of space. Switch mode mapped to F1 instead of F9 as my laptop has shrunken F keys and F9 is hard to find in a hurry.


From: Javier O. Cordero Pérez @.> Sent: Wednesday, February 2, 2022 7:43:34 PM To: Cuperino/QPrompt @.> Cc: Michael @.>; Mention @.> Subject: Re: [Cuperino/QPrompt] Keyboard shortcuts not persisting (Issue #53)

Out of curiosity @hafnerhttps://github.com/hafner: What values are you customizing your keyboard inputs to and why?

— Reply to this email directly, view it on GitHubhttps://github.com/Cuperino/QPrompt/issues/53#issuecomment-1028494214, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACBBZRT7DCC3DYT2HJ26D3UZHFTNANCNFSM5NMZAM3A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>

Cuperino commented 2 years ago

I see... Thanks for the feedback!

DrJPK commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

Cuperino commented 2 years ago

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