[PATCH] [Kmail2] [Bug 373040] Stop line wrapping for long links.

Stéphane Clérambault stephane at clerambault.fr
Thu Jan 13 01:11:36 GMT 2022


I have a working patch for *kpimtextedit*. My patch set the 
`nonBreakableLines` on block when it detects a links.

That means no more line breaks will occur on that paragraphe. It works well 
when link are alone on a paragraph.

-- 
Stéphane Clérambault

Le jeudi 13 janvier 2022 02:09:40 CET Stéphane Clérambault a écrit :
> ---
>  src/composer-ng/richtextcomposer.cpp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/composer-ng/richtextcomposer.cpp
> b/src/composer-ng/richtextcomposer.cpp index d9e79c4..568da8e 100644
> --- a/src/composer-ng/richtextcomposer.cpp
> +++ b/src/composer-ng/richtextcomposer.cpp
> @@ -77,6 +77,17 @@ RichTextComposer::RichTextComposer(QWidget *parent)
>                  d->undoHtmlVersion.clear();
>              }
>          }
> +
> +        if (d->mode == RichTextComposer::Plain) {
> +            QTextBlockFormat nonBreakableLinkFormat;
> +            nonBreakableLinkFormat.setNonBreakableLines(true);
> +            QTextCursor cursor = textCursor();
> +            const QLatin1String httpPattern = QLatin1String("http");
> +
> +            if (cursor.block().text().startsWith(httpPattern))
> +                if (cursor.blockFormat().nonBreakableLines() == false)
> +                    cursor.setBlockFormat(nonBreakableLinkFormat);
> +        }
>      });
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20220113/28241c0c/attachment-0001.sig>


More information about the kde-pim mailing list