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>
00024 #include <QGridLayout>
00025
00026 #include <klocale.h>
00027 #include <kcharselect.h>
00028 #include <kdebug.h>
00029 #include <kstdguiitem.h>
00030
00031
00032
00033
00034
00035 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _enableFont , bool _modal)
00036 : KDialog( parent )
00037 {
00038 setCaption( i18n("Select Character") );
00039 setModal( _modal );
00040 setButtons( Ok | Cancel );
00041 setDefaultButton( Ok );
00042 setObjectName( name );
00043
00044 initDialog(_chr,_font,_enableFont);
00045
00046 KGuiItem okItem = KStdGuiItem::ok();
00047 okItem.setText( i18n("&Insert") );
00048 okItem.setWhatsThis( i18n("Insert the selected character in the text") );
00049 setButtonGuiItem( KDialog::Ok, okItem );
00050 }
00051
00052 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
00053 : KDialog( parent )
00054 {
00055 setCaption( i18n("Select Character") );
00056 setModal( _modal );
00057 setButtons( User1 | Close );
00058 setDefaultButton( User1 );
00059 setObjectName( name );
00060
00061 initDialog(_chr,_font,true);
00062
00063 setButtonText( User1, i18n("&Insert") );
00064 setButtonToolTip( User1, i18n("Insert the selected character in the text") );
00065
00066 }
00067
00068 void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool )
00069 {
00070 QWidget *page = mainWidget();
00071
00072 grid = new QGridLayout( page );
00073 grid->setMargin(0);
00074 grid->setSpacing(KDialog::spacingHint());
00075
00076 charSelect = new KCharSelect( page, _font, _chr );
00077 connect(charSelect, SIGNAL(doubleClicked()),this, SLOT(slotDoubleClicked()));
00078 charSelect->resize( charSelect->sizeHint() );
00079 charSelect->enableFontCombo( true );
00080 grid->addWidget( charSelect, 0, 0 );
00081
00082 grid->addItem( new QSpacerItem( charSelect->width(), 0 ), 0, 0 );
00083 grid->addItem( new QSpacerItem( 0, charSelect->height() ), 0, 0 );
00084 grid->setRowStretch( 0, 0 );
00085 charSelect->setFocus();
00086 }
00087
00088 KoCharSelectDia::~KoCharSelectDia()
00089 {
00090 }
00091
00092 void KoCharSelectDia::closeDialog()
00093 {
00094 KDialog::close();
00095 }
00096
00097 bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont, QWidget* parent, const char* name )
00098 {
00099 bool res = false;
00100
00101 KoCharSelectDia *dlg = new KoCharSelectDia( parent, name, _chr, _font, _enableFont );
00102 dlg->setFocus();
00103 if ( dlg->exec() == Accepted )
00104 {
00105 _font = dlg->font();
00106 _chr = dlg->chr();
00107 res = true;
00108 }
00109
00110 delete dlg;
00111
00112 return res;
00113 }
00114
00115 QChar KoCharSelectDia::chr() const
00116 {
00117 return charSelect->chr();
00118 }
00119
00120 QString KoCharSelectDia::font() const
00121 {
00122 return charSelect->font();
00123 }
00124
00125 void KoCharSelectDia::slotUser1()
00126 {
00127 emit insertChar(chr(),font());
00128 }
00129
00130 void KoCharSelectDia::slotDoubleClicked()
00131 {
00132 emit insertChar(chr(),font());
00133 }