Use signals to propagate notifications in dviexport and psgs

Change KMessageBox into notifications (PageViewMessage).

REVIEW: 115925
remotes/origin/KDE/4.13
Luigi Toscano 12 years ago
parent 5a8d7e34aa
commit 4ae6ece82e
  1. 1
      generators/dvi/dviRenderer.cpp
  2. 11
      generators/dvi/dviRenderer.h
  3. 43
      generators/dvi/dviexport.cpp
  4. 3
      generators/dvi/dviexport.h
  5. 3
      generators/dvi/generator_dvi.cpp
  6. 10
      generators/dvi/psgs.cpp
  7. 1
      generators/dvi/psgs.h

@ -77,6 +77,7 @@ dviRenderer::dviRenderer(bool useFontHinting)
// connect( &clearStatusBarTimer, SIGNAL(timeout()), this, SLOT(clearStatusBar()) ); // connect( &clearStatusBarTimer, SIGNAL(timeout()), this, SLOT(clearStatusBar()) );
// pass status bar messages through // pass status bar messages through
// connect(PS_interface, SIGNAL(setStatusBarText(QString)), this, SIGNAL(setStatusBarText(QString)) ); // connect(PS_interface, SIGNAL(setStatusBarText(QString)), this, SIGNAL(setStatusBarText(QString)) );
connect( PS_interface, SIGNAL( error(QString,int) ), this, SIGNAL( error(QString,int) ) );
} }

@ -145,6 +145,17 @@ public:
void export_finished(const DVIExport*); void export_finished(const DVIExport*);
//void editor_finished(const DVISourceEditor*); //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: public slots:
void exportPS(const QString& fname = QString(), const QStringList& options = QStringList(), QPrinter* printer = 0, QPrinter::Orientation orientation = QPrinter::Portrait); void exportPS(const QString& fname = QString(), const QStringList& options = QStringList(), QPrinter* printer = 0, QPrinter::Orientation orientation = QPrinter::Portrait);
void exportPDF(); void exportPDF();

@ -47,7 +47,9 @@ DVIExport::DVIExport(dviRenderer& parent, QWidget* parent_widget)
progress_(0), progress_(0),
parent_(&parent), parent_(&parent),
parent_widget_(parent_widget) parent_widget_(parent_widget)
{} {
connect( this, SIGNAL(error(QString,int)), &parent, SIGNAL(error(QString,int)) );
}
DVIExport::~DVIExport() DVIExport::~DVIExport()
@ -138,7 +140,7 @@ void DVIExport::finished_impl(int exit_code)
} }
if (process_ && exit_code != 0) 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. // Remove this from the store of all export processes.
parent_->m_eventLoop->exit( exit_code ); parent_->m_eventLoop->exit( exit_code );
parent_->export_finished(this); parent_->export_finished(this);
@ -169,15 +171,14 @@ DVIExportToPDF::DVIExportToPDF(dviRenderer& parent, QWidget* parent_widget)
return; return;
if (KStandardDirs::findExe("dvipdfm").isEmpty()) { if (KStandardDirs::findExe("dvipdfm").isEmpty()) {
KMessageBox::sorry(parent_widget, emit error(i18n("Okular could not locate the program 'dvipdfm' on your computer. This program is "
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 "
"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 "
"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 "
"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 "
"Acrobat Reader. It may be wise to upgrade to a more recent version of your " "TeX distribution which includes the 'dvipdfm' program.\n"
"TeX distribution which includes the 'dvipdfm' program.\n" "Hint to the perplexed system administrator: Okular uses the PATH environment variable "
"Hint to the perplexed system administrator: Okular uses the PATH environment variable " "when looking for programs."), -1);
"when looking for programs."));
return; return;
} }
@ -241,23 +242,17 @@ DVIExportToPS::DVIExportToPS(dviRenderer& parent,
return; return;
if (dvi.numberOfExternalNONPSFiles != 0) { if (dvi.numberOfExternalNONPSFiles != 0) {
KMessageBox::sorry(parent_widget, emit error(i18n("This DVI file refers to external graphic files which are not in PostScript format, and cannot be handled by the "
i18n("<qt><P>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 "
"<strong>dvips</strong> 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);
"you require is therefore unavailable in this version of Okular.</p>"
"<p>As a workaround, you can use the <strong>File/Export As</strong>-Menu to save this file in PDF format, and then use "
"a PDF viewer.</p>"
"<p>It is planned to add this functionality at a later date.</p></qt>") ,
i18n("Functionality Unavailable"));
return; return;
} }
if (KStandardDirs::findExe("dvips").isEmpty()) { if (KStandardDirs::findExe("dvips").isEmpty()) {
KMessageBox::sorry(parent_widget, emit error(i18n("Okular could not locate the program 'dvips' on your computer. That program is "
i18n("Okular could not locate the program 'dvips' on your computer. That program is " "essential for the export function to work.\n"
"essential for the export function to work.\n" "Hint to the perplexed system administrator: Okular uses the PATH environment variable "
"Hint to the perplexed system administrator: Okular uses the PATH environment variable " "when looking for programs."), -1);
"when looking for programs."));
return; return;
} }

@ -45,6 +45,9 @@ public:
*/ */
bool started() const { return started_; } bool started() const { return started_; }
Q_SIGNALS:
void error( const QString &message, int duration );
protected: protected:
/** @param parent is stored internally in order to inform the parent /** @param parent is stored internally in order to inform the parent
* that the external process has finished and that this variable * that the external process has finished and that this variable

@ -81,6 +81,9 @@ bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page
(void)userMutex(); (void)userMutex();
m_dviRenderer = new dviRenderer(documentMetaData("TextHinting", QVariant()).toBool()); 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 #ifdef DVI_OPEN_BUSYLOOP
static const ushort s_waitTime = 800; // milliseconds static const ushort s_waitTime = 800; // milliseconds
static const int s_maxIterations = 10; static const int s_maxIterations = 10;

@ -16,7 +16,6 @@
#include "pageNumber.h" #include "pageNumber.h"
#include <klocale.h> #include <klocale.h>
#include <kmessagebox.h>
#include <kprocess.h> #include <kprocess.h>
#include <ktemporaryfile.h> #include <ktemporaryfile.h>
#include <kurl.h> #include <kurl.h>
@ -261,11 +260,10 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
gsDevice = knownDevices.begin(); gsDevice = knownDevices.begin();
if (knownDevices.isEmpty()) if (knownDevices.isEmpty())
// TODO: show a requestor of some sort. // 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 #if 0
KMessageBox::detailedError(0,
i18n("<qt>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.</qt>"),
i18n("<qt><p>The Ghostview program, which Okular uses internally to display the " i18n("<qt><p>The Ghostview program, which Okular uses internally to display the "
"PostScript graphics that is included in this DVI file, is generally able to " "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 " "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' " "Ghostview. Among others, Okular can use the 'png256', 'jpeg' and 'pnm' "
"drivers. Note that Okular needs to be restarted to re-enable PostScript support." "drivers. Note that Okular needs to be restarted to re-enable PostScript support."
"</p></qt>")); "</p></qt>"));
#else
{}
#endif #endif
else { else {
kDebug(kvs::dvi) << QString("Okular will now try to use the '%1' device driver.").arg(*gsDevice); kDebug(kvs::dvi) << QString("Okular will now try to use the '%1' device driver.").arg(*gsDevice);

@ -104,6 +104,7 @@ private:
signals: signals:
/** Passed through to the top-level kpart. */ /** Passed through to the top-level kpart. */
void setStatusBarText( const QString& ); void setStatusBarText( const QString& );
void error( const QString &message, int duration );
}; };
#endif #endif

Loading…
Cancel
Save