main.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef MAIN_H_
  2. #define MAIN_H_
  3. #include <QtGui/QApplication>
  4. #include <QtGui/QSystemTrayIcon>
  5. #include <QtGui/QMenu>
  6. #include <QtGui/QSlider>
  7. #include <QtGui/QLabel>
  8. #include <QtGui/QProgressBar>
  9. #include <QtGui/QCheckBox>
  10. #define __stringify(x) #x
  11. #define stringify(x) __stringify(x)
  12. #define round_up(n, s) ((((n) + (s) - 1) / (s)) * (s))
  13. class TrayIcon;
  14. class Backend;
  15. class TrayWindow : public QMenu
  16. {
  17. Q_OBJECT
  18. public:
  19. TrayWindow(TrayIcon *_tray);
  20. virtual ~TrayWindow();
  21. void update();
  22. void updateBattBar(struct pt_message *msg = NULL);
  23. void updateBacklightSlider(struct pt_message *msg = NULL);
  24. protected:
  25. virtual void showEvent(QShowEvent *event);
  26. void updateBacklightToolTip(bool autodim);
  27. protected slots:
  28. void desiredBrightnessChanged(int newVal);
  29. void brightnessAutoAdjChanged(int unused);
  30. protected:
  31. int max_autodim;
  32. TrayIcon *tray;
  33. QProgressBar *battBar;
  34. QLabel *battLabel;
  35. QSlider *brightness;
  36. QCheckBox *brAutoAdj;
  37. QCheckBox *brAutoAdjAC;
  38. bool blockBrightnessChange;
  39. int realBrightnessMinVal;
  40. };
  41. class TrayIcon : public QSystemTrayIcon
  42. {
  43. Q_OBJECT
  44. public:
  45. TrayIcon();
  46. virtual ~TrayIcon();
  47. bool init();
  48. Backend * getBackend()
  49. { return backend; }
  50. void setBacklightToolTip(const QString &text);
  51. void setBatteryToolTip(const QString &text);
  52. protected slots:
  53. void wasActivated(QSystemTrayIcon::ActivationReason reason);
  54. void batteryStateChanged(struct pt_message *msg);
  55. void backlightStateChanged(struct pt_message *msg);
  56. protected:
  57. void updateToolTip();
  58. protected:
  59. TrayWindow *window;
  60. Backend *backend;
  61. QString backlightToolTip;
  62. QString batteryToolTip;
  63. };
  64. #endif /* MAIN_H_ */