taskmanager.h00001
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 <qpoint.h>
00031 #include <qobject.h>
00032 #include <qvaluelist.h>
00033 #include <qptrlist.h>
00034 #include <qpixmap.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 QObject
00050 {
00051 Q_OBJECT
00052 Q_PROPERTY( QString name READ name )
00053 Q_PROPERTY( QString visibleName READ visibleName )
00054 Q_PROPERTY( QString visibleNameWithState READ visibleNameWithState )
00055 Q_PROPERTY( QString iconName READ iconName )
00056 Q_PROPERTY( QString visibleIconName READ visibleIconName )
00057 Q_PROPERTY( QPixmap pixmap READ pixmap )
00058 Q_PROPERTY( bool maximized READ isMaximized )
00059 Q_PROPERTY( bool iconified READ isIconified )
00060 Q_PROPERTY( bool shaded READ isShaded WRITE setShaded )
00061 Q_PROPERTY( bool active READ isActive )
00062 Q_PROPERTY( bool onCurrentDesktop READ isOnCurrentDesktop )
00063 Q_PROPERTY( bool onAllDesktops READ isOnAllDesktops )
00064 Q_PROPERTY( bool alwaysOnTop READ isAlwaysOnTop WRITE setAlwaysOnTop )
00065 Q_PROPERTY( bool modified READ isModified )
00066 Q_PROPERTY( int desktop READ desktop )
00067 Q_PROPERTY( double thumbnailSize READ thumbnailSize WRITE setThumbnailSize )
00068 Q_PROPERTY( bool hasThumbnail READ hasThumbnail )
00069 Q_PROPERTY( QPixmap thumbnail READ thumbnail )
00070
00071 public:
00072 Task( WId win, TaskManager * parent, const char *name = 0 );
00073 virtual ~Task();
00074
00075 TaskManager* taskManager() const { return (TaskManager*) parent(); }
00076
00077 WId window() const { return _win; }
00078 #ifdef KDE_3_2
00079 QString name() const { return _info.name(); }
00080 QString visibleName() const { return _info.visibleName(); }
00084 int desktop() const { return _info.desktop(); }
00085 #else
00086 QString name() const { return _info.name; }
00087 QString visibleName() const { return _info.visibleName; }
00091 int desktop() const { return _info.desktop; }
00092 #endif
00093 QString visibleNameWithState() const { return _info.visibleNameWithState(); }
00094 QString iconName() const;
00095 QString visibleIconName() const;
00096 QString className();
00097 QString classClass();
00098
00103 QValueList<WId> transients() const { return _transients; }
00104
00110 QPixmap pixmap() const { return _pixmap; }
00111
00126 QPixmap bestIcon( int size, bool &isStaticIcon );
00127
00137 QPixmap icon( int width, int height, bool allowResize = false );
00138
00143 static bool idMatch(const QString &, const QString &);
00144
00145
00146
00150 bool isMaximized() const;
00151
00155 bool isIconified() const;
00156
00160 bool isShaded() const;
00161
00165 bool isActive() const;
00166
00171 bool isOnTop() const;
00172
00176 bool isOnCurrentDesktop() const;
00177
00181 bool isOnAllDesktops() const;
00182
00187 bool isAlwaysOnTop() const;
00188
00195 bool isModified() const ;
00196
00197
00198
00199
00200 void refresh(bool icon = false);
00201
00202 void addTransient( WId w ) { _transients.append( w ); }
00203
00204 void removeTransient( WId w ) { _transients.remove( w ); }
00205
00206 bool hasTransient( WId w ) const { return _transients.contains( w ); }
00207
00208 void setActive(bool a);
00209
00210
00211
00215 double thumbnailSize() const { return _thumbSize; }
00216
00222 void setThumbnailSize( double size ) { _thumbSize = size; }
00223
00228 bool hasThumbnail() const { return !_thumb.isNull(); }
00229
00234 const QPixmap &thumbnail() const { return _thumb; }
00235
00236 public slots:
00237
00238
00242 void maximize();
00243
00247 void restore();
00248
00252 void iconify();
00253
00257 void close();
00258
00262 void raise();
00263
00267 void lower();
00268
00272 void activate();
00273
00279 void activateRaiseOrIconify();
00280
00284 void setAlwaysOnTop(bool);
00285 void toggleAlwaysOnTop();
00286
00291 void setShaded(bool);
00292 void toggleShaded();
00293
00297 void toDesktop(int);
00298
00302 void toCurrentDesktop();
00303
00309 void publishIconGeometry(QRect);
00310
00315 void updateThumbnail();
00316
00317 signals:
00321 void changed();
00322
00326 void iconChanged();
00327
00331 void activated();
00332
00336 void deactivated();
00337
00341 void thumbnailChanged();
00342
00343 protected slots:
00344
00345 void generateThumbnail();
00346
00347 private:
00348 bool _active;
00349 WId _win;
00350 QPixmap _pixmap;
00351 #ifdef KDE_3_2
00352 KWin::WindowInfo _info;
00353 #else
00354 KWin::Info _info;
00355 #endif
00356 QValueList<WId> _transients;
00357
00358 int _lastWidth;
00359 int _lastHeight;
00360 bool _lastResize;
00361 QPixmap _lastIcon;
00362
00363 double _thumbSize;
00364 QPixmap _thumb;
00365 QPixmap _grab;
00366
00367 class TaskPrivate *d;
00368 };
00369
00375 class Startup: public QObject
00376 {
00377 Q_OBJECT
00378 Q_PROPERTY( QString text READ text )
00379 Q_PROPERTY( QString bin READ bin )
00380 Q_PROPERTY( QString icon READ icon )
00381
00382 public:
00383 Startup( const KStartupInfoId& id, const KStartupInfoData& data, QObject * parent,
00384 const char *name = 0);
00385 virtual ~Startup();
00386
00390 QString text() const { return _data.findName(); }
00391
00395 QString bin() const { return _data.bin(); }
00396
00400 QString icon() const { return _data.findIcon(); }
00401 void update( const KStartupInfoData& data );
00402 const KStartupInfoId& id() const { return _id; }
00403
00404 signals:
00408 void changed();
00409
00410 private:
00411 KStartupInfoId _id;
00412 KStartupInfoData _data;
00413 class StartupPrivate *d;
00414 };
00415
00416 typedef QPtrList<Task> TaskList;
00417 typedef QPtrList<Startup> StartupList;
00418
00419
00430 class TaskManager : public QObject
00431 {
00432 Q_OBJECT
00433 Q_PROPERTY( int currentDesktop READ currentDesktop )
00434 Q_PROPERTY( int numberOfDesktops READ numberOfDesktops )
00435
00436 public:
00437 TaskManager( QObject *parent = 0, const char *name = 0 );
00438 virtual ~TaskManager();
00439
00444 TaskList tasks() const { return _tasks; }
00445
00450 StartupList startups() const { return _startups; }
00451
00455 QString desktopName(int n) const;
00456
00460 int numberOfDesktops() const;
00461
00465 int currentDesktop() const;
00466
00470 bool isOnTop( const Task*);
00471 signals:
00475 void activeTaskChanged(Task*);
00476
00480 void taskAdded(Task*);
00481
00485 void taskRemoved(Task*);
00486
00490 void startupAdded(Startup*);
00491
00497 void startupRemoved(Startup*);
00498
00502 void desktopChanged(int desktop);
00503
00507 void windowChanged(WId);
00508
00509 protected slots:
00510
00511 void windowAdded(WId);
00512
00513 void windowRemoved(WId);
00514
00515 void windowChanged(WId, unsigned int);
00516
00517
00518 void activeWindowChanged(WId);
00519
00520 void currentDesktopChanged(int);
00521
00522 void killStartup( const KStartupInfoId& );
00523
00524 void killStartup(Startup*);
00525
00526
00527 void gotNewStartup( const KStartupInfoId&, const KStartupInfoData& );
00528
00529 void gotStartupChange( const KStartupInfoId&, const KStartupInfoData& );
00530
00531 void gotRemoveStartup( const KStartupInfoId& );
00532
00533 protected:
00537 Task* findTask(WId w);
00538 void configure_startup();
00539
00540 private:
00541 Task* _active;
00542 TaskList _tasks;
00543 QValueList< WId > _skiptaskbar_windows;
00544 StartupList _startups;
00545 KStartupInfo* _startup_info;
00546
00547 class TaskManagerPrivate *d;
00548 };
00549
00550 #endif
|