Compare commits

...

3 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
29c4e4706e Use QT_CHECK_VERSION to condition on qt version 2024-10-23 13:23:05 +02:00
Jean-Marc Lasgouttes
c39d5b760c Require at least Qt 5.12. Part2: Qt frontend
Most of it is fairly mechanical, but some parts require care.
2024-10-23 12:00:20 +02:00
Jean-Marc Lasgouttes
6ba2b5c5b9 Require at least Qt 5.12
Update the #if confitional accordingly everywhere excpt in frontends/qt.

Update INSTALL and README.

Cmake will need to be updated too.
2024-10-23 10:50:23 +02:00
28 changed files with 61 additions and 237 deletions

View File

@ -59,10 +59,10 @@ LyX makes great use of the C++ Standard Library. This means that gcc
users will have to install the relevant libstdc++ library to be able users will have to install the relevant libstdc++ library to be able
to compile this version of LyX. to compile this version of LyX.
For full LyX usability we suggest to use Qt 5.6 and higher, or at the LyX requires Qt 5.12 and higher. It is also possible to compile
very least Qt 5.4. It is also possible to compile against Qt 6. The against Qt 6. The only special point to make is that you must ensure
only special point to make is that you must ensure that both LyX and that both LyX and the Qt libraries are compiled with the same C++
the Qt libraries are compiled with the same C++ compiler. compiler.
To build LyX with spell checking capabilities included you have to To build LyX with spell checking capabilities included you have to
install at least one of the development packages of the spell checker install at least one of the development packages of the spell checker

4
README
View File

@ -90,8 +90,8 @@ What do I need to compile LyX from the source distribution?
but clang and MSVC are known to work too. As of LyX 2.5.0, you but clang and MSVC are known to work too. As of LyX 2.5.0, you
need at least gcc 8.0. need at least gcc 8.0.
* The Qt library, at least version 5.2 (5.6 recommended). It is * The Qt library, at least version 5.12. It is also possible to
also possible to compile with Qt 6.x. compile with Qt 6.x.
Read the file "INSTALL" for more information on compiling. Read the file "INSTALL" for more information on compiling.

View File

@ -147,7 +147,7 @@ AC_CHECK_HEADERS(magic.h,
### setup the qt frontend. ### setup the qt frontend.
dnl The code below is not in a macro, because this would cause big dnl The code below is not in a macro, because this would cause big
dnl problems with the AC_REQUIRE contained in QT_DO_IT_ALL. dnl problems with the AC_REQUIRE contained in QT_DO_IT_ALL.
QT_DO_IT_ALL([5.0.0]) QT_DO_IT_ALL([5.12.0])
AC_SUBST([FRONTENDS_SUBDIRS], [qt]) AC_SUBST([FRONTENDS_SUBDIRS], [qt])
FRONTEND_INFO="${FRONTEND_INFO}\ FRONTEND_INFO="${FRONTEND_INFO}\
Qt Frontend:\n\ Qt Frontend:\n\

View File

@ -28,9 +28,7 @@
#include <QImage> #include <QImage>
#include <QFile> #include <QFile>
#include <QPainter> #include <QPainter>
#if (QT_VERSION >= 0x050300)
#include <QPdfWriter> #include <QPdfWriter>
#endif
const char * basename(const char * name) const char * basename(const char * name)
@ -143,7 +141,6 @@ int main(int argc, char **argv)
std::cerr << myname << ": Conversion of images to format '" << oformat << "' is not supported" << std::endl; std::cerr << myname << ": Conversion of images to format '" << oformat << "' is not supported" << std::endl;
return 4; return 4;
} else if (NULL != oformat && !strcmp(oformat, "pdf")) { } else if (NULL != oformat && !strcmp(oformat, "pdf")) {
#if (QT_VERSION >= 0x050300)
QSize size = img.size(); QSize size = img.size();
QPdfWriter pdfwriter(QString::fromLocal8Bit(outfile)); QPdfWriter pdfwriter(QString::fromLocal8Bit(outfile));
int dpi = pdfwriter.logicalDpiX(); int dpi = pdfwriter.logicalDpiX();
@ -154,10 +151,6 @@ int main(int argc, char **argv)
QPainter painter(&pdfwriter); QPainter painter(&pdfwriter);
painter.drawImage(0, 0, img); painter.drawImage(0, 0, img);
painter.end(); painter.end();
#else
std::cerr << myname << ": Conversion of images to format '" << oformat << "' is not supported" << std::endl;
return 4;
#endif
} else if (!img.save(QString::fromLocal8Bit(outfile), oformat)) { } else if (!img.save(QString::fromLocal8Bit(outfile), oformat)) {
std::cerr << myname << ": Cannot save converted image to '" << outfile << "'" << std::endl; std::cerr << myname << ": Cannot save converted image to '" << outfile << "'" << std::endl;
return 5; return 5;

View File

@ -287,11 +287,7 @@ void CategorizedCombo::Private::setFilter(QString const & s)
lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row(); lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
filter_ = s; filter_ = s;
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
#else
filterModel_->setFilterRegularExpression(charFilterRegExp(filter_)); filterModel_->setFilterRegularExpression(charFilterRegExp(filter_));
#endif
countCategories(); countCategories();
// restore old selection // restore old selection

View File

@ -59,7 +59,7 @@ static QString credits()
out << qt_("Please install correctly to estimate the great\namount of work other people have done for the LyX project."); out << qt_("Please install correctly to estimate the great\namount of work other people have done for the LyX project.");
} else { } else {
QTextStream ts(&file); QTextStream ts(&file);
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
ts.setCodec("UTF-8"); ts.setCodec("UTF-8");
#endif #endif
QString line; QString line;
@ -103,7 +103,7 @@ static QString release_notes()
out << qt_("Please install correctly to see what has changed\nfor this version of LyX."); out << qt_("Please install correctly to see what has changed\nfor this version of LyX.");
} else { } else {
QTextStream ts(&file); QTextStream ts(&file);
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
ts.setCodec("UTF-8"); ts.setCodec("UTF-8");
#endif #endif
QString line; QString line;
@ -295,14 +295,12 @@ static QString version(bool const plain = false)
out << '\n'; out << '\n';
else else
out << "</p><p>"; out << "</p><p>";
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
out << toqstr(bformat(_("OS Version (run-time): %1$s"), out << toqstr(bformat(_("OS Version (run-time): %1$s"),
qstring_to_ucs4(QSysInfo::prettyProductName()))); qstring_to_ucs4(QSysInfo::prettyProductName())));
if (plain) if (plain)
out << '\n'; out << '\n';
else else
out << "</p><p>"; out << "</p><p>";
#endif
out << toqstr(bformat(_("Python detected: %1$s"), from_utf8(os::python_info()))); out << toqstr(bformat(_("Python detected: %1$s"), from_utf8(os::python_info())));
if (plain) if (plain)
out << '\n'; out << '\n';

View File

@ -106,9 +106,7 @@
#include <QObject> #include <QObject>
#include <QPainter> #include <QPainter>
#include <QPixmap> #include <QPixmap>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator> #include <QRandomGenerator>
#endif
#include <QScreen> #include <QScreen>
#include <QSessionManager> #include <QSessionManager>
#include <QSettings> #include <QSettings>
@ -128,35 +126,33 @@
#endif #endif
#endif #endif
#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
#if (QT_VERSION >= 0x060000) # if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#if (QT_VERSION >= 0x060500) # if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
#include <QtGui/QWindowsMimeConverter> # include <QtGui/QWindowsMimeConverter>
#define QWINDOWSMIME QWindowsMimeConverter # define QWINDOWSMIME QWindowsMimeConverter
#define QVARIANTTYPE QMetaType # define QVARIANTTYPE QMetaType
#else # else
#include <QtGui/private/qguiapplication_p.h> # include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qwindowsmime_p.h> # include <QtGui/private/qwindowsmime_p.h>
#include <QtGui/qpa/qplatformintegration.h> # include <QtGui/qpa/qplatformintegration.h>
#define QWINDOWSMIME QWindowsMime # define QWINDOWSMIME QWindowsMime
#define QVARIANTTYPE QMetaType # define QVARIANTTYPE QMetaType
using QWindowsMime = QNativeInterface::Private::QWindowsMime; using QWindowsMime = QNativeInterface::Private::QWindowsMime;
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication; using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
#endif # endif
#else # else
#include <QWinMime> # include <QWinMime>
#define QWINDOWSMIME QWinMime # define QWINDOWSMIME QWinMime
#define QVARIANTTYPE QVariant::Type # define QVARIANTTYPE QVariant::Type
#endif # endif
#ifdef Q_CC_GNU # ifdef Q_CC_GNU
#include <wtypes.h> # include <wtypes.h>
#endif # endif
#include <objidl.h> # include <objidl.h>
#endif
#endif #endif
#if defined(Q_OS_MAC) && (QT_VERSION < 0x060000) #if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QMacPasteboardMime> #include <QMacPasteboardMime>
#endif // Q_OS_MAC #endif // Q_OS_MAC
@ -195,12 +191,10 @@ frontend::Application * createApplication(int & argc, char * argv[])
// Setup high DPI handling. This is a bit complicated, but will be default in Qt6. // Setup high DPI handling. This is a bit complicated, but will be default in Qt6.
// macOS does it by itself. // macOS does it by itself.
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_OS_MAC) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_OS_MAC)
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
// Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created // Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created
if (getEnv("QT_ENABLE_HIGHDPI_SCALING").empty() if (getEnv("QT_ENABLE_HIGHDPI_SCALING").empty()
&& getEnv("QT_AUTO_SCREEN_SCALE_FACTOR").empty()) && getEnv("QT_AUTO_SCREEN_SCALE_FACTOR").empty())
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
// HighDPI scale factor policy must be set before QGuiApplication is created // HighDPI scale factor policy must be set before QGuiApplication is created
@ -791,7 +785,7 @@ public:
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#if defined(Q_OS_MAC) && (QT_VERSION < 0x060000) #if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// QMacPasteboardMimeGraphics can only be compiled on Mac. // QMacPasteboardMimeGraphics can only be compiled on Mac.
class QMacPasteboardMimeGraphics : public QMacPasteboardMime class QMacPasteboardMimeGraphics : public QMacPasteboardMime
@ -851,7 +845,6 @@ public:
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Windows specific stuff goes here... // Windows specific stuff goes here...
#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
// QWindowsMimeMetafile can only be compiled on Windows. // QWindowsMimeMetafile can only be compiled on Windows.
@ -950,7 +943,6 @@ public:
}; };
#endif #endif
#endif
/// Allows to check whether ESC was pressed during a long operation /// Allows to check whether ESC was pressed during a long operation
@ -1014,21 +1006,19 @@ struct GuiApplication::Private
Private(): language_model_(nullptr), meta_fake_bit(NoModifier), Private(): language_model_(nullptr), meta_fake_bit(NoModifier),
global_menubar_(nullptr), last_state_(Qt::ApplicationInactive) global_menubar_(nullptr), last_state_(Qt::ApplicationInactive)
{ {
#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
/// WMF Mime handler for Windows clipboard. /// WMF Mime handler for Windows clipboard.
wmf_mime_ = new QWindowsMimeMetafile; wmf_mime_ = new QWindowsMimeMetafile;
#if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
win_app_ = dynamic_cast<QWindowsApplication *> win_app_ = dynamic_cast<QWindowsApplication *>
(QGuiApplicationPrivate::platformIntegration()); (QGuiApplicationPrivate::platformIntegration());
win_app_->registerMime(wmf_mime_); win_app_->registerMime(wmf_mime_);
#endif #endif
#endif
#endif #endif
initKeySequences(&theTopLevelKeymap()); initKeySequences(&theTopLevelKeymap());
} }
#if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
~Private() ~Private()
{ {
@ -1103,19 +1093,17 @@ struct GuiApplication::Private
/// Holds previous application state on Mac /// Holds previous application state on Mac
Qt::ApplicationState last_state_; Qt::ApplicationState last_state_;
#if defined(Q_OS_MAC) && (QT_VERSION < 0x060000) #if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
/// Linkback mime handler for MacOSX. /// Linkback mime handler for MacOSX.
QMacPasteboardMimeGraphics mac_pasteboard_mime_; QMacPasteboardMimeGraphics mac_pasteboard_mime_;
#endif #endif
#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
/// WMF Mime handler for Windows clipboard. /// WMF Mime handler for Windows clipboard.
QWindowsMimeMetafile * wmf_mime_; QWindowsMimeMetafile * wmf_mime_;
#if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
QWindowsApplication * win_app_; QWindowsApplication * win_app_;
#endif #endif
#endif
#endif #endif
/// Allows to check whether ESC was pressed during a long operation /// Allows to check whether ESC was pressed during a long operation
@ -1142,19 +1130,12 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
QCoreApplication::setOrganizationName(app_name); QCoreApplication::setOrganizationName(app_name);
QCoreApplication::setOrganizationDomain("lyx.org"); QCoreApplication::setOrganizationDomain("lyx.org");
QCoreApplication::setApplicationName(lyx_package); QCoreApplication::setApplicationName(lyx_package);
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif #endif
#if QT_VERSION >= 0x050700
setDesktopFileName(lyx_package); setDesktopFileName(lyx_package);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch()); QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch());
#else
qsrand(QDateTime::currentDateTime().toTime_t());
#endif
// Install LyX translator for missing Qt translations // Install LyX translator for missing Qt translations
installTranslator(&d->gui_trans_); installTranslator(&d->gui_trans_);
@ -2836,7 +2817,7 @@ void GuiApplication::execBatchCommands()
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
setAttribute(Qt::AA_MacDontSwapCtrlAndMeta,lyxrc.mac_dontswap_ctrl_meta); setAttribute(Qt::AA_MacDontSwapCtrlAndMeta,lyxrc.mac_dontswap_ctrl_meta);
# if QT_VERSION < 0x060000 # if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setAttribute(Qt::AA_UseHighDpiPixmaps,true); setAttribute(Qt::AA_UseHighDpiPixmaps,true);
# endif # endif
// Create the global default menubar which is shown for the dialogs // Create the global default menubar which is shown for the dialogs

View File

@ -122,7 +122,7 @@ public:
bool notify(QObject * receiver, QEvent * event) override; bool notify(QObject * receiver, QEvent * event) override;
void commitData(QSessionManager & sm); void commitData(QSessionManager & sm);
#if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB) #if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
#if (QT_VERSION < 0x060000) #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#define QINTPTR long #define QINTPTR long
#else #else
#define QINTPTR qintptr #define QINTPTR qintptr

View File

@ -70,15 +70,9 @@ void GuiChanges::updateContents()
text += inserted ? qt_("Inserted by %1").arg(author) text += inserted ? qt_("Inserted by %1").arg(author)
: qt_("Deleted by %1").arg(author); : qt_("Deleted by %1").arg(author);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
QString const date = QString const date =
QLocale().toString(QDateTime::fromSecsSinceEpoch(c.changetime), QLocale().toString(QDateTime::fromSecsSinceEpoch(c.changetime),
QLocale::LongFormat); QLocale::LongFormat);
#else
QString const date =
QLocale().toString(QDateTime::fromTime_t(c.changetime),
QLocale::LongFormat);
#endif
if (!date.isEmpty()) { if (!date.isEmpty()) {
if (!author.isEmpty()) if (!author.isEmpty())
text += qt_(" on[[date]] %1").arg(date); text += qt_(" on[[date]] %1").arg(date);

View File

@ -361,7 +361,7 @@ QString tidyHtml(QString const & input)
// clutter. // clutter.
QTextDocument converter; QTextDocument converter;
converter.setHtml(input); converter.setHtml(input);
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return converter.toHtml("utf-8"); return converter.toHtml("utf-8");
#else #else
return converter.toHtml(); return converter.toHtml();

View File

@ -494,13 +494,7 @@ PreambleModule::PreambleModule(QWidget * parent)
checkFindButton(); checkFindButton();
int const tabStop = 4; int const tabStop = 4;
QFontMetrics metrics(preambleTE->currentFont()); QFontMetrics metrics(preambleTE->currentFont());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
// horizontalAdvance() is available starting in 5.11.0
// setTabStopDistance() is available starting in 5.10.0
preambleTE->setTabStopDistance(tabStop * metrics.horizontalAdvance(' ')); preambleTE->setTabStopDistance(tabStop * metrics.horizontalAdvance(' '));
#else
preambleTE->setTabStopWidth(tabStop * metrics.width(' '));
#endif
} }
@ -646,13 +640,7 @@ LocalLayout::LocalLayout(QWidget * parent)
connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal())); connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
int const tabStop = 4; int const tabStop = 4;
QFontMetrics metrics(locallayoutTE->currentFont()); QFontMetrics metrics(locallayoutTE->currentFont());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
// horizontalAdvance() is available starting in 5.11.0
// setTabStopDistance() is available starting in 5.10.0
locallayoutTE->setTabStopDistance(tabStop * metrics.horizontalAdvance(' ')); locallayoutTE->setTabStopDistance(tabStop * metrics.horizontalAdvance(' '));
#else
locallayoutTE->setTabStopWidth(tabStop * metrics.width(' '));
#endif
} }
@ -2522,11 +2510,7 @@ void GuiDocument::updateQuoteStyles(bool const set)
for (int i = 0; i < langModule->quoteStyleCO->count(); ++i) { for (int i = 0; i < langModule->quoteStyleCO->count(); ++i) {
langModule->quoteStyleCO->setItemData(i, QVariant(comboFont), Qt::FontRole); langModule->quoteStyleCO->setItemData(i, QVariant(comboFont), Qt::FontRole);
QString str = langModule->quoteStyleCO->itemText(i); QString str = langModule->quoteStyleCO->itemText(i);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
qswidth = max(qswidth, fm.horizontalAdvance(str)); qswidth = max(qswidth, fm.horizontalAdvance(str));
#else
qswidth = max(qswidth, fm.width(str));
#endif
} }
// add scrollbar width and margin to width // add scrollbar width and margin to width
qswidth += langModule->quoteStyleCO->style()->pixelMetric(QStyle::PM_ScrollBarExtent); qswidth += langModule->quoteStyleCO->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
@ -2912,7 +2896,7 @@ void GuiDocument::updateFontlist()
fontModule->fontsMathCO->addItem(qt_("Class Default (TeX Fonts)"), QString("auto")); fontModule->fontsMathCO->addItem(qt_("Class Default (TeX Fonts)"), QString("auto"));
fontModule->fontsMathCO->addItem(unimath, QString("default")); fontModule->fontsMathCO->addItem(unimath, QString("default"));
#if QT_VERSION >= 0x060000 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QStringList families(QFontDatabase::families()); const QStringList families(QFontDatabase::families());
#else #else
QFontDatabase fontdb; QFontDatabase fontdb;

View File

@ -284,11 +284,7 @@ int GuiFontMetrics::width(docstring const & s) const
if (math_char) { if (math_char) {
QString const qs = toqstr(s); QString const qs = toqstr(s);
int br_width = rbearing(s[0]); int br_width = rbearing(s[0]);
#if QT_VERSION >= 0x050b00
int s_width = metrics_.horizontalAdvance(qs); int s_width = metrics_.horizontalAdvance(qs);
#else
int s_width = metrics_.width(qs);
#endif
// keep value 0 for math chars with width 0 // keep value 0 for math chars with width 0
if (s_width != 0) if (s_width != 0)
w = max(br_width, s_width); w = max(br_width, s_width);
@ -668,17 +664,10 @@ int GuiFontMetrics::width(char_type c) const
if (value != outOfLimitMetric) if (value != outOfLimitMetric)
return value; return value;
#if QT_VERSION >= 0x050b00
if (is_utf16(c)) if (is_utf16(c))
value = metrics_.horizontalAdvance(ucs4_to_qchar(c)); value = metrics_.horizontalAdvance(ucs4_to_qchar(c));
else else
value = metrics_.horizontalAdvance(toqstr(docstring(1, c))); value = metrics_.horizontalAdvance(toqstr(docstring(1, c)));
#else
if (is_utf16(c))
value = metrics_.width(ucs4_to_qchar(c));
else
value = metrics_.width(toqstr(docstring(1, c)));
#endif
width_cache_.insert(c, value); width_cache_.insert(c, value);

View File

@ -56,7 +56,7 @@ GuiHSpace::GuiHSpace(bool math_mode, QWidget * parent)
spacingCO->addItem(qt_("Visible Space"), "visible"); spacingCO->addItem(qt_("Visible Space"), "visible");
spacingCO->addItem(qt_("Custom"), "custom"); spacingCO->addItem(qt_("Custom"), "custom");
#if QT_VERSION < 0x050e00 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(spacingCO, SIGNAL(highlighted(QString)), connect(spacingCO, SIGNAL(highlighted(QString)),
this, SLOT(changedSlot())); this, SLOT(changedSlot()));
#else #else

View File

@ -845,25 +845,15 @@ bool KeySymbol::operator==(KeySymbol const & ks) const
KeyModifier q_key_state(Qt::KeyboardModifiers state) KeyModifier q_key_state(Qt::KeyboardModifiers state)
{ {
KeyModifier k = NoModifier; KeyModifier k = NoModifier;
#if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
/// Additional check for Control and Meta modifier swap state.
/// Starting with Qt 5 the modifiers aren't reported correctly.
/// Until this is fixed a correction is required.
/// AFAIK it is fixed at least with Qt 5.12.0
const bool dontSwapCtrlAndMeta =
frontend::theGuiApp()->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
#else
const bool dontSwapCtrlAndMeta = false;
#endif
if (state & (dontSwapCtrlAndMeta ? Qt::MetaModifier : Qt::ControlModifier)) if (state & Qt::ControlModifier)
k |= ControlModifier; k |= ControlModifier;
if (state & Qt::ShiftModifier) if (state & Qt::ShiftModifier)
k |= ShiftModifier; k |= ShiftModifier;
if (state & Qt::AltModifier) if (state & Qt::AltModifier)
k |= AltModifier; k |= AltModifier;
#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING) #if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
if (state & (dontSwapCtrlAndMeta ? Qt::ControlModifier : Qt::MetaModifier)) if (state & Qt::MetaModifier)
k |= MetaModifier; k |= MetaModifier;
#else #else
if (state & Qt::MetaModifier) if (state & Qt::MetaModifier)

View File

@ -802,7 +802,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
{ {
setupUi(this); setupUi(this);
#if QT_VERSION < 0x050e00 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(screenRomanCO, SIGNAL(activated(QString)), connect(screenRomanCO, SIGNAL(activated(QString)),
this, SLOT(selectRoman(QString))); this, SLOT(selectRoman(QString)));
connect(screenSansCO, SIGNAL(activated(QString)), connect(screenSansCO, SIGNAL(activated(QString)),
@ -818,7 +818,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
this, SLOT(selectTypewriter(QString))); this, SLOT(selectTypewriter(QString)));
#endif #endif
#if QT_VERSION >= 0x060000 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QStringList families(QFontDatabase::families()); const QStringList families(QFontDatabase::families());
#else #else
QFontDatabase fontdb; QFontDatabase fontdb;
@ -829,7 +829,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
screenSansCO->addItem(family); screenSansCO->addItem(family);
screenTypewriterCO->addItem(family); screenTypewriterCO->addItem(family);
} }
#if QT_VERSION < 0x050e00 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(screenRomanCO, SIGNAL(activated(QString)), connect(screenRomanCO, SIGNAL(activated(QString)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(screenSansCO, SIGNAL(activated(QString)), connect(screenSansCO, SIGNAL(activated(QString)),
@ -1563,7 +1563,7 @@ PrefConverters::PrefConverters(GuiPreferences * form)
this, SLOT(updateConverter())); this, SLOT(updateConverter()));
connect(convertersLW, SIGNAL(currentRowChanged(int)), connect(convertersLW, SIGNAL(currentRowChanged(int)),
this, SLOT(switchConverter())); this, SLOT(switchConverter()));
#if QT_VERSION < 0x050e00 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(converterFromCO, SIGNAL(activated(QString)), connect(converterFromCO, SIGNAL(activated(QString)),
this, SLOT(changeConverter())); this, SLOT(changeConverter()));
connect(converterToCO, SIGNAL(activated(QString)), connect(converterToCO, SIGNAL(activated(QString)),
@ -1934,7 +1934,7 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
this, SLOT(updatePrettyname())); this, SLOT(updatePrettyname()));
connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)), connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
#if QT_VERSION < 0x050e00 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(defaultFormatCB, SIGNAL(activated(QString)), connect(defaultFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(defaultOTFFormatCB, SIGNAL(activated(QString)), connect(defaultOTFFormatCB, SIGNAL(activated(QString)),

View File

@ -603,7 +603,7 @@ GuiSearch::GuiSearch(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags
void GuiSearch::mousePressEvent(QMouseEvent * event) void GuiSearch::mousePressEvent(QMouseEvent * event)
{ {
if (isFloating() && event->button() == Qt::LeftButton) { if (isFloating() && event->button() == Qt::LeftButton) {
#if QT_VERSION >= 0x060000 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft(); dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
#else #else
dragPosition = event->globalPos() - frameGeometry().topLeft(); dragPosition = event->globalPos() - frameGeometry().topLeft();
@ -617,7 +617,7 @@ void GuiSearch::mousePressEvent(QMouseEvent * event)
void GuiSearch::mouseMoveEvent(QMouseEvent * event) void GuiSearch::mouseMoveEvent(QMouseEvent * event)
{ {
if (isFloating() && event->buttons() & Qt::LeftButton) { if (isFloating() && event->buttons() & Qt::LeftButton) {
#if QT_VERSION >= 0x060000 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
move(event->globalPosition().toPoint() - dragPosition); move(event->globalPosition().toPoint() - dragPosition);
#else #else
move(event->globalPos() - dragPosition); move(event->globalPos() - dragPosition);

View File

@ -261,7 +261,7 @@ private:
/// Current ratio between physical pixels and device-independent pixels /// Current ratio between physical pixels and device-independent pixels
double pixelRatio() const { double pixelRatio() const {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return devicePixelRatioF(); return devicePixelRatioF();
#else #else
return devicePixelRatio(); return devicePixelRatio();
@ -665,11 +665,7 @@ GuiView::GuiView(int id)
connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed())); connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed()));
zoom_slider_ = new QSlider(Qt::Horizontal, statusBar()); zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15); zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15);
#else
zoom_slider_->setFixedWidth(fm.width('x') * 15);
#endif
// Make the defaultZoom center // Make the defaultZoom center
zoom_slider_->setRange(10, (lyxrc.defaultZoom * 2) - 10); zoom_slider_->setRange(10, (lyxrc.defaultZoom * 2) - 10);
// Initialize proper zoom value // Initialize proper zoom value
@ -682,11 +678,7 @@ GuiView::GuiView(int id)
zoom_slider_->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust.")); zoom_slider_->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust."));
// Buttons to change zoom stepwise // Buttons to change zoom stepwise
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize s(fm.horizontalAdvance('+'), fm.height()); QSize s(fm.horizontalAdvance('+'), fm.height());
#else
QSize s(fm.width('+'), fm.height());
#endif
zoom_in_ = new GuiClickableLabel(statusBar()); zoom_in_ = new GuiClickableLabel(statusBar());
zoom_in_->setText("+"); zoom_in_->setText("+");
zoom_in_->setFixedSize(s); zoom_in_->setFixedSize(s);
@ -726,11 +718,7 @@ GuiView::GuiView(int id)
// zoom_value_->setPalette(palette); // zoom_value_->setPalette(palette);
zoom_value_->setForegroundRole(statusBar()->foregroundRole()); zoom_value_->setForegroundRole(statusBar()->foregroundRole());
zoom_value_->setFixedHeight(fm.height()); zoom_value_->setFixedHeight(fm.height());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
zoom_value_->setMinimumWidth(fm.horizontalAdvance("444\%")); zoom_value_->setMinimumWidth(fm.horizontalAdvance("444\%"));
#else
zoom_value_->setMinimumWidth(fm.width("444\%"));
#endif
zoom_value_->setAlignment(Qt::AlignCenter); zoom_value_->setAlignment(Qt::AlignCenter);
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom))); zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
statusBar()->addPermanentWidget(zoom_value_); statusBar()->addPermanentWidget(zoom_value_);
@ -1706,10 +1694,8 @@ bool GuiView::event(QEvent * e)
} }
for (int i = 0; i != d.splitter_->count(); ++i) for (int i = 0; i != d.splitter_->count(); ++i)
d.tabWorkArea(i)->setFullScreen(true); d.tabWorkArea(i)->setFullScreen(true);
#if QT_VERSION > 0x050903 // Safe area measures won't allow us to go negative in margins
//Qt's 5.9.4 ba44cdae38406c safe area measures won't allow us to go negative in margins
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false); setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);
#endif
setContentsMargins(-2, -2, -2, -2); setContentsMargins(-2, -2, -2, -2);
// bug 5274 // bug 5274
hideDialogs("prefs", nullptr); hideDialogs("prefs", nullptr);
@ -1728,9 +1714,7 @@ bool GuiView::event(QEvent * e)
} }
for (int i = 0; i != d.splitter_->count(); ++i) for (int i = 0; i != d.splitter_->count(); ++i)
d.tabWorkArea(i)->setFullScreen(false); d.tabWorkArea(i)->setFullScreen(false);
#if QT_VERSION > 0x050903
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true); setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true);
#endif
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
} }
return result; return result;
@ -1872,7 +1856,7 @@ void GuiView::resetCommandExecute()
double GuiView::pixelRatio() const double GuiView::pixelRatio() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return devicePixelRatioF(); return devicePixelRatioF();
#else #else
return devicePixelRatio(); return devicePixelRatio();
@ -5189,14 +5173,10 @@ bool GuiView::lfunUiToggle(string const & ui_component)
//are the frames in default state? //are the frames in default state?
d.current_work_area_->setFrameStyle(QFrame::NoFrame); d.current_work_area_->setFrameStyle(QFrame::NoFrame);
if (l == 0) { if (l == 0) {
#if QT_VERSION > 0x050903
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false); setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);
#endif
setContentsMargins(-2, -2, -2, -2); setContentsMargins(-2, -2, -2, -2);
} else { } else {
#if QT_VERSION > 0x050903
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true); setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true);
#endif
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
} }
} else } else

View File

@ -178,7 +178,7 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv)
double GuiWorkArea::pixelRatio() const double GuiWorkArea::pixelRatio() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return devicePixelRatioF(); return devicePixelRatioF();
#else #else
return devicePixelRatio(); return devicePixelRatio();
@ -774,8 +774,7 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(), FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
#endif #endif
q_button_state(e->button()), q_key_state(e->modifiers())); q_button_state(e->button()), q_key_state(e->modifiers()));
#if (QT_VERSION > QT_VERSION_CHECK(5,10,1) && \ #if QT_VERSION < QT_VERSION_CHECK(5,15,1)
QT_VERSION < QT_VERSION_CHECK(5,15,1))
d->synthetic_mouse_event_.cmd = cmd; // QtBug QAbstractScrollArea::mouseMoveEvent d->synthetic_mouse_event_.cmd = cmd; // QtBug QAbstractScrollArea::mouseMoveEvent
#endif #endif
d->dispatch(cmd); d->dispatch(cmd);
@ -785,8 +784,7 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
void GuiWorkArea::mouseMoveEvent(QMouseEvent * e) void GuiWorkArea::mouseMoveEvent(QMouseEvent * e)
{ {
#if (QT_VERSION > QT_VERSION_CHECK(5,10,1) && \ #if QT_VERSION < QT_VERSION_CHECK(5,15,1)
QT_VERSION < QT_VERSION_CHECK(5,15,1))
// cancel the event if the coordinates didn't change, this is due to QtBug // cancel the event if the coordinates didn't change, this is due to QtBug
// QAbstractScrollArea::mouseMoveEvent, the event is triggered falsely when quickly // QAbstractScrollArea::mouseMoveEvent, the event is triggered falsely when quickly
// double tapping a touchpad. To test: try to select a word by quickly double tapping // double tapping a touchpad. To test: try to select a word by quickly double tapping
@ -1597,12 +1595,10 @@ QVariant GuiWorkArea::inputMethodQuery(Qt::InputMethodQuery query) const
return QVariant(d->im_cursor_rect_); return QVariant(d->im_cursor_rect_);
break; break;
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
case Qt::ImAnchorRectangle: { case Qt::ImAnchorRectangle: {
return QVariant(d->im_anchor_rect_); return QVariant(d->im_anchor_rect_);
break; break;
} }
#endif
default: default:
return QWidget::inputMethodQuery(query); return QWidget::inputMethodQuery(query);
} }

View File

@ -50,7 +50,7 @@ void TearOff::mouseReleaseEvent(QMouseEvent * /*event*/)
} }
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void TearOff::enterEvent(QEvent * event) void TearOff::enterEvent(QEvent * event)
#else #else
void TearOff::enterEvent(QEnterEvent * event) void TearOff::enterEvent(QEnterEvent * event)
@ -81,7 +81,7 @@ void TearOff::paintEvent(QPaintEvent * /*event*/)
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.menuRect = rect(); menuOpt.menuRect = rect();
menuOpt.maxIconWidth = 0; menuOpt.maxIconWidth = 0;
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
menuOpt.tabWidth = 0; menuOpt.tabWidth = 0;
#endif #endif
menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; menuOpt.menuItemType = QStyleOptionMenuItem::TearOff;
@ -103,7 +103,7 @@ IconPalette::IconPalette(QWidget * parent)
v->setSpacing(0); v->setSpacing(0);
layout_ = new QGridLayout; layout_ = new QGridLayout;
layout_->setSpacing(0); layout_->setSpacing(0);
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
layout_->setMargin(fw); layout_->setMargin(fw);
#else #else

View File

@ -27,7 +27,7 @@ class TearOff : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
TearOff(QWidget * parent); TearOff(QWidget * parent);
#if QT_VERSION < 0x060000 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent *) override; void enterEvent(QEvent *) override;
#else #else
void enterEvent(QEnterEvent *) override; void enterEvent(QEnterEvent *) override;

View File

@ -320,11 +320,7 @@ void LayoutBox::Private::setFilter(QString const & s)
lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row(); lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
filter_ = s; filter_ = s;
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
filterModel_->setFilterRegExp(charFilterRegExp(filter_)); filterModel_->setFilterRegExp(charFilterRegExp(filter_));
#else
filterModel_->setFilterRegularExpression(charFilterRegExp(filter_));
#endif
countCategories(); countCategories();
// restore old selection // restore old selection

View File

@ -766,11 +766,7 @@ QString formatToolTip(QString text, int width)
text = Qt::convertFromPlainText(text, Qt::WhiteSpaceNormal); text = Qt::convertFromPlainText(text, Qt::WhiteSpaceNormal);
// Compute desired width in pixels // Compute desired width in pixels
QFont const font = QToolTip::font(); QFont const font = QToolTip::font();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int const px_width = width * QFontMetrics(font).horizontalAdvance("M"); int const px_width = width * QFontMetrics(font).horizontalAdvance("M");
#else
int const px_width = width * QFontMetrics(font).width("M");
#endif
// Determine the ideal width of the tooltip // Determine the ideal width of the tooltip
QTextDocument td(""); QTextDocument td("");
td.setHtml(text); td.setHtml(text);

View File

@ -179,24 +179,6 @@ QString changeExtension(QString const & oldname, QString const & ext);
QString formatToolTip(QString text, int width = 30); QString formatToolTip(QString text, int width = 30);
#if QT_VERSION < 0x050300
// Very partial implementation of QSignalBlocker for archaic qt versions.
class QSignalBlocker {
public:
explicit QSignalBlocker(QObject * o)
: obj(o), init_state(obj && obj->blockSignals(true)) {}
~QSignalBlocker() {
if (obj)
obj->blockSignals(init_state);
}
private:
QObject * obj;
bool init_state;
};
#endif
// Check if text is understood as rich text (Qt HTML) and if so, produce a // Check if text is understood as rich text (Qt HTML) and if so, produce a
// rendering in plain text. // rendering in plain text.
QString qtHtmlToPlainText(QString const & text); QString qtHtmlToPlainText(QString const & text);

View File

@ -303,11 +303,7 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
string const dt = split(name, '@'); string const dt = split(name, '@');
QDate date; QDate date;
if (itype == "moddate") if (itype == "moddate")
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
date = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).date(); date = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).date();
#else
date = QDateTime::fromTime_t(buf->fileName().lastModified()).date();
#endif
else if (itype == "fixdate" && !dt.empty()) { else if (itype == "fixdate" && !dt.empty()) {
QDate const gdate = QDate::fromString(toqstr(dt), Qt::ISODate); QDate const gdate = QDate::fromString(toqstr(dt), Qt::ISODate);
date = (gdate.isValid()) ? gdate : QDate::currentDate(); date = (gdate.isValid()) ? gdate : QDate::currentDate();
@ -334,11 +330,7 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
string const tt = split(name, '@'); string const tt = split(name, '@');
QTime time; QTime time;
if (itype == "modtime") if (itype == "modtime")
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
time = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).time(); time = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).time();
#else
time = QDateTime::fromTime_t(buf->fileName().lastModified()).time();
#endif
else if (itype == "fixtime" && !tt.empty()) { else if (itype == "fixtime" && !tt.empty()) {
QTime const gtime = QTime::fromString(toqstr(tt), Qt::ISODate); QTime const gtime = QTime::fromString(toqstr(tt), Qt::ISODate);
time = (gtime.isValid()) ? gtime : QTime::currentTime(); time = (gtime.isValid()) ? gtime : QTime::currentTime();
@ -1230,11 +1222,7 @@ void InsetInfo::build()
? split(params_.name, date_format, '@') : string(); ? split(params_.name, date_format, '@') : string();
QDate date; QDate date;
if (params_.type == InsetInfoParams::MODDATE_INFO) if (params_.type == InsetInfoParams::MODDATE_INFO)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
date = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).date(); date = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).date();
#else
date = QDateTime::fromTime_t(buffer().fileName().lastModified()).date();
#endif
else if (params_.type == InsetInfoParams::FIXDATE_INFO && !date_specifier.empty()) else if (params_.type == InsetInfoParams::FIXDATE_INFO && !date_specifier.empty())
date = QDate::fromString(toqstr(date_specifier), Qt::ISODate); date = QDate::fromString(toqstr(date_specifier), Qt::ISODate);
else else
@ -1252,11 +1240,7 @@ void InsetInfo::build()
? split(params_.name, time_format, '@') : string(); ? split(params_.name, time_format, '@') : string();
QTime time; QTime time;
if (params_.type == InsetInfoParams::MODTIME_INFO) if (params_.type == InsetInfoParams::MODTIME_INFO)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
time = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).time(); time = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).time();
#else
time = QDateTime::fromTime_t(buffer().fileName().lastModified()).time();
#endif
else if (params_.type == InsetInfoParams::FIXTIME_INFO && !time_specifier.empty()) else if (params_.type == InsetInfoParams::FIXTIME_INFO && !time_specifier.empty())
time = QTime::fromString(toqstr(time_specifier), Qt::ISODate); time = QTime::fromString(toqstr(time_specifier), Qt::ISODate);
else else
@ -1303,11 +1287,7 @@ std::pair<QDate, std::string> parseDate(Buffer const & buffer, const InsetInfoPa
QDate date; QDate date;
if (params.type == InsetInfoParams::MODDATE_INFO) if (params.type == InsetInfoParams::MODDATE_INFO)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
date = QDateTime::fromSecsSinceEpoch(buffer.fileName().lastModified()).date(); date = QDateTime::fromSecsSinceEpoch(buffer.fileName().lastModified()).date();
#else
date = QDateTime::fromTime_t(buffer.fileName().lastModified()).date();
#endif
else if (params.type == InsetInfoParams::FIXDATE_INFO && !date_specifier.empty()) { else if (params.type == InsetInfoParams::FIXDATE_INFO && !date_specifier.empty()) {
QDate date = QDate::fromString(toqstr(date_specifier), Qt::ISODate); QDate date = QDate::fromString(toqstr(date_specifier), Qt::ISODate);
date = (date.isValid()) ? date : QDate::currentDate(); date = (date.isValid()) ? date : QDate::currentDate();
@ -1328,11 +1308,7 @@ std::pair<QTime, std::string> parseTime(Buffer const & buffer, const InsetInfoPa
QTime time; QTime time;
if (params.type == InsetInfoParams::MODTIME_INFO) if (params.type == InsetInfoParams::MODTIME_INFO)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
time = QDateTime::fromSecsSinceEpoch(buffer.fileName().lastModified()).time(); time = QDateTime::fromSecsSinceEpoch(buffer.fileName().lastModified()).time();
#else
time = QDateTime::fromTime_t(buffer.fileName().lastModified()).time();
#endif
else if (params.type == InsetInfoParams::FIXTIME_INFO && !date_specifier.empty()) { else if (params.type == InsetInfoParams::FIXTIME_INFO && !date_specifier.empty()) {
time = QTime::fromString(toqstr(date_specifier), Qt::ISODate); time = QTime::fromString(toqstr(date_specifier), Qt::ISODate);
time = (time.isValid()) ? time : QTime::currentTime(); time = (time.isValid()) ? time : QTime::currentTime();

View File

@ -16,9 +16,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDateTime> #include <QDateTime>
#include <QTimer> #include <QTimer>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator> #include <QRandomGenerator>
#endif
#include <string> #include <string>
@ -41,11 +39,7 @@ public:
setOrganizationDomain("lyx.org"); setOrganizationDomain("lyx.org");
setApplicationName(toqstr(app)); setApplicationName(toqstr(app));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch()); QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch());
#else
qsrand(QDateTime::currentDateTime().toTime_t());
#endif
} }
int execute() int execute()
{ {

View File

@ -518,12 +518,7 @@ time_t FileName::lastModified() const
// been touched between the object creation and now, we refresh the file // been touched between the object creation and now, we refresh the file
// information. // information.
d->refresh(); d->refresh();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
return d->fi.lastModified().toSecsSinceEpoch(); return d->fi.lastModified().toSecsSinceEpoch();
#else
return d->fi.lastModified().toTime_t();
#endif
} }

View File

@ -369,11 +369,7 @@ SystemcallPrivate::SystemcallPrivate(std::string const & sf, std::string const &
connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut())); connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
connect(process_, SIGNAL(readyReadStandardError()), SLOT(stdErr())); connect(process_, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
#if QT_VERSION >= 0x050600
connect(process_, SIGNAL(errorOccurred(QProcess::ProcessError)), SLOT(processError(QProcess::ProcessError))); connect(process_, SIGNAL(errorOccurred(QProcess::ProcessError)), SLOT(processError(QProcess::ProcessError)));
#else
connect(process_, SIGNAL(error(QProcess::ProcessError)), SLOT(processError(QProcess::ProcessError)));
#endif
connect(process_, SIGNAL(started()), this, SLOT(processStarted())); connect(process_, SIGNAL(started()), this, SLOT(processStarted()));
connect(process_, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus))); connect(process_, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus)));
} }

View File

@ -37,20 +37,12 @@ time_t current_time()
docstring formatted_datetime(time_t t, string const & fmt) docstring formatted_datetime(time_t t, string const & fmt)
{ {
QString qres; QString qres;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
if (fmt.empty()) if (fmt.empty())
qres = QLocale().toString(QDateTime::fromSecsSinceEpoch(t), qres = QLocale().toString(QDateTime::fromSecsSinceEpoch(t),
QLocale::ShortFormat); QLocale::ShortFormat);
else else
qres = QLocale().toString(QDateTime::fromSecsSinceEpoch(t), qres = QLocale().toString(QDateTime::fromSecsSinceEpoch(t),
toqstr(fmt)); 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); return qstring_to_ucs4(qres);
} }
@ -77,11 +69,7 @@ time_t from_asctime_utc(string t)
#else #else
loc_dt.setTimeSpec(Qt::UTC); loc_dt.setTimeSpec(Qt::UTC);
#endif #endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
return loc_dt.toSecsSinceEpoch(); return loc_dt.toSecsSinceEpoch();
#else
return loc_dt.toTime_t();
#endif
} }
} // namespace support } // namespace support