Commit e4a4d400 authored by Vishesh Handa's avatar Vishesh Handa

Port the poppler generator

parent 7123b4d9
......@@ -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()
......
......@@ -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;
}
......
......@@ -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.
......
......@@ -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)
......
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})
......
......@@ -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
......
......@@ -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;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment