2020-01-16 16:34:08 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file compatibility.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 16 1, 2020
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2020 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2020-01-16 16:34:08 +01:00
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
#ifndef COMPATIBILITY_H
|
|
|
|
#define COMPATIBILITY_H
|
|
|
|
|
2022-02-19 20:17:51 +01:00
|
|
|
#include <QFontMetrics>
|
2023-02-14 13:55:19 +01:00
|
|
|
#include <QLibraryInfo>
|
2023-05-11 15:23:57 +02:00
|
|
|
#include <QLineF>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QtGlobal>
|
2020-01-16 16:34:08 +01:00
|
|
|
|
2023-02-09 15:43:58 +01:00
|
|
|
#include "defglobal.h"
|
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
// WARNING:QVariant::load: unknown user type with name QMarginsF.
|
|
|
|
// QVariant::value<T>() fails to convert unless QVariant::fromValue<T>() has been called previously.
|
|
|
|
// https://stackoverflow.com/questions/70974383/qvariantvaluet-fails-to-convert-unless-qvariantfromvaluet-has-been-c
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
2023-06-22 17:30:43 +02:00
|
|
|
#define REGISTER_META_TYPE_STREAM_OPERATORS(TYPE) \
|
|
|
|
QMetaType::fromType<TYPE>().hasRegisteredDataStreamOperators(); // Dummy call
|
2023-02-09 15:43:58 +01:00
|
|
|
#else
|
2023-06-22 17:30:43 +02:00
|
|
|
#define REGISTER_META_TYPE_STREAM_OPERATORS(TYPE) QVariant::fromValue<TYPE>(TYPE{}); // Dummy call
|
2023-02-09 15:43:58 +01:00
|
|
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
|
|
|
#else
|
2023-06-22 17:30:43 +02:00
|
|
|
#define REGISTER_META_TYPE_STREAM_OPERATORS(TYPE) qRegisterMetaTypeStreamOperators<TYPE>(#TYPE);
|
2023-02-09 15:43:58 +01:00
|
|
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
|
2020-01-16 16:34:08 +01:00
|
|
|
class QPointF;
|
|
|
|
|
2023-10-09 12:40:55 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOEXCEPT
|
|
|
|
{
|
|
|
|
return rhs.size() == 1 && lhs == rhs[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOEXCEPT
|
|
|
|
{
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOEXCEPT
|
|
|
|
{
|
|
|
|
return rhs == lhs;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-10-07 17:56:39 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
|
|
|
namespace Qt
|
|
|
|
{
|
|
|
|
inline namespace Literals
|
|
|
|
{
|
|
|
|
inline namespace StringLiterals
|
|
|
|
{
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-10-09 12:40:55 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto operator"" _L1(char ch) Q_DECL_NOEXCEPT->QLatin1Char
|
2023-10-07 17:56:39 +02:00
|
|
|
{
|
|
|
|
return QLatin1Char(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-10-09 12:40:55 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto operator"" _L1(const char *str, size_t size) Q_DECL_NOEXCEPT->QLatin1String
|
2023-10-07 17:56:39 +02:00
|
|
|
{
|
|
|
|
return QLatin1String(str, static_cast<vsizetype>(size));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-10-09 12:40:55 +02:00
|
|
|
inline auto operator"" _ba(const char *str, size_t size) Q_DECL_NOEXCEPT->QByteArray
|
2023-10-07 17:56:39 +02:00
|
|
|
{
|
|
|
|
return {str, static_cast<vsizetype>(size)};
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-10-09 12:40:55 +02:00
|
|
|
inline auto operator"" _s(const char16_t *str, size_t size) Q_DECL_NOEXCEPT->QString
|
2023-10-07 17:56:39 +02:00
|
|
|
{
|
|
|
|
return QString::fromUtf16(str, static_cast<vsizetype>(size));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace StringLiterals
|
|
|
|
} // namespace Literals
|
|
|
|
} // namespace Qt
|
|
|
|
#endif
|
|
|
|
|
2020-01-16 16:34:08 +01:00
|
|
|
// Contains helpful methods to hide version dependent code. It can be deprecation of method or change in API
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
2022-01-29 08:46:01 +01:00
|
|
|
inline auto Intersects(const T &l1, const T &l2, QPointF *intersectionPoint) -> typename T::IntersectType
|
2020-01-16 16:34:08 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
|
|
return l1.intersects(l2, intersectionPoint);
|
|
|
|
#else
|
|
|
|
return l1.intersect(l2, intersectionPoint);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-01-16 18:09:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T, template <typename> class C> inline auto ConvertToList(const C<T> &container) -> QList<T>
|
2020-01-16 18:09:23 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
2020-01-17 13:44:25 +01:00
|
|
|
return QList<T>(container.begin(), container.end());
|
2020-01-16 18:09:23 +01:00
|
|
|
#else
|
|
|
|
return container.toList();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-08-17 14:51:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T, template <typename> class C> inline auto ConvertToStringList(const C<T> &container) -> QStringList
|
2022-08-17 14:51:35 +02:00
|
|
|
{
|
|
|
|
return {ConvertToList(container)};
|
|
|
|
}
|
|
|
|
|
2020-01-16 18:09:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T, template <typename> class C> inline auto ConvertToSet(const C<T> &container) -> QSet<T>
|
2020-01-16 18:09:23 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
2020-01-17 13:44:25 +01:00
|
|
|
return QSet<T>(container.begin(), container.end());
|
2020-01-16 18:09:23 +01:00
|
|
|
#else
|
|
|
|
return container.toSet();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T, typename C> inline auto ConvertToSet(const C &container) -> QSet<T>
|
2020-01-16 18:09:23 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
2020-01-17 13:44:25 +01:00
|
|
|
return QSet<T>(container.begin(), container.end());
|
2020-01-16 18:09:23 +01:00
|
|
|
#else
|
|
|
|
return container.toSet();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-01-16 18:20:55 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T, template <typename> class C> inline auto ConvertToVector(const C<T> &container) -> QVector<T>
|
2020-01-16 18:20:55 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
|
|
return QVector<T>(container.begin(), container.end());
|
|
|
|
#else
|
|
|
|
return container.toVector();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-01-16 18:46:05 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T> inline auto ConvertToVector(const QSet<T> &container) -> QVector<T>
|
2020-01-16 18:46:05 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
|
|
return QVector<T>(container.begin(), container.end());
|
|
|
|
#else
|
|
|
|
return container.toList().toVector();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-01-16 18:09:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-08-28 14:09:16 +02:00
|
|
|
// NOTE: Delete if not necessary anymore
|
2023-06-22 17:30:43 +02:00
|
|
|
// template <typename T>
|
|
|
|
// inline void SwapItemsAt(T &container, int i, int j)
|
2020-08-28 14:09:16 +02:00
|
|
|
//{
|
2023-06-22 17:30:43 +02:00
|
|
|
// #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
2020-08-28 14:09:16 +02:00
|
|
|
// container.swapItemsAt(i, j);
|
2023-06-22 17:30:43 +02:00
|
|
|
// #else
|
2020-08-28 14:09:16 +02:00
|
|
|
// container.swap(i, j);
|
2023-06-22 17:30:43 +02:00
|
|
|
// #endif
|
2020-08-28 14:09:16 +02:00
|
|
|
//}
|
2020-01-16 18:09:23 +01:00
|
|
|
|
2020-07-13 15:28:13 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T> inline auto Reverse(const QVector<T> &container) -> QVector<T>
|
2020-07-13 15:28:13 +02:00
|
|
|
{
|
|
|
|
if (container.isEmpty())
|
|
|
|
{
|
|
|
|
return container;
|
|
|
|
}
|
2020-07-13 17:23:15 +02:00
|
|
|
QVector<T> reversed(container.size());
|
2023-02-09 16:23:11 +01:00
|
|
|
vsizetype j = 0;
|
|
|
|
for (vsizetype i = container.size() - 1; i >= 0; --i)
|
2020-07-13 15:28:13 +02:00
|
|
|
{
|
|
|
|
reversed.replace(j, container.at(i));
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
return reversed;
|
|
|
|
}
|
|
|
|
|
2020-07-13 17:23:15 +02:00
|
|
|
template <typename T, template <typename> class C>
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-28 15:16:02 +02:00
|
|
|
inline auto Reverse(const C<T> &container) -> C<T>
|
2020-07-13 17:23:15 +02:00
|
|
|
{
|
|
|
|
return ConvertToList(Reverse(ConvertToVector(container)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T, typename std::enable_if<std::is_same<T, QStringList>::value, T>::type * = nullptr>
|
2022-10-28 15:16:02 +02:00
|
|
|
inline auto Reverse(const T &container) -> T
|
2020-07-13 17:23:15 +02:00
|
|
|
{
|
|
|
|
return Reverse<QString, QList>(container);
|
|
|
|
}
|
|
|
|
|
2022-02-19 20:17:51 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto TextWidth(const QFontMetrics &fm, const QString &text, int len = -1) -> int
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
|
|
|
return fm.horizontalAdvance(text, len);
|
|
|
|
#else
|
|
|
|
return fm.width(text, len);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto TextWidthF(const QFontMetricsF &fm, const QString &text) -> qreal
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
|
|
|
return fm.horizontalAdvance(text);
|
|
|
|
#else
|
|
|
|
return fm.width(text);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-12-31 13:41:10 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename Key, typename T> inline auto Insert(QMap<Key, T> &map1, const QMap<Key, T> &map2) -> void
|
2022-12-31 13:41:10 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
|
|
|
map1.insert(map2);
|
|
|
|
#else
|
|
|
|
auto i = map2.constBegin();
|
|
|
|
while (i != map2.constEnd())
|
|
|
|
{
|
|
|
|
map1.insert(i.key(), i.value());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-02-09 14:42:34 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto VLocaleCharacter(const QString &character) -> QChar
|
|
|
|
{
|
|
|
|
Q_ASSERT(character.size() == 1);
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
|
|
return character.front();
|
|
|
|
#else
|
|
|
|
return character.at(0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto VLocaleCharacter(const QChar &character) -> QChar
|
|
|
|
{
|
|
|
|
return character;
|
|
|
|
}
|
2023-02-09 15:13:18 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T> inline auto DropEventPos(const T *event) -> QPoint
|
2023-02-09 15:13:18 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
return event->position().toPoint();
|
|
|
|
#else
|
|
|
|
return event->pos();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-02-09 16:23:46 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-06-22 17:30:43 +02:00
|
|
|
template <typename T> inline auto QLibraryPath(T loc) -> QString
|
2023-02-09 16:23:46 +01:00
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
return QLibraryInfo::path(loc);
|
|
|
|
#else
|
|
|
|
return QLibraryInfo::location(loc);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-05-11 15:23:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto LineCenter(const QLineF &line) -> QPointF
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
|
|
|
return line.center();
|
|
|
|
#else
|
|
|
|
return {0.5 * line.p1().x() + 0.5 * line.p2().x(), 0.5 * line.p1().y() + 0.5 * line.p2().y()};
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-06-22 17:30:43 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T, typename N> inline auto First(const T &list, N n) -> T
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
return list.first(n);
|
|
|
|
#else
|
|
|
|
Q_ASSERT(n <= list.size());
|
|
|
|
T result;
|
|
|
|
result.reserve(n);
|
|
|
|
std::copy(list.begin(), list.begin() + n, std::back_inserter(result));
|
|
|
|
return result;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T, typename N> inline auto Last(const T &list, N n) -> T
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
return list.last(n);
|
|
|
|
#else
|
|
|
|
Q_ASSERT(n <= list.size());
|
|
|
|
T result;
|
|
|
|
result.reserve(n);
|
|
|
|
std::copy(list.end() - n, list.end(), std::back_inserter(result));
|
|
|
|
return result;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T, typename N> inline auto Sliced(const T &list, N pos) -> T
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
return list.sliced(pos);
|
|
|
|
#else
|
|
|
|
Q_ASSERT(pos <= list.size());
|
|
|
|
T result;
|
|
|
|
result.reserve(list.size() - pos);
|
|
|
|
std::copy(list.begin() + pos, list.end(), std::back_inserter(result));
|
|
|
|
return result;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T, typename N> inline auto Sliced(const T &list, N pos, N n) -> T
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
return list.sliced(pos, n);
|
|
|
|
#else
|
|
|
|
Q_ASSERT(pos <= list.size());
|
|
|
|
Q_ASSERT(n >= 0);
|
|
|
|
Q_ASSERT(pos + n <= list.size());
|
|
|
|
T result;
|
|
|
|
result.reserve(n);
|
|
|
|
std::copy(list.begin() + pos, list.begin() + pos + n, std::back_inserter(result));
|
|
|
|
return result;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-06-27 13:22:49 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto Back(const QString &str) -> QChar
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
|
|
return str.back();
|
|
|
|
#else
|
|
|
|
return str.at(str.size() - 1);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-06-28 09:19:17 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto Front(const QString &str) -> QChar
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
|
|
return str.front();
|
|
|
|
#else
|
|
|
|
return str.at(0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-07-07 15:42:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline auto FontFromString(const QString &descrip) -> QFont
|
|
|
|
{
|
2023-10-07 17:56:39 +02:00
|
|
|
using namespace Qt::Literals::StringLiterals;
|
|
|
|
|
2023-07-07 15:42:54 +02:00
|
|
|
QFont font;
|
|
|
|
|
|
|
|
if (!descrip.isEmpty())
|
|
|
|
{
|
|
|
|
// Qt 6's QFont::toString returns a value with 17 fields, e.g.
|
|
|
|
// Ubuntu,11,-1,5,400,0,0,0,0,0,0,0,0,0,0,1
|
|
|
|
// Qt 5's QFont::fromString expects a value with 11 fields, e.g.
|
|
|
|
// Ubuntu,10,-1,5,50,0,0,0,0,0
|
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
2023-10-07 17:56:39 +02:00
|
|
|
const auto l = descrip.split(','_L1);
|
2023-07-07 15:42:54 +02:00
|
|
|
// Qt5's QFont::fromString() isn't compatible with Qt6's QFont::toString().
|
|
|
|
// If we were built with Qt5, don't try to process a font preference that
|
|
|
|
// was created by Qt6.
|
|
|
|
if (l.count() <= 11)
|
|
|
|
{
|
|
|
|
font.fromString(descrip);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
font.fromString(descrip);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2020-01-16 16:34:08 +01:00
|
|
|
#endif // COMPATIBILITY_H
|