Commit 55fa8d51 authored by Atsuhito Kohda's avatar Atsuhito Kohda

Imported Upstream version 0.5~svn1302

parent 211ec79e
......@@ -25,7 +25,7 @@ if( NOT WIN32 )
find_package(PkgConfig)
pkg_check_modules(POPPLER_PKG QUIET poppler)
pkg_check_modules(POPPLER_QT4_PKG QUIET poppler-qt4)
pkg_check_modules(POPPLER_QT_PKG QUIET poppler-qt${QT_VERSION_MAJOR})
endif( NOT WIN32 )
# Check for Poppler XPDF headers (optional)
......@@ -40,15 +40,10 @@ FIND_PATH(POPPLER_XPDF_INCLUDE_DIR NAMES poppler-config.h
)
IF( NOT(POPPLER_XPDF_INCLUDE_DIR) )
MESSAGE( STATUS "Could not find poppler-config.h, disabling support for Xpdf headers." )
SET( POPPLER_HAS_XPDF false )
ELSE( NOT(POPPLER_XPDF_INCLUDE_DIR) )
SET( POPPLER_HAS_XPDF true )
ENDIF( NOT(POPPLER_XPDF_INCLUDE_DIR) )
# Find libpoppler, libpoppler-qt4 and associated header files (Required)
......@@ -77,22 +72,21 @@ ELSE ()
ENDIF ()
FIND_PATH(POPPLER_QT4_INCLUDE_DIR NAMES poppler-qt4.h poppler-link.h
FIND_PATH(POPPLER_QT_INCLUDE_DIR NAMES poppler-qt${QT_VERSION_MAJOR}.h poppler-link.h
PATHS
/usr/local/include
/usr/include
HINTS
${POPPLER_QT4_PKG_INCLUDE_DIRS} # Generated by pkg-config
${POPPLER_QT_PKG_INCLUDE_DIRS} # Generated by pkg-config
PATH_SUFFIXES
poppler
qt4
poppler/qt4
qt${QT_VERSION_MAJOR}
poppler/qt${QT_VERSION_MAJOR}
)
IF ( NOT(POPPLER_QT4_INCLUDE_DIR) )
MESSAGE(STATUS "Could not find Poppler-Qt4 headers." )
IF ( NOT(POPPLER_QT_INCLUDE_DIR) )
MESSAGE(STATUS "Could not find Poppler-Qt${QT_VERSION_MAJOR} headers." )
ENDIF ()
FIND_LIBRARY(POPPLER_QT4_LIBRARIES NAMES poppler-qt4 ${POPPLER_QT4_PKG_LIBRARIES}
FIND_LIBRARY(POPPLER_QT_LIBRARIES NAMES poppler-qt${QT_VERSION_MAJOR} ${POPPLER_QT_PKG_LIBRARIES}
PATHS
/usr/local
/usr
......@@ -102,17 +96,17 @@ FIND_LIBRARY(POPPLER_QT4_LIBRARIES NAMES poppler-qt4 ${POPPLER_QT4_PKG_LIBRARIES
lib64
lib
)
MARK_AS_ADVANCED(POPPLER_QT4_LIBRARIES)
IF ( NOT(POPPLER_QT4_LIBRARIES) )
MESSAGE(STATUS "Could not find libpoppler-qt4." )
MARK_AS_ADVANCED(POPPLER_QT_LIBRARIES)
IF ( NOT(POPPLER_QT_LIBRARIES) )
MESSAGE(STATUS "Could not find libpoppler-qt${QT_VERSION_MAJOR}." )
ENDIF ()
LIST(APPEND POPPLER_LIBRARIES ${POPPLER_QT4_LIBRARIES})
LIST(INSERT POPPLER_LIBRARIES 0 ${POPPLER_QT_LIBRARIES})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Poppler DEFAULT_MSG POPPLER_LIBRARIES POPPLER_QT4_INCLUDE_DIR )
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Poppler DEFAULT_MSG POPPLER_LIBRARIES POPPLER_QT_INCLUDE_DIR )
# show the POPPLER_(XPDF/QT4)_INCLUDE_DIR and POPPLER_LIBRARIES variables only in the advanced view
MARK_AS_ADVANCED(POPPLER_XPDF_INCLUDE_DIR POPPLER_QT4_INCLUDE_DIR POPPLER_LIBRARIES)
MARK_AS_ADVANCED(POPPLER_XPDF_INCLUDE_DIR POPPLER_QT_INCLUDE_DIR POPPLER_LIBRARIES)
......@@ -93,6 +93,17 @@ STRING(REGEX MATCH "([0-9]+)" TeXworks_SVN_REV ${TeXworks_SVN_REV})
SET(TW_BUILD_ID "personal" CACHE STRING "A distribution-specific identifier for TeXworks")
# Build shared libs by default
IF ( NOT DEFINED BUILD_SHARED_LIBS )
SET(BUILD_SHARED_LIBS ON)
ENDIF ()
OPTION(BUILD_SHARED_LIBS "Build shared libraries?" ${BUILD_SHARED_LIBS})
MARK_AS_ADVANCED(BUILD_SHARED_LIBS)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} CACHE PATH "Path to place libraries in")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} CACHE PATH "Path to place programs in")
MARK_AS_ADVANCED(CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_RUNTIME_OUTPUT_DIRECTORY)
# On UNIX, CMake installs to `/usr/local` by default. However, Mac users
# will probably find `/Applications` a more convenient default.
IF( APPLE AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local" )
......@@ -106,7 +117,7 @@ ENDIF ()
# Options controlling the creation of scripting language plugins.
OPTION(WITH_LUA "Build TeXworks Lua plugin?" ON)
OPTION(WITH_PYTHON "Build TeXworks Python plugin?" ON)
OPTION(WITH_PYTHON "Build TeXworks Python plugin?" OFF)
# On OS X we default to linking against the Python libraries provided by Apple
# even if other Pythons are available. This helps when building
......@@ -116,6 +127,23 @@ IF ( APPLE )
OPTION(USE_SYSTEM_PYTHON "Link against Python Framework distributed with OS X?" ON)
ENDIF ()
IF (UNIX AND NOT APPLE)
SET(TeXworks_HELP_DIR share/doc/texworks-help CACHE PATH "Path where TeXworks looks for help files")
SET(TeXworks_DIC_DIR /usr/share/myspell/dicts CACHE PATH "Path where TeXworks looks for spellchecking dictionaries")
SET(TeXworks_DOCS_DIR share/doc/texworks CACHE PATH "Path in which documentation files are installed")
SET(TeXworks_ICON_DIR share/pixmaps CACHE PATH "Path in which icons are installed")
SET(TeXworks_MAN_DIR share/man/man1 CACHE PATH "Path in which manpages are installed")
SET(TeXworks_DESKTOP_DIR share/applications CACHE PATH "Path in which .desktop files are installed")
MARK_AS_ADVANCED(TeXworks_HELP_DIR)
MARK_AS_ADVANCED(TeXworks_DIC_DIR)
MARK_AS_ADVANCED(TeXworks_DOCS_DIR)
MARK_AS_ADVANCED(TeXworks_ICON_DIR)
MARK_AS_ADVANCED(TeXworks_MAN_DIR)
MARK_AS_ADVANCED(TeXworks_DESKTOP_DIR)
IF (EXISTS ${TeXworks_SOURCE_DIR}/manual/)
INSTALL(DIRECTORY ${TeXworks_SOURCE_DIR}/manual/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${TeXworks_HELP_DIR}/ OPTIONAL)
ENDIF()
ENDIF()
# Dependency Configuration
# ========================
......@@ -131,7 +159,6 @@ SET (QT_COMPONENTS
QtUiTools
QtScript
QtScriptTools
QtXML
)
IF ( UNIX AND NOT APPLE )
......@@ -159,7 +186,7 @@ ENDIF ()
SET(TeXworks_INCLUDE_DIRS
${QT_INCLUDE_DIR}
${HUNSPELL_INCLUDE_DIR}
${POPPLER_QT4_INCLUDE_DIR}
${POPPLER_QT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
)
IF ( POPPLER_NEEDS_FONTCONFIG )
......@@ -199,6 +226,15 @@ IF ( WITH_PYTHON )
ENDIF ()
ENDIF()
IF ( LUA51_FOUND AND WITH_LUA AND NOT ${BUILD_SHARED_LIBS})
ADD_DEFINITIONS(-DQT_STATICPLUGIN -DSTATIC_LUA_SCRIPTING_PLUGIN)
ENDIF ()
IF ( PYTHONLIBS_FOUND AND WITH_PYTHON AND NOT ${BUILD_SHARED_LIBS})
ADD_DEFINITIONS(-DQT_STATICPLUGIN -DSTATIC_PYTHON_SCRIPTING_PLUGIN)
ENDIF ()
# Update Header Templates
# -----------------------
......@@ -227,10 +263,6 @@ ADD_SUBDIRECTORY(src)
# Build Plugins
# -------------
# Set the plugin installation path. This is a good default for UNIX-like
# systems, but is not appropriate for Windows.
SET(TeXworks_PLUGIN_DIR lib)
# On OS X, the plugins should live inside the application bundle.
IF ( APPLE )
SET(TeXworks_PLUGIN_DIR ${PROJECT_NAME}.app/Contents/PlugIns)
......@@ -239,15 +271,20 @@ IF ( APPLE )
# freak out about this.
SET(CMAKE_MODULE_LINKER_FLAGS
"${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS} -undefined dynamic_lookup")
ELSE ()
# Set the plugin installation path. This is a good default for UNIX-like
# systems, but is not appropriate for Windows.
SET(TeXworks_PLUGIN_DIR lib/texworks CACHE PATH "Path where TeXworks looks for plugins")
MARK_AS_ADVANCED(TeXworks_PLUGIN_DIR)
ENDIF ()
# Build scripting language plugins if the required libraries are available.
IF ( LUA51_FOUND )
IF ( LUA51_FOUND AND WITH_LUA )
ADD_SUBDIRECTORY(${TeXworks_SOURCE_DIR}/plugins-src/TWLuaPlugin)
ENDIF ()
IF ( PYTHONLIBS_FOUND )
IF ( PYTHONLIBS_FOUND AND WITH_PYTHON )
ADD_SUBDIRECTORY(${TeXworks_SOURCE_DIR}/plugins-src/TWPythonPlugin)
ENDIF ()
......@@ -346,6 +383,7 @@ MESSAGE("TeXworks has been configured:\n")
CONFIG_INFO("Version" ${TeXworks_VERSION})
CONFIG_INFO("SVN Revision" ${TeXworks_SVN_REV})
CONFIG_INFO("Build ID" ${TW_BUILD_ID})
CONFIG_INFO("Qt version" ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
CONFIG_INFO("Compiler optimization" ${CMAKE_BUILD_TYPE})
MESSAGE("")
......
......@@ -68,7 +68,7 @@ unix:!macx {
isEmpty(TW_BUILD_ID):TW_BUILD_ID = personal
QMAKE_CXXFLAGS += -DTW_BUILD_ID=$$TW_BUILD_ID
QT += xml script scripttools
QT += script scripttools
CONFIG += rtti uitools
unix {
......@@ -146,13 +146,13 @@ win32 { # paths here are specific to my setup
RC_FILE = res/TeXworks.rc
# for the Windows build, we use static plugins:
QMAKE_CXXFLAGS += -DSTATIC_SCRIPTING_PLUGINS
QMAKE_CXXFLAGS += -DSTATIC_LUA_SCRIPTING_PLUGIN
LIBS += -Lplugins-src/TWLuaPlugin/release -lTWLuaPlugin
LIBS += -llua
LIBS += -Lplugins-src/TWPythonPlugin/release -lTWPythonPlugin
LIBS += -Lc:/Python26/libs -lpython26
# QMAKE_CXXFLAGS += -DSTATIC_PYTHON_SCRIPTING_PLUGIN
# LIBS += -Lplugins-src/TWPythonPlugin/release -lTWPythonPlugin
# LIBS += -Lc:/Python26/libs -lpython26
}
......
......@@ -7,30 +7,31 @@ svn update
# get the current revision number
REV=`LANG=C svn info | fgrep Revision: | cut -d ' ' -f 2`
if [ `svn status | grep -c "^[^?]"` == 0 ]; then
# make a new SvnRev.h file
echo "#define SVN_REVISION $REV" > src/SvnRev.h.new
echo "#define SVN_REVISION_STR \"$REV\"" >> src/SvnRev.h.new
# and check if it matches the existing one
diff src/SvnRev.h.new src/SvnRev.h > /dev/null
if [ $? == 0 ]; then
rm src/SvnRev.h.new
echo "revision is current"
fi
else
MODIFIED=0
if [ `svn status | grep -c "^[^?]"` -ne 0 ]; then
# if we have local modifications, we'll bump the revision number
REV=$((1+REV))
echo "#define SVN_REVISION $REV" > src/SvnRev.h.new
echo "#define SVN_REVISION_STR \"$REV\"" >> src/SvnRev.h.new
MODIFIED=1
fi
# is there a new revision file?
if [ -e src/SvnRev.h.new ]; then
# make a new SvnRev.h file
echo "#define SVN_REVISION $REV" > src/SvnRev.h.new
echo "#define SVN_REVISION_STR \"$REV\"" >> src/SvnRev.h.new
# and check if it matches the existing one
diff src/SvnRev.h.new src/SvnRev.h > /dev/null
if [ $? == 0 ]; then
rm src/SvnRev.h.new
else
mv src/SvnRev.h.new src/SvnRev.h
VER=`fgrep TEXWORKS_VERSION src/TWVersion.h | cut -d '"' -f 2`
sed -e "s/@VER@/$VER/;s/@REV@/$REV/;" <TeXworks.plist.in >TeXworks.plist
cp TeXworks.plist Info.plist
echo "revision updated"
svn status # show status, as a reminder to commit the change(s)
echo "updating files...done"
fi
if [ $MODIFIED -eq 1 ]; then
echo "There are local modifications"
else
echo "revision is current"
fi
......@@ -13,15 +13,21 @@ LINK_DIRECTORIES(${QT_LIBRARY_DIR})
# already been mocced during the build of the main program seems redundant, but
# I'm not wise enough in the ways of Qt and CMake to figure out a good
# alternative._
QT4_WRAP_CPP(LUA_PLUGIN_MOC ${TeXworks_SCRIPT_API_H} TWLuaPlugin.h)
IF (${QT_VERSION_MAJOR} EQUAL 5)
QT5_WRAP_CPP(LUA_PLUGIN_MOC ${TeXworks_SCRIPT_API_H} TWLuaPlugin.h)
ELSE()
QT4_WRAP_CPP(LUA_PLUGIN_MOC ${TeXworks_SCRIPT_API_H} TWLuaPlugin.h)
ENDIF()
ADD_LIBRARY(TWLuaPlugin MODULE
ADD_LIBRARY(TWLuaPlugin
TWLuaPlugin.cpp
${TeXworks_SCRIPT_API}
${LUA_PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES(TWLuaPlugin ${QT_LIBRARIES} ${LUA_LIBRARIES})
INSTALL(TARGETS TWLuaPlugin
LIBRARY DESTINATION ${TeXworks_PLUGIN_DIR}
)
IF (${BUILD_SHARED_LIBS})
INSTALL(TARGETS TWLuaPlugin
LIBRARY DESTINATION ${TeXworks_PLUGIN_DIR}
)
ENDIF()
......@@ -48,7 +48,9 @@ TWScript* TWLuaPlugin::newScript(const QString& fileName)
return new LuaScript(this, fileName);
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(TWLuaPlugin, TWLuaPlugin)
#endif
bool LuaScript::execute(TWScriptAPI *tw) const
......@@ -189,8 +191,10 @@ int LuaScript::pushVariant(lua_State * L, const QVariant & v, const bool throwEr
return 1;
case QMetaType::QObjectStar:
return LuaScript::pushQObject(L, v.value<QObject*>(), throwError);
#if QT_VERSION < 0x050000
case QMetaType::QWidgetStar:
return LuaScript::pushQObject(L, qobject_cast<QObject*>(v.value<QWidget*>()), throwError);
#endif
default:
// Don't throw errors if we are not in protected mode in lua, i.e.
// if the call to this function originated from C code, not in response
......
......@@ -35,7 +35,10 @@ class TWLuaPlugin : public QObject, public TWScriptLanguageInterface
{
Q_OBJECT
Q_INTERFACES(TWScriptLanguageInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.tug.texworks.ScriptPlugins.LuaPlugin")
#endif
public:
/** \brief Constructor
*
......
......@@ -13,15 +13,21 @@ LINK_DIRECTORIES(${QT_LIBRARY_DIR})
# already been mocced during the build of the main program seems redundant, but
# I'm not wise enough in the ways of Qt and CMake to figure out an
# alternative._
QT4_WRAP_CPP(PYTHON_PLUGIN_MOC ${TeXworks_SCRIPT_API_H} TWPythonPlugin.h)
IF (${QT_VERSION_MAJOR} EQUAL 5)
QT5_WRAP_CPP(PYTHON_PLUGIN_MOC ${TeXworks_SCRIPT_API_H} TWPythonPlugin.h)
ELSE()
QT4_WRAP_CPP(PYTHON_PLUGIN_MOC ${TeXworks_SCRIPT_API_H} TWPythonPlugin.h)
ENDIF()
ADD_LIBRARY(TWPythonPlugin MODULE
ADD_LIBRARY(TWPythonPlugin
TWPythonPlugin.cpp
${TeXworks_SCRIPT_API}
${PYTHON_PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES(TWPythonPlugin ${QT_LIBRARIES} ${PYTHON_LIBRARIES})
INSTALL(TARGETS TWPythonPlugin
LIBRARY DESTINATION ${TeXworks_PLUGIN_DIR}
)
IF (${BUILD_SHARED_LIBS})
INSTALL(TARGETS TWPythonPlugin
LIBRARY DESTINATION ${TeXworks_PLUGIN_DIR}
)
ENDIF()
......@@ -100,7 +100,9 @@ TWScript* TWPythonPlugin::newScript(const QString& fileName)
return new PythonScript(this, fileName);
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(TWPythonPlugin, TWPythonPlugin)
#endif
bool PythonScript::execute(TWScriptAPI *tw) const
......@@ -446,8 +448,10 @@ PyObject * PythonScript::VariantToPython(const QVariant & v)
return pyDict;
case QMetaType::QObjectStar:
return PythonScript::QObjectToPython(v.value<QObject*>());
#if QT_VERSION < 0x050000
case QMetaType::QWidgetStar:
return PythonScript::QObjectToPython(qobject_cast<QObject*>(v.value<QWidget*>()));
#endif
default:
PyErr_Format(PyExc_TypeError, qPrintable(tr("the type %s is currently not supported")), v.typeName());
return NULL;
......
......@@ -39,6 +39,9 @@ class TWPythonPlugin : public QObject, public TWScriptLanguageInterface
{
Q_OBJECT
Q_INTERFACES(TWScriptLanguageInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.tug.texworks.ScriptPlugins.PythonPlugin")
#endif
public:
/** \brief Constructor
......
......@@ -2,8 +2,8 @@
// Title: Errors, warnings, badboxes
// Description: Looks for errors, warnings or badboxes in the LaTeX terminal output
// Author: Jonathan Kew, Stefan Löffler, Antonio Macrì, Henrik Skov Midtiby
// Version: 0.8.5
// Date: 2012-10-20
// Version: 0.8.6
// Date: 2013-07-05
// Script-Type: hook
// Hook: AfterTypeset
......@@ -150,6 +150,27 @@ function LogParser()
return new Result(Severity.BadBox, f, 0, m[0]);
}
},
{
// This pattern recognizes tight/loose boxes in paragraphs with context given on one, two or more lines.
Regex: new RegExp("^((?:Tight|Loose) \\\\hbox\\s*\\([^)]+\\) in paragraph at lines (\\d+)--\\d+\n)((?:.{" + max_print_line + "}\n)*)(.*)"),
Callback: function(m, f) {
return new Result(Severity.BadBox, f, m[2], (m[1] + m[3].replace(/\n/g, '') + m[4]).trimRight());
}
},
{
// This pattern recognizes tight/loose boxes without context, but with line numbers
Regex: new RegExp("^(?:Tight|Loose) \\\\[hv]box\\s*\\([^)]+\\) (?:detected at line (\\d+)|in alignment at lines (\\d+)--\\d+)\n"),
Callback: function(m, f) {
return new Result(Severity.BadBox, f, m[1] || m[2], m[0].trimRight());
}
},
{
// This pattern recognizes tight/loose boxes without context and line numbers
Regex: new RegExp("^(?:Tight|Loose) \\\\[hv]box\\s*\\([^)]+\\) has occurred while \\\\output is active\\b"),
Callback: function(m, f) {
return new Result(Severity.BadBox, f, 0, m[0]);
}
},
{
// \show and \showthe
Regex: new RegExp("^>\\s(.+(?:\\.|=(?:\\\\long\\s)?macro:)\n(?:.*\n)*?l\\.(\\d+)\\s.*)\n"),
......
......@@ -64,6 +64,23 @@ INCLUDE_DIRECTORIES(${TeXworks_INCLUDE_DIRS})
LINK_DIRECTORIES(${TeXworks_LIB_DIRS})
ADD_DEFINITIONS(-DTW_BUILD_ID=${TW_BUILD_ID})
IF (UNIX AND NOT APPLE)
IF (IS_ABSOLUTE ${TeXworks_HELP_DIR})
ADD_DEFINITIONS(-DTW_HELPPATH="${TeXworks_HELP_DIR}")
ELSE ()
ADD_DEFINITIONS(-DTW_HELPPATH="${CMAKE_INSTALL_PREFIX}/${TeXworks_HELP_DIR}")
ENDIF ()
IF (IS_ABSOLUTE ${TeXworks_PLUGIN_DIR})
ADD_DEFINITIONS(-DTW_PLUGINPATH="${TeXworks_PLUGIN_DIR}")
ELSE ()
ADD_DEFINITIONS(-DTW_PLUGINPATH="${CMAKE_INSTALL_PREFIX}/${TeXworks_PLUGIN_DIR}")
ENDIF ()
IF (IS_ABSOLUTE ${TeXworks_DIC_DIR})
ADD_DEFINITIONS(-DTW_DICPATH="${TeXworks_DIC_DIR}")
ELSE ()
ADD_DEFINITIONS(-DTW_DICPATH="${CMAKE_INSTALL_PREFIX}/${TeXworks_DIC_DIR}")
ENDIF ()
ENDIF ()
# Poppler supports XPDF API calls?
IF (POPPLER_HAS_XPDF)
......@@ -75,14 +92,25 @@ ENDIF ()
# Qt-Specific Source Code Processing
# ----------------------------------
# Run moc on header files.
QT4_WRAP_CPP(TEXWORKS_GEN_MOC ${TEXWORKS_MOC_HDRS})
# Run uic on user interface files.
QT4_WRAP_UI(TEXWORKS_GEN_UI ${TEXWORKS_UIS})
# Run rcc on reasource files.
QT4_ADD_RESOURCES(TEXWORKS_GEN_RCS ${TEXWORKS_RCS})
# Prep language translations.
QT4_ADD_TRANSLATION(TEXWORKS_GEN_TRANS ${TEXWORKS_TRANS})
IF (${QT_VERSION_MAJOR} EQUAL 5)
# Run moc on header files.
QT5_WRAP_CPP(TEXWORKS_GEN_MOC ${TEXWORKS_MOC_HDRS})
# Run uic on user interface files.
QT5_WRAP_UI(TEXWORKS_GEN_UI ${TEXWORKS_UIS})
# Run rcc on reasource files.
QT5_ADD_RESOURCES(TEXWORKS_GEN_RCS ${TEXWORKS_RCS})
# Prep language translations.
QT5_ADD_TRANSLATION(TEXWORKS_GEN_TRANS ${TEXWORKS_TRANS})
ELSE()
# Run moc on header files.
QT4_WRAP_CPP(TEXWORKS_GEN_MOC ${TEXWORKS_MOC_HDRS})
# Run uic on user interface files.
QT4_WRAP_UI(TEXWORKS_GEN_UI ${TEXWORKS_UIS})
# Run rcc on reasource files.
QT4_ADD_RESOURCES(TEXWORKS_GEN_RCS ${TEXWORKS_RCS})
# Prep language translations.
QT4_ADD_TRANSLATION(TEXWORKS_GEN_TRANS ${TEXWORKS_TRANS})
ENDIF()
IF ( APPLE OR NOT UNIX )
SET(EXE_NAME TeXworks)
......@@ -93,6 +121,15 @@ ENDIF ( APPLE OR NOT UNIX )
# Compilation
# -----------
IF (NOT ${BUILD_SHARED_LIBS})
IF (WITH_LUA)
LIST(APPEND TeXworks_LIBS TWLuaPlugin)
ENDIF()
IF (WITH_PYTHON)
LIST(APPEND TeXworks_LIBS TWPythonPlugin)
ENDIF()
ENDIF()
# Build the executible.
ADD_EXECUTABLE( ${EXE_NAME} ${GUI_TYPE}
${TEXWORKS_SRCS}
......@@ -118,6 +155,9 @@ IF (APPLE)
)
ENDIF ()
IF (${QT_VERSION_MAJOR} EQUAL 5 AND UNIX)
SET_TARGET_PROPERTIES(${EXE_NAME} PROPERTIES COMPILE_FLAGS -fPIC)
ENDIF ()
# Installation
# ------------
......@@ -126,6 +166,17 @@ INSTALL( TARGETS ${EXE_NAME}
BUNDLE DESTINATION . COMPONENT
)
IF ( UNIX AND NOT APPLE )
INSTALL(FILES ${TeXworks_SOURCE_DIR}/res/images/TeXworks.png DESTINATION ${CMAKE_INSTALL_PREFIX}/${TeXworks_ICON_DIR})
INSTALL(FILES
${TeXworks_SOURCE_DIR}/COPYING
${TeXworks_SOURCE_DIR}/README
${TeXworks_SOURCE_DIR}/NEWS
DESTINATION ${CMAKE_INSTALL_PREFIX}/${TeXworks_DOCS_DIR})
INSTALL(FILES ${TeXworks_SOURCE_DIR}/man/texworks.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/${TeXworks_MAN_DIR})
INSTALL(FILES ${TeXworks_SOURCE_DIR}/texworks.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/${TeXworks_DESKTOP_DIR})
ENDIF ( UNIX AND NOT APPLE )
# On OS X, ensure there is always a `qt.conf` file as all hell will break loose
# if one isn't there. This may need to be customized for use on non-Apple
# systems.
......@@ -139,7 +190,7 @@ IF ( APPLE )
INSTALL( CODE
"
FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DIR}/qt.conf\"
FILE(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${QTCONF_DIR}/qt.conf\"
\"${QTCONF_CONTENTS}\"
)
"
......
......@@ -227,7 +227,7 @@ void CompletingEdit::mouseMoveEvent(QMouseEvent *e)
// need to make sure that the source text is removed
// (inserting the text in the target has already
// been completed at this point)
bool insideWindow = (drag->target() && (this == drag->target() || this->isAncestorOf(drag->target())));
bool insideWindow = (drag->target() && (this == drag->target() || this->isAncestorOf(qobject_cast<QWidget*>(drag->target()))));
bool insideSelection = (insideWindow && droppedOffset >= sourceStart && droppedOffset <= sourceEnd);
if (insideSelection) {
// The text was dropped into the same window at
......
......@@ -25,6 +25,8 @@
#include <QTextEdit>
#include <QHash>
#include <QTimer>
#include <QDrag>
#include <QMimeData>
#include <hunspell.h>
......
......@@ -542,8 +542,13 @@ void SearchResults::presentResults(const QString& searchText,
}
resultsWindow->table->setHorizontalHeaderLabels(QStringList() << tr("File") << tr("Line") << tr("Start") << tr("End") << tr("Text"));
#if QT_VERSION >= 0x050000
resultsWindow->table->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
resultsWindow->table->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#else
resultsWindow->table->horizontalHeader()->setResizeMode(4, QHeaderView::Stretch);
resultsWindow->table->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#endif
resultsWindow->table->verticalHeader()->hide();
resultsWindow->table->setColumnHidden(2, true);
resultsWindow->table->setColumnHidden(3, true);
......
......@@ -27,7 +27,11 @@
#include <QListWidget>
#include <QScrollArea>
#if QT_VERSION < 0x050000
#include "poppler-qt4.h"
#else
#include "poppler-qt5.h"
#endif
class PDFDocument;
class QListWidget;
......
......@@ -231,6 +231,12 @@ void PDFWidget::setDocument(Poppler::Document *doc)
void PDFWidget::windowResized()
{
// the fitting functions below may trigger resize events (e.g., if scroll
// bars are shown/hidden as a result of resizing the page image). To avoid
// infinite loops of resize events, disconnect the event here and reconnect
// it in the end.
disconnect(parent()->parent(), SIGNAL(resized()), this, SLOT(windowResized()));
switch (scaleOption) {
case kFixedMag:
break;
......@@ -241,7 +247,10 @@ void PDFWidget::windowResized()
fitWindow(true);
break;
}
// Ensure all resizing is finished before reconnecting the resize event.
update();
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
connect(parent()->parent(), SIGNAL(resized()), this, SLOT(windowResized()));
}
void PDFWidget::paintEvent(QPaintEvent *event)
......@@ -482,7 +491,7 @@ void PDFWidget::doLink(const Poppler::Link *link)
{
const Poppler::LinkBrowse *browse = dynamic_cast<const Poppler::LinkBrowse*>(link);
Q_ASSERT(browse != NULL);
QUrl url = QUrl::fromEncoded(browse->url().toAscii());
QUrl url = QUrl::fromEncoded(browse->url().toLatin1());
if (url.scheme() == "file") {
PDFDocument *doc = qobject_cast<PDFDocument*>(window());
if (doc) {
......@@ -925,9 +934,15 @@ void PDFWidget::doPageDialog()
return;
bool ok;
setCursor(Qt::ArrowCursor);
#if QT_VERSION >= 0x050000
int pageNo = QInputDialog::getInt(this, tr("Go to Page"),
tr("Page number:"), pageIndex + 1,
1, document->numPages(), 1, &ok);
#else
int pageNo = QInputDialog::getInteger(this, tr("Go to Page"),
tr("Page number:"), pageIndex + 1,
1, document->numPages(), 1, &ok);
#endif
if (ok)
goToPage(pageNo - 1);
}
......@@ -1773,7 +1788,14 @@ void PDFDocument::doFindAgain(bool newSearch /* = false */)
for (pageIdx = firstPage; pageIdx != lastPage; pageIdx += deltaPage) {
page = document->page(pageIdx);
#if QT_VERSION >= 0x050000
double left, top, bottom, right;
lastSearchResult.selRect.getCoords(&left, &top, &right, &bottom);
if (page->search(searchText, left, top, right, bottom, searchDir, searchMode)) {
lastSearchResult.selRect.setCoords(left, top, right, bottom);
#else
if (page->search(searchText, lastSearchResult.selRect, searchDir, searchMode)) {
#endif
lastSearchResult.doc = this;
lastSearchResult.pageIdx = pageIdx;
QPainterPath p;
......
......@@ -35,7 +35,11 @@
#include "TWApp.h"
#include "FindDialog.h"
#if QT_VERSION < 0x050000
#include "poppler-qt4.h"
#else
#include "poppler-qt5.h"
#endif
#include "synctex_parser.h"
#include "ui_PDFDocument.h"
......
......@@ -672,7 +672,7 @@ QDialog::DialogCode PrefsDialog::doPrefsDialog(QWidget *parent)
font = QFont(dlg.editorFont->currentText());
font.setPointSize(dlg.fontSize->value());
settings.setValue("font", font.toString());
TWApp::instance()->setDefaultCodec(QTextCodec::codecForName(dlg.encoding->currentText().toAscii()));
TWApp::instance()->setDefaultCodec(QTextCodec::codecForName(dlg.encoding->currentText().toLatin1()));
if (dlg.language->currentIndex() >= 0) {
QVariant data = dlg.language->itemData(dlg.language->currentIndex());
if (data.isValid())
......
#define SVN_REVISION 1286
#define SVN_REVISION_STR "1286"
#define SVN_REVISION 1300
#define SVN_REVISION_STR "1300"
......@@ -186,7 +186,7 @@ void TWApp::init()
recentFilesLimit = settings.value("maxRecentFiles", kDefaultMaxRecentFiles).toInt();
QString codecName = settings.value("defaultEncoding", "UTF-8").toString();
defaultCodec = QTextCodec::codecForName(codecName.toAscii());
defaultCodec = QTextCodec::codecForName(codecName.toLatin1());
if (defaultCodec == NULL)
defaultCodec = QTextCodec::codecForName("UTF-8");
......@@ -1188,7 +1188,6 @@ void TWApp::createMessageTarget(QWidget* aWindow)
}
#endif
#ifdef Q_WS_X11
void TWApp::bringToFront()
{
foreach (QWidget* widget, topLevelWidgets()) {
......@@ -1199,7 +1198,6 @@ void TWApp::bringToFront()
}
}
}
#endif
QList<QVariant> TWApp::getOpenWindows() const
{
......@@ -1225,9 +1223,11 @@ void TWApp::setGlobal(const QString& key, const QVariant& val)
case QMetaType::QObjectStar:
connect(v.value<QObject*>(), SIGNAL(destroyed(QObject*)), this, SLOT(globalDestroyed(QObject*)));
break;
#if QT_VERSION < 0x050000
case QMetaType::QWidgetStar:
connect((QWidget*)v.data(), SIGNAL(destroyed(QObject*)), this, SLOT(globalDestroyed(QObject*)));
break;
#endif
default: break;
}
m_globals[key] = v;
......@@ -1245,12 +1245,14 @@ void TWApp::globalDestroyed(QObject * obj)
else
++i;
break;
#if QT_VERSION < 0x050000
case QMetaType::QWidgetStar:
if (i.value().value<QWidget*>() == obj)
i = m_globals.erase(i);
else
++i;
break;
#endif
default:
++i;
break;
......
......@@ -121,9 +121,7 @@ public:
static QString GetWindowsVersionString();