DisplayComponent.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef DISPLAYCOMPONENT_H
  2. #define DISPLAYCOMPONENT_H
  3. #include "DisplayManager.h"
  4. #include "ComponentManager.h"
  5. #include <QScreen>
  6. #include <QTimer>
  7. class DisplayComponent : public ComponentBase
  8. {
  9. Q_OBJECT
  10. DEFINE_SINGLETON(DisplayComponent);
  11. public:
  12. ~DisplayComponent();
  13. virtual const char* componentName() { return "display"; }
  14. virtual bool componentExport() { return true; }
  15. virtual bool componentInitialize();
  16. inline DisplayManager* getDisplayManager() { return m_displayManager; }
  17. int getApplicationDisplay();
  18. // Switch to the best video mode for the given video framerate. Return true only if the actual
  19. // mode was switched. If a good match was found, but the current video mode didn't have to be
  20. // changed, return false. Return false on failure too.
  21. bool switchToBestVideoMode(float frameRate);
  22. // Switch to best overall video mode. This will also switch the resolution.
  23. bool switchToBestOverallVideoMode(int display);
  24. double currentRefreshRate();
  25. private:
  26. DisplayComponent(QObject *parent = 0);
  27. DisplayManager *m_displayManager;
  28. int m_lastVideoMode;
  29. int m_lastDisplay;
  30. QTimer m_initTimer;
  31. public Q_SLOTS:
  32. void monitorChange();
  33. bool initializeDisplayManager();
  34. bool restorePreviousVideoMode();
  35. Q_SIGNALS:
  36. void refreshRateChanged();
  37. };
  38. #endif // DISPLAYCOMPONENT_H