• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KPIMTextedit Library

  • kpimtextedit
inserthtmldialog.cpp
1 /*
2  Copyright (c) 2012 Montel Laurent <montel@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include "inserthtmldialog.h"
22 #include "htmlhighlighter.h"
23 #include <KLocale>
24 
25 #include <KTextEdit>
26 #include <QVBoxLayout>
27 #include <QLabel>
28 namespace KPIMTextEdit {
29 
30 class InsertHtmlDialogPrivate
31 {
32 public:
33  InsertHtmlDialogPrivate(InsertHtmlDialog *qq)
34  :q( qq )
35  {
36  q->setCaption( i18n( "Insert HTML" ) );
37  q->setButtons( KDialog::Ok|KDialog::Cancel );
38  q->setButtonText( KDialog::Ok, i18n( "Insert" ) );
39  QWidget *page = new QWidget( q );
40  q->setMainWidget( page );
41  QVBoxLayout *lay = new QVBoxLayout( page );
42  QLabel *label = new QLabel( i18n( "Insert HTML tags and texts:" ) );
43  lay->addWidget( label );
44  editor = new KTextEdit;
45  new HtmlHighlighter( editor->document() );
46  editor->setAcceptRichText( false );
47  editor->setFocus();
48  lay->addWidget( editor );
49  label = new QLabel( i18n( "Example: <i> Hello word </i>" ) );
50  QFont font = label->font();
51  font.setBold( true );
52  label->setFont( font );
53  label->setTextFormat( Qt::PlainText );
54  lay->addWidget( label );
55  q->connect( editor, SIGNAL(textChanged()),q,SLOT(_k_slotTextChanged()) );
56  q->enableButtonOk( false );
57  q->resize(640,480);
58  }
59 
60  void _k_slotTextChanged();
61 
62  KTextEdit *editor;
63  InsertHtmlDialog *q;
64 };
65 
66 void InsertHtmlDialogPrivate::_k_slotTextChanged()
67 {
68  q->enableButtonOk( !editor->toPlainText().isEmpty() );
69 }
70 
71 InsertHtmlDialog::InsertHtmlDialog(QWidget *parent)
72  : KDialog( parent ), d( new InsertHtmlDialogPrivate( this ) )
73 {
74 }
75 
76 InsertHtmlDialog::~InsertHtmlDialog()
77 {
78  delete d;
79 }
80 
81 QString InsertHtmlDialog::html() const
82 {
83  return d->editor->toPlainText();
84 }
85 
86 }
87 
88 #include "moc_inserthtmldialog.cpp"
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:01 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KPIMTextedit Library

Skip menu "KPIMTextedit Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal