Only allow one recipient per line in composer
ClosedPublic

Authored by dvratil on Jul 30 2016, 3:58 PM.

Details

Summary

For the Opportunistic encryption task (T2520, D1639), we need to show an icon next to a each recipient showing status of the encryption key we are going to use. However it is not possible to put icons mid-text in K(Q)LineEdit, only at the beginning of the line, which is a problem if there are multiple recipients in a single line. I've spent quite some time trying to come up with a fake LineEdit widget that would be seemlessly composed of multiple QToolButton+QLineEdit widgets inside a QScrollArea, but the user experience was never as good as with a single QLineEdit. Therefore I opted for an alternative strategy of only allowing a single recipient per line. The RecipientEditor already automatically jumps to next line when you autocomplete a contact from addressbook/LDAP, so I only needed to handle situation when user does not autocomplete but instead types comma (or semicolon) to write more contacts into single edit, or when they copy-paste a comma-separated list of emails into a single edit.

This patch adds a simple eventFilter that listens for comma/semicolon keypresses in the RecipientLineEdit and adds a new line, gives it a focus and consumes the keypress. I also adjusted the slotCalculateTotal() method which is called whenever a new email(s) are entered into any RecipientLineEdit to automatically split any RecipientLineEdit which has more than one recipient into multiple lines.

If you can figure out any other way how get multiple contacts into single line, let me know :-)

Diff Detail

Repository
R94 PIM: Message Library
Lint
Lint Skipped
Unit
Unit Tests Skipped
dvratil updated this revision to Diff 5574.Jul 30 2016, 3:58 PM
dvratil retitled this revision from to Only allow one recipient per line in composer.
dvratil updated this object.
dvratil edited the test plan for this revision. (Show Details)
dvratil added reviewers: mlaurent, aheinecke.
dvratil set the repository for this revision to R94 PIM: Message Library.
dvratil added a project: KDE PIM.
dvratil added a subscriber: KDE PIM.
Restricted Application added a subscriber: kde-pim. · View Herald TranscriptJul 30 2016, 3:58 PM
mlaurent edited edge metadata.Jul 30 2016, 6:07 PM

Is it work when we copy/paste a list of emails (list email with a comma separator) ?

Could you provide an autotest ?

mlaurent requested changes to this revision.Jul 30 2016, 6:08 PM
mlaurent edited edge metadata.
This revision now requires changes to proceed.Jul 30 2016, 6:08 PM

Is it work when we copy/paste a list of emails (list email with a comma separator) ?

Yes it does - pasting a text to an entry triggers RecipientEditor::slotCalculateTotal() which will take care for splitting the comma-separated list to multiple lines

Could you provide an autotest ?

Will do.

dvratil updated this revision to Diff 5585.Jul 31 2016, 2:07 PM
dvratil edited edge metadata.

Add a simple unit-test

mlaurent requested changes to this revision.Aug 1 2016, 5:15 AM
mlaurent edited edge metadata.

I see an email as "foo, bla" <bloblo@kde.org>" for example how do you manage it ?

Regards

This revision now requires changes to proceed.Aug 1 2016, 5:15 AM
dvratil updated this revision to Diff 5607.Aug 1 2016, 3:29 PM
dvratil edited edge metadata.

Correctly handle commas in names

mlaurent accepted this revision.Aug 2 2016, 5:11 AM
mlaurent edited edge metadata.

I tested it it seems ok.

Thanks
Regards

This revision is now accepted and ready to land.Aug 2 2016, 5:11 AM