00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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();
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 )
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 }