diff --git a/Makefile.am b/Makefile.am index ab4bfd258..544299fc1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,20 +6,20 @@ INCLUDES= $(all_includes) -Ikpathsea # claim, which subdirectories you want to install SUBDIRS = kpathsea . pix -# you can add here more. This one gets installed +# you can add here more. This one gets installed bin_PROGRAMS = kdvi lib_LTLIBRARIES=libkdvi.la noinst_PROGRAMS = squeeze -# just to make sure, automake makes them -METASOURCES = USE_AUTOMOC +# just to make sure, automake makes them +METASOURCES = AUTO # Which sources should be compiled for kdvi. libkdvi_la_SOURCES = kdvi.cpp dviwin.cpp marklist.cpp prefs.cpp print.cpp\ printData.cpp printSetup.cpp printSetupData.cpp pushbutton.cpp\ scrbox.cpp kdvi_miniwidget.cpp kdvi_view.cpp kbrowser.moc.cc\ psheader.c dvi_draw.c dvi_init.c font-open.c gf.c new.c pk.c psgs.c\ - special.c util.c vf.c konq_progressproxy.cc + special.c util.c vf.c # konq_progressproxy.cc kdvi_SOURCES = main.cpp @@ -27,7 +27,7 @@ kdvi_SOURCES = main.cpp squeeze_SOURCES = squeeze.c # the library search path -libkdvi_la_LDFLAGS = $(all_libraries) -avoid-version -module +libkdvi_la_LDFLAGS = $(all_libraries) -avoid-version -module libkdvi_la_LIBADD = $(LIB_KFILE) -lkparts kpathsea/libkpathsea.la kdvi_LDFLAGS = $(all_libraries) $(KDE_RPATH) @@ -36,14 +36,17 @@ kdvi_LDADD = libkdvi.la ## this option you can leave out. Just, if you use "make dist", you need it noinst_HEADERS = c-openmx.h dvi.h dviwin.h kdvi.h marklist.h oconfig.h\ prefs.h print.h printData.h printSetup.h printSetupData.h pushbutton.h\ - scrbox.h xdvi.h kdvi_miniwidget.h kdvi_view.h konq_progressproxy.h + scrbox.h xdvi.h kdvi_miniwidget.h kdvi_view.h # konq_progressproxy.h messages: $(XGETTEXT) -C -ki18n -x $(includedir)/kde.pot *.cpp && mv messages.po $(podir)/kdvi.pot apps_DATA = kdvi.desktop -psheader.c: psheader.txt squeeze +partdir = $(kde_datadir)/kdvi +part_DATA = kdvi_part.rc + +psheader.c: psheader.txt squeeze ./squeeze $(srcdir)/psheader.txt $@ kbrowser.moc.cc: $(kde_includes)/kbrowser.h diff --git a/kdvi_part.rc b/kdvi_part.rc new file mode 100644 index 000000000..8c50b2c50 --- /dev/null +++ b/kdvi_part.rc @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/kdvi_view.cpp b/kdvi_view.cpp index 6135dcc15..9c086b9dc 100644 --- a/kdvi_view.cpp +++ b/kdvi_view.cpp @@ -1,24 +1,14 @@ #include "kdvi_view.h" -#include "konq_progressproxy.h" +//#include "konq_progressproxy.h" #include "kdvi_miniwidget.h" #include #include #include -#include -#include +#include #include +#include #include -#include -#ifdef HAVE_PATHS_H -#include -#endif - -#ifndef _PATH_TMP -#define _PATH_TMP "/tmp/" -#endif - - extern "C"{ void *init_libkdvi() { @@ -43,7 +33,7 @@ KDVIFactory::~KDVIFactory() QObject* KDVIFactory::create(QObject *parent , const char *name , const char*, const QStringList & ) { - QObject *obj = new KDVIKonqView( (QWidget *)parent, name ); + QObject *obj = new KDVIPart( (QWidget *)parent, name ); emit objectCreated( obj ); return obj; } @@ -55,163 +45,85 @@ KInstance *KDVIFactory::instance() return s_instance; } -KDVIKonqView::KDVIKonqView( QWidget *parent, const char *name ) - : BrowserView( parent, name ) +KDVIPart::KDVIPart( QWidget *parent, const char *name ) + : KParts::ReadOnlyPart( parent, name ) { - urlStr = ""; - w = new KDVIMiniWidget(NULL, this ); + setInstance( KDVIFactory::instance() ); + w = new KDVIMiniWidget(NULL, parent ); dviWindow *dviwin = w->window(); - jobId = 0; + + setWidget( w ); + startAct = new KAction(i18n("Go to first page"), QIconSet(BarIcon("start", KDVIFactory::instance())) , - 0, dviwin, SLOT(firstPage() ), this); + 0, dviwin, SLOT(firstPage() ), actionCollection(), "firstPage"); backAct = new KAction(i18n("Go to previous page"), QIconSet(BarIcon("back", KDVIFactory::instance())) , - 0, dviwin, SLOT(prevPage() ), this); + 0, dviwin, SLOT(prevPage() ), actionCollection(), "prevPage"); forPageAct = new KAction(i18n("Go down then top of next page"), QIconSet(BarIcon("forwpage", KDVIFactory::instance())) , - 0, dviwin, SLOT(goForward() ), this); + 0, dviwin, SLOT(goForward() ), actionCollection(), "goForward"); forwardAct = new KAction(i18n("Go to next page"), QIconSet(BarIcon("forward", KDVIFactory::instance())) , - 0, dviwin, SLOT(nextPage() ), this); + 0, dviwin, SLOT(nextPage() ), actionCollection(), "nextPage"); finishAct = new KAction(i18n("Go to last page"), QIconSet(BarIcon("finish", KDVIFactory::instance())) , - 0, dviwin, SLOT(lastPage() ), this); + 0, dviwin, SLOT(lastPage() ), actionCollection(), "lastPage"); zoomOutAct = new KAction(i18n("Decrease magnification"), QIconSet(BarIcon("viewmag-", KDVIFactory::instance())) , - 0, dviwin, SLOT(nextShrink() ), this); + 0, dviwin, SLOT(nextShrink() ), actionCollection(), "nextShrink"); smallAct = new KAction(i18n("Small text"), QIconSet(BarIcon("smalltext", KDVIFactory::instance())) , - 0, w, SLOT(selectSmall() ), this); + 0, w, SLOT(selectSmall() ), actionCollection(), "selectSmall"); largeAct = new KAction(i18n("Large text"), QIconSet(BarIcon("largetext", KDVIFactory::instance())) , - 0, w, SLOT(selectLarge() ), this); + 0, w, SLOT(selectLarge() ), actionCollection(), "selectLarge"); zoomInAct = new KAction(i18n("Increase magnification"), QIconSet(BarIcon("viewmag+", KDVIFactory::instance())) , - 0, dviwin, SLOT(prevShrink() ), this); - - actions()->append(BrowserView::ViewAction(startAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(backAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(forPageAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(forwardAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(finishAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(zoomOutAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(smallAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(largeAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - actions()->append(BrowserView::ViewAction(zoomInAct, BrowserView::MenuEdit - | BrowserView::ToolBar ) ); - - (void)new KDVIPrintingExtension( this ); - - connect(w, SIGNAL(statusMessage(const QString &)), this, - SLOT(slotMessage(const QString &))); - connect(w->window(), SIGNAL(statusChange(const QString &)), this, - SLOT(slotMessage(const QString &))); - -} - -KDVIKonqView::~KDVIKonqView() -{ - stop(); - warning("In KDVIKonqView destructor"); - KURL destURL(destStr); - if(QFile::exists(destURL.path())) - QFile::remove(destURL.path()); -} - -void KDVIKonqView::openURL(const QString &url, bool, int, int) -{ - urlStr = url; - KIOCachedJob *iojob = new KIOCachedJob; - iojob->setGUImode(KIOJob::NONE); - jobId = iojob->id(); - connect(iojob, SIGNAL(sigFinished(int)), this, - SLOT(slotFinished(int))); - connect(iojob, SIGNAL(sigRedirection(int, const char *)), this, - SLOT(slotRedirection(int, const char *))); - connect(iojob, SIGNAL(sigError(int, int, const char *)), this, - SLOT(slotError(int, int, const char *))); - - (void)new KonqProgressProxy( this, iojob ); - destStr.sprintf("file:"_PATH_TMP"/kdvi%i", time( 0L )); - iojob->copy(url.latin1(), destStr.latin1()); - emit started(); -} - -QString KDVIKonqView::url() -{ - return urlStr; -} + 0, dviwin, SLOT(prevShrink() ), actionCollection(), "prevShrink"); -int KDVIKonqView::xOffset() -{ - return 0; -} - -int KDVIKonqView::yOffset() -{ - return 0; -} - -void KDVIKonqView::stop() -{ - if (jobId){ - KIOJob *job = KIOJob::find(jobId); - if (job) - job->kill(); - jobId = 0; - } -} + m_extension = new KDVIBrowserExtension( this ); -void KDVIKonqView::slotMessage(const QString &s) -{ - emit setStatusBarText(s); -} + connect(w, SIGNAL(statusMessage(const QString &)), + m_extension, SIGNAL( setStatusBarText( const QString & ) ) ); + connect(w->window(), SIGNAL(statusChange(const QString &)), + m_extension, SIGNAL( setStatusBarText( const QString & ) ) ); -void KDVIKonqView::slotFinished( int ) -{ + setXMLFile( "kdvi_part.rc" ); - KURL destURL(destStr); - if(!QFile::exists(destURL.path())) - warning("KDVIKonqView: dest file %s does not exist!", - destURL.path().latin1()); - else - w->openFile(destURL.path()); - jobId = 0; - emit completed(); } -void KDVIKonqView::slotRedirection( int, const char *url ) +KDVIPart::~KDVIPart() { - emit setLocationBarURL(QString(url)); } -void KDVIKonqView::slotError( int, int, const char * ) +bool KDVIPart::openFile() { - stop(); - emit canceled(); + if(!QFile::exists(m_file)) + { + kDebugWarning("KDVIKonqView: dest file %s does not exist!", + m_file.latin1()); + return false; + } + else + { + w->openFile(m_file); + return true; + } } -void KDVIKonqView::resizeEvent( QResizeEvent * ) +///////// +KDVIBrowserExtension::KDVIBrowserExtension( KDVIPart *parent ) : + KParts::BrowserExtension( parent, "KDVIBrowserExtension" ) { - w->setGeometry(0, 0, width(), height() ); + emit enableAction( "print", true ); } -void KDVIPrintingExtension::print() +void KDVIBrowserExtension::print() { - ((KDVIKonqView *)parent())->miniWidget()->filePrint(); + ((KDVIPart *)parent())->miniWidget()->filePrint(); } #include "kdvi_view.moc" - - diff --git a/kdvi_view.h b/kdvi_view.h index 6884cecc9..fb75b6bf6 100644 --- a/kdvi_view.h +++ b/kdvi_view.h @@ -4,9 +4,10 @@ #include #include +class KAction; class KInstance; class KDVIMiniWidget; -class KDVIKonqView; +class KDVIBrowserExtension; class KDVIFactory : public KLibFactory { @@ -25,51 +26,48 @@ private: static KInstance *s_instance; }; -class KDVIPrintingExtension : public PrintingExtension +class KDVIPart: public KParts::ReadOnlyPart { Q_OBJECT public: - KDVIPrintingExtension( QObject *parent ) : - PrintingExtension( parent, "KDVIPrintingExtension" ) {} - virtual void print(); -}; - -class KDVIKonqView: public BrowserView -{ - Q_OBJECT -public: - KDVIKonqView( QWidget *parent, const char *name ); - virtual ~KDVIKonqView(); - - virtual void openURL(const QString &url, bool reload = false, - int xOffset = 0, int yOffset = 0); - - virtual QString url(); - virtual int xOffset(); - virtual int yOffset(); - virtual void stop(); + KDVIPart( QWidget *parent = 0, const char *name = 0 ); + virtual ~KDVIPart(); KDVIMiniWidget *miniWidget() const { return w; } +protected: + // reimplemented from ReadOnlyPart + virtual bool openFile(); protected slots: - void slotMessage(const QString &s); - void slotFinished(int); - void slotRedirection(int, const char *); - void slotError(int, int, const char *); -protected: - virtual void resizeEvent(QResizeEvent *); private: - int xOff, yOff; - QString urlStr, destStr; KDVIMiniWidget *w; - int jobId; + KDVIBrowserExtension * m_extension; KAction *startAct, *backAct, *forPageAct, *forwardAct, *finishAct, *zoomOutAct, *smallAct, *largeAct, *zoomInAct; }; +class KDVIBrowserExtension : public KParts::BrowserExtension +{ + Q_OBJECT + friend class KDVIPart; // emits our signals +public: + KDVIBrowserExtension( KDVIPart *parent ); + virtual ~KDVIBrowserExtension() {} + + /* + virtual void setXYOffset( int x, int y ); + virtual int xOffset(); + virtual int yOffset(); + */ + +public slots: + // Automatically detected by konqueror + void print(); +}; + #endif