Difference between revisions of "Development/Tutorials/Sonnet/SonnetTutorial"

Jump to: navigation, search
m
m (Text replace - "</code>" to "</syntaxhighlight>")
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
==Spellcheck action==
 
==Spellcheck action==
 
yourkmainwindowrderivative.h:
 
yourkmainwindowrderivative.h:
 +
<syntaxhighlight lang="cpp-qt">
 
  #include <sonnet/dialog.h>
 
  #include <sonnet/dialog.h>
 
   
 
   
Line 18: Line 19:
 
  private:
 
  private:
 
     Sonnet::Dialog* m_sonnetDialog;
 
     Sonnet::Dialog* m_sonnetDialog;
 
+
</syntaxhighlight>
  
 
yourkmainwindowrderivative.cpp:
 
yourkmainwindowrderivative.cpp:
 
+
<syntaxhighlight lang="cpp-qt">
 
  YourKMainWindowrDerivative::YourKMainWindowrDerivative(...)
 
  YourKMainWindowrDerivative::YourKMainWindowrDerivative(...)
 
     : KMainWindow(...)
 
     : KMainWindow(...)
Line 44: Line 45:
 
         m_sonnetDialog=new Sonnet::Dialog(
 
         m_sonnetDialog=new Sonnet::Dialog(
 
             new Sonnet::BackgroundChecker( this ),
 
             new Sonnet::BackgroundChecker( this ),
             0 );
+
             this );
 
         //connect signals to slots:
 
         //connect signals to slots:
 
         connect(m_sonnetDialog,SIGNAL(misspelling(const QString&,int)),
 
         connect(m_sonnetDialog,SIGNAL(misspelling(const QString&,int)),
Line 50: Line 51:
 
         //and so on:
 
         //and so on:
 
         ...
 
         ...
 
 
     }
 
     }
 
   
 
   
Line 63: Line 63:
 
  //other slots implemetation
 
  //other slots implemetation
 
  ...
 
  ...
+
</syntaxhighlight>
 
see [http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/classSonnet_1_1Dialog.html Sonnet::Dialog API] and [http://api.kde.org/4.0-api/kdelibs-apidocs/kdecore/html/namespaceSonnet.html Sonnet namespace page]
 
see [http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/classSonnet_1_1Dialog.html Sonnet::Dialog API] and [http://api.kde.org/4.0-api/kdelibs-apidocs/kdecore/html/namespaceSonnet.html Sonnet namespace page]
  
 
==On-the-fly (inline) spellcheck==
 
==On-the-fly (inline) spellcheck==
 
stub
 
stub

Latest revision as of 21:56, 29 June 2011

TODO

[edit] Spellcheck action

yourkmainwindowrderivative.h:

 #include <sonnet/dialog.h>
 
 ...
 
 private slots:
 ...
    void spellcheck();
    //void spellcheckDone();
    //void spellcheckShow(const QString&,int);
    //void spellcheckReplace(const QString&,int,const QString&);
    //void spellcheckStop(); 
    //void spellcheckCancel();
 ...
 private:
    Sonnet::Dialog* m_sonnetDialog;

yourkmainwindowrderivative.cpp:

 YourKMainWindowrDerivative::YourKMainWindowrDerivative(...)
    : KMainWindow(...)
    ...
    , m_sonnetDialog(0)
 
 ...
 
 void YourKMainWindowrDerivative::setupActions()
 {
    ...
    KStandardAction::spelling(this,SLOT(spellcheck()),actionCollection());
    ...
 }
 
 ...
 
 void KAider::spellcheck()
 {
    if (!m_sonnetDialog)
    {
        m_sonnetDialog=new Sonnet::Dialog(
            new Sonnet::BackgroundChecker( this ),
            this );
        //connect signals to slots:
        connect(m_sonnetDialog,SIGNAL(misspelling(const QString&,int)),
            this,SLOT(spellcheckShow(const QString&,int)));
        //and so on:
        ...
    }
 
    if (!m_view->selection().isEmpty())
        m_sonnetDialog->setBuffer( m_view->selection() );
    else
        m_sonnetDialog->setBuffer( m_view->toPlaintText());
 
    m_sonnetDialog->show();
 }
 
 //other slots implemetation
 ...

see Sonnet::Dialog API and Sonnet namespace page

[edit] On-the-fly (inline) spellcheck

stub


This page was last modified on 29 June 2011, at 21:56. This page has been accessed 10,106 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal