Make poppler optional
Stefan Bund [Tue, 26 Oct 2010 10:34:16 +0000 (12:34 +0200)]
.gitignore
Makefile [new file with mode: 0644]
Viewer.cc
pykit.pro

index 2daed2e..85f641b 100644 (file)
@@ -4,4 +4,4 @@ moc_*
 .sconsign*
 *.moc
 /pykit
-/Makefile
+/Makefile.qmake
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..2ed7bae
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,15 @@
+default: all ;
+
+Makefile.qmake:
+       qmake -o Makefile.qmake pykit.pro
+
+%: Makefile.qmake FORCE
+       @$(MAKE) -f Makefile.qmake $@
+FORCE: ;
+
+clean:
+       @$(MAKE) -f Makefile.qmake clean
+       rm -f pykit Makefile.qmake
+
+Makefile: ;
+
index abb1b2f..a67a092 100644 (file)
--- a/Viewer.cc
+++ b/Viewer.cc
@@ -19,6 +19,8 @@
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
+#ifdef POPPLER
+
 namespace {
 
     class PDFWebPluginFactory
@@ -77,6 +79,8 @@ prefix_ QList<QWebPluginFactory::Plugin> PDFWebPluginFactory::plugins()
     return plugins;
 }
 
+#endif
+
 ///////////////////////////////////////////////////////////////////////////
 // pykit::Viewer
 
@@ -86,7 +90,9 @@ prefix_ pykit::Viewer::Viewer(QUrl const & url, Publisher * publisher, QWidget *
     QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
     page()->setNetworkAccessManager(
         new InternalNetworkAccessManager(page()->networkAccessManager(), this, publisher));
+#ifdef POPPLER
     page()->setPluginFactory(new PDFWebPluginFactory (page()->networkAccessManager(), this));
+#endif
     load(url);
 }
 
index 63d9604..1cb9fb6 100644 (file)
--- a/pykit.pro
+++ b/pykit.pro
@@ -1,3 +1,4 @@
+# CONFIG += no_poppler
 TEMPLATE = app
 TARGET = pykit
 DEPENDPATH += .
@@ -12,18 +13,21 @@ QMAKE_CXXFLAGS += $$system(python-config --cflags)
 QMAKE_CFFLAGS += $$system(python-config --cflags)
 LIBS += $$system(python-config --ldflags)
 
-# poppler
-LIBS += -lpoppler-qt4 -lpoppler
-
 # Input
 HEADERS += MainWindow.hh \
            Publisher.hh \
            PythonPublisher.hh \
-           Viewer.hh \
-           PDFWidget.hh
+           Viewer.hh
 SOURCES += main.cc \
            MainWindow.cc \
            Publisher.cc \
            PythonPublisher.cc \
-           Viewer.cc \
-           PDFWidget.cc
+           Viewer.cc
+
+# poppler
+!no_poppler {
+    LIBS += -lpoppler-qt4 -lpoppler
+    HEADERS += PDFWidget.hh
+    SOURCES += PDFWidget.cc
+    DEFINES += POPPLER
+}