Ticket #105: spell-checker.patch

File spell-checker.patch, 8.2 KB (added by amroth, 4 years ago)
  • kmess/chat/chatwindow.h

     
    128128    void               toggleEmoticons(bool useEmoticons); 
    129129    // Called when the "show sidebar" action is called. 
    130130    void               toggleSidebar(); 
     131    // Called when the "use spell checking" action is called. 
     132    void               toggleSpellCheck( bool useSpellCheck ); 
    131133 
    132134  private: // Private methods 
    133135    // Check if the user enabled an auto-reply, and send it 
  • kmess/chat/chatwindowinterface.cpp

     
    316316  settingsMenu = new KPopupMenu( this, "settingsmenu" ); 
    317317 
    318318  // Create the "settings" menus 
    319   emoticonAction_ = new KToggleAction( i18n("Show &Emoticons"),            "services", KShortcut(), this, "emoticons" ); 
    320   sidebarAction_  = new KAction      ( i18n("Show/Hide &Contact Sidebar"), "fonts",    KShortcut( QKeySequence( "Ctrl+T" ) ), this, "sidebar"   ); 
     319  spellCheckAction_ = new KToggleAction( i18n("Use &Spell Checking"),        "spellcheck", KShortcut(), this, "spellcheck" ); 
     320  emoticonAction_   = new KToggleAction( i18n("Show &Emoticons"),            "services",   KShortcut(), this, "emoticons" ); 
     321  sidebarAction_    = new KAction      ( i18n("Show/Hide &Contact Sidebar"), "fonts",      KShortcut( QKeySequence( "Ctrl+T" ) ), this, "sidebar"   ); 
    321322  showToolBar_    = KStdAction::showToolbar  ( this, SLOT( showToolBar() ),   actionCollection() ); 
    322323  showStatusBar_  = KStdAction::showStatusbar( this, SLOT( showStatusBar() ), actionCollection() ); 
    323324 
    324   connect ( emoticonAction_, SIGNAL(         toggled(bool) ), 
    325             this,            SLOT  ( toggleEmoticons(bool) ) ); 
    326   connect ( sidebarAction_,  SIGNAL(       activated()     ), 
    327             this,            SLOT  (   toggleSidebar()     ) ); 
     325  connect ( emoticonAction_,   SIGNAL(          toggled(bool) ), 
     326            this,              SLOT  (  toggleEmoticons(bool) ) ); 
     327  connect ( sidebarAction_,    SIGNAL(        activated()     ), 
     328            this,              SLOT  (    toggleSidebar()     ) ); 
     329  connect ( spellCheckAction_, SIGNAL(          toggled(bool) ), 
     330            this,              SLOT  ( toggleSpellCheck(bool) ) ); 
    328331 
    329332  // Give the sidebar action a tool tip like the standard actions 
    330333  sidebarAction_ ->setToolTip( i18n("Show or hide the contact sidebar") ); 
     
    332335  sidebarAction_->setIcon( "view_right" ); 
    333336 
    334337  // Plug the items into "settings" 
    335   emoticonAction_->plug( settingsMenu ); 
    336   showToolBar_->   plug( settingsMenu ); 
    337   showStatusBar_-> plug( settingsMenu ); 
    338   sidebarAction_-> plug( settingsMenu ); 
     338  spellCheckAction_->plug( settingsMenu ); 
     339  settingsMenu->insertSeparator(); 
     340  emoticonAction_  ->plug( settingsMenu ); 
     341  showToolBar_     ->plug( settingsMenu ); 
     342  showStatusBar_   ->plug( settingsMenu ); 
     343  sidebarAction_   ->plug( settingsMenu ); 
    339344 
    340345  // Plug the menu into the menubar 
    341346  menuBar()->insertItem( i18n("&Settings"), settingsMenu ); 
     
    472477} 
    473478 
    474479 
     480 
     481// Called when the "use spell checking" action is called. 
     482void ChatWindowInterface::toggleSpellCheck( bool /*useSpellCheck*/ ) 
     483{ 
     484  kdDebug() << "ChatWindowInterface::toggleSpellCheck not implemented" << endl; 
     485} 
     486 
     487 
    475488#include "chatwindowinterface.moc" 
  • kmess/chat/chatwindow.cpp

     
    2626#include <qregexp.h> 
    2727#include <qstylesheet.h> 
    2828#include <qtextcodec.h> 
    29 #include <qtextedit.h> 
    3029#include <qtoolbox.h> 
    3130 
    3231#include <kaction.h> 
     
    4241#include <kprocess.h> 
    4342#include <kstatusbar.h> 
    4443#include <ksqueezedtextlabel.h> 
     44#include <ksyntaxhighlighter.h> 
    4545#include <ktextbrowser.h> 
     46#include <ktextedit.h> 
    4647#include <ktoolbarbutton.h> 
    4748 
    4849#include "../actions/accountaction.h" 
     
    10481049  kdDebug() << "ChatWindow::readProperties() - Reading saved properties." << endl; 
    10491050#endif 
    10501051 
     1052  // First save the general interface settings 
    10511053  ChatWindowInterface::readProperties( config ); 
    10521054 
    1053 // Decomment should we need to read or save something again 
    1054 //  config->setGroup("Chat Window"); 
     1055  // Start saving our stuff 
     1056  config->setGroup( "Chat Window" ); 
     1057 
     1058  // Save the spell checking preference 
     1059  toggleSpellCheck( config->readBoolEntry("UseSpellCheck", false) ); 
     1060 
    10551061} 
    10561062 
    10571063 
     
    12891295  kdDebug() << "ChatWindow - Saving properties." << endl; 
    12901296#endif 
    12911297 
     1298  // First save the general interface settings 
     1299  ChatWindowInterface::saveProperties( config ); 
     1300 
     1301 
     1302  // Start saving our stuff 
     1303  config->setGroup( "Chat Window" ); 
     1304 
     1305  // Save the spell checking preference 
     1306  config->writeEntry( "UseSpellCheck", chatView_->messageEdit_->checkSpellingEnabled() ); 
     1307 
    12921308  // Also save ChatView's settings 
    12931309  chatView_->saveProperties( config ); 
    1294  
    1295   ChatWindowInterface::saveProperties( config ); 
    1296  
    1297 // Decomment should we need to read or save something again 
    1298 //   config->setGroup( "Chat Window" ); 
    12991310} 
    13001311 
    13011312 
     
    16561667 
    16571668 
    16581669 
     1670// Called when the "use spell checking" action is called. 
     1671void ChatWindow::toggleSpellCheck( bool useSpellCheck ) 
     1672{ 
     1673  // Don't crash if the chat view isn't available 
     1674  if( KMESS_NULL(chatView_) ) return; 
     1675 
     1676#ifdef KMESSDEBUG_CHATWINDOW_GENERAL 
     1677  kdDebug() << "ChatWindow::toggleSpellCheck() - Spell checking is now " << useSpellCheck << endl; 
     1678#endif 
     1679 
     1680  // Access the spell checker 
     1681  QSyntaxHighlighter       *syntax = chatView_->messageEdit_->syntaxHighlighter(); 
     1682  KDictSpellingHighlighter *spell  = dynamic_cast<KDictSpellingHighlighter*>( syntax ); 
     1683 
     1684  if( spell ) 
     1685  { 
     1686    // Put it to work 
     1687    spell->setAutomatic( useSpellCheck ); 
     1688    spell->setActive( useSpellCheck ); 
     1689  } 
     1690#ifdef KMESSDEBUG_CHATWINDOW_GENERAL 
     1691  else 
     1692  { 
     1693    kdDebug() << "ChatWindow::toggleSpellCheck() - Spell checking unavailable." << endl; 
     1694  } 
     1695#endif 
     1696 
     1697  // Enable the spell check for the message editor 
     1698  chatView_->messageEdit_->setCheckSpellingEnabled( useSpellCheck ); 
     1699} 
     1700 
     1701 
     1702 
    16591703// Called when the "show sidebar" action is called. 
    16601704void ChatWindow::toggleSidebar() 
    16611705{ 
  • kmess/chat/chatview.cpp

     
    2727#include <qstringlist.h> 
    2828#include <qtextbrowser.h> 
    2929#include <qtextcodec.h> 
    30 #include <qtextedit.h> 
    3130#include <qtoolbox.h> 
    3231 
    3332#include <kaction.h> 
     
    4241#include <krun.h> 
    4342#include <kstddirs.h> 
    4443#include <ktextbrowser.h> 
     44#include <ktextedit.h> 
    4545#include <kurl.h> 
    4646 
    4747#include "chatmessage.h" 
  • kmess/chat/chatviewinterface.ui

     
    192192                                </spacer> 
    193193                            </vbox> 
    194194                        </widget> 
    195                         <widget class="QTextEdit" row="0" column="0"> 
     195                        <widget class="KTextEdit" row="0" column="0"> 
    196196                            <property name="name"> 
    197197                                <cstring>messageEdit_</cstring> 
    198198                            </property> 
  • kmess/chat/chatwindowinterface.h

     
    7979    virtual void     toggleEmoticons(bool useEmoticons); 
    8080    // Called when the "show sidebar" action is called. 
    8181    virtual void     toggleSidebar(); 
     82    // Called when the "use spell checking" action is called. 
     83    virtual void     toggleSpellCheck(bool useSpellCheck); 
    8284    // Send a nudge 
    8385    virtual void     slotSendNudge(); 
    8486    // Send a file to a contact. 
     
    99101    KToggleAction   *showStatusBar_, *showToolBar_; 
    100102    // The sidebar toggle 
    101103    KAction         *sidebarAction_; 
     104    // The spell checking toggle 
     105    KToggleAction   *spellCheckAction_; 
    102106 
    103107 
    104108  private: // Private methods