Skip to content

Commit

Permalink
fix(core): register Settings::ContentAppearance type explicitly
Browse files Browse the repository at this point in the history
Fixes setting management with Qt 5.
  • Loading branch information
trollixx committed Sep 17, 2023
1 parent 9d376c2 commit 4e5e58b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libs/core/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ Settings::Settings(QObject *parent)
: QObject(parent)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qRegisterMetaTypeStreamOperators<ContentAppearance>("ContentAppearance");
qRegisterMetaTypeStreamOperators<ExternalLinkPolicy>("ExternalLinkPolicy");
#else
qRegisterMetaType<ContentAppearance>("ContentAppearance");
qRegisterMetaType<ExternalLinkPolicy>("ExternalLinkPolicy");
#endif

Expand Down Expand Up @@ -370,6 +372,20 @@ QSettings *Settings::qsettings(QObject *parent)
#endif
}

QDataStream &operator<<(QDataStream &out, Settings::ContentAppearance policy)
{
out << static_cast<std::underlying_type<Settings::ContentAppearance>::type>(policy);
return out;
}

QDataStream &operator>>(QDataStream &in, Settings::ContentAppearance &policy)
{
std::underlying_type<Settings::ContentAppearance>::type value;
in >> value;
policy = static_cast<Settings::ContentAppearance>(value);
return in;
}

QDataStream &operator<<(QDataStream &out, Settings::ExternalLinkPolicy policy)
{
out << static_cast<std::underlying_type<Settings::ExternalLinkPolicy>::type>(policy);
Expand Down
4 changes: 4 additions & 0 deletions src/libs/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ public slots:
} // namespace Core
} // namespace Zeal

QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ContentAppearance policy);
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ContentAppearance &policy);

QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ExternalLinkPolicy policy);
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ExternalLinkPolicy &policy);

Q_DECLARE_METATYPE(Zeal::Core::Settings::ContentAppearance)
Q_DECLARE_METATYPE(Zeal::Core::Settings::ExternalLinkPolicy)

#endif // ZEAL_CORE_SETTINGS_H

0 comments on commit 4e5e58b

Please sign in to comment.