Skip to content

Commit

Permalink
[Qt] Fix qt4 build
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Apr 27, 2016
1 parent fd4060c commit 0607643
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ ELSEIF("${INTERFACE_TYPE}" STREQUAL "qt4")
FIND_PACKAGE(Qt4 REQUIRED)
PKG_CHECK_MODULES(QTSPELL REQUIRED QtSpell-qt4>=0.8.0)
PKG_CHECK_MODULES(POPPLER REQUIRED poppler-qt4)
INCLUDE_DIRECTORIES(${QTSPELL_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS})
SET(gimagereader_LIBS ${QTSPELL_LDFLAGS} ${POPPLER_LDFLAGS})
PKG_CHECK_MODULES(QJSON REQUIRED QJson)
INCLUDE_DIRECTORIES(${QTSPELL_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS} ${QJSON_INCLUDE_DIRS})
SET(gimagereader_LIBS ${QTSPELL_LDFLAGS} ${POPPLER_LDFLAGS} ${QJSON_LDFLAGS})
SET(srcdir "qt")
ELSEIF("${INTERFACE_TYPE}" STREQUAL "qt5")
SET(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -215,7 +216,7 @@ TARGET_LINK_LIBRARIES(gimagereader
SET_TARGET_PROPERTIES(gimagereader PROPERTIES COMPILE_FLAGS "-fopenmp")
SET_TARGET_PROPERTIES(gimagereader PROPERTIES OUTPUT_NAME gimagereader-${INTERFACE_TYPE})
IF("${INTERFACE_TYPE}" STREQUAL "qt4")
QT4_USE_MODULES(gimagereader Core Gui Network DBus Xml PrintSupport)
QT4_USE_MODULES(gimagereader Core Gui Network DBus Xml)
ADD_DEPENDENCIES(gimagereader gettextizeui)
ELSEIF("${INTERFACE_TYPE}" STREQUAL "qt5")
QT5_USE_MODULES(gimagereader Widgets Network DBus Xml PrintSupport)
Expand Down
4 changes: 4 additions & 0 deletions qt/src/OutputEditorHOCR.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,11 @@ void OutputEditorHOCR::savePDF(bool overlay)
doc.setContent(item->data(0, SourceRole).toString());
int pageDpi = 0;
if(setCurrentSource(doc.firstChildElement("div"), &pageDpi)) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
printer.setPaperSize(QSizeF(bbox.width() / double(pageDpi), bbox.height() / double(pageDpi)), QPrinter::Inch);
#else
printer.setPageSize(QPageSize(QSizeF(bbox.width() / double(pageDpi), bbox.height() / double(pageDpi)), QPageSize::Inch));
#endif
printer.newPage();
if(i == 0) {
painter.begin(&printer);
Expand Down
20 changes: 19 additions & 1 deletion qt/src/TessdataManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
#include <QDialogButtonBox>
#include <QDir>
#include <QFile>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <qjson/parser.h>
#else
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#endif
#include <QLabel>
#include <QListWidget>
#include <QMessageBox>
Expand Down Expand Up @@ -88,17 +92,31 @@ bool TessdataManager::fetchLanguageList(QString& messages)
return false;
}

QList<QPair<QString,QString>> extraFiles;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QJson::Parser parser;
bool ok = false;
QVariantList json = parser.parse( data, &ok ).toList();
if(!ok) {
messages = _("Parsing error: %1").arg(parser.errorLine() + ": " + parser.errorString());
return false;
}
for(const QVariant& value : json) {
QVariantMap treeObj = value.toMap();
QString name = treeObj.value("name").toString();
QString url = treeObj.value("download_url").toString();
#else
QJsonParseError err;
QJsonDocument json = QJsonDocument::fromJson(data, &err);
if(json.isNull()) {
messages = _("Parsing error: %1").arg(err.errorString());
return false;
}
QList<QPair<QString,QString>> extraFiles;
for(const QJsonValue& value : json.array()) {
QJsonObject treeObj = value.toObject();
QString name = treeObj.find("name").value().toString();
QString url = treeObj.find("download_url").value().toString();
#endif
if(name.endsWith(".traineddata")) {
m_languageFiles[name.left(name.indexOf("."))].append({name,url});
} else {
Expand Down
1 change: 1 addition & 0 deletions qt/src/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QMimeData>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QSslConfiguration>
#include <QTextStream>
#include <QTimer>
#include <QUrl>
Expand Down

0 comments on commit 0607643

Please sign in to comment.