[PATCH] Add clickMessage to KTextEdit

David Faure faure at kde.org
Mon Jul 21 11:11:20 BST 2008


On Thursday 17 July 2008, Davide Bettio wrote:
> Hi,
> 
> Attached patch is an updated patch that uses paintEvent and it works better 
> than the previous patch...

> @@ -97,6 +101,10 @@
>      QAction *spellCheckAction;
>      bool customPalette : 1;
>
> +    QString clickMessage;
> +    bool enableClickMsg:1;
> +    bool drawClickMsg:1;
> +
>      bool checkSpellingEnabled : 1;
>      bool findReplaceEnabled: 1;
>      QString originalBuffer;

Better keep the bools together to save on padding, so put clickMessage before customPalette for instance.

> +    //FIXME: fugly alert!
> +    // qlineedit uses an internal qstyleoption set to figure this out
> +    // and then adds a hardcoded 2 pixel interior to that.
> +    // probably requires fixes to Qt itself to do this cleanly
> +    // see define horizontalMargin 2 in qlineedit.cpp

Well, this doesn't apply to QTextEdit, does it?

> +    QStyleOptionFrame opt;
> +    opt.initFrom( viewport() );
> +    QRect cr = style()->subElementRect( QStyle::SE_LineEditContents, &opt,
> this ); +    cr.setLeft( cr.left() + 2 );
> +    cr.setRight( cr.right() - 2 );

This should be adapted to whatever QTextEdit uses as margins, it might
not be the same as QLineEdit margins.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list