commit 67b829bf098fc1f6a288e949b289fc22646636fd Author: Juergen Spitzmueller <sp...@lyx.org> Date: Sat Mar 13 10:16:40 2021 +0100
Backport one more deprecation fix --- src/support/ConsoleApplicationPrivate.h | 7 +++++++ src/support/FileName.cpp | 4 ++++ src/support/lyxtime.cpp | 13 +++++++++++++ 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/support/ConsoleApplicationPrivate.h b/src/support/ConsoleApplicationPrivate.h index 74aa161..ee53139 100644 --- a/src/support/ConsoleApplicationPrivate.h +++ b/src/support/ConsoleApplicationPrivate.h @@ -15,6 +15,9 @@ #include <QCoreApplication> #include <QDateTime> +#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) +#include <QRandomGenerator> +#endif #include <QTimer> #include <string> @@ -38,7 +41,11 @@ public: setOrganizationDomain("lyx.org"); setApplicationName(toqstr(app)); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) + QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch()); +#else qsrand(QDateTime::currentDateTime().toTime_t()); +#endif } int execute() { diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index df5b443..a4075d6 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -507,7 +507,11 @@ time_t FileName::lastModified() const // been touched between the object creation and now, we refresh the file // information. d->refresh(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) + return d->fi.lastModified().toSecsSinceEpoch(); +#else return d->fi.lastModified().toTime_t(); +#endif } diff --git a/src/support/lyxtime.cpp b/src/support/lyxtime.cpp index 5415ac4..b432188 100644 --- a/src/support/lyxtime.cpp +++ b/src/support/lyxtime.cpp @@ -43,11 +43,20 @@ string const formatted_time(time_t t, string const & fmt) docstring formatted_datetime(time_t t, string const & fmt) { QString qres; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) + if (fmt.empty()) + qres = QLocale().toString(QDateTime::fromSecsSinceEpoch(t), + QLocale::ShortFormat); + else + qres = QLocale().toString(QDateTime::fromSecsSinceEpoch(t), + toqstr(fmt)); +#else if (fmt.empty()) qres = QLocale().toString(QDateTime::fromTime_t(t), QLocale::ShortFormat); else qres = QLocale().toString(QDateTime::fromTime_t(t), toqstr(fmt)); +#endif return qstring_to_ucs4(qres); } @@ -70,7 +79,11 @@ time_t from_asctime_utc(string t) return static_cast<time_t>(-1); } loc_dt.setTimeSpec(Qt::UTC); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) + return loc_dt.toSecsSinceEpoch(); +#else return loc_dt.toTime_t(); +#endif } } // namespace support -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs