diff --git a/generators/dvi/dviRenderer.cpp b/generators/dvi/dviRenderer.cpp index 4513ee236..16fe5a84f 100644 --- a/generators/dvi/dviRenderer.cpp +++ b/generators/dvi/dviRenderer.cpp @@ -77,6 +77,7 @@ dviRenderer::dviRenderer(bool useFontHinting) // connect( &clearStatusBarTimer, SIGNAL(timeout()), this, SLOT(clearStatusBar()) ); // pass status bar messages through // connect(PS_interface, SIGNAL(setStatusBarText(QString)), this, SIGNAL(setStatusBarText(QString)) ); + connect( PS_interface, SIGNAL( error(QString,int) ), this, SIGNAL( error(QString,int) ) ); } diff --git a/generators/dvi/dviRenderer.h b/generators/dvi/dviRenderer.h index 842c11e9f..677b2d4c2 100644 --- a/generators/dvi/dviRenderer.h +++ b/generators/dvi/dviRenderer.h @@ -145,6 +145,17 @@ public: void export_finished(const DVIExport*); //void editor_finished(const DVISourceEditor*); + +Q_SIGNALS: + /** + * The following three signals are modeleed on the corresponding signals + * of the Document class. + */ + void error( const QString &message, int duration ); + void warning( const QString &message, int duration ); + void notice( const QString &message, int duration ); + + public slots: void exportPS(const QString& fname = QString(), const QStringList& options = QStringList(), QPrinter* printer = 0, QPrinter::Orientation orientation = QPrinter::Portrait); void exportPDF(); diff --git a/generators/dvi/dviexport.cpp b/generators/dvi/dviexport.cpp index c35f4b43b..1bd56d461 100644 --- a/generators/dvi/dviexport.cpp +++ b/generators/dvi/dviexport.cpp @@ -47,7 +47,9 @@ DVIExport::DVIExport(dviRenderer& parent, QWidget* parent_widget) progress_(0), parent_(&parent), parent_widget_(parent_widget) -{} +{ + connect( this, SIGNAL(error(QString,int)), &parent, SIGNAL(error(QString,int)) ); +} DVIExport::~DVIExport() @@ -138,7 +140,7 @@ void DVIExport::finished_impl(int exit_code) } if (process_ && exit_code != 0) - KMessageBox::error(parent_widget_, error_message_); + emit error(error_message_, -1); // Remove this from the store of all export processes. parent_->m_eventLoop->exit( exit_code ); parent_->export_finished(this); @@ -169,15 +171,14 @@ DVIExportToPDF::DVIExportToPDF(dviRenderer& parent, QWidget* parent_widget) return; if (KStandardDirs::findExe("dvipdfm").isEmpty()) { - KMessageBox::sorry(parent_widget, - i18n("Okular could not locate the program 'dvipdfm' on your computer. This program is " - "essential for the export function to work. You can, however, convert " - "the DVI-file to PDF using the print function of Okular, but that will often " - "produce documents which print okay, but are of inferior quality if viewed in " - "Acrobat Reader. It may be wise to upgrade to a more recent version of your " - "TeX distribution which includes the 'dvipdfm' program.\n" - "Hint to the perplexed system administrator: Okular uses the PATH environment variable " - "when looking for programs.")); + emit error(i18n("Okular could not locate the program 'dvipdfm' on your computer. This program is " + "essential for the export function to work. You can, however, convert " + "the DVI-file to PDF using the print function of Okular, but that will often " + "produce documents which print okay, but are of inferior quality if viewed in " + "Acrobat Reader. It may be wise to upgrade to a more recent version of your " + "TeX distribution which includes the 'dvipdfm' program.\n" + "Hint to the perplexed system administrator: Okular uses the PATH environment variable " + "when looking for programs."), -1); return; } @@ -241,23 +242,17 @@ DVIExportToPS::DVIExportToPS(dviRenderer& parent, return; if (dvi.numberOfExternalNONPSFiles != 0) { - KMessageBox::sorry(parent_widget, - i18n("

This DVI file refers to external graphic files which are not in PostScript format, and cannot be handled by the " - "dvips program that Okular uses internally to print or to export to PostScript. The functionality that " - "you require is therefore unavailable in this version of Okular.

" - "

As a workaround, you can use the File/Export As-Menu to save this file in PDF format, and then use " - "a PDF viewer.

" - "

It is planned to add this functionality at a later date.

") , - i18n("Functionality Unavailable")); + emit error(i18n("This DVI file refers to external graphic files which are not in PostScript format, and cannot be handled by the " + "'dvips' program that Okular uses internally to print or to export to PostScript. The functionality that " + "you require is therefore unavailable in this version of Okular."), -1); return; } if (KStandardDirs::findExe("dvips").isEmpty()) { - KMessageBox::sorry(parent_widget, - i18n("Okular could not locate the program 'dvips' on your computer. That program is " - "essential for the export function to work.\n" - "Hint to the perplexed system administrator: Okular uses the PATH environment variable " - "when looking for programs.")); + emit error(i18n("Okular could not locate the program 'dvips' on your computer. That program is " + "essential for the export function to work.\n" + "Hint to the perplexed system administrator: Okular uses the PATH environment variable " + "when looking for programs."), -1); return; } diff --git a/generators/dvi/dviexport.h b/generators/dvi/dviexport.h index 32656452c..4ae5c6546 100644 --- a/generators/dvi/dviexport.h +++ b/generators/dvi/dviexport.h @@ -45,6 +45,9 @@ public: */ bool started() const { return started_; } +Q_SIGNALS: + void error( const QString &message, int duration ); + protected: /** @param parent is stored internally in order to inform the parent * that the external process has finished and that this variable diff --git a/generators/dvi/generator_dvi.cpp b/generators/dvi/generator_dvi.cpp index c66693338..ba4e71fce 100644 --- a/generators/dvi/generator_dvi.cpp +++ b/generators/dvi/generator_dvi.cpp @@ -81,6 +81,9 @@ bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page (void)userMutex(); m_dviRenderer = new dviRenderer(documentMetaData("TextHinting", QVariant()).toBool()); + connect( m_dviRenderer, SIGNAL( error(QString,int) ), this, SIGNAL( error(QString,int) ) ); + connect( m_dviRenderer, SIGNAL( warning(QString,int) ), this, SIGNAL( warning(QString,int) ) ); + connect( m_dviRenderer, SIGNAL( notice(QString,int) ), this, SIGNAL( notice(QString,int) ) ); #ifdef DVI_OPEN_BUSYLOOP static const ushort s_waitTime = 800; // milliseconds static const int s_maxIterations = 10; diff --git a/generators/dvi/psgs.cpp b/generators/dvi/psgs.cpp index f54d78ecf..5d6b807c5 100644 --- a/generators/dvi/psgs.cpp +++ b/generators/dvi/psgs.cpp @@ -16,7 +16,6 @@ #include "pageNumber.h" #include -#include #include #include #include @@ -261,11 +260,10 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co gsDevice = knownDevices.begin(); if (knownDevices.isEmpty()) // TODO: show a requestor of some sort. + emit error(i18n("The version of Ghostview that is installed on this computer does not contain " + "any of the Ghostview device drivers that are known to Okular. PostScript " + "support has therefore been turned off in Okular."), -1); #if 0 - KMessageBox::detailedError(0, - i18n("The version of Ghostview that is installed on this computer does not contain " - "any of the Ghostview device drivers that are known to Okular. PostScript " - "support has therefore been turned off in Okular."), i18n("

The Ghostview program, which Okular uses internally to display the " "PostScript graphics that is included in this DVI file, is generally able to " "write its output in a variety of formats. The sub-programs that Ghostview uses " @@ -282,8 +280,6 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co "Ghostview. Among others, Okular can use the 'png256', 'jpeg' and 'pnm' " "drivers. Note that Okular needs to be restarted to re-enable PostScript support." "

")); -#else - {} #endif else { kDebug(kvs::dvi) << QString("Okular will now try to use the '%1' device driver.").arg(*gsDevice); diff --git a/generators/dvi/psgs.h b/generators/dvi/psgs.h index 6842a942f..8e8bf3eff 100644 --- a/generators/dvi/psgs.h +++ b/generators/dvi/psgs.h @@ -104,6 +104,7 @@ private: signals: /** Passed through to the top-level kpart. */ void setStatusBarText( const QString& ); + void error( const QString &message, int duration ); }; #endif