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

KPIMTextedit Library

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 
24 #include <KLocalizedString>
25 #include <KTextEdit>
26 
27 #include <QVBoxLayout>
28 #include <QLabel>
29 
30 namespace KPIMTextEdit {
31 
32 class InsertHtmlDialogPrivate
33 {
34  public:
35  InsertHtmlDialogPrivate( InsertHtmlDialog *qq )
36  : q( qq )
37  {
38  q->setCaption( i18n( "Insert HTML" ) );
39  q->setButtons( KDialog::Ok|KDialog::Cancel );
40  q->setButtonText( KDialog::Ok, i18n( "Insert" ) );
41  QWidget *page = new QWidget( q );
42  q->setMainWidget( page );
43  QVBoxLayout *lay = new QVBoxLayout( page );
44  QLabel *label = new QLabel( i18n( "Insert HTML tags and texts:" ) );
45  lay->addWidget( label );
46  editor = new KTextEdit;
47  new HtmlHighlighter( editor->document() );
48  editor->setAcceptRichText( false );
49  editor->setFocus();
50  lay->addWidget( editor );
51  label = new QLabel( i18n( "Example: <i> Hello word </i>" ) );
52  QFont font = label->font();
53  font.setBold( true );
54  label->setFont( font );
55  label->setTextFormat( Qt::PlainText );
56  lay->addWidget( label );
57  q->connect( editor, SIGNAL(textChanged()),
58  q, SLOT(_k_slotTextChanged()) );
59  q->enableButtonOk( false );
60  q->resize( 640, 480 );
61  }
62 
63  void _k_slotTextChanged();
64 
65  KTextEdit *editor;
66  InsertHtmlDialog *q;
67 };
68 
69 void InsertHtmlDialogPrivate::_k_slotTextChanged()
70 {
71  q->enableButtonOk( !editor->toPlainText().isEmpty() );
72 }
73 
74 InsertHtmlDialog::InsertHtmlDialog( QWidget *parent )
75  : KDialog( parent ), d( new InsertHtmlDialogPrivate( this ) )
76 {
77 }
78 
79 InsertHtmlDialog::~InsertHtmlDialog()
80 {
81  delete d;
82 }
83 
84 QString InsertHtmlDialog::html() const
85 {
86  return d->editor->toPlainText();
87 }
88 
89 }
90 
91 #include "moc_inserthtmldialog.cpp"
QWidget
QFont
QFont::setBold
void setBold(bool enable)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QLabel::setTextFormat
void setTextFormat(Qt::TextFormat)
QVBoxLayout
QString
QWidget::font
font
QLabel
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:23 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

Search



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