• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
kactivelabel.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; version 2
7 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kactivelabel.h"
21
22#include <tdeapplication.h>
23#include <tqregexp.h>
24#include <tqwhatsthis.h>
25#include <tqsimplerichtext.h>
26#include <kdebug.h>
27
28KActiveLabel::KActiveLabel(TQWidget * parent, const char * name)
29 : TQTextBrowser(parent, name)
30{
31 init();
32}
33
34KActiveLabel::KActiveLabel(const TQString &text, TQWidget * parent, const char * name)
35 : TQTextBrowser(parent, name)
36{
37 init();
38 setText(text);
39}
40
41void KActiveLabel::init()
42{
43 setTextFormat(TQt::RichText);
44 setVScrollBarMode(TQScrollView::AlwaysOff);
45 setHScrollBarMode(TQScrollView::AlwaysOff);
46 setFrameStyle(TQFrame::NoFrame);
47 setFocusPolicy( TQWidget::TabFocus );
48 paletteChanged();
49
50 connect(this, TQ_SIGNAL(linkClicked(const TQString &)),
51 this, TQ_SLOT(openLink(const TQString &)));
52 if (tdeApp)
53 {
54 connect(tdeApp, TQ_SIGNAL(tdedisplayPaletteChanged()),
55 this, TQ_SLOT(paletteChanged()));
56 }
57}
58
59void KActiveLabel::paletteChanged()
60{
61 TQPalette p = tdeApp ? tdeApp->palette() : palette();
62 p.setBrush(TQColorGroup::Base, p.brush(TQPalette::Active, TQColorGroup::Background));
63 p.setColor(TQColorGroup::Text, p.color(TQPalette::Active, TQColorGroup::Foreground));
64 setPalette(p);
65}
66
67void KActiveLabel::openLink(const TQString & link)
68{
69 TQRegExp whatsthis("whatsthis:/*([^/].*)");
70 if (whatsthis.exactMatch(link)) {
71 TQWhatsThis::display(whatsthis.cap(1));
72 return;
73 }
74
75 TQStringList args;
76 args << "exec" << link;
77 tdeApp->tdeinitExec("kfmclient", args);
78}
79
80void KActiveLabel::virtual_hook( int, void* )
81{ /*BASE::virtual_hook( id, data );*/ }
82
83void KActiveLabel::focusInEvent( TQFocusEvent* fe )
84{
85 TQTextBrowser::focusInEvent(fe);
86 if(fe->reason() == TQFocusEvent::Tab || fe->reason() == TQFocusEvent::Backtab)
87 selectAll(true);
88}
89
90void KActiveLabel::focusOutEvent( TQFocusEvent* fe )
91{
92 TQTextBrowser::focusOutEvent(fe);
93 if(fe->reason() == TQFocusEvent::Tab || fe->reason() == TQFocusEvent::Backtab)
94 selectAll(false);
95}
96
97void KActiveLabel::keyPressEvent( TQKeyEvent *e )
98{
99 switch ( e->key() )
100 {
101 case Key_Down:
102 case Key_Up:
103 case Key_Left:
104 case Key_Right:
105 // jump over QTextEdit's key navigation breakage.
106 // we're not interested in keyboard navigation within the text
107 TQWidget::keyPressEvent( e );
108 break;
109 default:
110 TQTextBrowser::keyPressEvent( e );
111 }
112}
113
114TQSize KActiveLabel::minimumSizeHint() const
115{
116 TQSize ms = minimumSize();
117 if ((ms.width() > 0) && (ms.height() > 0))
118 return ms;
119
120 int w = 400;
121 if (ms.width() > 0)
122 w = ms.width();
123
124 TQString txt = text();
125 TQSimpleRichText rt(txt, font());
126 rt.setWidth(w - 2*frameWidth() - 10);
127 w = 10 + rt.widthUsed() + 2*frameWidth();
128 if (w < ms.width())
129 w = ms.width();
130 int h = rt.height() + 2*frameWidth();
131 if ( h < ms.height())
132 h = ms.height();
133
134 return TQSize(w, h);
135}
136
137TQSize KActiveLabel::sizeHint() const
138{
139 return minimumSizeHint();
140}
141
142#include "kactivelabel.moc"
KActiveLabel::openLink
virtual void openLink(const TQString &link)
Opens link in the default browser.
Definition: kactivelabel.cpp:67
KActiveLabel::KActiveLabel
KActiveLabel(TQWidget *parent, const char *name=0)
Constructor.
Definition: kactivelabel.cpp:28
TDEStdAccel::selectAll
const TDEShortcut & selectAll()

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.