32 #include <tqtooltip.h>
34 #include <tqtextedit.h>
36 #include <tdeapplication.h>
37 #include <tdeglobalsettings.h>
40 #include "knotes_part_p.h"
43 KNoteTip::KNoteTip( TDEIconView *parent )
44 : TQFrame( 0, 0, WX11BypassWM |
45 WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop ),
49 mPreview( new TQTextEdit( this ) )
51 mPreview->setReadOnly(
true );
52 mPreview->setHScrollBarMode( TQScrollView::AlwaysOff );
53 mPreview->setVScrollBarMode( TQScrollView::AlwaysOff );
55 TQBoxLayout *layout =
new TQVBoxLayout(
this );
56 layout->addWidget( mPreview );
58 setPalette( TQToolTip::palette() );
60 setFrameStyle( TQFrame::Plain | TQFrame::Box );
70 void KNoteTip::setNote( KNotesIconViewItem *item )
72 if ( mNoteIVI == item )
86 mPreview->setTextFormat( TQt::RichText );
88 mPreview->setTextFormat( TQt::PlainText );
95 mPreview->zoomTo( 8 );
99 int h = mPreview->heightForWidth( w );
100 while ( w > 60 && h == mPreview->heightForWidth( w - 20 ) )
103 TQRect desk = TDEGlobalSettings::desktopGeometry( mNoteIVI->rect().center() );
104 resize( w, TQMIN( h, desk.height() / 2 - 20 ) );
116 void KNoteTip::resizeEvent( TQResizeEvent *ev )
118 TQFrame::resizeEvent( ev );
122 void KNoteTip::timerEvent( TQTimerEvent * )
126 if ( !isVisible() ) {
136 bool KNoteTip::eventFilter( TQObject *, TQEvent *e )
138 switch ( e->type() ) {
140 case TQEvent::MouseButtonPress:
141 case TQEvent::MouseButtonRelease:
142 case TQEvent::KeyPress:
143 case TQEvent::KeyRelease:
144 case TQEvent::FocusIn:
145 case TQEvent::FocusOut:
160 void KNoteTip::setColor(
const TQColor &fg,
const TQColor &bg )
162 TQPalette newpalette = palette();
163 newpalette.setColor( TQColorGroup::Background, bg );
164 newpalette.setColor( TQColorGroup::Foreground, fg );
165 newpalette.setColor( TQColorGroup::Base, bg );
166 newpalette.setColor( TQColorGroup::Text, fg );
167 newpalette.setColor( TQColorGroup::Button, bg );
170 newpalette.setColor( TQColorGroup::Midlight, bg.light(110) );
171 newpalette.setColor( TQColorGroup::Shadow, bg.dark(116) );
172 newpalette.setColor( TQColorGroup::Light, bg.light(180) );
173 newpalette.setColor( TQColorGroup::Dark, bg.dark(108) );
174 setPalette( newpalette );
177 mPreview->setColor( fg );
181 void KNoteTip::setFilter(
bool enable )
183 if ( enable == mFilter )
187 kapp->installEventFilter(
this );
188 TQApplication::setGlobalMouseTracking(
true );
190 TQApplication::setGlobalMouseTracking(
false );
191 kapp->removeEventFilter(
this );
197 void KNoteTip::reposition()
202 TQRect rect = mNoteIVI->rect();
203 TQPoint off = mView->mapToGlobal( mView->contentsToViewport( TQPoint( 0, 0 ) ) );
204 rect.moveBy( off.x(), off.y() );
206 TQPoint pos = rect.center();
209 TQRect desk = TDEGlobalSettings::desktopGeometry( pos );
210 if ( rect.center().x() + width() > desk.right() ) {
212 if ( pos.x() - width() < 0 )
215 pos.setX( pos.x() - width() );
219 if ( rect.bottom() + height() > desk.bottom() ) {
221 pos.setY( rect.top() - height() );
223 pos.setY( rect.bottom() );
TQString customProperty(const TQCString &app, const TQCString &key) const
TQString description() const