mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools. For a successful compilation the following 2 conditions must be met. 1) The Qt6 qmake has to come first in PATH, so that the command "qmake -v | grep -o 'Qt version .'" returns "Qt version 6". 2) The --enable-qt6 switch has to be passed to the configure command. If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback. If also Qt5 is not found, configuring for Qt4 is attempted. If --enable-qt6 is not used, then things go as usual. This means that Qt5 is tried first and then Qt4, unless --disable-qt5 is used, in which case Qt4 is directly attempted. This means that existing scripts should continue working unmodified. LyX should compile with Qt6 on windows and linux, and possibly also on mac, but I could not test that. However, it is not guaranteed that it works as it should. In particular I am not sure that I got right the conversion from QRegExp to QRegularExpression. For sure, the syntax highlighting seems to not work right. Someone in the know should take a look at that. I am able to load documents and compile them but some thourough testing is needed. However, when compiling for Qt5 or Qt4, I tried to make sure that the functionality is preserved.
This commit is contained in:
parent
d5263f857e
commit
635a7d77dd
@ -63,7 +63,16 @@ AC_MSG_RESULT([$withval])
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl Check whether to configure for Qt4 or Qt5. Default is Qt5.
|
dnl Check whether to configure for Qt4, Qt5, or Qt6. Default is Qt5.
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([LYX_CHECK_QT6],[
|
||||||
|
AC_MSG_CHECKING([whether Qt6 is requested])
|
||||||
|
AC_ARG_ENABLE([qt6],
|
||||||
|
[AS_HELP_STRING([--enable-qt6],[use Qt6 for building])],
|
||||||
|
USE_QT6=$enableval, USE_QT6=no)
|
||||||
|
AC_MSG_RESULT([$USE_QT6])
|
||||||
|
AC_SUBST([USE_QT6])
|
||||||
|
])
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN([LYX_CHECK_QT5],[
|
AC_DEFUN([LYX_CHECK_QT5],[
|
||||||
AC_MSG_CHECKING([whether Qt5 is disabled])
|
AC_MSG_CHECKING([whether Qt5 is disabled])
|
||||||
@ -372,7 +381,7 @@ if test x$GXX = xyes; then
|
|||||||
AM_CXXFLAGS="$AM_CXXFLAGS -fno-omit-frame-pointer"
|
AM_CXXFLAGS="$AM_CXXFLAGS -fno-omit-frame-pointer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$USE_QT5 = xyes ; then
|
if test x$USE_QT5 = xyes -o x$USE_QT6 = xyes; then
|
||||||
AS_CASE([$host], [*mingw*|*cygwin*], [], [AM_CXXFLAGS="-fPIC $AM_CXXFLAGS"])
|
AS_CASE([$host], [*mingw*|*cygwin*], [], [AM_CXXFLAGS="-fPIC $AM_CXXFLAGS"])
|
||||||
fi
|
fi
|
||||||
dnl Warnings are for preprocessor too
|
dnl Warnings are for preprocessor too
|
||||||
|
138
config/qt.m4
138
config/qt.m4
@ -26,7 +26,10 @@ AC_DEFUN([QT_CHECK_COMPILE],
|
|||||||
CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
|
CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
|
||||||
qt_corelibs="-lQtCore -lQtCore4"
|
qt_corelibs="-lQtCore -lQtCore4"
|
||||||
qt_guilibs="'-lQtCore -lQtGui' '-lQtCore4 -lQtGui4'"
|
qt_guilibs="'-lQtCore -lQtGui' '-lQtCore4 -lQtGui4'"
|
||||||
if test $USE_QT5 = "yes" ; then
|
if test $USE_QT6 = "yes" ; then
|
||||||
|
qt_corelibs="-lQt6Core -lQt6Core5Compat"
|
||||||
|
qt_guilibs="-lQt6Core -lQt6Core5Compat -lQt6Concurrent -lQt6Gui -lQt6Svg -lQt6Widgets"
|
||||||
|
elif test $USE_QT5 = "yes" ; then
|
||||||
qt_corelibs="-lQt5Core"
|
qt_corelibs="-lQt5Core"
|
||||||
qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg -lQt5Widgets"
|
qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg -lQt5Widgets"
|
||||||
fi
|
fi
|
||||||
@ -52,7 +55,9 @@ AC_DEFUN([QT_CHECK_COMPILE],
|
|||||||
])
|
])
|
||||||
|
|
||||||
if test -z "$qt_cv_libname"; then
|
if test -z "$qt_cv_libname"; then
|
||||||
if test x$USE_QT5 = xyes ; then
|
if test x$USE_QT6 = xyes ; then
|
||||||
|
AC_MSG_RESULT([failed, retrying with Qt5])
|
||||||
|
elif test x$USE_QT5 = xyes ; then
|
||||||
AC_MSG_RESULT([failed, retrying with Qt4])
|
AC_MSG_RESULT([failed, retrying with Qt4])
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([failed])
|
AC_MSG_RESULT([failed])
|
||||||
@ -68,7 +73,9 @@ AC_DEFUN([QT_FIND_TOOL],
|
|||||||
[
|
[
|
||||||
$1=
|
$1=
|
||||||
qt_ext=qt4
|
qt_ext=qt4
|
||||||
if test "x$USE_QT5" != "xno" ; then
|
if test "x$USE_QT6" != "xno" ; then
|
||||||
|
qt_ext=qt6
|
||||||
|
elif test "x$USE_QT5" != "xno" ; then
|
||||||
qt_ext=qt5
|
qt_ext=qt5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -161,17 +168,41 @@ AC_DEFUN([QT_DO_IT_ALL],
|
|||||||
|
|
||||||
dnl Check if it possible to do a pkg-config
|
dnl Check if it possible to do a pkg-config
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
if test -n "$PKG_CONFIG" ; then
|
dnl Not possible with Qt6 (QTBUG-86080)
|
||||||
QT_DO_PKG_CONFIG
|
if test x$USE_QT6 = xno ; then
|
||||||
fi
|
if test -n "$PKG_CONFIG" ; then
|
||||||
if test "$pkg_failed" != "no" ; then
|
QT_DO_PKG_CONFIG
|
||||||
QT_DO_MANUAL_CONFIG
|
fi
|
||||||
|
if test "$pkg_failed" != "no" ; then
|
||||||
|
QT_DO_MANUAL_CONFIG
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
QT6_QMAKE_CONFIG
|
||||||
|
if test -z "$QT_LIB"; then
|
||||||
|
QT_DO_MANUAL_CONFIG
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$QT_LIB"; then
|
if test -z "$QT_LIB"; then
|
||||||
dnl Try again with Qt4 if configuring for Qt5 fails
|
dnl Try again with Qt5 and then Qt4 if configuring for Qt6/5 fails
|
||||||
if test x$USE_QT5 = xyes ; then
|
if test x$USE_QT6 = xyes ; then
|
||||||
|
USE_QT6=no
|
||||||
|
USE_QT5=yes
|
||||||
|
AC_SUBST([USE_QT6])
|
||||||
|
AC_SUBST([USE_QT5])
|
||||||
|
if test -n "$PKG_CONFIG" ; then
|
||||||
|
QT_DO_PKG_CONFIG
|
||||||
|
fi
|
||||||
|
if test "$pkg_failed" != "no" ; then
|
||||||
|
QT_DO_MANUAL_CONFIG
|
||||||
|
fi
|
||||||
|
if test -z "$QT_LIB"; then
|
||||||
|
AC_MSG_ERROR([cannot find qt libraries.])
|
||||||
|
fi
|
||||||
|
elif test x$USE_QT5 = xyes ; then
|
||||||
|
USE_QT6=no
|
||||||
USE_QT5=no
|
USE_QT5=no
|
||||||
|
AC_SUBST([USE_QT6])
|
||||||
AC_SUBST([USE_QT5])
|
AC_SUBST([USE_QT5])
|
||||||
if test -n "$PKG_CONFIG" ; then
|
if test -n "$PKG_CONFIG" ; then
|
||||||
QT_DO_PKG_CONFIG
|
QT_DO_PKG_CONFIG
|
||||||
@ -197,8 +228,21 @@ AC_DEFUN([QT_DO_IT_ALL],
|
|||||||
AC_CHECK_HEADER(QtGui/qtgui-config.h,
|
AC_CHECK_HEADER(QtGui/qtgui-config.h,
|
||||||
[lyx_qt5_config=QtGui/qtgui-config.h],
|
[lyx_qt5_config=QtGui/qtgui-config.h],
|
||||||
[lyx_qt5_config=qconfig.h],[-])
|
[lyx_qt5_config=qconfig.h],[-])
|
||||||
|
AC_CHECK_HEADER(QtGui/private/qtgui-config_p.h,
|
||||||
|
[lyx_qt6_config=QtGui/private/qtgui-config_p.h],
|
||||||
|
[lyx_qt6_config=qconfig.h],[-])
|
||||||
AC_MSG_CHECKING([whether Qt uses the X Window system])
|
AC_MSG_CHECKING([whether Qt uses the X Window system])
|
||||||
if test x$USE_QT5 = xyes ; then
|
if test x$USE_QT6 = xyes ; then
|
||||||
|
dnl FIXME: Check whether defining QPA_XCB makes sense with Qt6
|
||||||
|
AC_PREPROC_IFELSE([AC_LANG_SOURCE([
|
||||||
|
[#include <$lyx_qt6_config>]
|
||||||
|
[#if !defined(QT_FEATURE_xcb) || QT_FEATURE_xcb < 0]
|
||||||
|
[#error Fail]
|
||||||
|
[#endif]])],
|
||||||
|
[AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
|
||||||
|
[AC_MSG_RESULT(no)])
|
||||||
|
elif test x$USE_QT5 = xyes ; then
|
||||||
AC_EGREP_CPP(xcb,
|
AC_EGREP_CPP(xcb,
|
||||||
[#include <$lyx_qt5_config>
|
[#include <$lyx_qt5_config>
|
||||||
QT_QPA_DEFAULT_PLATFORM_NAME],
|
QT_QPA_DEFAULT_PLATFORM_NAME],
|
||||||
@ -351,3 +395,75 @@ AC_DEFUN([QT_DO_MANUAL_CONFIG],
|
|||||||
QT_GET_VERSION
|
QT_GET_VERSION
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([QT6_QMAKE_CONFIG],
|
||||||
|
[
|
||||||
|
AC_MSG_CHECKING([for Qt6])
|
||||||
|
dnl Use first qmake in PATH
|
||||||
|
ver=`qmake -v | grep -o "Qt version ."`
|
||||||
|
if test "$ver" = "Qt version 6"; then
|
||||||
|
dnl Use a .pro file for getting qmake's variables
|
||||||
|
lyx_test_qt_dir=`mktemp -d`
|
||||||
|
lyx_test_qt_pro="$lyx_test_qt_dir/test.pro"
|
||||||
|
lyx_test_qt_mak="$lyx_test_qt_dir/Makefile"
|
||||||
|
cat > $lyx_test_qt_pro << EOF1
|
||||||
|
qtHaveModule(core): QT += core
|
||||||
|
qtHaveModule(core5compat): QT += core5compat
|
||||||
|
percent.target = %
|
||||||
|
percent.commands = @echo -n "\$(\$(@))\ "
|
||||||
|
QMAKE_EXTRA_TARGETS += percent
|
||||||
|
EOF1
|
||||||
|
qmake $lyx_test_qt_pro -o $lyx_test_qt_mak 1>/dev/null 2>&1
|
||||||
|
QT_CORE_INCLUDES=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak INCPATH | sed 's/-I\. //g'`
|
||||||
|
qt_corelibs=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak LIBS`
|
||||||
|
QT_CORE_LDFLAGS=`echo $qt_corelibs | tr ' ' '\n' | grep -e "^-L" | tr '\n' ' '`
|
||||||
|
if test -z "$QT_CORE_LDFLAGS"; then
|
||||||
|
QT_CORE_LDFLAGS="-L`qmake -query QT_INSTALL_LIBS`"
|
||||||
|
QT_CORE_LIB="$qt_corelibs"
|
||||||
|
else
|
||||||
|
QT_CORE_LIB=`echo $qt_corelibs | tr ' ' '\n' | grep -e "^-l" | tr '\n' ' '`
|
||||||
|
fi
|
||||||
|
if test -z "$QT_CORE_LIB"; then
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
else
|
||||||
|
AC_SUBST(QT_CORE_INCLUDES)
|
||||||
|
AC_SUBST(QT_CORE_LDFLAGS)
|
||||||
|
AC_SUBST(QT_CORE_LIB)
|
||||||
|
cat > $lyx_test_qt_pro << EOF2
|
||||||
|
qtHaveModule(core): QT += core
|
||||||
|
qtHaveModule(core5compat): QT += core5compat
|
||||||
|
qtHaveModule(concurrent): QT += concurrent
|
||||||
|
qtHaveModule(gui): QT += gui
|
||||||
|
qtHaveModule(svg): QT += svg
|
||||||
|
qtHaveModule(widgets): QT += widgets
|
||||||
|
percent.target = %
|
||||||
|
percent.commands = @echo -n "\$(\$(@))\ "
|
||||||
|
QMAKE_EXTRA_TARGETS += percent
|
||||||
|
EOF2
|
||||||
|
qmake $lyx_test_qt_pro -o $lyx_test_qt_mak 1>/dev/null 2>&1
|
||||||
|
QT_INCLUDES=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak INCPATH | sed 's/-I\. //g'`
|
||||||
|
qt_guilibs=`cd $lyx_test_qt_dir; make -s -f $lyx_test_qt_mak LIBS`
|
||||||
|
QT_LDFLAGS=`echo $qt_guilibs | tr ' ' '\n' | grep -e "^-L" | tr '\n' ' '`
|
||||||
|
if test -z "$QT_LDFLAGS"; then
|
||||||
|
QT_LDFLAGS="-L`qmake -query QT_INSTALL_LIBS`"
|
||||||
|
QT_LIB="$qt_guilibs"
|
||||||
|
else
|
||||||
|
QT_LIB=`echo $qt_guilibs | tr ' ' '\n' | grep -e "^-l" | tr '\n' ' '`
|
||||||
|
fi
|
||||||
|
QTLIB_VERSION=`qmake -v | grep "Qt version" | sed -e 's/.*\([[0-9]]\.[[0-9]]*\.[[0-9]]\).*/\1/'`
|
||||||
|
if test -z "$QT_LIB"; then
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_SUBST(QT_INCLUDES)
|
||||||
|
AC_SUBST(QT_LDFLAGS)
|
||||||
|
AC_SUBST(QT_LIB)
|
||||||
|
AC_SUBST(QTLIB_VERSION)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm $lyx_test_qt_pro $lyx_test_qt_mak $lyx_test_qt_dir/.qmake.stash
|
||||||
|
rmdir $lyx_test_qt_dir
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
@ -13,7 +13,10 @@ AC_CONFIG_AUX_DIR(config)
|
|||||||
# First check the version
|
# First check the version
|
||||||
LYX_CHECK_VERSION
|
LYX_CHECK_VERSION
|
||||||
LYX_VERSION_SUFFIX
|
LYX_VERSION_SUFFIX
|
||||||
|
LYX_CHECK_QT6
|
||||||
|
if test x$USE_QT6 = xno ; then
|
||||||
LYX_CHECK_QT5
|
LYX_CHECK_QT5
|
||||||
|
fi
|
||||||
# Check how the files should be packaged
|
# Check how the files should be packaged
|
||||||
AC_CANONICAL_TARGET
|
AC_CANONICAL_TARGET
|
||||||
LYX_USE_PACKAGING
|
LYX_USE_PACKAGING
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTextFrame>
|
#include <QTextFrame>
|
||||||
|
#if QT_VERSION >= 0x060000
|
||||||
|
#include <QtCore5Compat/QRegExp>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
@ -270,7 +273,11 @@ QString CCItemDelegate::underlineFilter(QString const & s) const
|
|||||||
if (f.isEmpty())
|
if (f.isEmpty())
|
||||||
return s;
|
return s;
|
||||||
QString r(s);
|
QString r(s);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp pattern(charFilterRegExpC(f));
|
QRegExp pattern(charFilterRegExpC(f));
|
||||||
|
#else
|
||||||
|
QRegularExpression pattern(charFilterRegExpC(f));
|
||||||
|
#endif
|
||||||
r.replace(pattern, "<u><b>\\1</b></u>");
|
r.replace(pattern, "<u><b>\\1</b></u>");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -287,7 +294,11 @@ 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 < 0x060000
|
||||||
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
|
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
|
||||||
|
#else
|
||||||
|
filterModel_->setFilterRegularExpression(charFilterRegExp(filter_));
|
||||||
|
#endif
|
||||||
countCategories();
|
countCategories();
|
||||||
|
|
||||||
// restore old selection
|
// restore old selection
|
||||||
|
@ -59,7 +59,9 @@ 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
|
||||||
ts.setCodec("UTF-8");
|
ts.setCodec("UTF-8");
|
||||||
|
#endif
|
||||||
QString line;
|
QString line;
|
||||||
do {
|
do {
|
||||||
line = ts.readLine();
|
line = ts.readLine();
|
||||||
@ -101,7 +103,9 @@ 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
|
||||||
ts.setCodec("UTF-8");
|
ts.setCodec("UTF-8");
|
||||||
|
#endif
|
||||||
QString line;
|
QString line;
|
||||||
bool incomment = false;
|
bool incomment = false;
|
||||||
bool inlist = false;
|
bool inlist = false;
|
||||||
@ -123,8 +127,13 @@ static QString release_notes()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// detect links to the tracker
|
// detect links to the tracker
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
|
line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
|
||||||
"<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
|
"<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
|
||||||
|
#else
|
||||||
|
line.replace(QRegularExpression("(bug )(\\#)(\\d+)*"),
|
||||||
|
"<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
|
||||||
|
#endif
|
||||||
|
|
||||||
// headings
|
// headings
|
||||||
if (line.startsWith("!!!")) {
|
if (line.startsWith("!!!")) {
|
||||||
|
@ -89,7 +89,9 @@
|
|||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#endif
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -135,6 +137,7 @@
|
|||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
#if (QT_VERSION < 0x050000) || (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 < 0x050000)
|
#if (QT_VERSION < 0x050000)
|
||||||
#include <QWindowsMime>
|
#include <QWindowsMime>
|
||||||
#define QWINDOWSMIME QWindowsMime
|
#define QWINDOWSMIME QWindowsMime
|
||||||
@ -142,6 +145,7 @@
|
|||||||
#include <QWinMime>
|
#include <QWinMime>
|
||||||
#define QWINDOWSMIME QWinMime
|
#define QWINDOWSMIME QWinMime
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
#include <wtypes.h>
|
#include <wtypes.h>
|
||||||
#endif
|
#endif
|
||||||
@ -808,7 +812,7 @@ public:
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Windows specific stuff goes here...
|
// Windows specific stuff goes here...
|
||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400 && QT_VERSION < 0x060000)
|
||||||
#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.
|
||||||
|
|
||||||
@ -974,7 +978,7 @@ struct GuiApplication::Private
|
|||||||
, last_state_(Qt::ApplicationInactive)
|
, last_state_(Qt::ApplicationInactive)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400 && QT_VERSION < 0x060000)
|
||||||
#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;
|
||||||
@ -1049,7 +1053,7 @@ struct GuiApplication::Private
|
|||||||
QMacPasteboardMimeGraphics mac_pasteboard_mime_;
|
QMacPasteboardMimeGraphics mac_pasteboard_mime_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400 && QT_VERSION < 0x060000)
|
||||||
#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_;
|
||||||
@ -1080,7 +1084,7 @@ 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 >= 0x050000
|
#if QT_VERSION >= 0x050000 && QT_VERSION < 0x060000
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2567,6 +2571,7 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
|
|||||||
int x, y;
|
int x, y;
|
||||||
int w, h;
|
int w, h;
|
||||||
QChar sx, sy;
|
QChar sx, sy;
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
|
QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
|
||||||
re.indexIn(geometry_arg);
|
re.indexIn(geometry_arg);
|
||||||
w = re.cap(1).toInt();
|
w = re.cap(1).toInt();
|
||||||
@ -2575,6 +2580,16 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
|
|||||||
y = re.cap(4).toInt();
|
y = re.cap(4).toInt();
|
||||||
sx = re.cap(3).isEmpty() ? '+' : re.cap(3).at(0);
|
sx = re.cap(3).isEmpty() ? '+' : re.cap(3).at(0);
|
||||||
sy = re.cap(4).isEmpty() ? '+' : re.cap(4).at(0);
|
sy = re.cap(4).isEmpty() ? '+' : re.cap(4).at(0);
|
||||||
|
#else
|
||||||
|
QRegularExpression re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
|
||||||
|
QRegularExpressionMatch match = re.match(geometry_arg);
|
||||||
|
w = match.captured(1).toInt();
|
||||||
|
h = match.captured(2).toInt();
|
||||||
|
x = match.captured(3).toInt();
|
||||||
|
y = match.captured(4).toInt();
|
||||||
|
sx = match.captured(3).isEmpty() ? '+' : match.captured(3).at(0);
|
||||||
|
sy = match.captured(4).isEmpty() ? '+' : match.captured(4).at(0);
|
||||||
|
#endif
|
||||||
// Set initial geometry such that we can get the frame size.
|
// Set initial geometry such that we can get the frame size.
|
||||||
view->setGeometry(x, y, w, h);
|
view->setGeometry(x, y, w, h);
|
||||||
int framewidth = view->geometry().x() - view->x();
|
int framewidth = view->geometry().x() - view->x();
|
||||||
@ -2582,7 +2597,11 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
|
|||||||
// Negative displacements must be interpreted as distances
|
// Negative displacements must be interpreted as distances
|
||||||
// from the right or bottom screen borders.
|
// from the right or bottom screen borders.
|
||||||
if (sx == '-' || sy == '-') {
|
if (sx == '-' || sy == '-') {
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRect rec = QApplication::desktop()->screenGeometry();
|
QRect rec = QApplication::desktop()->screenGeometry();
|
||||||
|
#else
|
||||||
|
QRect rec = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
#endif
|
||||||
if (sx == '-')
|
if (sx == '-')
|
||||||
x += rec.width() - w - framewidth;
|
x += rec.width() - w - framewidth;
|
||||||
if (sy == '-')
|
if (sy == '-')
|
||||||
|
@ -361,7 +361,11 @@ QString tidyHtml(QString const & input)
|
|||||||
// clutter.
|
// clutter.
|
||||||
QTextDocument converter;
|
QTextDocument converter;
|
||||||
converter.setHtml(input);
|
converter.setHtml(input);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
return converter.toHtml("utf-8");
|
return converter.toHtml("utf-8");
|
||||||
|
#else
|
||||||
|
return converter.toHtml();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -123,9 +123,17 @@ GuiCommandBuffer::GuiCommandBuffer(GuiView * view)
|
|||||||
layout->addWidget(upPB, 0);
|
layout->addWidget(upPB, 0);
|
||||||
layout->addWidget(downPB, 0);
|
layout->addWidget(downPB, 0);
|
||||||
layout->addWidget(edit_, 10);
|
layout->addWidget(edit_, 10);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
|
#else
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
top->addLayout(layout);
|
top->addLayout(layout);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
top->setMargin(0);
|
top->setMargin(0);
|
||||||
|
#else
|
||||||
|
top->setContentsMargins(0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
setFocusProxy(edit_);
|
setFocusProxy(edit_);
|
||||||
|
|
||||||
LastCommandsSection::LastCommands last_commands
|
LastCommandsSection::LastCommands last_commands
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "support/Package.h"
|
#include "support/Package.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
|
|
||||||
|
#include "GuiApplication.h"
|
||||||
|
|
||||||
#include <QFontInfo>
|
#include <QFontInfo>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
|
||||||
@ -207,14 +209,16 @@ QFont symbolFont(QString const & family, bool * ok)
|
|||||||
upper[0] = family[0].toUpper();
|
upper[0] = family[0].toUpper();
|
||||||
|
|
||||||
QFont font;
|
QFont font;
|
||||||
#if defined Q_WS_X11 || defined(QPA_XCB)
|
if (guiApp->platformName() == "qt4x11"
|
||||||
// On *nix we have to also specify the foundry to be able to
|
|| guiApp->platformName() == "xcb"
|
||||||
// discriminate our fonts when the texlive fonts are managed by
|
|| guiApp->platformName().contains("wayland")) {
|
||||||
// fontconfig. Unfortunately, doing the same on Windows breaks things.
|
// On *nix we have to also specify the foundry to be able to
|
||||||
font.setFamily(family + QLatin1String(" [LyEd]"));
|
// discriminate our fonts when the texlive fonts are managed by
|
||||||
#else
|
// fontconfig. Unfortunately, doing the same on Windows breaks things.
|
||||||
font.setFamily(family);
|
font.setFamily(family + QLatin1String(" [LyEd]"));
|
||||||
#endif
|
} else {
|
||||||
|
font.setFamily(family);
|
||||||
|
}
|
||||||
font.setStyleStrategy(QFont::NoFontMerging);
|
font.setStyleStrategy(QFont::NoFontMerging);
|
||||||
#if QT_VERSION >= 0x040800
|
#if QT_VERSION >= 0x040800
|
||||||
font.setStyleName("LyX");
|
font.setStyleName("LyX");
|
||||||
|
@ -30,7 +30,11 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
#include <QRegExpValidator>
|
#include <QRegExpValidator>
|
||||||
|
#else
|
||||||
|
#include <QRegularExpressionValidator>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
@ -232,7 +236,11 @@ GuiListings::GuiListings(GuiView & lv)
|
|||||||
numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
|
numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
|
||||||
firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
|
firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
|
||||||
lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
|
lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
|
placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
|
||||||
|
#else
|
||||||
|
placementLE->setValidator(new QRegularExpressionValidator(QRegularExpression("[\\*tbph]*"), this));
|
||||||
|
#endif
|
||||||
|
|
||||||
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
||||||
bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
|
bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
|
||||||
|
@ -41,12 +41,21 @@ namespace frontend {
|
|||||||
// Regular expressions needed at several places
|
// Regular expressions needed at several places
|
||||||
// FIXME: These regexes are incomplete. It would be good if we could collect those used in LaTeX::scanLogFile
|
// FIXME: These regexes are incomplete. It would be good if we could collect those used in LaTeX::scanLogFile
|
||||||
// and LaTeX::scanBlgFile and re-use them here!(spitz, 2013-05-27)
|
// and LaTeX::scanBlgFile and re-use them here!(spitz, 2013-05-27)
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
// Information
|
// Information
|
||||||
QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
|
QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
|
||||||
// Warnings
|
// Warnings
|
||||||
QRegExp exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
|
QRegExp exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
|
||||||
// Errors
|
// Errors
|
||||||
QRegExp exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
|
QRegExp exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
|
||||||
|
#else
|
||||||
|
// Information
|
||||||
|
QRegularExpression exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
|
||||||
|
// Warnings
|
||||||
|
QRegularExpression exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
|
||||||
|
// Errors
|
||||||
|
QRegularExpression exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@ -82,6 +91,7 @@ LogHighlighter::LogHighlighter(QTextDocument * parent)
|
|||||||
|
|
||||||
void LogHighlighter::highlightBlock(QString const & text)
|
void LogHighlighter::highlightBlock(QString const & text)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
// Info
|
// Info
|
||||||
int index = exprInfo.indexIn(text);
|
int index = exprInfo.indexIn(text);
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
@ -103,6 +113,35 @@ void LogHighlighter::highlightBlock(QString const & text)
|
|||||||
setFormat(index, length, errorFormat);
|
setFormat(index, length, errorFormat);
|
||||||
index = exprError.indexIn(text, index + length);
|
index = exprError.indexIn(text, index + length);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Info
|
||||||
|
QRegularExpressionMatch match = exprInfo.match(text);
|
||||||
|
int index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int length = match.capturedEnd(1) - index;
|
||||||
|
setFormat(index, length, infoFormat);
|
||||||
|
match = exprInfo.match(text, index + length);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
// LaTeX Warning:
|
||||||
|
match = exprWarning.match(text);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int length = match.capturedEnd(1) - index;
|
||||||
|
setFormat(index, length, warningFormat);
|
||||||
|
match = exprWarning.match(text, index + length);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
// ! error
|
||||||
|
match = exprError.match(text);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int length = match.capturedEnd(1) - index;
|
||||||
|
setFormat(index, length, errorFormat);
|
||||||
|
match = exprError.match(text, index + length);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +234,11 @@ void GuiLog::on_openDirPB_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
void GuiLog::goTo(QRegExp const & exp) const
|
void GuiLog::goTo(QRegExp const & exp) const
|
||||||
|
#else
|
||||||
|
void GuiLog::goTo(QRegularExpression const & exp) const
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QTextCursor const newc =
|
QTextCursor const newc =
|
||||||
logTB->document()->find(exp, logTB->textCursor());
|
logTB->document()->find(exp, logTB->textCursor());
|
||||||
@ -203,7 +246,11 @@ void GuiLog::goTo(QRegExp const & exp) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
bool GuiLog::contains(QRegExp const & exp) const
|
bool GuiLog::contains(QRegExp const & exp) const
|
||||||
|
#else
|
||||||
|
bool GuiLog::contains(QRegularExpression const & exp) const
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
return !logTB->document()->find(exp, logTB->textCursor()).isNull();
|
return !logTB->document()->find(exp, logTB->textCursor()).isNull();
|
||||||
}
|
}
|
||||||
|
@ -66,10 +66,17 @@ private:
|
|||||||
docstring title() const;
|
docstring title() const;
|
||||||
/// put the log file into the ostream
|
/// put the log file into the ostream
|
||||||
void getContents(std::ostream & ss) const;
|
void getContents(std::ostream & ss) const;
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
/// go to the next occurrence of the RegExp
|
/// go to the next occurrence of the RegExp
|
||||||
void goTo(QRegExp const & exp) const;
|
void goTo(QRegExp const & exp) const;
|
||||||
/// does the document after cursor position contain the RegExp?
|
/// does the document after cursor position contain the RegExp?
|
||||||
bool contains(QRegExp const & exp) const;
|
bool contains(QRegExp const & exp) const;
|
||||||
|
#else
|
||||||
|
/// go to the next occurrence of the RegExp
|
||||||
|
void goTo(QRegularExpression const & exp) const;
|
||||||
|
/// does the document after cursor position contain the RegExp?
|
||||||
|
bool contains(QRegularExpression const & exp) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Recognized log file-types
|
/// Recognized log file-types
|
||||||
|
@ -188,7 +188,11 @@ QString browseRelToSub(QString const & filename, QString const & relpath,
|
|||||||
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
|
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
|
||||||
|
|
||||||
QString testname = reloutname;
|
QString testname = reloutname;
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
testname.remove(QRegExp("^(\\.\\./)+"));
|
testname.remove(QRegExp("^(\\.\\./)+"));
|
||||||
|
#else
|
||||||
|
testname.remove(QRegularExpression("^(\\.\\./)+"));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (testname.contains("/"))
|
if (testname.contains("/"))
|
||||||
return outname;
|
return outname;
|
||||||
@ -2424,7 +2428,11 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
|
|||||||
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
|
startCommandED->setValidator(new NoNewLineValidator(startCommandED));
|
||||||
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
|
endCommandED->setValidator(new NoNewLineValidator(endCommandED));
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
defaultDecimalSepED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
|
defaultDecimalSepED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
|
||||||
|
#else
|
||||||
|
defaultDecimalSepED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
|
||||||
|
#endif
|
||||||
defaultDecimalSepED->setMaxLength(1);
|
defaultDecimalSepED->setMaxLength(1);
|
||||||
|
|
||||||
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
|
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
|
||||||
@ -2584,9 +2592,12 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
|
|||||||
iconSetCO->addItem(qt_("Classic"), "classic");
|
iconSetCO->addItem(qt_("Classic"), "classic");
|
||||||
iconSetCO->addItem(qt_("Oxygen"), "oxygen");
|
iconSetCO->addItem(qt_("Oxygen"), "oxygen");
|
||||||
|
|
||||||
#if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600)
|
#if QT_VERSION >= 0x040600
|
||||||
useSystemThemeIconsCB->hide();
|
if (guiApp->platformName() != "qt4x11"
|
||||||
|
&& guiApp->platformName() != "xcb"
|
||||||
|
&& !guiApp->platformName().contains("wayland"))
|
||||||
#endif
|
#endif
|
||||||
|
useSystemThemeIconsCB->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,7 +176,11 @@ GuiTabular::GuiTabular(QWidget * parent)
|
|||||||
connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
|
connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
|
||||||
this, SLOT(checkEnabled()));
|
this, SLOT(checkEnabled()));
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
decimalPointED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
|
decimalPointED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
|
||||||
|
#else
|
||||||
|
decimalPointED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
|
||||||
|
#endif
|
||||||
decimalPointED->setMaxLength(1);
|
decimalPointED->setMaxLength(1);
|
||||||
|
|
||||||
// initialize the length validator
|
// initialize the length validator
|
||||||
|
@ -124,9 +124,14 @@ void GuiThesaurus::selectionChanged()
|
|||||||
QString item = meaningsTV->currentItem()->text(col);
|
QString item = meaningsTV->currentItem()->text(col);
|
||||||
// cut out the classification in brackets:
|
// cut out the classification in brackets:
|
||||||
// "hominid (generic term)" -> "hominid"
|
// "hominid (generic term)" -> "hominid"
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
|
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
|
||||||
|
#else
|
||||||
|
QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
|
||||||
|
#endif
|
||||||
// This is for items with classifications at the beginning:
|
// This is for items with classifications at the beginning:
|
||||||
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
|
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
|
QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
|
||||||
int pos = re.indexIn(item);
|
int pos = re.indexIn(item);
|
||||||
if (pos > -1)
|
if (pos > -1)
|
||||||
@ -134,6 +139,15 @@ void GuiThesaurus::selectionChanged()
|
|||||||
pos = rex.indexIn(item);
|
pos = rex.indexIn(item);
|
||||||
if (pos > -1)
|
if (pos > -1)
|
||||||
item = rex.cap(2).trimmed();
|
item = rex.cap(2).trimmed();
|
||||||
|
#else
|
||||||
|
QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
|
||||||
|
QRegularExpressionMatch match = re.match(item);
|
||||||
|
if (match.hasMatch())
|
||||||
|
item = match.captured(1).trimmed();
|
||||||
|
match = rex.match(item);
|
||||||
|
if (match.hasMatch())
|
||||||
|
item = match.captured(2).trimmed();
|
||||||
|
#endif
|
||||||
replaceED->setText(item);
|
replaceED->setText(item);
|
||||||
replacePB->setEnabled(!isBufferReadonly());
|
replacePB->setEnabled(!isBufferReadonly());
|
||||||
changed();
|
changed();
|
||||||
@ -151,9 +165,14 @@ void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col)
|
|||||||
QString str = item->text(col);
|
QString str = item->text(col);
|
||||||
// cut out the classification in brackets:
|
// cut out the classification in brackets:
|
||||||
// "hominid (generic term)" -> "hominid"
|
// "hominid (generic term)" -> "hominid"
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
|
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
|
||||||
|
#else
|
||||||
|
QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
|
||||||
|
#endif
|
||||||
// This is for items with classifications at the beginning:
|
// This is for items with classifications at the beginning:
|
||||||
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
|
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
|
QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
|
||||||
int pos = re.indexIn(str);
|
int pos = re.indexIn(str);
|
||||||
if (pos > -1)
|
if (pos > -1)
|
||||||
@ -161,6 +180,15 @@ void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col)
|
|||||||
pos = rex.indexIn(str);
|
pos = rex.indexIn(str);
|
||||||
if (pos > -1)
|
if (pos > -1)
|
||||||
str = rex.cap(2).trimmed();
|
str = rex.cap(2).trimmed();
|
||||||
|
#else
|
||||||
|
QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
|
||||||
|
QRegularExpressionMatch match = re.match(str);
|
||||||
|
if (match.hasMatch())
|
||||||
|
str = match.captured(1).trimmed();
|
||||||
|
match = rex.match(str);
|
||||||
|
if (match.hasMatch())
|
||||||
|
str = match.captured(2).trimmed();
|
||||||
|
#endif
|
||||||
entryCO->insertItem(0, str);
|
entryCO->insertItem(0, str);
|
||||||
entryCO->setCurrentIndex(0);
|
entryCO->setCurrentIndex(0);
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ GuiView::GuiView(int id)
|
|||||||
zoom_in_->setFlat(true);
|
zoom_in_->setFlat(true);
|
||||||
zoom_in_->setFixedSize(QSize(fm.height(), fm.height()));
|
zoom_in_->setFixedSize(QSize(fm.height(), fm.height()));
|
||||||
zoom_out_ = new QPushButton(statusBar());
|
zoom_out_ = new QPushButton(statusBar());
|
||||||
zoom_out_->setText(QString(0x2212));
|
zoom_out_->setText(QString(QChar(0x2212)));
|
||||||
zoom_out_->setFixedSize(QSize(fm.height(), fm.height()));
|
zoom_out_->setFixedSize(QSize(fm.height(), fm.height()));
|
||||||
zoom_out_->setFlat(true);
|
zoom_out_->setFlat(true);
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#endif
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStyleOptionFrame>
|
#include <QStyleOptionFrame>
|
||||||
@ -76,7 +78,9 @@ 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
|
||||||
menuOpt.tabWidth = 0;
|
menuOpt.tabWidth = 0;
|
||||||
|
#endif
|
||||||
menuOpt.menuItemType = QStyleOptionMenuItem::TearOff;
|
menuOpt.menuItemType = QStyleOptionMenuItem::TearOff;
|
||||||
menuOpt.rect.setRect(fw, fw, width() - (fw * 2),
|
menuOpt.rect.setRect(fw, fw, width() - (fw * 2),
|
||||||
style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this));
|
style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this));
|
||||||
@ -92,12 +96,20 @@ IconPalette::IconPalette(QWidget * parent)
|
|||||||
: QWidget(parent, Qt::Popup), tornoff_(false)
|
: QWidget(parent, Qt::Popup), tornoff_(false)
|
||||||
{
|
{
|
||||||
QVBoxLayout * v = new QVBoxLayout(this);
|
QVBoxLayout * v = new QVBoxLayout(this);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
v->setMargin(0);
|
v->setMargin(0);
|
||||||
|
#else
|
||||||
|
v->setContentsMargins(0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
v->setSpacing(0);
|
v->setSpacing(0);
|
||||||
layout_ = new QGridLayout;
|
layout_ = new QGridLayout;
|
||||||
layout_->setSpacing(0);
|
layout_->setSpacing(0);
|
||||||
const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
|
const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
layout_->setMargin(fw);
|
layout_->setMargin(fw);
|
||||||
|
#else
|
||||||
|
layout_->setContentsMargins(0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
tearoffwidget_ = new TearOff(this);
|
tearoffwidget_ = new TearOff(this);
|
||||||
connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff()));
|
connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff()));
|
||||||
v->addWidget(tearoffwidget_);
|
v->addWidget(tearoffwidget_);
|
||||||
@ -166,7 +178,11 @@ void IconPalette::showEvent(QShowEvent * /*event*/)
|
|||||||
voffset -= parheight;
|
voffset -= parheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRect const screen = qApp->desktop()->availableGeometry(this);
|
QRect const screen = qApp->desktop()->availableGeometry(this);
|
||||||
|
#else
|
||||||
|
QRect const screen = qApp->primaryScreen()->availableGeometry();
|
||||||
|
#endif
|
||||||
QPoint const gpos = parentWidget()->mapToGlobal(
|
QPoint const gpos = parentWidget()->mapToGlobal(
|
||||||
parentWidget()->geometry().bottomLeft());
|
parentWidget()->geometry().bottomLeft());
|
||||||
|
|
||||||
|
@ -27,7 +27,11 @@ class TearOff : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TearOff(QWidget * parent);
|
TearOff(QWidget * parent);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
void enterEvent(QEvent *) override;
|
void enterEvent(QEvent *) override;
|
||||||
|
#else
|
||||||
|
void enterEvent(QEvent *);
|
||||||
|
#endif
|
||||||
void leaveEvent(QEvent *) override;
|
void leaveEvent(QEvent *) override;
|
||||||
void mouseReleaseEvent (QMouseEvent *) override;
|
void mouseReleaseEvent (QMouseEvent *) override;
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -43,6 +43,7 @@ LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter)
|
|||||||
|
|
||||||
void LaTeXHighlighter::highlightBlock(QString const & text)
|
void LaTeXHighlighter::highlightBlock(QString const & text)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
// $ $
|
// $ $
|
||||||
static const QRegExp exprMath("\\$[^\\$]*\\$");
|
static const QRegExp exprMath("\\$[^\\$]*\\$");
|
||||||
int index = exprMath.indexIn(text);
|
int index = exprMath.indexIn(text);
|
||||||
@ -127,6 +128,102 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
|
|||||||
setFormat(index, length, warningFormat);
|
setFormat(index, length, warningFormat);
|
||||||
index = exprWarning.indexIn(text, index + length);
|
index = exprWarning.indexIn(text, index + length);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// $ $
|
||||||
|
static const QRegularExpression exprMath("\\$[^\\$]*\\$");
|
||||||
|
QRegularExpressionMatch match = exprMath.match(text);
|
||||||
|
int index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int length = match.capturedEnd(1) - index;
|
||||||
|
setFormat(index, length, mathFormat);
|
||||||
|
match = exprMath.match(text, index + length);
|
||||||
|
int index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
// [ ]
|
||||||
|
static const QRegularExpression exprStartDispMath("(\\\\\\[|"
|
||||||
|
"\\\\begin\\{equation\\**\\}|"
|
||||||
|
"\\\\begin\\{eqnarray\\**\\}|"
|
||||||
|
"\\\\begin\\{align(ed|at)*\\**\\}|"
|
||||||
|
"\\\\begin\\{flalign\\**\\}|"
|
||||||
|
"\\\\begin\\{gather\\**\\}|"
|
||||||
|
"\\\\begin\\{multline\\**\\}|"
|
||||||
|
"\\\\begin\\{array\\**\\}|"
|
||||||
|
"\\\\begin\\{cases\\**\\}"
|
||||||
|
")");
|
||||||
|
static const QRegularExpression exprEndDispMath("(\\\\\\]|"
|
||||||
|
"\\\\end\\{equation\\**\\}|"
|
||||||
|
"\\\\end\\{eqnarray\\**\\}|"
|
||||||
|
"\\\\end\\{align(ed|at)*\\**\\}|"
|
||||||
|
"\\\\end\\{flalign\\**\\}|"
|
||||||
|
"\\\\end\\{gather\\**\\}|"
|
||||||
|
"\\\\end\\{multline\\**\\}|"
|
||||||
|
"\\\\end\\{array\\**\\}|"
|
||||||
|
"\\\\end\\{cases\\**\\}"
|
||||||
|
")");
|
||||||
|
int startIndex = 0;
|
||||||
|
// if previous block was in 'disp math'
|
||||||
|
// start search from 0 (for end disp math)
|
||||||
|
// otherwise, start search from 'begin disp math'
|
||||||
|
if (previousBlockState() != 1) {
|
||||||
|
match = exprStartDispMath.match(text);
|
||||||
|
startIndex = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
while (startIndex >= 0) {
|
||||||
|
match = exprEndDispMath.match(text, startIndex);
|
||||||
|
int endIndex = match.capturedStart(1);
|
||||||
|
int length;
|
||||||
|
if (endIndex == -1) {
|
||||||
|
setCurrentBlockState(1);
|
||||||
|
length = text.length() - startIndex;
|
||||||
|
} else {
|
||||||
|
length = match.capturedEnd(1) - startIndex;
|
||||||
|
}
|
||||||
|
setFormat(startIndex, length, mathFormat);
|
||||||
|
match = exprStartDispMath.match(text, startIndex + length);
|
||||||
|
startIndex = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
// \whatever
|
||||||
|
static const QRegularExpression exprKeywordAtOther("\\\\[A-Za-z]+");
|
||||||
|
// \wh@tever
|
||||||
|
static const QRegularExpression exprKeywordAtLetter("\\\\[A-Za-z@]+");
|
||||||
|
QRegularExpression const & exprKeyword = at_letter_
|
||||||
|
? exprKeywordAtLetter : exprKeywordAtOther;
|
||||||
|
match = exprKeyword.match(text);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int length = match.capturedEnd(1) - index;
|
||||||
|
setFormat(index, length, keywordFormat);
|
||||||
|
match = exprKeyword.match(text, index + length);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
// %comment
|
||||||
|
// Treat a line as a comment starting at a percent sign
|
||||||
|
// * that is the first character in a line
|
||||||
|
// * that is preceded by
|
||||||
|
// ** an even number of backslashes
|
||||||
|
// ** any character other than a backslash
|
||||||
|
QRegularExpression exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
|
||||||
|
match = exprComment.match(text);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int const length = match.capturedEnd(1) - index
|
||||||
|
- (index - match.capturedStart(0));
|
||||||
|
setFormat(index, length, commentFormat);
|
||||||
|
match = exprComment.match(text, index + length);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
// <LyX Warning: ...>
|
||||||
|
QString lyxwarn = qt_("LyX Warning: ");
|
||||||
|
QRegularExpression exprWarning("<" + lyxwarn + "[^<]*>");
|
||||||
|
match = exprWarning.match(text);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
while (index >= 0) {
|
||||||
|
int length = match.capturedEnd(1) - index;
|
||||||
|
setFormat(index, length, warningFormat);
|
||||||
|
match = exprWarning.match(text, index + length);
|
||||||
|
index = match.capturedStart(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -300,7 +300,11 @@ QString LayoutItemDelegate::underlineFilter(QString const & s) const
|
|||||||
if (f.isEmpty())
|
if (f.isEmpty())
|
||||||
return s;
|
return s;
|
||||||
QString r(s);
|
QString r(s);
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
QRegExp pattern(charFilterRegExpC(f));
|
QRegExp pattern(charFilterRegExpC(f));
|
||||||
|
#else
|
||||||
|
QRegularExpression pattern(charFilterRegExpC(f));
|
||||||
|
#endif
|
||||||
r.replace(pattern, "<u><b>\\1</b></u>");
|
r.replace(pattern, "<u><b>\\1</b></u>");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -321,7 +325,11 @@ 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 < 0x060000
|
||||||
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
|
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
|
||||||
|
#else
|
||||||
|
filterModel_->setFilterRegularExpression(charFilterRegExp(filter_));
|
||||||
|
#endif
|
||||||
countCategories();
|
countCategories();
|
||||||
|
|
||||||
// restore old selection
|
// restore old selection
|
||||||
|
@ -182,7 +182,11 @@ NoNewLineValidator::NoNewLineValidator(QWidget * parent)
|
|||||||
|
|
||||||
QValidator::State NoNewLineValidator::validate(QString & qtext, int &) const
|
QValidator::State NoNewLineValidator::validate(QString & qtext, int &) const
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
qtext.remove(QRegExp("[\\n\\r]"));
|
qtext.remove(QRegExp("[\\n\\r]"));
|
||||||
|
#else
|
||||||
|
qtext.remove(QRegularExpression("[\\n\\r]"));
|
||||||
|
#endif
|
||||||
return QValidator::Acceptable;
|
return QValidator::Acceptable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +20,20 @@ namespace lyx {
|
|||||||
|
|
||||||
struct Mutex::Private
|
struct Mutex::Private
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < 0x060000
|
||||||
// QMutex::Recursive: less risks for dead-locks
|
// QMutex::Recursive: less risks for dead-locks
|
||||||
Private() : qmutex_(QMutex::Recursive)
|
Private() : qmutex_(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex qmutex_;
|
QMutex qmutex_;
|
||||||
|
#else
|
||||||
|
Private() : qmutex_()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QRecursiveMutex qmutex_;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user