qt_shim.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_QT_QT_SHIM_H_
  5. #define UI_QT_QT_SHIM_H_
  6. #include <QApplication>
  7. #include <QImage>
  8. #include <QObject>
  9. #include "ui/qt/qt_interface.h"
  10. namespace qt {
  11. // This class directly interacts with QT. It's required to be a QObject
  12. // to receive signals from QT via slots.
  13. class QtShim : public QObject, public QtInterface {
  14. Q_OBJECT
  15. public:
  16. QtShim(QtInterface::Delegate* delegate, int* argc, char** argv);
  17. ~QtShim() override;
  18. // QtInterface:
  19. double GetScaleFactor() const override;
  20. FontRenderParams GetFontRenderParams() const override;
  21. FontDescription GetFontDescription() const override;
  22. Image GetIconForContentType(const String& content_type,
  23. int size) const override;
  24. SkColor GetColor(ColorType role, ColorState state) const override;
  25. SkColor GetFrameColor(ColorState state, bool use_custom_frame) const override;
  26. Image DrawHeader(int width,
  27. int height,
  28. SkColor default_color,
  29. ColorState state,
  30. bool use_custom_frame) const override;
  31. int GetCursorBlinkIntervalMs() const override;
  32. int GetAnimationDurationMs() const override;
  33. private slots:
  34. void FontChanged(const QFont& font);
  35. void PaletteChanged(const QPalette& palette);
  36. private:
  37. QImage DrawHeaderImpl(int width,
  38. int height,
  39. SkColor default_color,
  40. ColorState state,
  41. bool use_custom_frame) const;
  42. QtInterface::Delegate* const delegate_;
  43. QApplication app_;
  44. };
  45. } // namespace qt
  46. #endif // UI_QT_QT_SHIM_H_