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 setButtonOKText(i18n("&Insert"),
00038 i18n("Insert the selected character in the text"));
00039
00040 }
00041
00042 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
00043 : KDialogBase( Plain, i18n("Select Character"), User1 | Close, User1 , parent, name, _modal )
00044 {
00045 initDialog(_chr,_font,true);
00046
00047 setButtonText( User1, i18n("&Insert") );
00048 setButtonTip( User1, i18n("Insert the selected character in the text") );
00049
00050 }
00051
00052 void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool )
00053 {
00054 QWidget *page = plainPage();
00055
00056 grid = new QGridLayout( page, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
00057
00058 charSelect = new KCharSelect( page, "", _font, _chr );
00059 connect(charSelect, SIGNAL(doubleClicked()),this, SLOT(slotDoubleClicked()));
00060 charSelect->resize( charSelect->sizeHint() );
00061 charSelect->enableFontCombo( true );
00062 grid->addWidget( charSelect, 0, 0 );
00063
00064 grid->addColSpacing( 0, charSelect->width() );
00065 grid->addRowSpacing( 0, charSelect->height() );
00066 grid->setRowStretch( 0, 0 );
00067 charSelect->setFocus();
00068 }
00069
00070 KoCharSelectDia::~KoCharSelectDia()
00071 {
00072 }
00073
00074 void KoCharSelectDia::closeDialog()
00075 {
00076 KDialogBase::close();
00077 }
00078
00079 bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont )
00080 {
00081 bool res = false;
00082
00083 KoCharSelectDia *dlg = new KoCharSelectDia( 0L, "Select Character", _chr, _font, _enableFont );
00084 dlg->setFocus();
00085 if ( dlg->exec() == Accepted )
00086 {
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()
00099 {
00100 return charSelect->chr();
00101 }
00102
00103 QString KoCharSelectDia::font()
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 }