[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [patch] Spell checking in HTML TextEdits
From:       Scott Wheeler <wheeler () kde ! org>
Date:       2003-01-31 18:44:07
[Download RAW message or body]

Hi folks,

After another fit of misspelling in a web form today, it occurred to me that 
it would be rather nice to be able to spell check things in HTML forms, 
namely in text edits.  This is potentially useful for webmail, online forums 
(a.k.a. the dot).  Thinking about it, I'm surprised that this hasn't been 
done before...

This patch adds support for doing so to the RMB menu of TextAreaWidget in 
KHTML.  This can improve a bit -- i.e. actually tracking progress in the 
original widget and such, but that can come later.

If nobody objects, I'll commit this in the next day or two.

Cheers,

-Scott

-- 
"There is more stupidity than hydrogen in the universe, and it has a longer 
shelf life."
--Frank Zappa


["khtml-spellcheck.patch" (text/x-diff)]

? Doxyfile
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdelibs/khtml/Makefile.am,v
retrieving revision 1.140
diff -u -3 -p -r1.140 Makefile.am
--- Makefile.am	16 Jan 2003 18:56:01 -0000	1.140
+++ Makefile.am	31 Jan 2003 18:36:15 -0000
@@ -52,7 +52,8 @@ libkhtml_la_LIBADD = ./xml/libkhtmlxml.l
 	./misc/libkhtmlmisc.la ecma/libkjs_html.la ./dom/libkhtmldom.la $(LIBKJAVA) \
 	$(LIB_KPARTS) \
 	$(top_builddir)/kdeprint/libkdeprint.la  \
-	$(top_builddir)/kutils/libkutils.la 
+	$(top_builddir)/kutils/libkutils.la \
+	$(top_builddir)/kspell/libkspell.la
 
 dummy.cpp:
 	echo > $@
Index: rendering/render_form.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.cpp,v
retrieving revision 1.212
diff -u -3 -p -r1.212 render_form.cpp
--- rendering/render_form.cpp	21 Jan 2003 16:20:33 -0000	1.212
+++ rendering/render_form.cpp	31 Jan 2003 18:36:15 -0000
@@ -28,6 +28,8 @@
 #include <kfiledialog.h>
 #include <kcompletionbox.h>
 #include <kcursor.h>
+#include <kspell.h>
+#include <kiconloader.h>
 
 #include <qstyle.h>
 
@@ -1195,6 +1197,31 @@ bool TextAreaWidget::event( QEvent *e )
         }
     }
     return KTextEdit::event( e );
+}
+
+QPopupMenu *TextAreaWidget::createPopupMenu( const QPoint &pos )
+{
+    QPopupMenu *m = KTextEdit::createPopupMenu( pos );
+    m->insertSeparator();
+    m->insertItem( SmallIcon( "spellcheck" ), i18n( "Check Spelling" ), this, SLOT( \
slotCheckSpelling() ) ); +    return m;
+}
+
+void TextAreaWidget::slotCheckSpelling()
+{
+    (void) new KSpell( this, i18n( "Check Spelling" ), this, SLOT( \
slotSpellCheckReady( KSpell *) ), 0, true, true ); +}
+
+void TextAreaWidget::slotSpellCheckReady( KSpell *s )
+{
+    s->check( text() );
+    connect( s, SIGNAL( done( const QString & ) ), this, SLOT( slotSpellCheckDone( \
const QString & ) ) ); +}
+
+void TextAreaWidget::slotSpellCheckDone( const QString &s )
+{
+    if( s != text() )
+	setText( s );
 }
 
 // -------------------------------------------------------------------------
Index: rendering/render_form.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.h,v
retrieving revision 1.82
diff -u -3 -p -r1.82 render_form.h
--- rendering/render_form.h	29 Jan 2003 18:19:24 -0000	1.82
+++ rendering/render_form.h	31 Jan 2003 18:36:15 -0000
@@ -46,6 +46,7 @@ class QListboxItem;
 #include "dom/dom_misc.h"
 
 class KHTMLPartBrowserExtension;
+class KSpell;
 
 namespace DOM {
     class HTMLFormElementImpl;
@@ -385,11 +386,18 @@ protected slots:
 
 class TextAreaWidget : public KTextEdit
 {
+    Q_OBJECT
 public:
     TextAreaWidget(int wrap, QWidget* parent);
 
 protected:
     virtual bool event (QEvent *e );
+    virtual QPopupMenu *createPopupMenu(const QPoint &pos);
+
+protected slots:
+    void slotCheckSpelling();
+    void slotSpellCheckReady(KSpell *s);
+    void slotSpellCheckDone(const QString &s);
 };
 
 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic