In the note applet, always paste without formatting by default. Add an action to paste preserving formatting in the contextual menu.
ClosedPublic

Authored by luc4 on Jul 27 2019, 10:56 AM.

Details

Summary

It frequently happens to me that formatting is preserved when pasting into the note, making the note a bit confusing. I added a button to remove formatting from the pasted text so that I can apply a different one with the other buttons. For example this is what I get when pasting from konsole:

but I'd personally prefer to be able to do something like this, in this specific case:

Do you think this makes sense? Would you be against integrating this?
Thanks.

Diff Detail

Repository
R114 Plasma Addons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
luc4 created this revision.Jul 27 2019, 10:56 AM
Restricted Application added a project: Plasma. · View Herald TranscriptJul 27 2019, 10:56 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
luc4 requested review of this revision.Jul 27 2019, 10:56 AM

The use of a broom-style clear button suggests to me that it will clear everything, not just formatting. I think we either need a new/better icon, or else to give the button some explanatory text.

Also, it might be helpful to take a step back and look at the root cause issue. The problem is that when you paste formatted text, it preserves the formatting, and this is annoying for your use cases. Maybe there's another way we can fix this? Perhaps it could detect formatted text in a paste and ask whether or not you want to preserve it. Or we could add a new menu item and keyboard shortcut to paste without formatting (or paste without formatting by default, and make the new actions be the ones that preserve the formatting--this is how macOS handles this).

luc4 added a comment.Jul 27 2019, 4:39 PM

Yes, I couldn't find a better icon so I temporarily used this.

All the options you proposed are perfectly fine for me. I personally find the button sufficient but if you decide for something else I can try to update my patch. Thanks!

I'd be in favor of making the paste action always paste unformatted text, and then add a second menu item to paste with preserved formatting.

luc4 added a comment.Jul 27 2019, 10:32 PM

I'll try to implement that behavior then.

luc4 added a comment.Jul 28 2019, 10:12 AM

I had a look at the code. It is my understanding the menu is provided by Qt and it is probably styled somewhere. Is this correct? I can't find a way to modify it, so I guess I'll have to create an entirely new menu. Before I go on, can someone maybe confirm if I'm on the right track? Thanks!

luc4 added a comment.EditedAug 1 2019, 9:01 PM

I started to reimplement the menu. This is how it looked for me:

this is how a new menu would look like (some items and shortcuts are missing):

Do you think I'm on the right track? Or do you think it is possible to add an item to the previous menu somehow? Thanks!

Hmm, if the existing menu is provided by Qt, changes might need to be made upstream. :/ I wonder if there's a way to inject new items into it though, without creating an entirely new one?

Hopefully Plasma people should be able to answer those questions.

luc4 added a comment.Aug 1 2019, 10:13 PM

Also notice that the current aspect doesn't look good nor consistent with the rest of Plasma.
In my researches I found this: https://git.reviewboard.kde.org/r/121698/diff/1/#, which is a bit what I'm doing. I'll stop with this until an agreement is found.

luc4 added a comment.EditedAug 4 2019, 2:03 PM

Hello, I'm not a Plasma expert, but I tried to investigate the situation a bit in Qt and plasma-framework. My understanding is that the notes applet is using TextArea from QtQuick.Controls 1. TextArea 1 creates an edit menu inside Qt, probably the one defined in EditMenu_base.qml. I see it is probably possible to replace this. Not sure if this can be modified, it is not public.

I could not find a default edit menu in QtQuick.Controls 2. I see that plasma-framework also includes a template for TextArea from QtQuick.Controls 2. It may be possible to define a edit menu in the template, making it disabled by default. This would have the benefit of showing a menu with a more consistent look.

Can someone confirm this? What about upgrading the TextArea element in notes to QtQuick.Controls 2 and adding the menu in the template in plasma-frameworks? Or is there a edit menu available already somewhere? If someone could provide a hint I may be able to provide a patch for this. Thanks!

luc4 updated this revision to Diff 63248.Aug 7 2019, 12:29 AM

I updated the TextArea element to QtQuickControls 2 (this may not be necessary) and I added a menu with a look more consistent with the rest of Plasma. The menu includes the same actions we had before: undo, redo, copy, cut, paste, delete, clear and select all. In addition, I added a new paste action (now the default paste action), which pastes without formatting. Also, I set the shortcut to remove formatting before pasting.

Thanks, looks like it was a lot of work! It all seems to work well. Could you update the title and summary so they reflect what's in the patch now? I'll let Plasma folks take over the review now.

luc4 retitled this revision from Add a button to the notes applet to clear formatting to In the note applet, always paste without formatting by default. Add an action to paste preserving formatting in the contextual menu..Aug 7 2019, 1:05 AM

Could you update the title and summary so they reflect what's in the patch now?

This isn't done (or at least phabricator is being unhelpful and not showing it if you have)

Generally seems ok. Two minor comments.

applets/notes/package/contents/ui/main.qml
238

Where does this libplasma5 domain come from?

applets/notes/plugin/documenthandler.cpp
94

This could benefit from a name to explain the difference from the regular text edit paste.

luc4 added a comment.EditedAug 26 2019, 10:42 AM

Could you update the title and summary so they reflect what's in the patch now?

This isn't done (or at least phabricator is being unhelpful and not showing it if you have)

Not sure if I understand, sorry. I changed the title and I read an update message:

luc4 retitled this revision from Add a button to the notes applet to clear formatting to In the note applet, always paste without formatting by default. Add an action to paste preserving formatting in the contextual menu..

Sorry, not very comfortable with phabricator yet.
Thanks for your review!

applets/notes/package/contents/ui/main.qml
238

I think I copied from here: https://git.reviewboard.kde.org/r/121698/diff/1/#. Is it outdated maybe?

davidedmundson added inline comments.Aug 26 2019, 3:22 PM
applets/notes/package/contents/ui/main.qml
238

~ish.

To explain what it's doing.

i18n("hello")

will return a translated version of the word "hello" based on the currently loaded domain, which is done automatically for applets and applications, but there's some issues with library code.

i18nd("somePotFile", "hello") will explicitly load the pot file "somePotFile" then translate the word hello.


In this particular case, everything used is within the applet, so you can just use i18n

luc4 updated this revision to Diff 64689.Aug 26 2019, 6:10 PM

Updated according to requests.

luc4 marked 4 inline comments as done.Aug 26 2019, 6:12 PM
davidedmundson accepted this revision.Sep 7 2019, 2:43 PM
This revision is now accepted and ready to land.Sep 7 2019, 2:43 PM
luc4 added a comment.Sep 7 2019, 3:22 PM

Sorry but someone will have to also commit for me, I don't have commit access.
Thanks!

This revision was automatically updated to reflect the committed changes.

Lovely contribution!