borisbn

WatchDog.h

Mar 13th, 2013
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef WATCHDOG_H
  2. #define WATCHDOG_H
  3.  
  4. #include <QtGui/QDialog>
  5. #include "ui_WatchDog.h"
  6. #include <QSystemTrayIcon>
  7. #include <QTimerEvent>
  8. #include <QString>
  9. #include <vector>
  10. #include <windows.h>
  11.  
  12. class QAction;
  13.  
  14. class WatchDog : public QDialog
  15. {
  16.     Q_OBJECT
  17.  
  18. public:
  19.     WatchDog( QWidget * parent = 0, Qt::WFlags flags = 0 );
  20.     ~WatchDog();
  21.    
  22. protected:
  23.     void setVisible( bool visible );
  24.     void closeEvent( QCloseEvent * event );
  25.     void timerEvent( QTimerEvent * event );
  26.  
  27. protected slots:
  28.     void iconActivated( QSystemTrayIcon::ActivationReason reason );
  29.  
  30. private:
  31.     Ui::WatchDogClass ui;
  32.  
  33. struct ExeParams {
  34.     QString exeName;
  35.     QString startCommand;
  36.     QStringList captionMasks;
  37. };
  38. typedef std::vector< ExeParams > ExeParamsList;
  39.  
  40.     ExeParamsList m_exeNames;
  41.     QSystemTrayIcon * m_trayIcon;
  42.     QAction * m_restoreAction;
  43.     int m_timerInterval;
  44.    
  45.     std::vector< HWND > m_windows;
  46.    
  47.     static BOOL CALLBACK nextWindow( HWND hwnd, LPARAM lParam );
  48.     static DWORD getProcessId( const QString & exe );
  49.     static QString getWindowCaption( HWND hwnd );
  50.     static bool isCaptionMatches( HWND hwnd, const QStringList & masks );
  51. };
  52.  
  53. #endif // WATCHDOG_H
Add Comment
Please, Sign In to add comment