20 #include "messagewindow.h"
27 #include <kiconloader.h>
28 #include <tdeapplication.h>
31 TQPtrDict<MessageWindow> MessageWindow::m_windows;
33 MessageWindow::MessageWindow(
const TQString& txt,
int delay, TQWidget *parent,
const char *name )
34 : TQWidget( parent, name, (WFlags)(WStyle_Customize|WStyle_NoBorder|WShowModal|WType_Dialog|WDestructiveClose) )
36 TQHBox *box =
new TQHBox(
this );
37 box->setFrameStyle( TQFrame::Panel|TQFrame::Raised );
38 box->setLineWidth( 1 );
39 box->setSpacing( 10 );
41 TQLabel *pix =
new TQLabel( box );
42 pix->setPixmap( DesktopIcon(
"tdeprint_printer" ) );
43 m_text =
new TQLabel( txt, box );
45 TQHBoxLayout *l0 =
new TQHBoxLayout(
this, 0, 0 );
48 m_windows.insert( parent,
this );
53 TQTimer::singleShot( delay,
this, TQ_SLOT( slotTimer() ) );
56 MessageWindow::~MessageWindow()
58 m_windows.remove( parentWidget() );
61 void MessageWindow::slotTimer()
63 TQSize psz = parentWidget()->size(), sz = sizeHint();
64 move( parentWidget()->mapToGlobal( TQPoint( (psz.width()-sz.width())/2, (psz.height()-sz.height())/2 ) ) );
68 kapp->processEvents();
72 TQString MessageWindow::text()
const
74 return m_text->text();
77 void MessageWindow::setText(
const TQString& txt )
79 m_text->setText( txt );
82 void MessageWindow::add( TQWidget *parent,
const TQString& txt,
int delay )
85 kdWarning( 500 ) <<
"Cannot add a message window to a null parent" << endl;
88 MessageWindow *w = m_windows.find( parent );
92 new MessageWindow( txt, delay, parent,
"MessageWindow" );
96 void MessageWindow::remove( TQWidget *parent )
99 delete m_windows.find( parent );
102 void MessageWindow::change( TQWidget *parent,
const TQString& txt )
106 MessageWindow *w = m_windows.find( parent );
110 kdWarning( 500 ) <<
"MessageWindow::change, no message window found" << endl;
114 void MessageWindow::removeAll()
116 TQPtrDictIterator<MessageWindow> it( m_windows );
117 while ( it.current() )
121 #include "messagewindow.moc"