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