~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to ksystraycmd/ksystraycmd.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
 
 
3
#ifndef KSYSTRAYCMD_H
 
4
#define KSYSTRAYCMD_H
 
5
 
 
6
#include <KSystemTrayIcon>
 
7
 
 
8
class KProcess;
 
9
class KMenu;
 
10
 
 
11
/**
 
12
 * Provides a system tray icon for a normal window.
 
13
 *
 
14
 * @author Richard Moore, rich@kde.org
 
15
 */
 
16
class KSysTrayCmd : public KSystemTrayIcon
 
17
{
 
18
  Q_OBJECT
 
19
public:
 
20
  KSysTrayCmd();
 
21
  ~KSysTrayCmd();
 
22
 
 
23
  void setWindow( WId w ) { win = w; }
 
24
  void setCommand( const QString &cmd ) { command = cmd; }
 
25
  void setPattern( const QString &regexp ) { window = regexp; }
 
26
  void setStartOnShow( bool enable ) { lazyStart = enable; isVisible = !enable; }
 
27
  void setNoQuit( bool enable ) { noquit = enable; }
 
28
  void setQuitOnHide( bool enable ) { quitOnHide = enable; }
 
29
  void setOnTop( bool enable ) { onTop = enable; }
 
30
  void setOwnIcon( bool enable ) { ownIcon = enable; }
 
31
  void setDefaultTip( const QString &tip ) { tooltip = tip; }
 
32
  bool hasTargetWindow() const { return (win != 0); }
 
33
  bool hasRunningClient() const { return (client != 0); }
 
34
  const QString &errorMsg() const { return errStr; }
 
35
 
 
36
  bool start();
 
37
 
 
38
  static WId findRealWindow( WId w, int depth = 0 );
 
39
 
 
40
public Q_SLOTS:
 
41
  void refresh();
 
42
 
 
43
  void showWindow();
 
44
  void hideWindow();
 
45
  void toggleWindow() { if ( isVisible ) hideWindow(); else showWindow(); }
 
46
 
 
47
  void setTargetWindow( WId w );
 
48
  void execContextMenu( const QPoint &pos );
 
49
 
 
50
  void quit();
 
51
  void quitClient();
 
52
 
 
53
protected Q_SLOTS:
 
54
  void clientExited();
 
55
 
 
56
  void windowAdded(WId w);
 
57
  void windowChanged(WId w);
 
58
  void mousePressEvent(QSystemTrayIcon::ActivationReason reason);
 
59
 
 
60
protected:
 
61
  bool startClient();
 
62
  void checkExistingWindows();
 
63
 
 
64
private:
 
65
  QString command;
 
66
  QString window;
 
67
  QString tooltip;
 
68
  bool isVisible;
 
69
  bool lazyStart;
 
70
  bool noquit;
 
71
  bool quitOnHide;
 
72
  bool onTop; ///< tells if window must stay on top or not
 
73
  bool ownIcon; ///< tells if the ksystraycmd icon must be used in systray
 
74
  bool waitingForWindow;
 
75
  KMenu * menu;
 
76
 
 
77
  WId win;
 
78
  KProcess *client;
 
79
  QString errStr;
 
80
 
 
81
  /** Memorized 'top' position of the window*/
 
82
  int top;
 
83
  /** Memorized 'left' position of the window*/
 
84
  int left;
 
85
};
 
86
 
 
87
#endif // KSYSTRAYCMD_H