22 #include <tqpainter.h> 23 #include <tqpushbutton.h> 24 #include <klineedit.h> 27 #include <kcharselect.h> 28 #include <tdelocale.h> 29 #include <kpushbutton.h> 30 #include <kstdguiitem.h> 34 #include "psymbolcombo.h" 38 PSymbolCombo::PSymbolCombo(MultiProperty *property, TQWidget *parent,
const char *name)
39 :PropertyWidget(property, parent, name)
41 l =
new TQHBoxLayout(
this);
42 m_edit =
new KLineEdit(
this);
43 m_edit->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding);
44 m_edit->setMaxLength(1);
46 m_select =
new TQPushButton(
"...",
this);
47 m_select->setSizePolicy(TQSizePolicy::Maximum, TQSizePolicy::MinimumExpanding);
48 l->addWidget(m_select);
54 connect(m_select, TQT_SIGNAL(clicked()),
this, TQT_SLOT(selectChar()));
55 connect(m_edit, TQT_SIGNAL(textChanged(
const TQString&)),
this, TQT_SLOT(updateProperty(
const TQString&)));
60 if (!(m_edit->text().isNull()))
61 return TQVariant(TQString(
"%1").arg(m_edit->text().at(0).unicode()));
68 if (!(value.isNull()))
70 disconnect(m_edit, TQT_SIGNAL(textChanged(
const TQString&)),
this, TQT_SLOT(updateProperty(
const TQString&)));
71 m_edit->setText(TQChar(value.toInt()));
72 connect(m_edit, TQT_SIGNAL(textChanged(
const TQString&)),
this, TQT_SLOT(updateProperty(
const TQString&)));
78 void PSymbolCombo::selectChar()
81 TQDialog* dia =
new TQDialog(
this,
"select_dialog",
true);
82 TQVBoxLayout *dv =
new TQVBoxLayout(dia, 2);
84 KCharSelect *select =
new KCharSelect(dia,
"select_char");
85 dv->addWidget(select);
87 TQHBoxLayout *dh =
new TQHBoxLayout(dv, 6);
88 KPushButton *pbOk =
new KPushButton(KStdGuiItem::ok(), dia);
89 KPushButton *pbCancel =
new KPushButton(KStdGuiItem::cancel(), dia);
90 TQSpacerItem *si =
new TQSpacerItem(30, 0, TQSizePolicy::Expanding, TQSizePolicy::Expanding);
92 connect(pbOk, TQT_SIGNAL(clicked()), dia, TQT_SLOT(accept()));
93 connect(pbCancel, TQT_SIGNAL(clicked()), dia, TQT_SLOT(reject()));
97 dh->addWidget(pbCancel);
99 if (!(m_edit->text().isNull()))
100 select->setChar(m_edit->text().at(0));
102 if (dia->exec() == TQDialog::Accepted)
104 m_edit->setText(select->chr());
110 void PSymbolCombo::updateProperty(
const TQString& val)
112 emit
propertyChanged(m_property, TQVariant(TQString(
"%1").arg(val.at(0).unicode())));
117 p->setBrush(cg.background());
118 p->setPen(TQt::NoPen);
120 p->drawText(r, TQt::AlignLeft | TQt::AlignVCenter | TQt::SingleLine, TQChar(value.toInt()));
126 #include "psymbolcombo.moc" virtual void setValue(const TQVariant &value, bool emitChange=true)
Sets the value shown in the editor widget.
Namespace which contain property editing classes.
virtual TQVariant value() const
virtual void drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
Function to draw a property viewer when the editor isn't shown.
virtual TQVariant value() const