summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishesh Handa <me@vhanda.in>2014-08-13 09:16:28 (GMT)
committerVishesh Handa <me@vhanda.in>2014-08-13 09:16:28 (GMT)
commite4a4d400c35b3e41a60d490a7f56cd43c8707372 (patch)
tree2dcacd6975ad1fe7a86bee0a58cb72aa98880dca
parent7123b4d9d26feedb12caf326d50fd4b986a6ee97 (diff)
Port the poppler generator
-rw-r--r--core/document.cpp35
-rw-r--r--core/generator.cpp5
-rw-r--r--core/generator.h2
-rw-r--r--generators/CMakeLists.txt6
-rw-r--r--generators/poppler/CMakeLists.txt8
-rw-r--r--generators/poppler/generator_pdf.cpp19
-rw-r--r--part.cpp4
7 files changed, 44 insertions, 35 deletions
diff --git a/core/document.cpp b/core/document.cpp
index 053f87c..eab4050 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -815,21 +815,28 @@ bool DocumentPrivate::openRelativeFile( const QString & fileName )
Generator * DocumentPrivate::loadGeneratorLibrary( const KService::Ptr &service )
{
-#pragma message("KF5 FIXME DocumentPrivate::loadGeneratorLibrary is disabled")
-// KPluginFactory *factory = KPluginLoader( service->library() ).factory();
-// if ( !factory )
-// {
-// kWarning(OkularDebug).nospace() << "Invalid plugin factory for " << service->library() << "!";
-// return 0;
-// }
-// Generator * generator = factory->create< Okular::Generator >( service->pluginKeyword(), 0 );
+ KPluginFactory *factory = KPluginLoader( service->library() ).factory();
+ if ( !factory )
+ {
+ kWarning(OkularDebug).nospace() << "Invalid plugin factory for " << service->library() << "!";
+ return 0;
+ }
+
+ QObject* plugin = service->createInstance<QObject>();
+ // vHanda: qobject_cast seems to be failing. Not sure why!
+ Generator* generator = dynamic_cast< Okular::Generator* >(plugin);
+#pragma message("We're using dynamic_cast over here instead of qobject_cast")
+ // Generator * generator = factory->create< Okular::Generator >( service->pluginKeyword(), 0 );
+
// GeneratorInfo info( factory->componentData() );
-// info.generator = generator;
-// if ( info.data.isValid() && info.data.aboutData() )
-// info.catalogName = info.data.aboutData()->catalogName();
-// m_loadedGenerators.insert( service->name(), info );
-// return generator;
- return 0;
+ KComponentData data = KComponentData::mainComponent();
+ GeneratorInfo info( data );
+ info.generator = generator;
+ if ( info.data.isValid() && info.data.aboutData() )
+ info.catalogName = info.data.aboutData()->catalogName();
+ qDebug() << "JACK" << service->name();
+ m_loadedGenerators.insert( service->name(), info );
+ return generator;
}
void DocumentPrivate::loadAllGeneratorLibraries()
diff --git a/core/generator.cpp b/core/generator.cpp
index 1308921..451188e 100644
--- a/core/generator.cpp
+++ b/core/generator.cpp
@@ -157,8 +157,9 @@ QImage GeneratorPrivate::image( PixmapRequest * )
}
-Generator::Generator()
- : d_ptr( new GeneratorPrivate() )
+Generator::Generator(QObject* parent, const QVariantList&)
+ : QObject(parent)
+ , d_ptr( new GeneratorPrivate() )
{
d_ptr->q_ptr = this;
}
diff --git a/core/generator.h b/core/generator.h
index 3be8c9a..c8f1015 100644
--- a/core/generator.h
+++ b/core/generator.h
@@ -213,7 +213,7 @@ class OKULAR_EXPORT Generator : public QObject
/**
* Creates a new generator.
*/
- Generator();
+ Generator(QObject* parent = 0, const QVariantList& args = QVariantList());
/**
* Destroys the generator.
diff --git a/generators/CMakeLists.txt b/generators/CMakeLists.txt
index 9db8fcd..7c6c8e3 100644
--- a/generators/CMakeLists.txt
+++ b/generators/CMakeLists.txt
@@ -80,9 +80,9 @@ set_package_properties("libqmobipocket" PROPERTIES
# let's enable the generators properly configured
message("KF5 enable generators")
-#if(POPPLER_FOUND)
-# add_subdirectory(poppler)
-#endif(POPPLER_FOUND)
+if(POPPLER_FOUND)
+ add_subdirectory(poppler)
+endif(POPPLER_FOUND)
#if(LIBSPECTRE_FOUND)
# add_subdirectory(spectre)
diff --git a/generators/poppler/CMakeLists.txt b/generators/poppler/CMakeLists.txt
index 8d9b1f0..333d493 100644
--- a/generators/poppler/CMakeLists.txt
+++ b/generators/poppler/CMakeLists.txt
@@ -1,7 +1,7 @@
add_subdirectory( conf )
set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR})
-set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY})
+set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} Qt5::Xml)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
@@ -36,15 +36,15 @@ set(okularGenerator_poppler_PART_SRCS
synctex/synctex_parser_utils.c
)
-kde4_add_ui_files(okularGenerator_poppler_PART_SRCS
+ki18n_wrap_ui(okularGenerator_poppler_PART_SRCS
conf/pdfsettingswidget.ui
)
kconfig_add_kcfg_files(okularGenerator_poppler_PART_SRCS conf/pdfsettings.kcfgc )
-kde4_add_plugin(okularGenerator_poppler ${okularGenerator_poppler_PART_SRCS})
+add_library(okularGenerator_poppler MODULE ${okularGenerator_poppler_PART_SRCS})
-target_link_libraries(okularGenerator_poppler ${POPPLER_LIBRARY} okularcore ${KDE4_KDEUI_LIBS} ${QT_QTXML_LIBRARY} ${ZLIB_LIBRARIES})
+target_link_libraries(okularGenerator_poppler ${POPPLER_LIBRARY} okularcore Qt5::Xml Qt5::Widgets Qt5::Gui ${ZLIB_LIBRARIES})
install(TARGETS okularGenerator_poppler DESTINATION ${PLUGIN_INSTALL_DIR})
diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index 7930f83..f68ceeb 100644
--- a/generators/poppler/generator_pdf.cpp
+++ b/generators/poppler/generator_pdf.cpp
@@ -21,10 +21,10 @@
#include <qregexp.h>
#include <qstack.h>
#include <qtextstream.h>
-#include <QtGui/QPrinter>
-#include <QtGui/QPainter>
+#include <QPrinter>
+#include <QPainter>
-#include <kaboutdata.h>
+#include <k4aboutdata.h>
#include <kconfigdialog.h>
#include <klocale.h>
#include <kmessagebox.h>
@@ -244,7 +244,7 @@ Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink)
case Poppler::Link::Browse:
popplerLinkBrowse = static_cast<const Poppler::LinkBrowse *>(popplerLink);
- link = new Okular::BrowseAction( popplerLinkBrowse->url() );
+ link = new Okular::BrowseAction( QUrl(popplerLinkBrowse->url()) );
break;
case Poppler::Link::Action:
@@ -378,13 +378,13 @@ static QLinkedList<Okular::ObjectRect*> generateLinks( const QList<Poppler::Link
static KAboutData createAboutData()
{
- KAboutData aboutData(
+ K4AboutData aboutData(
"okular_poppler",
"okular_poppler",
ki18n( "PDF Backend" ),
"0.6.4",
ki18n( "A PDF file renderer" ),
- KAboutData::License_GPL,
+ K4AboutData::License_GPL,
ki18n( "© 2005-2008 Albert Astals Cid" )
);
aboutData.addAuthor( ki18n( "Albert Astals Cid" ), KLocalizedString(), "aacid@kde.org" );
@@ -747,7 +747,8 @@ Okular::FontInfo::List PDFGenerator::fontsForPage( int page )
QList<Poppler::FontInfo> fonts;
userMutex()->lock();
- pdfdoc->scanForFonts( 1, &fonts );
+#pragma message("scanForFonts doesn't exist in Poppler5. BahhhH!")
+ //pdfdoc->scanForFonts( 1, &fonts );
userMutex()->unlock();
foreach (const Poppler::FontInfo &font, fonts)
@@ -1691,7 +1692,7 @@ void PDFGenerator::loadPdfSync( const QString & filePath, QVector<Okular::Page*>
void PDFGenerator::initSynctexParser( const QString& filePath )
{
- synctex_scanner = synctex_scanner_new_with_output_file( QFile::encodeName( filePath ), 0, 1);
+ synctex_scanner = synctex_scanner_new_with_output_file( QFile::encodeName( filePath ).constData(), 0, 1);
}
const Okular::SourceReference * PDFGenerator::dynamicSourceReference( int pageNr, double absX, double absY )
@@ -1757,7 +1758,7 @@ void PDFGenerator::fillViewportFromSourceReference( Okular::DocumentViewport & v
if (!ok) line = -1;
// Use column == -1 for now.
- if( synctex_display_query( synctex_scanner, QFile::encodeName(name), line, -1 ) > 0 )
+ if( synctex_display_query( synctex_scanner, QFile::encodeName(name).constData(), line, -1 ) > 0 )
{
synctex_node_t node;
// For now use the first hit. Could possibly be made smarter
diff --git a/part.cpp b/part.cpp
index 4dd6004..d3e9a27 100644
--- a/part.cpp
+++ b/part.cpp
@@ -2912,9 +2912,9 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
QWidget *container = factory()->container("bookmarks", clients[i]);
if (container && container->actions().contains(m_bookmarkActions.first()))
{
- Q_ASSERT(dynamic_cast<KMenu*>(container));
+ Q_ASSERT(dynamic_cast<QMenu*>(container));
disconnect(container, 0, this, 0);
- connect(container, SIGNAL(aboutToShowContextMenu(KMenu*,QAction*,QMenu*)), this, SLOT(slotAboutToShowContextMenu(KMenu*,QAction*,QMenu*)));
+ connect(container, SIGNAL(aboutToShowContextMenu(QMenu*,QAction*,QMenu*)), this, SLOT(slotAboutToShowContextMenu(QMenu*,QAction*,QMenu*)));
containerFound = true;
}
}