diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 1171dd84c..2069cd035 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -361,7 +361,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : break; } - std::this_thread::sleep_for(100ms); + std::this_thread::sleep_for(MSECONDS(100)); } } @@ -391,7 +391,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : if (m_cmd->IsGuiEnabled()) { - QTimer::singleShot(1s, this, &VPMainWindow::SetDefaultGUILanguage); + QTimer::singleShot(SECONDS(1), this, &VPMainWindow::SetDefaultGUILanguage); } } diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 1623cd5b2..8b3df51b7 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -245,7 +245,7 @@ TMainWindow::TMainWindow(QWidget *parent) if (MApplication::VApp()->IsAppInGUIMode()) { - QTimer::singleShot(1s, this, &TMainWindow::SetDefaultGUILanguage); + QTimer::singleShot(SECONDS(1), this, &TMainWindow::SetDefaultGUILanguage); } } diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.cpp b/src/app/valentina/dialogs/dialoglayoutprogress.cpp index 953dcf21a..1b2778ee5 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.cpp +++ b/src/app/valentina/dialogs/dialoglayoutprogress.cpp @@ -88,7 +88,7 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, m_progressTimer->stop(); } }); - m_progressTimer->start(1s); + m_progressTimer->start(SECONDS(1)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index bc9e0f0ea..5c7e3d093 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -96,7 +96,7 @@ void VWidgetDetails::UpdateList() // The filling table is a very expensive operation. This optimization will postpone it. // Each time a new request happen we will wait 800 ms before calling it. If at this time a new request will arrive // we will wait 800 ms more. And so on, until nothing happens within 800ms. - m_updateListTimer->start(800ms); + m_updateListTimer->start(MSECONDS(800)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 1165c2bf8..8d52ff2f6 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -474,7 +474,7 @@ MainWindow::MainWindow(QWidget *parent) if (VApplication::IsGUIMode()) { - QTimer::singleShot(1s, this, &MainWindow::SetDefaultGUILanguage); + QTimer::singleShot(SECONDS(1), this, &MainWindow::SetDefaultGUILanguage); } } @@ -2139,7 +2139,7 @@ void MainWindow::MeasurementsChanged(const QString &path) { m_mChanges = true; m_mChangesAsked = false; - m_measurementsSyncTimer->start(1500ms); + m_measurementsSyncTimer->start(MSECONDS(1500)); } else { @@ -2149,7 +2149,7 @@ void MainWindow::MeasurementsChanged(const QString &path) { m_mChanges = true; m_mChangesAsked = false; - m_measurementsSyncTimer->start(1500ms); + m_measurementsSyncTimer->start(MSECONDS(1500)); break; } diff --git a/src/libs/vmisc/bpstd/chrono.hpp b/src/libs/vmisc/bpstd/chrono.hpp index e390eb339..84af34903 100644 --- a/src/libs/vmisc/bpstd/chrono.hpp +++ b/src/libs/vmisc/bpstd/chrono.hpp @@ -35,14 +35,6 @@ #include // std::chrono::duration, std::chrono::system_clock, etc #include // std::int32_t -#if __cplusplus < 201402L -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) -#include "../vmisc/diagnostic.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) -#endif - BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE namespace bpstd { @@ -90,93 +82,21 @@ namespace bpstd { constexpr auto operator""_h(unsigned long long x) -> std::chrono::hours; constexpr auto operator""_h(long double x) -> std::chrono::duration>; -#if __cplusplus < 201402L - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") - QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - - // available only since C++14 - constexpr auto operator""h(unsigned long long x) -> std::chrono::hours; - constexpr auto operator""h(long double x) -> std::chrono::duration>; - - QT_WARNING_POP -#endif - constexpr auto operator""_min(unsigned long long x) -> chrono::minutes; constexpr auto operator""_min(long double x) -> chrono::duration>; -#if __cplusplus < 201402L - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") - QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - - // available only since C++14 - constexpr auto operator""min(unsigned long long x) -> chrono::minutes; - constexpr auto operator""min(long double x) -> chrono::duration>; - - QT_WARNING_POP -#endif - constexpr auto operator""_s(unsigned long long x) -> chrono::seconds; constexpr auto operator""_s(long double x) -> chrono::duration; -#if __cplusplus < 201402L - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") - QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - - // available only since C++14 - constexpr auto operator""s(unsigned long long x) -> chrono::seconds; - constexpr auto operator""s(long double x) -> chrono::duration; - - QT_WARNING_POP -#endif - constexpr auto operator""_ms(unsigned long long x) -> chrono::milliseconds; constexpr auto operator""_ms(long double x) -> chrono::duration; -#if __cplusplus < 201402L - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") - QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - - // available only since C++14 - constexpr auto operator""ms(unsigned long long x) -> chrono::milliseconds; - constexpr auto operator""ms(long double x) -> chrono::duration; - - QT_WARNING_POP -#endif - constexpr auto operator""_us(unsigned long long x) -> chrono::microseconds; constexpr auto operator""_us(long double x) -> chrono::duration; -#if __cplusplus < 201402L - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") - QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - - // available only since C++14 - constexpr auto operator""us(unsigned long long x) -> chrono::microseconds; - constexpr auto operator""us(long double x) -> chrono::duration; - - QT_WARNING_POP -#endif - constexpr auto operator""_ns(unsigned long long x) -> chrono::nanoseconds; constexpr auto operator""_ns(long double x) -> chrono::duration; -#if __cplusplus < 201402L - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") - QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - - // available only since C++14 - constexpr auto operator""ns(unsigned long long x) -> chrono::nanoseconds; - constexpr auto operator""ns(long double x) -> chrono::duration; - - QT_WARNING_POP -#endif - } // namespace chrono_literals } // namespace literals } // namespace bpstd @@ -188,251 +108,72 @@ auto return chrono::hours{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""h(unsigned long long x) -> std::chrono::hours -{ - return chrono::hours{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_h(long double x) -> std::chrono::duration> { return chrono::duration>{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""h(long double x) -> std::chrono::duration> -{ - return chrono::duration>{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_min(unsigned long long x) -> bpstd::chrono::minutes { return chrono::minutes{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""min(unsigned long long x) -> bpstd::chrono::minutes -{ - return chrono::minutes{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_min(long double x) -> bpstd::chrono::duration> { return chrono::duration>{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""min(long double x) -> bpstd::chrono::duration> -{ - return chrono::duration>{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_s(unsigned long long x) -> bpstd::chrono::seconds { return chrono::seconds{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""s(unsigned long long x) -> bpstd::chrono::seconds -{ - return chrono::seconds{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_s(long double x) -> bpstd::chrono::duration { return chrono::duration{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""s(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_ms(unsigned long long x) -> bpstd::chrono::milliseconds { return chrono::milliseconds{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""ms(unsigned long long x) -> bpstd::chrono::milliseconds -{ - return chrono::milliseconds{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_ms(long double x) -> bpstd::chrono::duration { return chrono::duration{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""ms(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator ""_us(unsigned long long x) -> bpstd::chrono::microseconds { return chrono::microseconds{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator ""us(unsigned long long x) -> bpstd::chrono::microseconds -{ - return chrono::microseconds{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_us(long double x) -> bpstd::chrono::duration { return chrono::duration{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""us(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_ns(unsigned long long x) -> bpstd::chrono::nanoseconds { return chrono::nanoseconds{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""ns(unsigned long long x) -> bpstd::chrono::nanoseconds -{ - return chrono::nanoseconds{x}; -} - -QT_WARNING_POP -#endif - inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::chrono_literals::operator""_ns(long double x) -> bpstd::chrono::duration { return chrono::duration{x}; } -#if __cplusplus < 201402L -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals") -QT_WARNING_DISABLE_GCC("-Wliteral-suffix") - -// available only since C++14 -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator""ns(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -QT_WARNING_POP -#endif - BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE #endif /* BPSTD_CHRONO_HPP */ diff --git a/src/libs/vmisc/defglobal.h b/src/libs/vmisc/defglobal.h index 7aff87ec8..4fd33b3ba 100644 --- a/src/libs/vmisc/defglobal.h +++ b/src/libs/vmisc/defglobal.h @@ -55,4 +55,22 @@ void qAsConst(const T &&) Q_DECL_EQ_DELETE; Q_DISABLE_MOVE(Class) #endif +#define SUFFIX_APPEND(x, y) x ## y // NOLINT(cppcoreguidelines-macro-usage) + +#if __cplusplus >= 201402L +#define HOURS(x) SUFFIX_APPEND(x, h) // NOLINT(cppcoreguidelines-macro-usage) +#define MINUTES(x) SUFFIX_APPEND(x, min) // NOLINT(cppcoreguidelines-macro-usage) +#define SECONDS(x) SUFFIX_APPEND(x, s) // NOLINT(cppcoreguidelines-macro-usage) +#define MSECONDS(x) SUFFIX_APPEND(x, ms) // NOLINT(cppcoreguidelines-macro-usage) +#define MICSECONDS(x) SUFFIX_APPEND(x, us) // NOLINT(cppcoreguidelines-macro-usage) +#define NANOSECONDS(x) SUFFIX_APPEND(x, ns) // NOLINT(cppcoreguidelines-macro-usage) +#else +#define HOURS(x) SUFFIX_APPEND(x, _h) // NOLINT(cppcoreguidelines-macro-usage) +#define MINUTES(x) SUFFIX_APPEND(x, _min) // NOLINT(cppcoreguidelines-macro-usage) +#define SECONDS(x) SUFFIX_APPEND(x, _s) // NOLINT(cppcoreguidelines-macro-usage) +#define MSECONDS(x) SUFFIX_APPEND(x, _ms) // NOLINT(cppcoreguidelines-macro-usage) +#define MICSECONDS(x) SUFFIX_APPEND(x, _us) // NOLINT(cppcoreguidelines-macro-usage) +#define NANOSECONDS(x) SUFFIX_APPEND(x, _ns) // NOLINT(cppcoreguidelines-macro-usage) +#endif // __cplusplus >= 201402L + #endif // DEFGLOBAL_H