Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix behavior of DitheringMode with QVariant in Qt5 #3307

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core/Dithering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ enum class DitheringMode
Color888, //!< 24-bit color (AKA True color)
Color101010, //!< 30-bit color (AKA Deep color)
};
#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
// A similar pair of methods but templated for arbitrary enum first appears in Qt 5.14
inline QDataStream& operator>>(QDataStream& s, DitheringMode& m)
{
return s >> reinterpret_cast<std::underlying_type<DitheringMode>::type&>(m);
}
inline QDataStream& operator<<(QDataStream &s, const DitheringMode &m)
{
return s << static_cast<typename std::underlying_type<DitheringMode>::type>(m);
}
#endif

Vec3f calcRGBMaxValue(DitheringMode mode);

Expand Down
2 changes: 2 additions & 0 deletions src/core/StelCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,7 @@ void StelCore::registerMathMetaTypes()
qRegisterMetaType<Mat4f>();
qRegisterMetaType<Mat3d>();
qRegisterMetaType<Mat3f>();
qRegisterMetaType<DitheringMode>();

#if (QT_VERSION<QT_VERSION_CHECK(6,0,0))
//registers the QDataStream operators, so that QVariants with these types can be saved
Expand All @@ -2072,6 +2073,7 @@ void StelCore::registerMathMetaTypes()
qRegisterMetaTypeStreamOperators<Mat4f>();
qRegisterMetaTypeStreamOperators<Mat3d>();
qRegisterMetaTypeStreamOperators<Mat3f>();
qRegisterMetaTypeStreamOperators<DitheringMode>();
#endif
//for debugging QVariants with these types, it helps if we register the string converters
// This is also required for QJSEngine.
Expand Down