superkaramba
taskmanager.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __taskmanager_h__
00026 #define __taskmanager_h__
00027
00028 #include <sys/types.h>
00029
00030 #include <tqpoint.h>
00031 #include <tqobject.h>
00032 #include <tqvaluelist.h>
00033 #include <tqptrlist.h>
00034 #include <tqpixmap.h>
00035
00036 #include <dcopobject.h>
00037 #include <kwin.h>
00038 #include <kstartupinfo.h>
00039 #include "karambaapp.h"
00040
00041 class TaskManager;
00042
00049 class Task: public TQObject
00050 {
00051 Q_OBJECT
00052 TQ_OBJECT
00053 TQ_PROPERTY( TQString name READ name )
00054 TQ_PROPERTY( TQString visibleName READ visibleName )
00055 TQ_PROPERTY( TQString visibleNameWithState READ visibleNameWithState )
00056 TQ_PROPERTY( TQString iconName READ iconName )
00057 TQ_PROPERTY( TQString visibleIconName READ visibleIconName )
00058 TQ_PROPERTY( TQPixmap pixmap READ pixmap )
00059 TQ_PROPERTY( bool maximized READ isMaximized )
00060 TQ_PROPERTY( bool iconified READ isIconified )
00061 TQ_PROPERTY( bool shaded READ isShaded WRITE setShaded )
00062 TQ_PROPERTY( bool active READ isActive )
00063 TQ_PROPERTY( bool onCurrentDesktop READ isOnCurrentDesktop )
00064 TQ_PROPERTY( bool onAllDesktops READ isOnAllDesktops )
00065 TQ_PROPERTY( bool alwaysOnTop READ isAlwaysOnTop WRITE setAlwaysOnTop )
00066 TQ_PROPERTY( bool modified READ isModified )
00067 TQ_PROPERTY( int desktop READ desktop )
00068 TQ_PROPERTY( double thumbnailSize READ thumbnailSize WRITE setThumbnailSize )
00069 TQ_PROPERTY( bool hasThumbnail READ hasThumbnail )
00070 TQ_PROPERTY( TQPixmap thumbnail READ thumbnail )
00071
00072 public:
00073 Task( WId win, TaskManager * parent, const char *name = 0 );
00074 virtual ~Task();
00075
00076 TaskManager* taskManager() const { return (TaskManager*) parent(); }
00077
00078 WId window() const { return _win; }
00079 #ifdef KDE_3_2
00080 TQString name() const { return _info.name(); }
00081 TQString visibleName() const { return _info.visibleName(); }
00085 int desktop() const { return _info.desktop(); }
00086 #else
00087 TQString name() const { return _info.name; }
00088 TQString visibleName() const { return _info.visibleName; }
00092 int desktop() const { return _info.desktop; }
00093 #endif
00094 TQString visibleNameWithState() const { return _info.visibleNameWithState(); }
00095 TQString iconName() const;
00096 TQString visibleIconName() const;
00097 TQString className();
00098 TQString classClass();
00099
00104 TQValueList<WId> transients() const { return _transients; }
00105
00111 TQPixmap pixmap() const { return _pixmap; }
00112
00127 TQPixmap bestIcon( int size, bool &isStaticIcon );
00128
00138 TQPixmap icon( int width, int height, bool allowResize = false );
00139
00144 static bool idMatch(const TQString &, const TQString &);
00145
00146
00147
00151 bool isMaximized() const;
00152
00156 bool isIconified() const;
00157
00161 bool isShaded() const;
00162
00166 bool isActive() const;
00167
00172 bool isOnTop() const;
00173
00177 bool isOnCurrentDesktop() const;
00178
00182 bool isOnAllDesktops() const;
00183
00188 bool isAlwaysOnTop() const;
00189
00196 bool isModified() const ;
00197
00198
00199
00200
00201 void refresh(bool icon = false);
00202
00203 void addTransient( WId w ) { _transients.append( w ); }
00204
00205 void removeTransient( WId w ) { _transients.remove( w ); }
00206
00207 bool hasTransient( WId w ) const { return _transients.contains( w ); }
00208
00209 void setActive(bool a);
00210
00211
00212
00216 double thumbnailSize() const { return _thumbSize; }
00217
00223 void setThumbnailSize( double size ) { _thumbSize = size; }
00224
00229 bool hasThumbnail() const { return !_thumb.isNull(); }
00230
00235 const TQPixmap &thumbnail() const { return _thumb; }
00236
00237 public slots:
00238
00239
00243 void maximize();
00244
00248 void restore();
00249
00253 void iconify();
00254
00258 void close();
00259
00263 void raise();
00264
00268 void lower();
00269
00273 void activate();
00274
00280 void activateRaiseOrIconify();
00281
00285 void setAlwaysOnTop(bool);
00286 void toggleAlwaysOnTop();
00287
00292 void setShaded(bool);
00293 void toggleShaded();
00294
00298 void toDesktop(int);
00299
00303 void toCurrentDesktop();
00304
00310 void publishIconGeometry(TQRect);
00311
00316 void updateThumbnail();
00317
00318 signals:
00322 void changed();
00323
00327 void iconChanged();
00328
00332 void activated();
00333
00337 void deactivated();
00338
00342 void thumbnailChanged();
00343
00344 protected slots:
00345
00346 void generateThumbnail();
00347
00348 private:
00349 bool _active;
00350 WId _win;
00351 TQPixmap _pixmap;
00352 #ifdef KDE_3_2
00353 KWin::WindowInfo _info;
00354 #else
00355 KWin::Info _info;
00356 #endif
00357 TQValueList<WId> _transients;
00358
00359 int _lastWidth;
00360 int _lastHeight;
00361 bool _lastResize;
00362 TQPixmap _lastIcon;
00363
00364 double _thumbSize;
00365 TQPixmap _thumb;
00366 TQPixmap _grab;
00367
00368 class TaskPrivate *d;
00369 };
00370
00376 class Startup: public TQObject
00377 {
00378 Q_OBJECT
00379 TQ_OBJECT
00380 TQ_PROPERTY( TQString text READ text )
00381 TQ_PROPERTY( TQString bin READ bin )
00382 TQ_PROPERTY( TQString icon READ icon )
00383
00384 public:
00385 Startup( const KStartupInfoId& id, const KStartupInfoData& data, TQObject * parent,
00386 const char *name = 0);
00387 virtual ~Startup();
00388
00392 TQString text() const { return _data.findName(); }
00393
00397 TQString bin() const { return _data.bin(); }
00398
00402 TQString icon() const { return _data.findIcon(); }
00403 void update( const KStartupInfoData& data );
00404 const KStartupInfoId& id() const { return _id; }
00405
00406 signals:
00410 void changed();
00411
00412 private:
00413 KStartupInfoId _id;
00414 KStartupInfoData _data;
00415 class StartupPrivate *d;
00416 };
00417
00418 typedef TQPtrList<Task> TaskList;
00419 typedef TQPtrList<Startup> StartupList;
00420
00421
00432 class TaskManager : public TQObject
00433 {
00434 Q_OBJECT
00435 TQ_OBJECT
00436 TQ_PROPERTY( int currentDesktop READ currentDesktop )
00437 TQ_PROPERTY( int numberOfDesktops READ numberOfDesktops )
00438
00439 public:
00440 TaskManager( TQObject *parent = 0, const char *name = 0 );
00441 virtual ~TaskManager();
00442
00447 TaskList tasks() const { return _tasks; }
00448
00453 StartupList startups() const { return _startups; }
00454
00458 TQString desktopName(int n) const;
00459
00463 int numberOfDesktops() const;
00464
00468 int currentDesktop() const;
00469
00473 bool isOnTop( const Task*);
00474 signals:
00478 void activeTaskChanged(Task*);
00479
00483 void taskAdded(Task*);
00484
00488 void taskRemoved(Task*);
00489
00493 void startupAdded(Startup*);
00494
00500 void startupRemoved(Startup*);
00501
00505 void desktopChanged(int desktop);
00506
00510 void windowChanged(WId);
00511
00512 protected slots:
00513
00514 void windowAdded(WId);
00515
00516 void windowRemoved(WId);
00517
00518 void windowChanged(WId, unsigned int);
00519
00520
00521 void activeWindowChanged(WId);
00522
00523 void currentDesktopChanged(int);
00524
00525 void killStartup( const KStartupInfoId& );
00526
00527 void killStartup(Startup*);
00528
00529
00530 void gotNewStartup( const KStartupInfoId&, const KStartupInfoData& );
00531
00532 void gotStartupChange( const KStartupInfoId&, const KStartupInfoData& );
00533
00534 void gotRemoveStartup( const KStartupInfoId& );
00535
00536 protected:
00540 Task* findTask(WId w);
00541 void configure_startup();
00542
00543 private:
00544 Task* _active;
00545 TaskList _tasks;
00546 TQValueList< WId > _skiptaskbar_windows;
00547 StartupList _startups;
00548 KStartupInfo* _startup_info;
00549
00550 class TaskManagerPrivate *d;
00551 };
00552
00553 #endif