Add action to reset font size
ClosedPublic

Authored by kishoreg on May 26 2019, 6:09 AM.

Details

Summary

Add an action to reset the font size to the default and set the default shortcut to Ctrl+0

Test Plan

Zoom out the text. Press Ctrl+0 to go back to default zoom.
Do the same with the 'Reset font size' item in the 'View' menu.
Try to reassign the keyboard shortcut in the shortcuts manager and check that it works.

FEATURE: 407910

Diff Detail

Repository
R39 KTextEditor
Lint
Lint Skipped
Unit
Unit Tests Skipped
kishoreg created this revision.May 26 2019, 6:09 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptMay 26 2019, 6:09 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
kishoreg requested review of this revision.May 26 2019, 6:09 AM
cullmann requested changes to this revision.May 26 2019, 10:30 AM
cullmann added a subscriber: cullmann.

Hi, this is a good start!

Thanks for taking care of this.

I think to get the "default font", you need to call KateRendererConfig::global()->font() instead of using a default constructed QFont. That should return the font configured in the KTextEditor settings.

For the shortcut: I guess you should use KStandardShortcut::ActualSize().

As we now have three actions just for zooming I think some "Zoom" sub-menu would be nice.

This revision now requires changes to proceed.May 26 2019, 10:30 AM
kishoreg updated this revision to Diff 58678.May 26 2019, 10:51 AM
kishoreg edited the test plan for this revision. (Show Details)

Get the default font size correctly.

For the shortcut: I guess you should use KStandardShortcut::ActualSize().

I initially tried using this, but it doesn't compile. It complains that ‘ActualSize’ cannot be used as a function. Just using KStandardShortcut::ActualSize results in the shortcut being set to '8' on my machine.

As we now have three actions just for zooming I think some "Zoom" sub-menu would be nice.

Should I make this change here, or in a separate pull request?

Could you try: KStandardShortcut::shortcut(KStandardShortcut::ActualSize)

The sub-menu should be just made in this review request, no need for an extra one, thanks!

kishoreg updated this revision to Diff 58680.May 26 2019, 11:33 AM

I've made the suggested changes (use standard reset zoom shortcut, and move zoom option to a submenu). Everything seems to work now.

cullmann accepted this revision.May 26 2019, 11:36 AM

I think this look OK.
Can you commit yourself? Or shall I push for you?

This revision is now accepted and ready to land.May 26 2019, 11:36 AM

Btw., if should push, I would need your name + email address for the git commit, thanks.

I don't think I have the permissions for that. Could you please do it for me?

Name: Kishore Gopalakrishnan
Email: kishore96@gmail.com

Also, thanks for helping me with this!

Thank you for providing the patch!
Helping a bit to bring it up to speed is much easier and more motivating than to start from scratch for a thing one doesn't need oneself that much.

> Thanks, one bug less!

I hope more people that actually can scratch their own itch start to contribute with patches.

This revision was automatically updated to reflect the committed changes.