1 | /*************************************************************************** |
2 | dlgspecchar.cpp - description |
3 | ------------------- |
4 | copyright : (C) 2003-2009 Peter Hedlund <peter.hedlund@kdemail.net> |
5 | |
6 | ***************************************************************************/ |
7 | |
8 | /*************************************************************************** |
9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * |
14 | * * |
15 | ***************************************************************************/ |
16 | |
17 | #include "dlgspecchar.h" |
18 | |
19 | #include <KLocale> |
20 | #include <KCharSelect> |
21 | |
22 | DlgSpecChar::DlgSpecChar(QWidget *parent, const QFont &font, const QChar &chr) : KDialog(parent) |
23 | { |
24 | setCaption( i18nc("@title:window select character dialog" , "Select Character" ) ); |
25 | setButtons(User1 | Cancel); |
26 | setDefaultButton(User1); |
27 | setModal(true); |
28 | |
29 | initDialog(font, chr); |
30 | |
31 | setButtonText( User1, i18nc("@action:button select" , "&Select" ) ); |
32 | setButtonToolTip( User1, i18nc("@info:tooltip select this character" , "Select this character" ) ); |
33 | connect(this,SIGNAL(user1Clicked()),this,SLOT(slotUser1())); |
34 | } |
35 | |
36 | void DlgSpecChar::initDialog(const QFont &font, const QChar &chr) |
37 | { |
38 | m_charSelect = new KCharSelect(this, 0); |
39 | m_charSelect->setCurrentChar(chr); |
40 | m_charSelect->setCurrentFont(font); |
41 | connect(m_charSelect, SIGNAL(charSelected(QChar)),this, SLOT(slotDoubleClicked())); |
42 | m_charSelect->resize(m_charSelect->sizeHint()); |
43 | m_charSelect->setFocus(); |
44 | setMainWidget(m_charSelect); |
45 | } |
46 | |
47 | void DlgSpecChar::closeDialog() |
48 | { |
49 | KDialog::close(); |
50 | } |
51 | |
52 | QChar DlgSpecChar::chr() |
53 | { |
54 | return m_charSelect->currentChar(); |
55 | } |
56 | |
57 | void DlgSpecChar::slotDoubleClicked() |
58 | { |
59 | emit insertChar(chr()); |
60 | closeDialog(); |
61 | } |
62 | |
63 | void DlgSpecChar::slotUser1( ) |
64 | { |
65 | emit insertChar(chr()); |
66 | closeDialog(); |
67 | } |
68 | |
69 | #include "dlgspecchar.moc" |
70 | |