From 67b829bf098fc1f6a288e949b289fc22646636fd Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 13 Mar 2021 10:16:40 +0100 Subject: [PATCH] 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(+) diff --git a/src/support/ConsoleApplicationPrivate.h b/src/support/ConsoleApplicationPrivate.h index 74aa161ad2..ee53139e04 100644 --- a/src/support/ConsoleApplicationPrivate.h +++ b/src/support/ConsoleApplicationPrivate.h @@ -15,6 +15,9 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) +#include +#endif #include #include @@ -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 df5b443381..a4075d69ae 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 5415ac4eeb..b43218857d 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(-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