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

tdeui

twindowinfo.cpp

00001 /*
00002  *   copyright            : (C) 2001-2002 by Richard Moore
00003  *   License              : This file is released under the terms of the LGPL, version 2.
00004  *   email                : rich@kde.org
00005  */
00006 
00007 #include <tqobjectlist.h>
00008 #include <tqpixmap.h>
00009 #include <tqtimer.h>
00010 #include <tqtooltip.h>
00011 #include <ksystemtray.h>
00012 #include <twin.h>
00013 
00014 #include "twindowinfo.h"
00015 #include "twindowinfo.moc"
00016 
00017 static const int UNSPECIFIED_TIMEOUT = -1;
00018 static const int DEFAULT_MESSAGE_TIMEOUT = 3000;
00019 
00020 KWindowInfo::KWindowInfo( TQWidget *parent, const char *name )
00021     : TQObject( parent, name ), win( parent ), autoDel( false )
00022 {
00023 }
00024 
00025 KWindowInfo::~KWindowInfo()
00026 {
00027 }
00028 
00029 void KWindowInfo::showMessage( TQWidget *window, const TQString &text, int timeout )
00030 {
00031     KWindowInfo *info = new KWindowInfo( window );
00032     info->autoDel = true;
00033     info->message( text, timeout );
00034     if ( timeout == 0 )
00035     delete info;
00036 }
00037 
00038 void KWindowInfo::showMessage( TQWidget *window, const TQString &text, const TQPixmap &pix, int timeout )
00039 {
00040     KWindowInfo *info = new KWindowInfo( window );
00041     info->autoDel = true;
00042     info->message( text, pix, timeout );
00043 }
00044 
00045 void KWindowInfo::message( const TQString &text )
00046 {
00047     message( text, TQPixmap(), UNSPECIFIED_TIMEOUT );
00048 }
00049 
00050 void KWindowInfo::message( const TQString &text, const TQPixmap &pix )
00051 {
00052     message( text, pix, UNSPECIFIED_TIMEOUT );
00053 }
00054 
00055 void KWindowInfo::message( const TQString &text, int timeout )
00056 {
00057     message( text, TQPixmap(), timeout );
00058 }
00059 
00060 void KWindowInfo::message( const TQString &text, const TQPixmap &pix, int timeout )
00061 {
00062     if ( timeout != 0 )
00063     save();
00064 
00065     display( text, pix );
00066 
00067     if ( timeout < 0 )
00068     timeout = DEFAULT_MESSAGE_TIMEOUT;
00069     if ( timeout != 0 )
00070     TQTimer::singleShot( timeout, this, TQT_SLOT( restore() ) );
00071 }
00072 
00073 void KWindowInfo::permanent( const TQString &text )
00074 {
00075 #ifdef Q_WS_X11
00076     oldMiniIcon = KWin::icon( win->winId(), 16, 16, true );
00077     oldIcon = KWin::icon( win->winId(), 34, 34, false );
00078     if ( oldIcon.isNull() )
00079     oldIcon = KWin::icon( win->winId(), 32, 32, true );
00080 #endif
00081 
00082     permanent( text, oldIcon );
00083 }
00084 
00085 void KWindowInfo::permanent( const TQString &text, const TQPixmap &pix )
00086 {
00087     if ( !oldText.isNull() ) {
00088     TQObjectList *l = queryList( TQTIMER_OBJECT_NAME_STRING );
00089     TQObjectListIt it( *l );
00090     TQObject *obj;
00091 
00092     while ( (obj = it.current()) != 0 ) {
00093         ++it;
00094         delete obj;
00095     }
00096     delete l;
00097     }
00098 
00099     oldText = TQString::null;
00100     display( text, pix );
00101 }
00102 
00103 void KWindowInfo::display( const TQString &text, const TQPixmap &pix )
00104 {
00105     TQPixmap icon;
00106     if ( pix.isNull() )
00107     icon.load( "bell.png" );
00108     else
00109     icon = pix;
00110 
00111     if ( win->inherits( "KSystemTray" ) ) {
00112     KSystemTray *tray = static_cast<KSystemTray *>( win );
00113     tray->setPixmap( icon );
00114     TQToolTip::add( tray, text );
00115     return;
00116     }
00117 
00118     win->setCaption( text );
00119     win->setIcon( icon );
00120 #ifdef Q_WS_X11
00121     KWin::setIcons( win->winId(), icon, icon );
00122 #endif
00123 }
00124 
00125 void KWindowInfo::save()
00126 {
00127     if ( !oldText.isNull() )
00128     return;
00129 
00130     if ( win->inherits( "KSystemTray" ) ) {
00131     KSystemTray *tray = static_cast<KSystemTray *>( win );
00132     oldIcon = *(tray->pixmap());
00133     oldText = TQToolTip::textFor( tray );
00134     return;
00135     }
00136 
00137     oldText = win->caption();
00138 #ifdef Q_WS_X11
00139     oldMiniIcon = KWin::icon( win->winId(), 16, 16, true );
00140     oldIcon = KWin::icon( win->winId(), 34, 34, false );
00141     if ( oldIcon.isNull() )
00142     oldIcon = KWin::icon( win->winId(), 32, 32, true );
00143 #endif
00144 
00145     if ( oldIcon.isNull() ) {
00146     const TQPixmap *px = win->icon();
00147     if ( px )
00148         oldIcon = *px;
00149     else
00150         oldIcon.resize( 0, 0 );
00151     }
00152 }
00153 
00154 void KWindowInfo::restore()
00155 {
00156     if ( win->inherits( "KSystemTray" ) ) {
00157     KSystemTray *tray = static_cast<KSystemTray *>( win );
00158     tray->setPixmap( oldIcon );
00159     TQToolTip::add( tray, oldText );
00160     oldText = TQString::null;
00161     return;
00162     }
00163 
00164     win->setIcon( oldIcon );
00165 #ifdef Q_WS_X11
00166     KWin::setIcons( win->winId(), oldIcon, oldMiniIcon );
00167 #endif
00168     win->setCaption( oldText );
00169     oldText = TQString::null;
00170 
00171     if ( autoDel )
00172     delete this;
00173 }
00174 
00175 
00176 
00177 
00178 

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.7.1
This website is maintained by Timothy Pearson.