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
to compile this version of LyX.
For full LyX usability we suggest to use Qt 5.6 and higher, or at the
very least Qt 5.4. It is also possible to compile against Qt 6. The
only special point to make is that you must ensure that both LyX and
the Qt libraries are compiled with the same C++ compiler.
LyX requires Qt 5.12 and higher. It is also possible to compile
against Qt 6. The only special point to make is that you must ensure
that both LyX and the Qt libraries are compiled with the same C++
compiler.
To build LyX with spell checking capabilities included you have to
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
need at least gcc 8.0.
* The Qt library, at least version 5.2 (5.6 recommended). It is
also possible to compile with Qt 6.x.
* The Qt library, at least version 5.12. It is also possible to
compile with Qt 6.x.
Read the file "INSTALL" for more information on compiling.

View File

@ -147,7 +147,7 @@ AC_CHECK_HEADERS(magic.h,
### setup the qt frontend.
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.
QT_DO_IT_ALL([5.0.0])
QT_DO_IT_ALL([5.12.0])
AC_SUBST([FRONTENDS_SUBDIRS], [qt])
FRONTEND_INFO="${FRONTEND_INFO}\
Qt Frontend:\n\

View File

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

View File

@ -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

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.");
} else {
QTextStream ts(&file);
#if QT_VERSION < 0x060000
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
ts.setCodec("UTF-8");
#endif
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.");
} else {
QTextStream ts(&file);
#if QT_VERSION < 0x060000
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
ts.setCodec("UTF-8");
#endif
QString line;
@ -295,14 +295,12 @@ static QString version(bool const plain = false)
out << '\n';
else
out << "</p><p>";
#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 << "</p><p>";
#endif
out << toqstr(bformat(_("Python detected: %1$s"), from_utf8(os::python_info())));
if (plain)
out << '\n';

View File

@ -106,9 +106,7 @@
#include <QObject>
#include <QPainter>
#include <QPixmap>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator>
#endif
#include <QScreen>
#include <QSessionManager>
#include <QSettings>
@ -128,35 +126,33 @@
#endif
#endif
#if (QT_VERSION >= 0x050400)
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
#if (QT_VERSION >= 0x060000)
#if (QT_VERSION >= 0x060500)
#include <QtGui/QWindowsMimeConverter>
#define QWINDOWSMIME QWindowsMimeConverter
#define QVARIANTTYPE QMetaType
#else
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qwindowsmime_p.h>
#include <QtGui/qpa/qplatformintegration.h>
#define QWINDOWSMIME QWindowsMime
#define QVARIANTTYPE QMetaType
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
# if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
# include <QtGui/QWindowsMimeConverter>
# define QWINDOWSMIME QWindowsMimeConverter
# define QVARIANTTYPE QMetaType
# else
# include <QtGui/private/qguiapplication_p.h>
# include <QtGui/private/qwindowsmime_p.h>
# include <QtGui/qpa/qplatformintegration.h>
# define QWINDOWSMIME QWindowsMime
# define QVARIANTTYPE QMetaType
using QWindowsMime = QNativeInterface::Private::QWindowsMime;
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
#endif
#else
#include <QWinMime>
#define QWINDOWSMIME QWinMime
#define QVARIANTTYPE QVariant::Type
#endif
#ifdef Q_CC_GNU
#include <wtypes.h>
#endif
#include <objidl.h>
#endif
# endif
# else
# include <QWinMime>
# define QWINDOWSMIME QWinMime
# define QVARIANTTYPE QVariant::Type
# endif
# ifdef Q_CC_GNU
# include <wtypes.h>
# endif
# include <objidl.h>
#endif
#if defined(Q_OS_MAC) && (QT_VERSION < 0x060000)
#if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QMacPasteboardMime>
#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.
// 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
@ -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.
class QMacPasteboardMimeGraphics : public QMacPasteboardMime
@ -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,21 +1006,19 @@ 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;
#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 *>
(QGuiApplicationPrivate::platformIntegration());
win_app_->registerMime(wmf_mime_);
#endif
#endif
#endif
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)
~Private()
{
@ -1103,19 +1093,17 @@ struct GuiApplication::Private
/// Holds previous application state on Mac
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.
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)
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
QWindowsApplication * win_app_;
#endif
#endif
#endif
/// 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::setOrganizationDomain("lyx.org");
QCoreApplication::setApplicationName(lyx_package);
#if QT_VERSION < 0x060000
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
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_);
@ -2836,7 +2817,7 @@ void GuiApplication::execBatchCommands()
#ifdef Q_OS_MAC
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);
# endif
// 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;
void commitData(QSessionManager & sm);
#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
#else
#define QINTPTR qintptr

View File

@ -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);

View File

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

View File

@ -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);
@ -2912,7 +2896,7 @@ void GuiDocument::updateFontlist()
fontModule->fontsMathCO->addItem(qt_("Class Default (TeX Fonts)"), QString("auto"));
fontModule->fontsMathCO->addItem(unimath, QString("default"));
#if QT_VERSION >= 0x060000
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QStringList families(QFontDatabase::families());
#else
QFontDatabase fontdb;

View File

@ -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);

View File

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

View File

@ -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)

View File

@ -802,7 +802,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
{
setupUi(this);
#if QT_VERSION < 0x050e00
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(screenRomanCO, SIGNAL(activated(QString)),
this, SLOT(selectRoman(QString)));
connect(screenSansCO, SIGNAL(activated(QString)),
@ -818,7 +818,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
this, SLOT(selectTypewriter(QString)));
#endif
#if QT_VERSION >= 0x060000
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QStringList families(QFontDatabase::families());
#else
QFontDatabase fontdb;
@ -829,7 +829,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
screenSansCO->addItem(family);
screenTypewriterCO->addItem(family);
}
#if QT_VERSION < 0x050e00
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(screenRomanCO, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(screenSansCO, SIGNAL(activated(QString)),
@ -1563,7 +1563,7 @@ PrefConverters::PrefConverters(GuiPreferences * form)
this, SLOT(updateConverter()));
connect(convertersLW, SIGNAL(currentRowChanged(int)),
this, SLOT(switchConverter()));
#if QT_VERSION < 0x050e00
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(converterFromCO, SIGNAL(activated(QString)),
this, SLOT(changeConverter()));
connect(converterToCO, SIGNAL(activated(QString)),
@ -1934,7 +1934,7 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
this, SLOT(updatePrettyname()));
connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
this, SIGNAL(changed()));
#if QT_VERSION < 0x050e00
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect(defaultFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
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)
{
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();
#else
dragPosition = event->globalPos() - frameGeometry().topLeft();
@ -617,7 +617,7 @@ void GuiSearch::mousePressEvent(QMouseEvent * event)
void GuiSearch::mouseMoveEvent(QMouseEvent * event)
{
if (isFloating() && event->buttons() & Qt::LeftButton) {
#if QT_VERSION >= 0x060000
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
move(event->globalPosition().toPoint() - dragPosition);
#else
move(event->globalPos() - dragPosition);

View File

@ -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

View File

@ -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);
}

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)
#else
void TearOff::enterEvent(QEnterEvent * event)
@ -81,7 +81,7 @@ void TearOff::paintEvent(QPaintEvent * /*event*/)
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
menuOpt.menuRect = rect();
menuOpt.maxIconWidth = 0;
#if QT_VERSION < 0x060000
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
menuOpt.tabWidth = 0;
#endif
menuOpt.menuItemType = QStyleOptionMenuItem::TearOff;
@ -103,7 +103,7 @@ IconPalette::IconPalette(QWidget * parent)
v->setSpacing(0);
layout_ = new QGridLayout;
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);
layout_->setMargin(fw);
#else

View File

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

View File

@ -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);

View File

@ -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);

View File

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

View File

@ -16,9 +16,7 @@
#include <QCoreApplication>
#include <QDateTime>
#include <QTimer>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator>
#endif
#include <string>
@ -41,11 +39,7 @@ 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()
{

View File

@ -518,12 +518,7 @@ 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
}

View File

@ -369,11 +369,7 @@ SystemcallPrivate::SystemcallPrivate(std::string const & sf, std::string const &
connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
connect(process_, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
#if QT_VERSION >= 0x050600
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(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)
{
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);
}
@ -77,11 +69,7 @@ time_t from_asctime_utc(string t)
#else
loc_dt.setTimeSpec(Qt::UTC);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
return loc_dt.toSecsSinceEpoch();
#else
return loc_dt.toTime_t();
#endif
}
} // namespace support