qwkglobal_p.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (C) 2023-2024 Stdware Collections (https://www.github.com/stdware)
  2. // Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao)
  3. // SPDX-License-Identifier: Apache-2.0
  4. #ifndef QWKGLOBAL_P_H
  5. #define QWKGLOBAL_P_H
  6. //
  7. // W A R N I N G !!!
  8. // -----------------
  9. //
  10. // This file is not part of the QWindowKit API. It is used purely as an
  11. // implementation detail. This header file may change from version to
  12. // version without notice, or may even be removed.
  13. //
  14. #include <QtCore/QObject>
  15. #include <QtCore/QLoggingCategory>
  16. #include <QtGui/QMouseEvent>
  17. #include <core/qwkglobal.h>
  18. QWK_CORE_EXPORT Q_DECLARE_LOGGING_CATEGORY(qWindowKitLog)
  19. #define QWK_INFO qCInfo(qWindowKitLog)
  20. #define QWK_DEBUG qCDebug(qWindowKitLog)
  21. #define QWK_WARNING qCWarning(qWindowKitLog)
  22. #define QWK_CRITICAL qCCritical(qWindowKitLog)
  23. #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
  24. # define QWK_FATAL qCFatal(qWindowKitLog)
  25. #endif
  26. #define MAKE_RGB_COLOR(r, g, b) ((quint32) (((r) &0xFF) << 16) | (((g) &0xFF) << 8) | ((b) &0xFF))
  27. #define MAKE_RGBA_COLOR(r, g, b, a) \
  28. ((quint32) (((a) &0xFF) << 24) | (((r) &0xFF) << 16) | (((g) &0xFF) << 8) | ((b) &0xFF))
  29. #if defined(Q_CC_MSVC)
  30. # define QWK_NOINLINE __declspec(noinline)
  31. # define QWK_INLINE __forceinline
  32. # define QWK_USED
  33. #else
  34. # define QWK_NOINLINE __attribute__((noinline))
  35. # define QWK_INLINE __attribute__((always_inline))
  36. # define QWK_USED __attribute__((used))
  37. #endif
  38. namespace QWK {
  39. inline QPoint getMouseEventScenePos(const QMouseEvent *event) {
  40. #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  41. return event->scenePosition().toPoint();
  42. #else
  43. return event->windowPos().toPoint();
  44. #endif
  45. }
  46. inline QPoint getMouseEventGlobalPos(const QMouseEvent *event) {
  47. #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  48. return event->globalPosition().toPoint();
  49. #else
  50. return event->screenPos().toPoint();
  51. #endif
  52. }
  53. // Be careful when apply this function to a widget
  54. QWK_CORE_EXPORT bool forwardObjectEventFilters(QObject *currentFilter, QObject *receiver,
  55. QEvent *event);
  56. }
  57. #endif // QWKGLOBAL_P_H