20 #include "kactivelabel.h"
22 #include <tdeapplication.h>
24 #include <tqwhatsthis.h>
25 #include <tqsimplerichtext.h>
29 : TQTextBrowser(parent, name)
35 : TQTextBrowser(parent, name)
41 void KActiveLabel::init()
43 setTextFormat(TQt::RichText);
44 setVScrollBarMode(TQScrollView::AlwaysOff);
45 setHScrollBarMode(TQScrollView::AlwaysOff);
46 setFrameStyle(TQFrame::NoFrame);
47 setFocusPolicy( TQWidget::TabFocus );
50 connect(
this, TQ_SIGNAL(linkClicked(
const TQString &)),
51 this, TQ_SLOT(
openLink(
const TQString &)));
54 connect(kapp, TQ_SIGNAL(tdedisplayPaletteChanged()),
55 this, TQ_SLOT(paletteChanged()));
59 void KActiveLabel::paletteChanged()
61 TQPalette p = kapp ? kapp->palette() : palette();
62 p.setBrush(TQColorGroup::Base, p.brush(TQPalette::Active, TQColorGroup::Background));
63 p.setColor(TQColorGroup::Text, p.color(TQPalette::Active, TQColorGroup::Foreground));
69 TQRegExp whatsthis(
"whatsthis:/*([^/].*)");
70 if (whatsthis.exactMatch(link)) {
71 TQWhatsThis::display(whatsthis.cap(1));
76 args <<
"exec" << link;
77 kapp->tdeinitExec(
"kfmclient", args);
80 void KActiveLabel::virtual_hook(
int,
void* )
83 void KActiveLabel::focusInEvent( TQFocusEvent* fe )
85 TQTextBrowser::focusInEvent(fe);
86 if(fe->reason() == TQFocusEvent::Tab || fe->reason() == TQFocusEvent::Backtab)
90 void KActiveLabel::focusOutEvent( TQFocusEvent* fe )
92 TQTextBrowser::focusOutEvent(fe);
93 if(fe->reason() == TQFocusEvent::Tab || fe->reason() == TQFocusEvent::Backtab)
97 void KActiveLabel::keyPressEvent( TQKeyEvent *e )
107 TQWidget::keyPressEvent( e );
110 TQTextBrowser::keyPressEvent( e );
114 TQSize KActiveLabel::minimumSizeHint()
const
116 TQSize ms = minimumSize();
117 if ((ms.width() > 0) && (ms.height() > 0))
124 TQString txt = text();
125 TQSimpleRichText rt(txt, font());
126 rt.setWidth(w - 2*frameWidth() - 10);
127 w = 10 + rt.widthUsed() + 2*frameWidth();
130 int h = rt.height() + 2*frameWidth();
131 if ( h < ms.height())
137 TQSize KActiveLabel::sizeHint()
const
139 return minimumSizeHint();
142 #include "kactivelabel.moc"
virtual void openLink(const TQString &link)
Opens link in the default browser.
KActiveLabel(TQWidget *parent, const char *name=0)
Constructor.
const TDEShortcut & selectAll()