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

tdeui

  • tdeui
twindowinfo.cpp
1 /*
2  * copyright : (C) 2001-2002 by Richard Moore
3  * License : This file is released under the terms of the LGPL, version 2.
4  * email : rich@kde.org
5  */
6 
7 #include <tqobjectlist.h>
8 #include <tqpixmap.h>
9 #include <tqtimer.h>
10 #include <tqtooltip.h>
11 #include <ksystemtray.h>
12 #include <twin.h>
13 
14 #include "twindowinfo.h"
15 #include "twindowinfo.moc"
16 
17 static const int UNSPECIFIED_TIMEOUT = -1;
18 static const int DEFAULT_MESSAGE_TIMEOUT = 3000;
19 
20 KWindowInfo::KWindowInfo( TQWidget *parent, const char *name )
21  : TQObject( parent, name ), win( parent ), autoDel( false )
22 {
23 }
24 
25 KWindowInfo::~KWindowInfo()
26 {
27 }
28 
29 void KWindowInfo::showMessage( TQWidget *window, const TQString &text, int timeout )
30 {
31  KWindowInfo *info = new KWindowInfo( window );
32  info->autoDel = true;
33  info->message( text, timeout );
34  if ( timeout == 0 )
35  delete info;
36 }
37 
38 void KWindowInfo::showMessage( TQWidget *window, const TQString &text, const TQPixmap &pix, int timeout )
39 {
40  KWindowInfo *info = new KWindowInfo( window );
41  info->autoDel = true;
42  info->message( text, pix, timeout );
43 }
44 
45 void KWindowInfo::message( const TQString &text )
46 {
47  message( text, TQPixmap(), UNSPECIFIED_TIMEOUT );
48 }
49 
50 void KWindowInfo::message( const TQString &text, const TQPixmap &pix )
51 {
52  message( text, pix, UNSPECIFIED_TIMEOUT );
53 }
54 
55 void KWindowInfo::message( const TQString &text, int timeout )
56 {
57  message( text, TQPixmap(), timeout );
58 }
59 
60 void KWindowInfo::message( const TQString &text, const TQPixmap &pix, int timeout )
61 {
62  if ( timeout != 0 )
63  save();
64 
65  display( text, pix );
66 
67  if ( timeout < 0 )
68  timeout = DEFAULT_MESSAGE_TIMEOUT;
69  if ( timeout != 0 )
70  TQTimer::singleShot( timeout, this, TQT_SLOT( restore() ) );
71 }
72 
73 void KWindowInfo::permanent( const TQString &text )
74 {
75 #ifdef Q_WS_X11
76  oldMiniIcon = KWin::icon( win->winId(), 16, 16, true );
77  oldIcon = KWin::icon( win->winId(), 34, 34, false );
78  if ( oldIcon.isNull() )
79  oldIcon = KWin::icon( win->winId(), 32, 32, true );
80 #endif
81 
82  permanent( text, oldIcon );
83 }
84 
85 void KWindowInfo::permanent( const TQString &text, const TQPixmap &pix )
86 {
87  if ( !oldText.isNull() ) {
88  TQObjectList *l = queryList( TQTIMER_OBJECT_NAME_STRING );
89  TQObjectListIt it( *l );
90  TQObject *obj;
91 
92  while ( (obj = it.current()) != 0 ) {
93  ++it;
94  delete obj;
95  }
96  delete l;
97  }
98 
99  oldText = TQString::null;
100  display( text, pix );
101 }
102 
103 void KWindowInfo::display( const TQString &text, const TQPixmap &pix )
104 {
105  TQPixmap icon;
106  if ( pix.isNull() )
107  icon.load( "bell.png" );
108  else
109  icon = pix;
110 
111  if ( win->inherits( "KSystemTray" ) ) {
112  KSystemTray *tray = static_cast<KSystemTray *>( win );
113  tray->setPixmap( icon );
114  TQToolTip::add( tray, text );
115  return;
116  }
117 
118  win->setCaption( text );
119  win->setIcon( icon );
120 #ifdef Q_WS_X11
121  KWin::setIcons( win->winId(), icon, icon );
122 #endif
123 }
124 
125 void KWindowInfo::save()
126 {
127  if ( !oldText.isNull() )
128  return;
129 
130  if ( win->inherits( "KSystemTray" ) ) {
131  KSystemTray *tray = static_cast<KSystemTray *>( win );
132  oldIcon = *(tray->pixmap());
133  oldText = TQToolTip::textFor( tray );
134  return;
135  }
136 
137  oldText = win->caption();
138 #ifdef Q_WS_X11
139  oldMiniIcon = KWin::icon( win->winId(), 16, 16, true );
140  oldIcon = KWin::icon( win->winId(), 34, 34, false );
141  if ( oldIcon.isNull() )
142  oldIcon = KWin::icon( win->winId(), 32, 32, true );
143 #endif
144 
145  if ( oldIcon.isNull() ) {
146  const TQPixmap *px = win->icon();
147  if ( px )
148  oldIcon = *px;
149  else
150  oldIcon.resize( 0, 0 );
151  }
152 }
153 
154 void KWindowInfo::restore()
155 {
156  if ( win->inherits( "KSystemTray" ) ) {
157  KSystemTray *tray = static_cast<KSystemTray *>( win );
158  tray->setPixmap( oldIcon );
159  TQToolTip::add( tray, oldText );
160  oldText = TQString::null;
161  return;
162  }
163 
164  win->setIcon( oldIcon );
165 #ifdef Q_WS_X11
166  KWin::setIcons( win->winId(), oldIcon, oldMiniIcon );
167 #endif
168  win->setCaption( oldText );
169  oldText = TQString::null;
170 
171  if ( autoDel )
172  delete this;
173 }
174 
175 
176 
177 
178 
KWindowInfo::save
virtual void save()
Saves the window title and icon.
Definition: twindowinfo.cpp:125
KWindowInfo::showMessage
static void showMessage(TQWidget *window, const TQString &text, int timeout=-1)
Utility method to display a title bar message for the specified window.
Definition: twindowinfo.cpp:29
KWindowInfo::KWindowInfo
KWindowInfo(TQWidget *parent, const char *name=0)
Creates a KWindowInfo with the specified parent.
Definition: twindowinfo.cpp:20
KWindowInfo
Displays messages in the window icon and title.
Definition: twindowinfo.h:39
KWindowInfo::permanent
void permanent(const TQString &text)
Shows the specified text in the window title with no timeout.
Definition: twindowinfo.cpp:73
KSystemTray
KDE System Tray Window class
Definition: ksystemtray.h:63
KWindowInfo::display
virtual void display(const TQString &text, const TQPixmap &pix)
Displays the message in the titlebar/icon.
Definition: twindowinfo.cpp:103
KSystemTray::setPixmap
virtual void setPixmap(const TQPixmap &icon)
Changes the tray's icon.
Definition: ksystemtray.cpp:328
KWindowInfo::~KWindowInfo
virtual ~KWindowInfo()
Cleans up.
Definition: twindowinfo.cpp:25
KWindowInfo::message
void message(const TQString &text)
Shows the specified text in the window title.
Definition: twindowinfo.cpp:45
KWindowInfo::restore
virtual void restore()
Resets the window title and icon to the saved values.
Definition: twindowinfo.cpp:154
KWin::icon
static TQPixmap icon(WId win, int width=-1, int height=-1, bool scale=false)
KWin::setIcons
static void setIcons(WId win, const TQPixmap &icon, const TQPixmap &miniIcon)

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.