lib

KoCharSelectDia.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KoCharSelectDia.h"
00021 #include "KoCharSelectDia.moc"
00022 
00023 #include <qlayout.h>
00024 
00025 #include <klocale.h>
00026 #include <kcharselect.h>
00027 #include <kdebug.h>
00028 /******************************************************************/
00029 /* class KoCharSelectDia                                           */
00030 /******************************************************************/
00031 
00032 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _enableFont , bool _modal)
00033     : KDialogBase( Plain, i18n("Select Character"), Ok | Cancel, Ok , parent, name, _modal )
00034 {
00035     initDialog(_chr,_font,_enableFont);
00036 
00037     KGuiItem okItem = KStdGuiItem::ok(); // start from std item to keep the OK icon...
00038     okItem.setText( i18n("&Insert") );
00039     okItem.setWhatsThis( i18n("Insert the selected character in the text") );
00040     setButtonOK( okItem );
00041 }
00042 
00043 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
00044     : KDialogBase( Plain, i18n("Select Character"), User1 | Close, User1 , parent, name, _modal )
00045 {
00046     initDialog(_chr,_font,true);
00047 
00048     setButtonText( User1, i18n("&Insert") );
00049     setButtonTip( User1, i18n("Insert the selected character in the text") );
00050 
00051 }
00052 
00053 void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool /*_enableFont*/)
00054 {
00055    QWidget *page = plainPage();
00056 
00057     grid = new QGridLayout( page, 1, 1, 0, KDialog::spacingHint() );
00058 
00059     charSelect = new KCharSelect( page, "", _font, _chr );
00060     connect(charSelect, SIGNAL(doubleClicked()),this, SLOT(slotDoubleClicked()));
00061     charSelect->resize( charSelect->sizeHint() );
00062     charSelect->enableFontCombo( true );
00063     grid->addWidget( charSelect, 0, 0 );
00064 
00065     grid->addColSpacing( 0, charSelect->width() );
00066     grid->addRowSpacing( 0, charSelect->height() );
00067     grid->setRowStretch( 0, 0 );
00068     charSelect->setFocus();
00069 }
00070 
00071 KoCharSelectDia::~KoCharSelectDia()
00072 {
00073 }
00074 
00075 void KoCharSelectDia::closeDialog()
00076 {
00077     KDialogBase::close();
00078 }
00079 
00080 bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont, QWidget* parent, const char* name )
00081 {
00082     bool res = false;
00083 
00084     KoCharSelectDia *dlg = new KoCharSelectDia( parent, name, _chr, _font, _enableFont );
00085     dlg->setFocus();
00086     if ( dlg->exec() == Accepted )
00087     {
00088         _font = dlg->font();
00089         _chr = dlg->chr();
00090         res = true;
00091     }
00092 
00093     delete dlg;
00094 
00095     return res;
00096 }
00097 
00098 QChar KoCharSelectDia::chr() const
00099 {
00100     return charSelect->chr();
00101 }
00102 
00103 QString KoCharSelectDia::font() const
00104 {
00105     return charSelect->font();
00106 }
00107 
00108 void KoCharSelectDia::slotUser1()
00109 {
00110     emit insertChar(chr(),font());
00111 }
00112 
00113 void KoCharSelectDia::slotDoubleClicked()
00114 {
00115     emit insertChar(chr(),font());
00116 }
KDE Home | KDE Accessibility Home | Description of Access Keys