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

Laurent Montel montel at kde.org
Thu Jan 13 05:51:06 GMT 2022


Hi,
Please use invent.kde.org for posting your patch. Thanks

Please add autotests for it it’s more easy to see if it fixes bug.

You compare against http but what about ftp/imaps etc...

Regards

On jeudi 13 janvier 2022 02:11:36 CET Stéphane Clérambault wrote:
> 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.
> 
> > ---
> > 
> >  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);
> > +        }
> > 
> >      });
> >  
> >  }


-- 
Laurent Montel | laurent.montel at kdab.com | KDE/Qt Senior Software Engineer 
KDAB (France) S.A.S., a KDAB Group company
Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts




More information about the kde-pim mailing list