mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Prepare LyX code to compile and link with Qt5:
* some functionality is in new modules now new header locations and library names: QtConcurrent and QtWidgets * method setResizeMode is renamed to setSectionResizeMode * deprecated QAbstractItemModel::reset() is dropped now * platform specific code like QApplication::syncX() is not common anymore * QString::fromAscii() is dropped now * some QDesktopServices methods has been moved to QStandardPaths
This commit is contained in:
parent
e4d6730fca
commit
141fbb6f8c
@ -39,6 +39,7 @@ AC_DEFUN([QT4_CHECK_COMPILE],
|
||||
qt4_cv_libname=
|
||||
for libname in '-lQtCore -lQtGui' \
|
||||
'-lQtCore4 -lQtGui4' \
|
||||
'-framework QtCore -framework QtConcurrent -framework QtWidgets -framework QtGui'\
|
||||
'-framework QtCore -framework QtGui'
|
||||
do
|
||||
QT4_TRY_LINK($libname)
|
||||
@ -197,7 +198,7 @@ AC_DEFUN([QT4_DO_MANUAL_CONFIG],
|
||||
QT4_CORE_LDFLAGS=
|
||||
if test -n "$qt4_cv_includes"; then
|
||||
QT4_INCLUDES="-I$qt4_cv_includes"
|
||||
for i in Qt QtCore QtGui; do
|
||||
for i in Qt QtCore QtGui QtWidgets QtConcurrent; do
|
||||
QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
|
||||
done
|
||||
QT4_CORE_INCLUDES="-I$qt4_cv_includes -I$qt4_cv_includes/QtCore"
|
||||
|
@ -44,7 +44,7 @@ LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-x=no"
|
||||
LyXConfigureOptions="${LyXConfigureOptions} --disable-stdlib-debug"
|
||||
AspellConfigureOptions="--enable-warnings --enable-optimization=-O0 --enable-debug --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
|
||||
HunspellConfigureOptions="--with-warnings --disable-nls --disable-static"
|
||||
Qt4ConfigureOptions="${Qt4ConfigureOptions} -opensource -silent -shared -fast -no-exceptions"
|
||||
Qt4ConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -fast -no-exceptions"
|
||||
Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
|
||||
Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
|
||||
|
||||
@ -52,6 +52,11 @@ Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -noma
|
||||
case "${Qt4Version}:${Qt4API}" in
|
||||
4.6*:-carbon)
|
||||
;;
|
||||
5.0*)
|
||||
Qt4ConfigureOptions="${QtConfigureOptions} -opensource -silent -shared -fast -no-strip"
|
||||
Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-javascript-jit -no-pkg-config"
|
||||
Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
|
||||
;;
|
||||
*)
|
||||
Qt4ConfigureOptions="${Qt4ConfigureOptions} ${Qt4API}"
|
||||
;;
|
||||
@ -125,6 +130,12 @@ usage() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
NCPU=$(sysctl -n hw.ncpu)
|
||||
NCPU=$((NCPU / 2))
|
||||
if [ $NCPU -gt 1 ]; then
|
||||
MAKEJOBS=-j${NCPU}
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "${1}" in
|
||||
--with-qt4-frameworks=*)
|
||||
@ -226,7 +237,6 @@ done
|
||||
if [ "${configure_qt4_frameworks}" != "yes" ]; then
|
||||
QtInstallDir=${QTDIR:-"/opt/qt4"}
|
||||
fi
|
||||
QtFrameworkVersion="4"
|
||||
|
||||
ARCH_LIST=${ARCH_LIST:-"ppc i386"}
|
||||
|
||||
@ -277,7 +287,16 @@ LyxAppPrefix="${LyxAppDir}.app"
|
||||
# ---------------------------------
|
||||
|
||||
# don't change order here...
|
||||
QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
|
||||
case "${Qt4Version}" in
|
||||
5*)
|
||||
QtLibraries="QtSvg QtXml QtPrintSupport QtWidgets QtGui QtNetwork QtConcurrent QtCore"
|
||||
QtFrameworkVersion="5"
|
||||
;;
|
||||
*)
|
||||
QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
|
||||
QtFrameworkVersion="4"
|
||||
;;
|
||||
esac
|
||||
|
||||
DMGNAME="${LyxBase}"
|
||||
DMGSIZE="550m"
|
||||
@ -332,7 +351,7 @@ if [ "${configure_qt4_frameworks}" != "yes" -a -d "${Qt4SourceDir}" -a ! \( -d "
|
||||
echo configure options:
|
||||
echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
|
||||
echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
|
||||
make && make install
|
||||
make ${MAKEJOBS} && make install
|
||||
)
|
||||
cd "${QtInstallDir}" && (
|
||||
mkdir -p include
|
||||
@ -603,12 +622,7 @@ build_lyx() {
|
||||
${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
|
||||
${LyXConfigureOptions}\
|
||||
--enable-build-type=rel && \
|
||||
NCPU=$(sysctl -n hw.ncpu)
|
||||
NCPU=$((NCPU / 2))
|
||||
if [ $NCPU -gt 1 ]; then
|
||||
NUMJOBS=-j${NCPU}
|
||||
fi
|
||||
make ${NUMJOBS} && make install${strip}
|
||||
make ${MAKEJOBS} && make install${strip}
|
||||
for file in ${LYX_FILE_LIST} ; do
|
||||
if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
|
||||
mv "${LYX_BUNDLE_PATH}/${file}"\
|
||||
|
@ -17,18 +17,18 @@
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QPropertyAnimation>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QAbstractButton>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QPaintEvent>
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QLabel>
|
||||
#include <QAbstractButton>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QPaintEvent>
|
||||
|
||||
enum { margin = 6 };
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#ifndef FANCYLINEEDIT_H
|
||||
#define FANCYLINEEDIT_H
|
||||
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QAbstractButton>
|
||||
#include <QLineEdit>
|
||||
#include <QAbstractButton>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
@ -93,7 +93,6 @@
|
||||
#include <QLocale>
|
||||
#include <QLibraryInfo>
|
||||
#include <QList>
|
||||
#include <QMacPasteboardMime>
|
||||
#include <QMenuBar>
|
||||
#include <QMimeData>
|
||||
#include <QObject>
|
||||
@ -127,6 +126,10 @@
|
||||
#include <objidl.h>
|
||||
#endif // Q_WS_WIN
|
||||
|
||||
#ifdef Q_WS_MACX
|
||||
#include <QMacPasteboardMime>
|
||||
#endif // Q_WS_MACX
|
||||
|
||||
#include "support/bind.h"
|
||||
#include <boost/crc.hpp>
|
||||
|
||||
|
@ -90,9 +90,10 @@ public:
|
||||
~GuiCompletionModel() { delete list_; }
|
||||
///
|
||||
void setList(CompletionList const * l) {
|
||||
beginResetModel();
|
||||
delete list_;
|
||||
list_ = l;
|
||||
reset();
|
||||
endResetModel();
|
||||
}
|
||||
///
|
||||
bool sorted() const
|
||||
@ -444,8 +445,8 @@ void GuiCompleter::asyncUpdatePopup()
|
||||
// has a bad memory about it and we have to tell him again and again.
|
||||
QTreeView * listView = static_cast<QTreeView *>(popup());
|
||||
listView->header()->setStretchLastSection(false);
|
||||
listView->header()->setResizeMode(0, QHeaderView::Stretch);
|
||||
listView->header()->setResizeMode(1, QHeaderView::Fixed);
|
||||
setSectionResizeMode(listView->header(), 0, QHeaderView::Stretch);
|
||||
setSectionResizeMode(listView->header(), 1, QHeaderView::Fixed);
|
||||
listView->header()->resizeSection(1, 22);
|
||||
|
||||
// show/update popup
|
||||
|
@ -1132,8 +1132,7 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
|
||||
numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
|
||||
numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
|
||||
numberingModule->tocTW->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
|
||||
setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents);
|
||||
|
||||
// biblio
|
||||
biblioModule = new UiWidget<Ui::BiblioUi>;
|
||||
@ -1327,7 +1326,7 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
// Modules
|
||||
modulesModule = new UiWidget<Ui::ModulesUi>;
|
||||
modulesModule->availableLV->header()->setVisible(false);
|
||||
modulesModule->availableLV->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents);
|
||||
modulesModule->availableLV->header()->setStretchLastSection(false);
|
||||
selectionManager =
|
||||
new ModuleSelectionManager(modulesModule->availableLV,
|
||||
|
@ -248,8 +248,9 @@ public:
|
||||
|
||||
void setSymbols(QList<char_type> const & symbols)
|
||||
{
|
||||
QAbstractItemModel::beginResetModel();
|
||||
symbols_ = symbols;
|
||||
QAbstractItemModel::reset();
|
||||
QAbstractItemModel::endResetModel();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -55,7 +55,9 @@
|
||||
#include "frontends/WorkAreaManager.h"
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#if (QT_VERSION < 0x050000)
|
||||
#include <QInputContext>
|
||||
#endif
|
||||
#include <QDrag>
|
||||
#include <QHelpEvent>
|
||||
#ifdef Q_WS_MACX
|
||||
@ -674,7 +676,9 @@ void GuiWorkArea::scrollTo(int value)
|
||||
}
|
||||
// Show the cursor immediately after any operation.
|
||||
startBlinkingCursor();
|
||||
#ifdef Q_WS_X11
|
||||
QApplication::syncX();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -794,7 +798,9 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (QT_VERSION < 0x050000)
|
||||
inputContext()->reset();
|
||||
#endif
|
||||
|
||||
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
|
||||
q_button_state(e->button()));
|
||||
|
@ -49,7 +49,7 @@ LyXFileDialog::LyXFileDialog(QString const & title,
|
||||
// FIXME replace that with guiApp->currentView()
|
||||
: QFileDialog(qApp->focusWidget(), title, path)
|
||||
{
|
||||
setFilters(filters);
|
||||
setNameFilters(filters);
|
||||
setWindowTitle(title);
|
||||
|
||||
QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
|
||||
|
@ -1875,7 +1875,7 @@ void Menus::Impl::macxMenuBarInit(GuiView * view, QMenuBar * qmb)
|
||||
QAction::MenuRole role;
|
||||
};
|
||||
|
||||
MacMenuEntry entries[] = {
|
||||
static MacMenuEntry entries[] = {
|
||||
{LFUN_DIALOG_SHOW, "aboutlyx", "About LyX",
|
||||
QAction::AboutRole},
|
||||
{LFUN_DIALOG_SHOW, "prefs", "Preferences",
|
||||
|
@ -60,7 +60,7 @@ PanelStack::PanelStack(QWidget * parent)
|
||||
list_->setRootIsDecorated(false);
|
||||
list_->setColumnCount(1);
|
||||
list_->header()->hide();
|
||||
list_->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
setSectionResizeMode(list_->header(), QHeaderView::ResizeToContents);
|
||||
list_->header()->setStretchLastSection(false);
|
||||
list_->setMinimumSize(list_->viewport()->size());
|
||||
|
||||
|
@ -44,7 +44,11 @@ public:
|
||||
///
|
||||
void reset()
|
||||
{
|
||||
#if (QT_VERSION < 0x050000)
|
||||
QStandardItemModel::reset();
|
||||
#else
|
||||
QStandardItemModel::endResetModel();
|
||||
#endif
|
||||
}
|
||||
///
|
||||
void beginResetModel()
|
||||
|
@ -196,6 +196,23 @@ void setValid(QWidget * widget, bool valid)
|
||||
}
|
||||
}
|
||||
|
||||
/// wrapper to hide the change of method name to setSectionResizeMode
|
||||
void setSectionResizeMode(QHeaderView * view,
|
||||
int logicalIndex, QHeaderView::ResizeMode mode) {
|
||||
#if (QT_VERSION >= 0x050000)
|
||||
view->setSectionResizeMode(logicalIndex, mode);
|
||||
#else
|
||||
view->setResizeMode(logicalIndex, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setSectionResizeMode(QHeaderView * view, QHeaderView::ResizeMode mode) {
|
||||
#if (QT_VERSION >= 0x050000)
|
||||
view->setSectionResizeMode(mode);
|
||||
#else
|
||||
view->setResizeMode(mode);
|
||||
#endif
|
||||
}
|
||||
} // namespace frontend
|
||||
|
||||
QString const qt_(char const * str, const char *)
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "qt_i18n.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QHeaderView>
|
||||
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
@ -66,6 +67,13 @@ void doubleToWidget(QLineEdit * input, std::string const & value,
|
||||
/// colors a widget red if invalid
|
||||
void setValid(QWidget * widget, bool valid);
|
||||
|
||||
/// Qt5 changed setSectionMode to setSectionResizeMode
|
||||
/// These wrappers work for Qt4 and Qt5
|
||||
void setSectionResizeMode(QHeaderView * view,
|
||||
int logicalIndex, QHeaderView::ResizeMode mode);
|
||||
void setSectionResizeMode(QHeaderView * view,
|
||||
QHeaderView::ResizeMode mode);
|
||||
|
||||
} // namespace frontend
|
||||
|
||||
|
||||
|
@ -746,7 +746,11 @@ docstring FileName::fileContents(string const & encoding) const
|
||||
if (encoding.empty() || encoding == "UTF-8")
|
||||
s = QString::fromUtf8(contents.data());
|
||||
else if (encoding == "ascii")
|
||||
#if (QT_VERSION < 0x050000)
|
||||
s = QString::fromAscii(contents.data());
|
||||
#else
|
||||
s = QString::fromLatin1(contents.data());
|
||||
#endif
|
||||
else if (encoding == "local8bit")
|
||||
s = QString::fromLocal8Bit(contents.data());
|
||||
else if (encoding == "latin1")
|
||||
|
@ -381,6 +381,9 @@ FileName const get_document_dir(FileName const & home_dir)
|
||||
(void)home_dir; // Silence warning about unused variable.
|
||||
os::GetFolderPath win32_folder_path;
|
||||
return FileName(win32_folder_path(os::GetFolderPath::PERSONAL));
|
||||
#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
|
||||
(void)home_dir; // Silence warning about unused variable.
|
||||
return FileName(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)));
|
||||
#elif defined (USE_MACOSX_PACKAGING)
|
||||
(void)home_dir; // Silence warning about unused variable.
|
||||
return FileName(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)));
|
||||
@ -647,6 +650,10 @@ FileName const get_default_user_support_dir(FileName const & home_dir)
|
||||
os::GetFolderPath win32_folder_path;
|
||||
return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE));
|
||||
|
||||
#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
|
||||
(void)home_dir; // Silence warning about unused variable.
|
||||
return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DataLocation)), PACKAGE));
|
||||
|
||||
#elif defined (USE_MACOSX_PACKAGING)
|
||||
(void)home_dir; // Silence warning about unused variable.
|
||||
return FileName(addPath(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), PACKAGE));
|
||||
|
Loading…
Reference in New Issue
Block a user