add more spacing
[personal-kdebase.git] / workspace / libs / taskmanager / task.h
blobcc0e12981d0f357040d3c3dd1991d866c2f90979
1 /*****************************************************************
3 Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
4 Copyright (c) 2001 Richard Moore <rich@kde.org>
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 ******************************************************************/
25 #ifndef TASK_H
26 #define TASK_H
28 // Qt
29 #include <QtGui/QDrag>
30 #include <QtGui/QPixmap>
31 #include <QtGui/QWidget>
32 #include <QtGui/QIcon>
34 // KDE
35 #include <KDE/KSharedPtr>
36 #include <KDE/KWindowSystem>
37 #include <KDE/NETWinInfo>
39 #include <taskmanager/taskmanager.h>
40 #include <taskmanager/taskmanager_export.h>
42 namespace TaskManager
45 /**
46 * A dynamic interface to a task (main window).
48 * @see TaskManager
50 class TASKMANAGER_EXPORT Task : public QObject, public KShared
52 Q_OBJECT
53 Q_PROPERTY( QString visibleName READ visibleName )
54 Q_PROPERTY( QString name READ name )
55 Q_PROPERTY( QString className READ className )
56 Q_PROPERTY( QString visibleNameWithState READ visibleNameWithState )
57 Q_PROPERTY( QPixmap pixmap READ pixmap )
58 Q_PROPERTY( bool maximized READ isMaximized )
59 Q_PROPERTY( bool minimized READ isMinimized )
60 // KDE4 deprecated
61 Q_PROPERTY( bool iconified READ isIconified )
62 Q_PROPERTY( bool shaded READ isShaded WRITE setShaded )
63 Q_PROPERTY( bool active READ isActive )
64 Q_PROPERTY( bool onCurrentDesktop READ isOnCurrentDesktop )
65 Q_PROPERTY( bool onAllDesktops READ isOnAllDesktops )
66 Q_PROPERTY( bool alwaysOnTop READ isAlwaysOnTop WRITE setAlwaysOnTop )
67 Q_PROPERTY( bool modified READ isModified )
68 Q_PROPERTY( bool demandsAttention READ demandsAttention )
69 Q_PROPERTY( int desktop READ desktop )
71 public:
72 Task(WId win, QObject *parent, const char *name = 0);
73 virtual ~Task();
75 WId window() const;
76 KWindowInfo info() const;
78 QString visibleName() const;
79 QString visibleNameWithState() const;
80 QString name() const;
81 QString className() const;
82 QString classClass() const;
84 /**
85 * A list of the window ids of all transient windows (dialogs) associated
86 * with this task.
88 WindowList transients() const;
90 /**
91 * Returns a 16x16 (KIconLoader::Small) icon for the task. This method will
92 * only fall back to a static icon if there is no icon of any size in
93 * the WM hints.
95 QPixmap pixmap() const;
97 /**
98 * Returns the best icon for any of the KIconLoader::StdSizes. If there is no
99 * icon of the specified size specified in the WM hints, it will try to
100 * get one using KIconLoader.
102 * <pre>
103 * bool gotStaticIcon;
104 * QPixmap icon = myTask->icon( KIconLoader::SizeMedium, gotStaticIcon );
105 * </pre>
107 * @param size Any of the constants in KIconLoader::StdSizes.
108 * @param isStaticIcon Set to true if KIconLoader was used, false otherwise.
110 QPixmap bestIcon( int size, bool &isStaticIcon );
113 * Tries to find an icon for the task with the specified size. If there
114 * is no icon that matches then it will either resize the closest available
115 * icon or return a null pixmap depending on the value of allowResize.
117 * Note that the last icon is cached, so a sequence of calls with the same
118 * parameters will only query the NET properties if the icon has changed or
119 * none was found.
121 QPixmap icon( int width, int height, bool allowResize = false );
124 * \return a QIcon for the task
126 QIcon icon();
129 * Returns true iff the windows with the specified ids should be grouped
130 * together in the task list.
132 static bool idMatch(const QString &, const QString &);
134 // state
137 * Returns true if the task's window is maximized.
139 bool isMaximized() const;
142 * Returns true if the task's window is minimized.
144 bool isMinimized() const;
147 * @deprecated
148 * Returns true if the task's window is minimized(iconified).
150 bool isIconified() const;
153 * Returns true if the task's window is shaded.
155 bool isShaded() const;
158 * Returns true if the task's window is the active window.
160 bool isActive() const;
163 * Returns true if the task's window is the topmost non-iconified,
164 * non-always-on-top window.
166 bool isOnTop() const;
169 * Returns true if the task's window is on the current virtual desktop.
171 bool isOnCurrentDesktop() const;
174 * Returns true if the task's window is on all virtual desktops.
176 bool isOnAllDesktops() const;
179 * Returns true if the task's window will remain at the top of the
180 * stacking order.
182 bool isAlwaysOnTop() const;
185 * Returns true if the task's window will remain at the bottom of the
186 * stacking order.
188 bool isKeptBelowOthers() const;
191 * Returns true if the task's window is in full screen mode
193 bool isFullScreen() const;
196 * Returns true if the document the task is editing has been modified.
197 * This is currently handled heuristically by looking for the string
198 * '[i18n_modified]' in the window title where i18n_modified is the
199 * word 'modified' in the current language.
201 bool isModified() const ;
204 * Returns the desktop on which this task's window resides.
206 int desktop() const;
209 * Returns true if the task is not active but demands user's attention.
211 bool demandsAttention() const;
215 * Returns true if the window is on the specified screen of a multihead configuration
217 bool isOnScreen( int screen ) const;
220 * Returns true if the task should be shown in taskbar-like apps
222 bool showInTaskbar() const;
225 * Returns true if the task should be shown in pager-like apps
227 bool showInPager() const;
230 * Returns the geometry for this window
232 QRect geometry() const;
234 // internal
236 //* @internal
237 ::TaskManager::TaskChanges refresh(unsigned int dirty);
238 //* @internal
239 void addTransient( WId w, const NETWinInfo& info );
240 //* @internal
241 void removeTransient( WId w );
242 //* @internal
243 bool hasTransient(WId w) const;
244 //* @internal
245 void updateDemandsAttentionState( WId w );
246 //* @internal
247 void setActive(bool a);
250 * Adds the identifying information for this task to mime data for drags, copies, etc
252 void addMimeData(QMimeData *mimeData) const;
255 * Returns the mimetype used for a Task
257 static QString mimetype();
260 * Returns the mimetype used for multiple Tasks
262 static QString groupMimetype();
265 * Given mime data, will return a WId if it can decode one from the data. Otherwise
266 * returns 0.
268 static WId idFromMimeData(const QMimeData *mimeData, bool *ok = 0);
271 * Given mime data, will return a QList<WId> if it can decode WIds from the data. Otherwise
272 * returns an empty list.
274 static QList<WId> idsFromMimeData(const QMimeData *mimeData, bool *ok = 0);
276 public Q_SLOTS:
278 * Maximise the main window of this task.
280 void setMaximized(bool);
281 void toggleMaximized();
284 * Restore the main window of the task (if it was iconified).
286 void restore();
289 * Move the window of this task.
291 void move();
294 * Resize the window of this task.
296 void resize();
299 * Iconify the task.
301 void setIconified(bool);
302 void toggleIconified();
305 * Close the task's window.
307 void close();
310 * Raise the task's window.
312 void raise();
315 * Lower the task's window.
317 void lower();
320 * Activate the task's window.
322 void activate();
325 * Perform the action that is most appropriate for this task. If it
326 * is not active, activate it. Else if it is not the top window, raise
327 * it. Otherwise, iconify it.
329 void activateRaiseOrIconify();
332 * If true, the task's window will remain at the top of the stacking order.
334 void setAlwaysOnTop(bool);
335 void toggleAlwaysOnTop();
338 * If true, the task's window will remain at the bottom of the stacking order.
340 void setKeptBelowOthers(bool);
341 void toggleKeptBelowOthers();
344 * If true, the task's window will enter full screen mode.
346 void setFullScreen(bool);
347 void toggleFullScreen();
350 * If true then the task's window will be shaded. Most window managers
351 * represent this state by displaying on the window's title bar.
353 void setShaded(bool);
354 void toggleShaded();
357 * Moves the task's window to the specified virtual desktop.
359 void toDesktop(int);
362 * Moves the task's window to the current virtual desktop.
364 void toCurrentDesktop();
367 * This method informs the window manager of the location at which this
368 * task will be displayed when iconised. It is used, for example by the
369 * KWin inconify animation.
371 void publishIconGeometry(QRect);
373 Q_SIGNALS:
375 * Indicates that this task has changed in some way.
377 void changed(::TaskManager::TaskChanges change);
380 * Indicates that this task is now the active task.
382 void activated();
385 * Indicates that this task is no longer the active task.
387 void deactivated();
389 protected:
390 void findWindowFrameId();
391 void timerEvent(QTimerEvent *event);
392 //* @internal */
393 void refreshIcon();
395 private:
396 class Private;
397 Private * const d;
400 } // TaskManager namespace
402 #endif