diff --git a/src/frontends/qt/CategorizedCombo.cpp b/src/frontends/qt/CategorizedCombo.cpp
index 0482e1c874..ac4b45068f 100644
--- a/src/frontends/qt/CategorizedCombo.cpp
+++ b/src/frontends/qt/CategorizedCombo.cpp
@@ -287,11 +287,7 @@ void CategorizedCombo::Private::setFilter(QString const & s)
lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
filter_ = s;
-#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
- filterModel_->setFilterRegExp(charFilterRegExp(filter_));
-#else
filterModel_->setFilterRegularExpression(charFilterRegExp(filter_));
-#endif
countCategories();
// restore old selection
diff --git a/src/frontends/qt/GuiAbout.cpp b/src/frontends/qt/GuiAbout.cpp
index a62ade781e..a3614367de 100644
--- a/src/frontends/qt/GuiAbout.cpp
+++ b/src/frontends/qt/GuiAbout.cpp
@@ -295,14 +295,12 @@ static QString version(bool const plain = false)
out << '\n';
else
out << "
";
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
out << toqstr(bformat(_("OS Version (run-time): %1$s"),
qstring_to_ucs4(QSysInfo::prettyProductName())));
if (plain)
out << '\n';
else
out << "
";
-#endif
out << toqstr(bformat(_("Python detected: %1$s"), from_utf8(os::python_info())));
if (plain)
out << '\n';
diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 5685b1a0ef..6863de7fc1 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -106,9 +106,7 @@
#include
#include
#include
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include
-#endif
#include
#include
#include
@@ -128,32 +126,30 @@
#endif
#endif
-#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
-#if (QT_VERSION >= 0x060000)
-#if (QT_VERSION >= 0x060500)
-#include
-#define QWINDOWSMIME QWindowsMimeConverter
-#define QVARIANTTYPE QMetaType
-#else
-#include
-#include
-#include
-#define QWINDOWSMIME QWindowsMime
-#define QVARIANTTYPE QMetaType
+# if (QT_VERSION >= 0x060000)
+# if (QT_VERSION >= 0x060500)
+# include
+# define QWINDOWSMIME QWindowsMimeConverter
+# define QVARIANTTYPE QMetaType
+# else
+# include
+# include
+# include
+# define QWINDOWSMIME QWindowsMime
+# define QVARIANTTYPE QMetaType
using QWindowsMime = QNativeInterface::Private::QWindowsMime;
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
-#endif
-#else
-#include
-#define QWINDOWSMIME QWinMime
-#define QVARIANTTYPE QVariant::Type
-#endif
-#ifdef Q_CC_GNU
-#include
-#endif
-#include
-#endif
+# endif
+# else
+# include
+# define QWINDOWSMIME QWinMime
+# define QVARIANTTYPE QVariant::Type
+# endif
+# ifdef Q_CC_GNU
+# include
+# endif
+# include
#endif
#if defined(Q_OS_MAC) && (QT_VERSION < 0x060000)
@@ -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.
// macOS does it by itself.
#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
if (getEnv("QT_ENABLE_HIGHDPI_SCALING").empty()
&& getEnv("QT_AUTO_SCREEN_SCALE_FACTOR").empty())
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
-#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
// HighDPI scale factor policy must be set before QGuiApplication is created
@@ -851,7 +845,6 @@ public:
////////////////////////////////////////////////////////////////////////
// Windows specific stuff goes here...
-#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
// QWindowsMimeMetafile can only be compiled on Windows.
@@ -950,7 +943,6 @@ public:
};
#endif
-#endif
/// Allows to check whether ESC was pressed during a long operation
@@ -1014,7 +1006,6 @@ struct GuiApplication::Private
Private(): language_model_(nullptr), meta_fake_bit(NoModifier),
global_menubar_(nullptr), last_state_(Qt::ApplicationInactive)
{
- #if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
/// WMF Mime handler for Windows clipboard.
wmf_mime_ = new QWindowsMimeMetafile;
@@ -1023,7 +1014,6 @@ struct GuiApplication::Private
(QGuiApplicationPrivate::platformIntegration());
win_app_->registerMime(wmf_mime_);
#endif
- #endif
#endif
initKeySequences(&theTopLevelKeymap());
}
@@ -1108,14 +1098,12 @@ struct GuiApplication::Private
QMacPasteboardMimeGraphics mac_pasteboard_mime_;
#endif
-#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
/// WMF Mime handler for Windows clipboard.
QWindowsMimeMetafile * wmf_mime_;
#if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500)
QWindowsApplication * win_app_;
#endif
-#endif
#endif
/// Allows to check whether ESC was pressed during a long operation
@@ -1146,15 +1134,8 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
-#if QT_VERSION >= 0x050700
setDesktopFileName(lyx_package);
-#endif
-
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch());
-#else
- qsrand(QDateTime::currentDateTime().toTime_t());
-#endif
// Install LyX translator for missing Qt translations
installTranslator(&d->gui_trans_);
diff --git a/src/frontends/qt/GuiChanges.cpp b/src/frontends/qt/GuiChanges.cpp
index b2f809b026..d7b8223a79 100644
--- a/src/frontends/qt/GuiChanges.cpp
+++ b/src/frontends/qt/GuiChanges.cpp
@@ -70,15 +70,9 @@ void GuiChanges::updateContents()
text += inserted ? qt_("Inserted by %1").arg(author)
: qt_("Deleted by %1").arg(author);
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
QString const date =
QLocale().toString(QDateTime::fromSecsSinceEpoch(c.changetime),
QLocale::LongFormat);
-#else
- QString const date =
- QLocale().toString(QDateTime::fromTime_t(c.changetime),
- QLocale::LongFormat);
-#endif
if (!date.isEmpty()) {
if (!author.isEmpty())
text += qt_(" on[[date]] %1").arg(date);
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index a98680b9a5..4c2c98cb5b 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -494,13 +494,7 @@ PreambleModule::PreambleModule(QWidget * parent)
checkFindButton();
int const tabStop = 4;
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(' '));
-#else
- preambleTE->setTabStopWidth(tabStop * metrics.width(' '));
-#endif
}
@@ -646,13 +640,7 @@ LocalLayout::LocalLayout(QWidget * parent)
connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
int const tabStop = 4;
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(' '));
-#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) {
langModule->quoteStyleCO->setItemData(i, QVariant(comboFont), Qt::FontRole);
QString str = langModule->quoteStyleCO->itemText(i);
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
qswidth = max(qswidth, fm.horizontalAdvance(str));
-#else
- qswidth = max(qswidth, fm.width(str));
-#endif
}
// add scrollbar width and margin to width
qswidth += langModule->quoteStyleCO->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
diff --git a/src/frontends/qt/GuiFontMetrics.cpp b/src/frontends/qt/GuiFontMetrics.cpp
index 5b9805a079..b106b1d619 100644
--- a/src/frontends/qt/GuiFontMetrics.cpp
+++ b/src/frontends/qt/GuiFontMetrics.cpp
@@ -284,11 +284,7 @@ int GuiFontMetrics::width(docstring const & s) const
if (math_char) {
QString const qs = toqstr(s);
int br_width = rbearing(s[0]);
-#if QT_VERSION >= 0x050b00
int s_width = metrics_.horizontalAdvance(qs);
-#else
- int s_width = metrics_.width(qs);
-#endif
// keep value 0 for math chars with width 0
if (s_width != 0)
w = max(br_width, s_width);
@@ -668,17 +664,10 @@ int GuiFontMetrics::width(char_type c) const
if (value != outOfLimitMetric)
return value;
-#if QT_VERSION >= 0x050b00
if (is_utf16(c))
value = metrics_.horizontalAdvance(ucs4_to_qchar(c));
else
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);
diff --git a/src/frontends/qt/GuiKeySymbol.cpp b/src/frontends/qt/GuiKeySymbol.cpp
index b785791c85..a054f4bc4d 100644
--- a/src/frontends/qt/GuiKeySymbol.cpp
+++ b/src/frontends/qt/GuiKeySymbol.cpp
@@ -845,25 +845,15 @@ bool KeySymbol::operator==(KeySymbol const & ks) const
KeyModifier q_key_state(Qt::KeyboardModifiers state)
{
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;
if (state & Qt::ShiftModifier)
k |= ShiftModifier;
if (state & Qt::AltModifier)
k |= AltModifier;
#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
- if (state & (dontSwapCtrlAndMeta ? Qt::ControlModifier : Qt::MetaModifier))
+ if (state & Qt::MetaModifier)
k |= MetaModifier;
#else
if (state & Qt::MetaModifier)
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 3778b7e2d3..624b2413c5 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -261,7 +261,7 @@ private:
/// Current ratio between physical pixels and device-independent pixels
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();
#else
return devicePixelRatio();
@@ -665,11 +665,7 @@ GuiView::GuiView(int id)
connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed()));
zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15);
-#else
- zoom_slider_->setFixedWidth(fm.width('x') * 15);
-#endif
// Make the defaultZoom center
zoom_slider_->setRange(10, (lyxrc.defaultZoom * 2) - 10);
// 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."));
// Buttons to change zoom stepwise
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize s(fm.horizontalAdvance('+'), fm.height());
-#else
- QSize s(fm.width('+'), fm.height());
-#endif
zoom_in_ = new GuiClickableLabel(statusBar());
zoom_in_->setText("+");
zoom_in_->setFixedSize(s);
@@ -726,11 +718,7 @@ GuiView::GuiView(int id)
// zoom_value_->setPalette(palette);
zoom_value_->setForegroundRole(statusBar()->foregroundRole());
zoom_value_->setFixedHeight(fm.height());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
zoom_value_->setMinimumWidth(fm.horizontalAdvance("444\%"));
-#else
- zoom_value_->setMinimumWidth(fm.width("444\%"));
-#endif
zoom_value_->setAlignment(Qt::AlignCenter);
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
statusBar()->addPermanentWidget(zoom_value_);
@@ -1706,10 +1694,8 @@ bool GuiView::event(QEvent * e)
}
for (int i = 0; i != d.splitter_->count(); ++i)
d.tabWorkArea(i)->setFullScreen(true);
-#if QT_VERSION > 0x050903
- //Qt's 5.9.4 ba44cdae38406c safe area measures won't allow us to go negative in margins
+ // Safe area measures won't allow us to go negative in margins
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);
-#endif
setContentsMargins(-2, -2, -2, -2);
// bug 5274
hideDialogs("prefs", nullptr);
@@ -1728,9 +1714,7 @@ bool GuiView::event(QEvent * e)
}
for (int i = 0; i != d.splitter_->count(); ++i)
d.tabWorkArea(i)->setFullScreen(false);
-#if QT_VERSION > 0x050903
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true);
-#endif
setContentsMargins(0, 0, 0, 0);
}
return result;
@@ -1872,7 +1856,7 @@ void GuiView::resetCommandExecute()
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();
#else
return devicePixelRatio();
@@ -5189,14 +5173,10 @@ bool GuiView::lfunUiToggle(string const & ui_component)
//are the frames in default state?
d.current_work_area_->setFrameStyle(QFrame::NoFrame);
if (l == 0) {
-#if QT_VERSION > 0x050903
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);
-#endif
setContentsMargins(-2, -2, -2, -2);
} else {
-#if QT_VERSION > 0x050903
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true);
-#endif
setContentsMargins(0, 0, 0, 0);
}
} else
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 4c71d17c07..a54c033277 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -178,7 +178,7 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv)
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();
#else
return devicePixelRatio();
@@ -774,8 +774,7 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
#endif
q_button_state(e->button()), q_key_state(e->modifiers()));
-#if (QT_VERSION > QT_VERSION_CHECK(5,10,1) && \
- QT_VERSION < QT_VERSION_CHECK(5,15,1))
+#if QT_VERSION < QT_VERSION_CHECK(5,15,1)
d->synthetic_mouse_event_.cmd = cmd; // QtBug QAbstractScrollArea::mouseMoveEvent
#endif
d->dispatch(cmd);
@@ -785,8 +784,7 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
void GuiWorkArea::mouseMoveEvent(QMouseEvent * e)
{
-#if (QT_VERSION > QT_VERSION_CHECK(5,10,1) && \
- QT_VERSION < QT_VERSION_CHECK(5,15,1))
+#if QT_VERSION < QT_VERSION_CHECK(5,15,1)
// cancel the event if the coordinates didn't change, this is due to QtBug
// QAbstractScrollArea::mouseMoveEvent, the event is triggered falsely when quickly
// 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_);
break;
}
-#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
case Qt::ImAnchorRectangle: {
return QVariant(d->im_anchor_rect_);
break;
}
-#endif
default:
return QWidget::inputMethodQuery(query);
}
diff --git a/src/frontends/qt/LayoutBox.cpp b/src/frontends/qt/LayoutBox.cpp
index 1cc6476a30..70d5fd6ad9 100644
--- a/src/frontends/qt/LayoutBox.cpp
+++ b/src/frontends/qt/LayoutBox.cpp
@@ -320,11 +320,7 @@ void LayoutBox::Private::setFilter(QString const & s)
lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
filter_ = s;
-#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
-#else
- filterModel_->setFilterRegularExpression(charFilterRegExp(filter_));
-#endif
countCategories();
// restore old selection
diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index 37e5ed5ba6..aa978952d6 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -766,11 +766,7 @@ QString formatToolTip(QString text, int width)
text = Qt::convertFromPlainText(text, Qt::WhiteSpaceNormal);
// Compute desired width in pixels
QFont const font = QToolTip::font();
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
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
QTextDocument td("");
td.setHtml(text);
diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h
index 11d7133920..dc5b9fc7d3 100644
--- a/src/frontends/qt/qt_helpers.h
+++ b/src/frontends/qt/qt_helpers.h
@@ -179,24 +179,6 @@ QString changeExtension(QString const & oldname, QString const & ext);
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
// rendering in plain text.
QString qtHtmlToPlainText(QString const & text);