mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 10:55:37 +00:00
added export functionality (DVI -> PS or PDF)
svn path=/trunk/kdegraphics/kdvi/; revision=94909
This commit is contained in:
parent
b698bc1bdf
commit
028b2218c8
10
TODO
10
TODO
|
@ -3,18 +3,12 @@ ToDo-List for kdvi
|
|||
|
||||
URGENT
|
||||
|
||||
o i18n for infoDialog, fontPool & friends
|
||||
|
||||
o implement SaveAs
|
||||
|
||||
o feedback when running kpsewhich or ghostview
|
||||
|
||||
o "Helper-Application" setup
|
||||
|
||||
|
||||
HIGHLY DESIRABLE
|
||||
|
||||
o Speedup, in particular for ghostscript and kpsewhich.
|
||||
o Speedup, in particular for ghostscript and glyph enlarging.
|
||||
|
||||
o Support for colored font specials
|
||||
|
||||
|
@ -29,14 +23,12 @@ o Extra enlargement of characters for improved readability should be switchable.
|
|||
|
||||
NOT SO URGENT
|
||||
|
||||
o Document info dialog
|
||||
o Internal printing using QPrinter
|
||||
o Redirect error messages to a window
|
||||
o More background processing to keep the UI responsive
|
||||
o Magnifier window
|
||||
o Two page view
|
||||
o Support for even more TeX specials
|
||||
o Popup-Window to inform the user when Fonts are generated
|
||||
o Search option
|
||||
o dynamical storage allocation for hyperlinks (see dviwin.h)
|
||||
o more robust Error handling with throw/catch; no need to abort just because a PK-file is bad.
|
||||
|
|
208
dviwin.cpp
208
dviwin.cpp
|
@ -1,3 +1,4 @@
|
|||
|
||||
//
|
||||
// Class: dviWindow
|
||||
//
|
||||
|
@ -10,17 +11,20 @@
|
|||
#include <unistd.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <qpainter.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qkeycode.h>
|
||||
#include <qpaintdevice.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qimage.h>
|
||||
#include <qkeycode.h>
|
||||
#include <qlabel.h>
|
||||
#include <qpaintdevice.h>
|
||||
#include <qpainter.h>
|
||||
#include <qurl.h>
|
||||
|
||||
#include <kapp.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kdebug.h>
|
||||
#include <kfiledialog.h>
|
||||
#include <kio/job.h>
|
||||
#include <klocale.h>
|
||||
#include <kprocess.h>
|
||||
|
||||
|
@ -97,23 +101,12 @@ dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
|||
|
||||
dviFile = 0;
|
||||
|
||||
progress = new fontProgressDialog(this);
|
||||
if (progress == NULL) {
|
||||
kdError(4300) << "Could not allocate memory for the font progress dialog." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
font_pool = new fontPool();
|
||||
if (font_pool == NULL) {
|
||||
kdError(4300) << "Could not allocate memory for the font pool." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
qApp->connect(font_pool, SIGNAL(MFOutput(const QString)), progress, SLOT(outputReceiver(const QString)));
|
||||
qApp->connect(font_pool, SIGNAL(hide_progress_dialog()), progress, SLOT(hideDialog()));
|
||||
qApp->connect(font_pool, SIGNAL(fonts_have_been_loaded()), this, SLOT(drawPage()));
|
||||
qApp->connect(font_pool, SIGNAL(totalFontsInJob(int)), progress, SLOT(setTotalSteps(int)));
|
||||
qApp->connect(font_pool, SIGNAL(show_progress(void)), progress, SLOT(show(void)));
|
||||
qApp->connect(progress, SIGNAL(finished(void)), font_pool, SLOT(abortGeneration(void)));
|
||||
|
||||
info = new infoDialog(this);
|
||||
if (info == 0) {
|
||||
|
@ -121,8 +114,9 @@ dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
|||
// something goes wrong here.
|
||||
kdError(4300) << "Could not allocate memory for the info dialog." << endl;
|
||||
} else {
|
||||
qApp->connect(font_pool, SIGNAL(MFOutput(const QString)), info, SLOT(outputReceiver(const QString)));
|
||||
qApp->connect(font_pool, SIGNAL(MFOutput(QString)), info, SLOT(outputReceiver(QString)));
|
||||
qApp->connect(font_pool, SIGNAL(fonts_info(class fontPool *)), info, SLOT(setFontInfo(class fontPool *)));
|
||||
qApp->connect(font_pool, SIGNAL(new_kpsewhich_run(QString)), info, SLOT(clear(QString)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,7 +129,11 @@ dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
|||
mainwin = handle();
|
||||
mane = currwin;
|
||||
_postscript = 0;
|
||||
pixmap = NULL;
|
||||
pixmap = 0;
|
||||
|
||||
// Storage used for dvips and friends.
|
||||
proc = 0;
|
||||
progress = 0;
|
||||
|
||||
// Calculate the horizontal resolution of the display device. @@@
|
||||
// We assume implicitly that the horizontal and vertical resolutions
|
||||
|
@ -171,9 +169,6 @@ dviWindow::~dviWindow()
|
|||
if (info)
|
||||
delete info;
|
||||
|
||||
if (progress)
|
||||
delete progress;
|
||||
|
||||
delete PS_interface;
|
||||
|
||||
if (dviFile)
|
||||
|
@ -194,6 +189,179 @@ void dviWindow::showInfo(void)
|
|||
}
|
||||
|
||||
|
||||
void dviWindow::exportPDF(void)
|
||||
{
|
||||
// Should not happen since the progressDialog is modal... but who
|
||||
// knows?
|
||||
if (proc != 0) {
|
||||
KMessageBox::sorry(0, i18n("Another export command is currently running"));
|
||||
return;
|
||||
}
|
||||
|
||||
// That sould also not happen.
|
||||
if (dviFile == NULL)
|
||||
return;
|
||||
|
||||
QString fileName = KFileDialog::getSaveFileName(QString::null, "*.pdf|Portable Document Format (*.pdf)", this, i18n("Export File As"));
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
QFileInfo finfo(fileName);
|
||||
if (finfo.exists()) {
|
||||
int r = KMessageBox::warningYesNo (this, QString(i18n("The file %1\nexists. Shall I overwrite that file?")).arg(fileName),
|
||||
i18n("Overwrite file"));
|
||||
if (r == KMessageBox::No)
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the progress dialog
|
||||
progress = new fontProgressDialog( QString::null,
|
||||
i18n("Using dvipdfm to export the file to PDF"),
|
||||
QString::null,
|
||||
i18n("KDVI is currently using the external program 'dvipdfm' to "
|
||||
"convert your DVI-file to PDF. Sometimes that can take "
|
||||
"a while because dvipdfm needs to generate it's own bitmap fonts "
|
||||
"Please be patient."),
|
||||
i18n("Waiting for dvipdf to finish..."),
|
||||
this, "dvipdf progress dialog", false );
|
||||
if (progress != 0) {
|
||||
progress->TextLabel2->setText( i18n("Please be patient") );
|
||||
progress->setTotalSteps( dviFile->total_pages );
|
||||
qApp->connect(progress, SIGNAL(finished(void)), this, SLOT(abortExternalProgramm(void)));
|
||||
}
|
||||
|
||||
proc = new KShellProcess();
|
||||
if (proc == 0) {
|
||||
kdError(4300) << "Could not allocate ShellProcess for the dvipdfm command." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
qApp->connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)), this, SLOT(dvips_output_receiver(KProcess *, char *, int)));
|
||||
qApp->connect(proc, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(dvips_output_receiver(KProcess *, char *, int)));
|
||||
qApp->connect(proc, SIGNAL(processExited(KProcess *)), this, SLOT(dvips_terminated(KProcess *)));
|
||||
|
||||
if (info)
|
||||
info->clear(QString(i18n("Export: %1 to PDF")).arg(KShellProcess::quote(dviFile->filename)));
|
||||
|
||||
proc->clearArguments();
|
||||
finfo.setFile(dviFile->filename);
|
||||
*proc << QString("cd %1; dvipdfm").arg(KShellProcess::quote(finfo.dirPath(true)));
|
||||
*proc << QString("-o %1").arg(KShellProcess::quote(fileName));
|
||||
*proc << KShellProcess::quote(dviFile->filename);
|
||||
proc->closeStdin();
|
||||
if (proc->start(KProcess::NotifyOnExit, KProcess::AllOutput) == false) {
|
||||
kdError(4300) << "dvipdfm failed to start" << endl;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void dviWindow::exportPS(void)
|
||||
{
|
||||
// Should not happen since the progressDialog is modal... but who
|
||||
// knows?
|
||||
if (proc != 0) {
|
||||
KMessageBox::sorry(0, i18n("Another export command is currently running"));
|
||||
return;
|
||||
}
|
||||
|
||||
// That sould also not happen.
|
||||
if (dviFile == NULL)
|
||||
return;
|
||||
|
||||
QString fileName = KFileDialog::getSaveFileName(QString::null, "*.ps|PostScript (*.ps)", this, i18n("Export File As"));
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
QFileInfo finfo(fileName);
|
||||
if (finfo.exists()) {
|
||||
int r = KMessageBox::warningYesNo (this, QString(i18n("The file %1\nexists. Shall I overwrite that file?")).arg(fileName),
|
||||
i18n("Overwrite file"));
|
||||
if (r == KMessageBox::No)
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the progress dialog
|
||||
progress = new fontProgressDialog( QString::null,
|
||||
i18n("Using dvips to export the file to PostScript"),
|
||||
QString::null,
|
||||
i18n("KDVI is currently using the external program 'dvips' to "
|
||||
"convert your DVI-file to PostScript. Sometimes that can take "
|
||||
"a while because dvips needs to generate it's own bitmap fonts "
|
||||
"Please be patient."),
|
||||
i18n("Waiting for dvips to finish..."),
|
||||
this, "dvips progress dialog", false );
|
||||
if (progress != 0) {
|
||||
progress->TextLabel2->setText( i18n("Please be patient") );
|
||||
progress->setTotalSteps( dviFile->total_pages );
|
||||
qApp->connect(progress, SIGNAL(finished(void)), this, SLOT(abortExternalProgramm(void)));
|
||||
}
|
||||
|
||||
proc = new KShellProcess();
|
||||
if (proc == 0) {
|
||||
kdError(4300) << "Could not allocate ShellProcess for the dvips command." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
qApp->connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)),
|
||||
this, SLOT(dvips_output_receiver(KProcess *, char *, int)));
|
||||
qApp->connect(proc, SIGNAL(processExited(KProcess *)),
|
||||
this, SLOT(dvips_terminated(KProcess *)));
|
||||
|
||||
if (info)
|
||||
info->clear(QString(i18n("Export: %1 to PostScript")).arg(KShellProcess::quote(dviFile->filename)));
|
||||
|
||||
proc->clearArguments();
|
||||
finfo.setFile(dviFile->filename);
|
||||
*proc << QString("cd %1; dvips").arg(KShellProcess::quote(finfo.dirPath(true)));
|
||||
*proc << QString("%1").arg(KShellProcess::quote(dviFile->filename));
|
||||
*proc << QString("-o %1").arg(KShellProcess::quote(fileName));
|
||||
proc->closeStdin();
|
||||
if (proc->start(KProcess::NotifyOnExit, KProcess::Stderr) == false) {
|
||||
kdError(4300) << "dvips failed to start" << endl;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void dviWindow::abortExternalProgramm(void)
|
||||
{
|
||||
if (proc != 0) {
|
||||
delete proc; // Deleting the KProcess kills the child.
|
||||
proc = 0;
|
||||
}
|
||||
|
||||
if (progress != 0) {
|
||||
progress->hideDialog();
|
||||
delete progress;
|
||||
progress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void dviWindow::dvips_output_receiver(KProcess *, char *buffer, int buflen)
|
||||
{
|
||||
// Paranoia.
|
||||
if (buflen < 0)
|
||||
return;
|
||||
QString op = QString::fromLocal8Bit(buffer, buflen);
|
||||
|
||||
if (info != 0)
|
||||
info->outputReceiver(op);
|
||||
if (progress != 0)
|
||||
progress->show();
|
||||
}
|
||||
|
||||
void dviWindow::dvips_terminated(KProcess *)
|
||||
{
|
||||
if ((proc->normalExit() == true) && (proc->exitStatus() != 0))
|
||||
KMessageBox::error( this,
|
||||
i18n("The external program used to export the DVI-file\n"
|
||||
"reported an error. You might wish to look at the\n"
|
||||
"document info dialog for a precise error report.") );
|
||||
abortExternalProgramm();
|
||||
}
|
||||
|
||||
|
||||
void dviWindow::setShowPS( int flag )
|
||||
{
|
||||
#ifdef DEBUG_DVIWIN
|
||||
|
@ -362,7 +530,7 @@ bool dviWindow::setFile( const QString & fname )
|
|||
delete pixmap;
|
||||
pixmap = 0;
|
||||
resize(0, 0);
|
||||
return true; // added "true" to fix compilation. Is this correct ? (David)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Make sure the file actually exists.
|
||||
|
|
14
dviwin.h
14
dviwin.h
|
@ -24,6 +24,7 @@
|
|||
#include "dvi_init.h"
|
||||
|
||||
class infoDialog;
|
||||
class KShellProcess;
|
||||
class fontProgressDialog;
|
||||
|
||||
// max. number of hyperlinks per page. This should later be replaced by
|
||||
|
@ -52,6 +53,8 @@ public:
|
|||
class dvifile *dviFile;
|
||||
|
||||
void showInfo();
|
||||
void exportPS();
|
||||
void exportPDF();
|
||||
void changePageSize();
|
||||
int totalPages();
|
||||
void setShowPS( int flag );
|
||||
|
@ -94,14 +97,16 @@ public:
|
|||
void draw_page(void);
|
||||
|
||||
class fontPool *font_pool;
|
||||
class fontProgressDialog *progress;
|
||||
|
||||
public slots:
|
||||
void abortExternalProgramm(void);
|
||||
bool setFile(const QString & fname);
|
||||
void gotoPage(int page);
|
||||
double setZoom(double zoom);
|
||||
double zoom() { return _zoom; };
|
||||
void drawPage();
|
||||
|
||||
void dvips_output_receiver(KProcess *, char *buffer, int buflen);
|
||||
void dvips_terminated(KProcess *);
|
||||
|
||||
signals:
|
||||
/// Emitted to indicate that a hyperlink has been clicked on, and
|
||||
|
@ -113,6 +118,8 @@ protected:
|
|||
void paintEvent(QPaintEvent *ev);
|
||||
|
||||
private:
|
||||
// Used to run commands like "dvips" or "dvipdfm"
|
||||
KShellProcess *proc;
|
||||
|
||||
// These fields contain information about the geometry of the page.
|
||||
unsigned int unshrunk_paper_w; // basedpi * width(in inch)
|
||||
|
@ -159,6 +166,9 @@ private:
|
|||
// Indicates if the current page is already drawn (=1) or not (=0).
|
||||
char is_current_page_drawn;
|
||||
double _zoom;
|
||||
|
||||
// Used to show the progress of dvips and friends.
|
||||
fontProgressDialog *progress;
|
||||
};
|
||||
|
||||
|
||||
|
|
54
fontpool.cpp
54
fontpool.cpp
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "font.h"
|
||||
#include "fontpool.h"
|
||||
#include "fontprogress.h"
|
||||
#include "kdvi.h"
|
||||
#include "xdvi.h"
|
||||
|
||||
|
@ -26,10 +27,36 @@ const int MFResolutions[] = { 300, 600, 1200 };
|
|||
|
||||
fontPool::fontPool(void)
|
||||
{
|
||||
setName("Font Pool");
|
||||
|
||||
proc = 0;
|
||||
fontList.setAutoDelete(TRUE);
|
||||
|
||||
progress = new fontProgressDialog( "fontgen", // Chapter in the documentation for help.
|
||||
i18n( "KDVI is currently generating bitmap fonts..." ),
|
||||
i18n( "Aborts the font generation. Don't do this." ),
|
||||
i18n( "KDVI is currently generating bitmap fonts which are needed to display your document. "
|
||||
"For this, KDVI uses a number of external programs, such as MetaFont. You can find "
|
||||
"the output of these programs later in the document info dialog." ),
|
||||
i18n( "KDVI is generating fonts. Please wait." ),
|
||||
0 );
|
||||
if (progress == NULL)
|
||||
kdError(4300) << "Could not allocate memory for the font progress dialog." << endl;
|
||||
else {
|
||||
qApp->connect(this, SIGNAL(hide_progress_dialog()), progress, SLOT(hideDialog()));
|
||||
qApp->connect(this, SIGNAL(totalFontsInJob(int)), progress, SLOT(setTotalSteps(int)));
|
||||
qApp->connect(this, SIGNAL(show_progress(void)), progress, SLOT(show(void)));
|
||||
qApp->connect(progress, SIGNAL(finished(void)), this, SLOT(abortGeneration(void)));
|
||||
}
|
||||
}
|
||||
|
||||
fontPool::~fontPool(void)
|
||||
{
|
||||
if (progress)
|
||||
delete progress;
|
||||
}
|
||||
|
||||
|
||||
unsigned int fontPool::setMetafontMode( unsigned int mode )
|
||||
{
|
||||
if (mode >= NumberOfMFModes) {
|
||||
|
@ -202,7 +229,8 @@ char fontPool::check_if_fonts_are_loaded(unsigned char pass)
|
|||
this, SLOT(kpsewhich_terminated(KProcess *)));
|
||||
qApp->connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)),
|
||||
this, SLOT(mf_output_receiver(KProcess *, char *, int)));
|
||||
|
||||
emit(new_kpsewhich_run(i18n("Font Generation")));
|
||||
|
||||
proc->clearArguments();
|
||||
*proc << "kpsewhich";
|
||||
*proc << QString("--dpi %1").arg(MFResolutions[MetafontMode]);
|
||||
|
@ -428,6 +456,7 @@ void fontPool::mf_output_receiver(KProcess *, char *buffer, int buflen)
|
|||
bool show_prog = false;
|
||||
while( (numleft = MetafontOutput.find('\n')) != -1) {
|
||||
QString line = MetafontOutput.left(numleft+1);
|
||||
emit(MFOutput(line));
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << "MF OUTPUT RECEIVED: " << line;
|
||||
#endif
|
||||
|
@ -435,7 +464,28 @@ void fontPool::mf_output_receiver(KProcess *, char *buffer, int buflen)
|
|||
// and show the progress dialog at the end of this method.
|
||||
if (line.find("kpathsea:") == 0)
|
||||
show_prog = true;
|
||||
emit(MFOutput(line));
|
||||
|
||||
// If the Output of the kpsewhich program contains a line starting
|
||||
// with "kpathsea:", this means that a new MetaFont-run has been
|
||||
// started. We filter these lines out and update the display
|
||||
// accordingly.
|
||||
int startlineindex = line.find("kpathsea:");
|
||||
if (startlineindex != -1) {
|
||||
int endstartline = line.find("\n",startlineindex);
|
||||
QString startLine = line.mid(startlineindex,endstartline-startlineindex);
|
||||
|
||||
// The last word in the startline is the name of the font which we
|
||||
// are generating. The second-to-last word is the resolution in
|
||||
// dots per inch. Display this info in the text label below the
|
||||
// progress bar.
|
||||
int lastblank = startLine.findRev(' ');
|
||||
QString fontName = startLine.mid(lastblank+1);
|
||||
int secondblank = startLine.findRev(' ',lastblank-1);
|
||||
QString dpi = startLine.mid(secondblank+1,lastblank-secondblank-1);
|
||||
|
||||
progress->increaseNumSteps( i18n("Currently generating %1 at %2 dpi").arg(fontName).arg(dpi) );
|
||||
}
|
||||
|
||||
MetafontOutput = MetafontOutput.remove(0,numleft+1);
|
||||
}
|
||||
|
||||
|
|
12
fontpool.h
12
fontpool.h
|
@ -43,6 +43,9 @@ Q_OBJECT
|
|||
/** Default constructor. */
|
||||
fontPool( void );
|
||||
|
||||
/** Default destructor. */
|
||||
~fontPool( void );
|
||||
|
||||
/** Method used to set the MetafontMode for the PK font files. This
|
||||
data is used when loading fonts. Currently, a change here will
|
||||
be applied only to those font which were not yet loaded
|
||||
|
@ -134,7 +137,11 @@ signals:
|
|||
|
||||
/** Emitted to pass output of MetaFont and friends on to the user
|
||||
interface. */
|
||||
void MFOutput(const QString);
|
||||
void MFOutput(QString);
|
||||
|
||||
/** Emitted when a kpsewhich run is started in order to clear the
|
||||
info dialog window. */
|
||||
void new_kpsewhich_run(QString);
|
||||
|
||||
/** Emitted when the font-pool has changed. The class receiving the
|
||||
signal might whish to call status() in order to receive the
|
||||
|
@ -182,6 +189,9 @@ private:
|
|||
/** This is the ShellProcess which is used to run the kpsewhich
|
||||
command which locates the font-files for us. */
|
||||
KShellProcess *proc;
|
||||
|
||||
/** FontProgress; the progress dialog used when generating fonts. */
|
||||
class fontProgressDialog *progress;
|
||||
};
|
||||
|
||||
#endif //ifndef _FONTPOOL_H
|
||||
|
|
|
@ -22,36 +22,41 @@
|
|||
* Constructs a fontProgressDialog which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
fontProgressDialog::fontProgressDialog( QWidget* parent, const QString &name )
|
||||
fontProgressDialog::fontProgressDialog( QString helpIndex, QString label, QString abortTip, QString whatsThis, QString ttip, QWidget* parent, const QString &name, bool progressbar )
|
||||
: KDialogBase( parent, "Font Generation Progress Dialog", true, name, Cancel, Cancel, true )
|
||||
{
|
||||
setCursor( QCursor( 3 ) );
|
||||
// setCaption( i18n( "Please wait..." ) );
|
||||
|
||||
setButtonCancelText( i18n("Abort"), i18n("Aborts the font generation. Don't do this."));
|
||||
setButtonCancelText( i18n("Abort"), abortTip );
|
||||
|
||||
setHelp("fontgen", "kdvi");
|
||||
setHelpLinkText( i18n( "What's going on here?") );
|
||||
enableLinkedHelp(true);
|
||||
if (helpIndex.isEmpty() == false) {
|
||||
setHelp(helpIndex, "kdvi");
|
||||
setHelpLinkText( i18n( "What's going on here?") );
|
||||
enableLinkedHelp(true);
|
||||
} else
|
||||
enableLinkedHelp(false);
|
||||
|
||||
QVBox *page = makeVBoxMainWidget();
|
||||
|
||||
QString tip = i18n( "KDVI is currently generating bitmap fonts which are needed to display your document. For this, KDVI uses a number of external programs, such as MetaFont. You can find the output of these programs later in the document info dialog." );
|
||||
QString ttip = i18n( "KDVI is generating fonts. Please wait." );
|
||||
|
||||
TextLabel1 = new QLabel( i18n( "KDVI is currently generating bitmap fonts..." ), page, "TextLabel1" );
|
||||
TextLabel1 = new QLabel( label, page, "TextLabel2" );
|
||||
TextLabel1->setAlignment( int( QLabel::AlignCenter ) );
|
||||
QWhatsThis::add( TextLabel1, tip );
|
||||
QWhatsThis::add( TextLabel1, whatsThis );
|
||||
QToolTip::add( TextLabel1, ttip );
|
||||
|
||||
ProgressBar1 = new KProgress( page, "ProgressBar1" );
|
||||
QWhatsThis::add( ProgressBar1, tip );
|
||||
QToolTip::add( ProgressBar1, ttip );
|
||||
|
||||
if (progressbar) {
|
||||
ProgressBar1 = new KProgress( page, "ProgressBar1" );
|
||||
ProgressBar1->setFormat(i18n("%v of %m"));
|
||||
QWhatsThis::add( ProgressBar1, whatsThis );
|
||||
QToolTip::add( ProgressBar1, ttip );
|
||||
} else
|
||||
ProgressBar1 = NULL;
|
||||
|
||||
TextLabel2 = new QLabel( "", page, "TextLabel2" );
|
||||
TextLabel2->setAlignment( int( QLabel::AlignCenter ) );
|
||||
QWhatsThis::add( TextLabel2, tip );
|
||||
QWhatsThis::add( TextLabel2, whatsThis );
|
||||
QToolTip::add( TextLabel2, ttip );
|
||||
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,31 +69,14 @@ fontProgressDialog::~fontProgressDialog()
|
|||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
|
||||
void fontProgressDialog::outputReceiver(const QString op)
|
||||
void fontProgressDialog::increaseNumSteps( const QString explanation)
|
||||
{
|
||||
// If the Output of the kpsewhich program contains a line starting
|
||||
// with "kpathsea:", this means that a new MetaFont-run has been
|
||||
// started. We filter these lines out and print them in boldface.
|
||||
int startlineindex = op.find("kpathsea:");
|
||||
if (startlineindex != -1) {
|
||||
if (ProgressBar1 != 0)
|
||||
ProgressBar1->setValue(progress++);
|
||||
|
||||
int endstartline = op.find("\n",startlineindex);
|
||||
QString startLine = op.mid(startlineindex,endstartline-startlineindex);
|
||||
|
||||
// The last word in the startline is the name of the font which we
|
||||
// are generating. The second-to-last word is the resolution in
|
||||
// dots per inch. Display this info in the text label below the
|
||||
// progress bar.
|
||||
int lastblank = startLine.findRev(' ');
|
||||
QString fontName = startLine.mid(lastblank+1);
|
||||
int secondblank = startLine.findRev(' ',lastblank-1);
|
||||
QString dpi = startLine.mid(secondblank+1,lastblank-secondblank-1);
|
||||
TextLabel2->setText( i18n("Currently generating %1 at %2 dpi").arg(fontName).arg(dpi) );
|
||||
}
|
||||
TextLabel2->setText( explanation );
|
||||
}
|
||||
|
||||
|
||||
void fontProgressDialog::hideDialog(void)
|
||||
{
|
||||
hide();
|
||||
|
@ -96,8 +84,10 @@ void fontProgressDialog::hideDialog(void)
|
|||
|
||||
void fontProgressDialog::setTotalSteps(int steps)
|
||||
{
|
||||
ProgressBar1->setRange(0,steps);
|
||||
ProgressBar1->setValue(0);
|
||||
if (ProgressBar1 != 0) {
|
||||
ProgressBar1->setRange(0,steps);
|
||||
ProgressBar1->setValue(0);
|
||||
}
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class fontProgressDialog : public KDialogBase
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
fontProgressDialog( QWidget* parent = 0, const QString &name = 0 );
|
||||
fontProgressDialog( QString helpIndex, QString label, QString abortTip, QString whatsThis, QString ttip, QWidget* parent = 0, const QString &name = 0, bool progressbar=true );
|
||||
~fontProgressDialog();
|
||||
|
||||
QLabel* TextLabel1;
|
||||
|
@ -46,9 +46,9 @@ public:
|
|||
QLabel* TextLabel2;
|
||||
|
||||
public slots:
|
||||
/** Used to receive text from the external program. The text
|
||||
received here is analyzed and presented to the user. */
|
||||
void outputReceiver(const QString);
|
||||
/** The number of steps already done is increased, the text received
|
||||
here is analyzed and presented to the user. */
|
||||
void increaseNumSteps( const QString explanation );
|
||||
|
||||
/** Used to initialize the progress bar. */
|
||||
void setTotalSteps(int);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "infodialog.h"
|
||||
|
||||
infoDialog::infoDialog( QWidget* parent )
|
||||
: KDialogBase( Tabbed, "Document Info", Ok, Ok, parent, "documentinfo", false, false)
|
||||
: KDialogBase( Tabbed, "Document Info", Ok, Ok, parent, "Document Info", false, false)
|
||||
{
|
||||
QFrame *page1 = addPage( i18n("DVI File") );
|
||||
QVBoxLayout *topLayout1 = new QVBoxLayout( page1, 0, 6 );
|
||||
|
@ -31,18 +31,23 @@ infoDialog::infoDialog( QWidget* parent )
|
|||
TextLabel2->setMinimumWidth(fontMetrics().maxWidth()*50);
|
||||
TextLabel2->setMinimumHeight(fontMetrics().height()*10);
|
||||
QToolTip::add( TextLabel2, i18n("Information on currently loaded fonts.") );
|
||||
QWhatsThis::add( TextLabel2, i18n("This text field shows detailed information about the currently loaded fonts. This is useful for experts who want to locate problems in the setup of TeX or KDVI.") );
|
||||
QWhatsThis::add( TextLabel2, i18n("This text field shows detailed information about the currently loaded fonts. "
|
||||
"This is useful for experts who want to locate problems in the setup of TeX or KDVI.") );
|
||||
topLayout2->addWidget( TextLabel2 );
|
||||
|
||||
QFrame *page3 = addPage( i18n("MetaFont") );
|
||||
QFrame *page3 = addPage( i18n("External Programs") );
|
||||
QVBoxLayout *topLayout3 = new QVBoxLayout( page3, 0, 6 );
|
||||
TextLabel3 = new QTextView( page3, "TextLabel1" );
|
||||
TextLabel3->setText( i18n("No output from MetaFont received.") );
|
||||
QToolTip::add( TextLabel3, i18n("Output of the MetaFont program.") );
|
||||
QWhatsThis::add( TextLabel3, i18n("KDVI uses external programs, such as MetaFont, to generate the bitmap fonts. This text field shows the output of these programs which is useful for experts who want to find problems in the setup of TeX or KDVI.") );
|
||||
TextLabel3->setText( i18n("No output from any external program received.") );
|
||||
QToolTip::add( TextLabel3, i18n("Output of external programs.") );
|
||||
QWhatsThis::add( TextLabel3, i18n("KDVI uses external programs, such as MetaFont, dvipdfm or dvips. "
|
||||
"This text field shows the output of these programs. "
|
||||
"That is useful for experts who want to find problems in the setup of TeX or KDVI.") );
|
||||
topLayout3->addWidget( TextLabel3 );
|
||||
|
||||
MFOutputReceived = false;
|
||||
headline = QString::null;
|
||||
pool = QString::null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,25 +90,47 @@ void infoDialog::setFontInfo(class fontPool *fp)
|
|||
TextLabel2->setText(fp->status());
|
||||
}
|
||||
|
||||
void infoDialog::outputReceiver(const QString op)
|
||||
void infoDialog::outputReceiver(QString op)
|
||||
{
|
||||
if (MFOutputReceived == false)
|
||||
TextLabel3->setText("");
|
||||
op = op.replace( QRegExp("<"), "<" );
|
||||
|
||||
// If the Output of the kpsewhich program contains a line starting
|
||||
// with "kpathsea:", this means that a new MetaFont-run has been
|
||||
// started. We filter these lines out and print them in boldface.
|
||||
int startlineindex = op.find("kpathsea:");
|
||||
if (startlineindex != -1) {
|
||||
int endstartline = op.find("\n",startlineindex);
|
||||
QString startLine = op.mid(startlineindex,endstartline-startlineindex);
|
||||
if (MFOutputReceived)
|
||||
TextLabel3->append("<hr>\n<b>"+startLine+"</b>");
|
||||
else
|
||||
TextLabel3->append("<b>"+startLine+"</b>");
|
||||
TextLabel3->append(op.mid(endstartline));
|
||||
} else
|
||||
TextLabel3->append(op);
|
||||
if (MFOutputReceived == false) {
|
||||
TextLabel3->setText("<b>"+headline+"</b><br>");
|
||||
headline = QString::null;
|
||||
}
|
||||
|
||||
// It seems that the QTextView wants that we append only full lines.
|
||||
// We see to that.
|
||||
pool = pool+op;
|
||||
int idx = pool.findRev("\n");
|
||||
|
||||
while(idx != -1) {
|
||||
QString line = pool.left(idx);
|
||||
pool = pool.mid(idx+1);
|
||||
|
||||
// If the Output of the kpsewhich program contains a line starting
|
||||
// with "kpathsea:", this means that a new MetaFont-run has been
|
||||
// started. We filter these lines out and print them in boldface.
|
||||
int startlineindex = line.find("kpathsea:");
|
||||
if (startlineindex != -1) {
|
||||
int endstartline = line.find("\n",startlineindex);
|
||||
QString startLine = line.mid(startlineindex,endstartline-startlineindex);
|
||||
if (MFOutputReceived)
|
||||
TextLabel3->append("<hr>\n<b>"+startLine+"</b>");
|
||||
else
|
||||
TextLabel3->append("<b>"+startLine+"</b>");
|
||||
TextLabel3->append(line.mid(endstartline));
|
||||
} else
|
||||
TextLabel3->append(line);
|
||||
idx = pool.findRev("\n");
|
||||
}
|
||||
|
||||
MFOutputReceived = true;
|
||||
}
|
||||
|
||||
void infoDialog::clear(QString op)
|
||||
{
|
||||
headline = op;
|
||||
pool = QString::null;
|
||||
MFOutputReceived = false;
|
||||
}
|
||||
|
|
13
infodialog.h
13
infodialog.h
|
@ -6,6 +6,7 @@
|
|||
#ifndef INFO_KDVI_H
|
||||
#define INFO_KDVI_H
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qvariant.h>
|
||||
#include <kdialogbase.h>
|
||||
|
||||
|
@ -40,15 +41,23 @@ public:
|
|||
public slots:
|
||||
/** This slot is called when Output from the MetaFont programm
|
||||
is received via the fontpool/kpsewhich */
|
||||
void outputReceiver(const QString);
|
||||
void outputReceiver(QString);
|
||||
|
||||
/** This slot is called whenever anything in the fontpool has
|
||||
changed. If the infoDialog is shown, the dialog could then
|
||||
query the fontpool for more information. */
|
||||
void setFontInfo(class fontPool *fp);
|
||||
|
||||
/** Calling this slot clears the text view and stores the
|
||||
headline. The next time output is received via the
|
||||
outputReceiver, the headline is displayed in bold on top of
|
||||
the text view. */
|
||||
void clear(QString);
|
||||
|
||||
protected:
|
||||
bool MFOutputReceived;
|
||||
bool MFOutputReceived;
|
||||
QString headline;
|
||||
QString pool;
|
||||
};
|
||||
|
||||
#endif // INFO_KDVI_H
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
#include <kapp.h>
|
||||
#include <kbugreport.h>
|
||||
#include <kconfig.h>
|
||||
#include <klocale.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kglobal.h>
|
||||
#include <kimageeffect.h>
|
||||
#include <kinstance.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <qobject.h>
|
||||
#include <qlabel.h>
|
||||
#include <qstring.h>
|
||||
|
@ -75,25 +76,14 @@ KDVIMultiPage::KDVIMultiPage(QWidget *parentWidget, const char *widgetName, QObj
|
|||
window = new dviWindow( 1.0, true, scrollView());
|
||||
preferencesChanged();
|
||||
|
||||
new KAction(i18n("Document &Info"), 0, this,
|
||||
SLOT(doInfo()), actionCollection(),
|
||||
"info_dvi");
|
||||
docInfoAction = new KAction(i18n("Document &Info"), 0, this, SLOT(doInfo()), actionCollection(), "info_dvi");
|
||||
exportPSAction = new KAction(i18n("PostScript"), 0, this, SLOT(doExportPS()), actionCollection(), "export_postscript");
|
||||
exportPDFAction = new KAction(i18n("PDF"), 0, this, SLOT(doExportPDF()), actionCollection(), "export_pdf");
|
||||
|
||||
new KAction(i18n("&DVI Options"), 0, this,
|
||||
SLOT(doSettings()), actionCollection(),
|
||||
"settings_dvi");
|
||||
|
||||
new KAction(i18n("About the KDVI plugin..."), 0, this,
|
||||
SLOT(about()), actionCollection(),
|
||||
"about_kdvi");
|
||||
|
||||
new KAction(i18n("Help on the KDVI plugin..."), 0, this,
|
||||
SLOT(helpme()), actionCollection(),
|
||||
"help_dvi");
|
||||
|
||||
new KAction(i18n("Report Bug in the KDVI plugin..."), 0, this,
|
||||
SLOT(bugform()), actionCollection(),
|
||||
"bug_dvi");
|
||||
new KAction(i18n("&DVI Options"), 0, this, SLOT(doSettings()), actionCollection(), "settings_dvi");
|
||||
new KAction(i18n("About the KDVI plugin..."), 0, this, SLOT(about()), actionCollection(), "about_kdvi");
|
||||
new KAction(i18n("Help on the KDVI plugin..."), 0, this, SLOT(helpme()), actionCollection(), "help_dvi");
|
||||
new KAction(i18n("Report Bug in the KDVI plugin..."), 0, this, SLOT(bugform()), actionCollection(), "bug_dvi");
|
||||
|
||||
setXMLFile("kdvi_part.rc");
|
||||
|
||||
|
@ -101,6 +91,7 @@ KDVIMultiPage::KDVIMultiPage(QWidget *parentWidget, const char *widgetName, QObj
|
|||
connect(window, SIGNAL(request_goto_page(int, int)), this, SLOT(goto_page(int, int) ) );
|
||||
|
||||
readSettings();
|
||||
enableActions(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,6 +113,7 @@ bool KDVIMultiPage::openFile()
|
|||
emit numberOfPages(window->totalPages());
|
||||
scrollView()->resizeContents(window->width(), window->height());
|
||||
emit previewChanged(true);
|
||||
enableActions(r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -131,6 +123,7 @@ bool KDVIMultiPage::closeURL()
|
|||
{
|
||||
window->setFile(""); // That means: close the file. Resize the widget to 0x0.
|
||||
emit previewChanged(false);
|
||||
enableActions(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -138,7 +131,7 @@ bool KDVIMultiPage::closeURL()
|
|||
QStringList KDVIMultiPage::fileFormats()
|
||||
{
|
||||
QStringList r;
|
||||
r << i18n("*.dvi *.DVI|DVI files (*.dvi)");
|
||||
r << i18n("*.dvi *.DVI|TeX Device Independent files (*.dvi)");
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -215,6 +208,16 @@ void KDVIMultiPage::doInfo(void)
|
|||
window->showInfo();
|
||||
}
|
||||
|
||||
void KDVIMultiPage::doExportPS(void)
|
||||
{
|
||||
window->exportPS();
|
||||
}
|
||||
|
||||
void KDVIMultiPage::doExportPDF(void)
|
||||
{
|
||||
window->exportPDF();
|
||||
}
|
||||
|
||||
void KDVIMultiPage::doSettings()
|
||||
{
|
||||
if (options) {
|
||||
|
@ -233,7 +236,7 @@ void KDVIMultiPage::about()
|
|||
i18n("the KDVI plugin"),
|
||||
KAboutDialog::Close, KAboutDialog::Close);
|
||||
|
||||
ab->setProduct("kdvi", "0.9e", QString::null, QString::null);
|
||||
ab->setProduct("kdvi", "0.9f", QString::null, QString::null);
|
||||
ab->addTextPage (i18n("About"),
|
||||
i18n("A previewer for Device Independent files (DVI files) produced "
|
||||
"by the TeX typesetting system.<br>"
|
||||
|
@ -268,7 +271,7 @@ void KDVIMultiPage::about()
|
|||
|
||||
void KDVIMultiPage::bugform()
|
||||
{
|
||||
KAboutData *kab = new KAboutData("kdvi", I18N_NOOP("KDVI"), "0.9e", 0, 0, 0, 0, 0);
|
||||
KAboutData *kab = new KAboutData("kdvi", I18N_NOOP("KDVI"), "0.9f", 0, 0, 0, 0, 0);
|
||||
KBugReport *kbr = new KBugReport(0, true, kab );
|
||||
kbr->show();
|
||||
}
|
||||
|
@ -367,7 +370,8 @@ void KDVIMultiPage::reload()
|
|||
timer_id = -1;
|
||||
int currsav = window->curr_page();
|
||||
|
||||
window->setFile(m_file);
|
||||
bool r = window->setFile(m_file);
|
||||
enableActions(r);
|
||||
|
||||
// Go to the old page and tell kviewshell where we are.
|
||||
window->gotoPage(currsav);
|
||||
|
@ -382,3 +386,10 @@ void KDVIMultiPage::reload()
|
|||
timer_id = startTimer(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void KDVIMultiPage::enableActions(bool b)
|
||||
{
|
||||
docInfoAction->setEnabled(b);
|
||||
exportPSAction->setEnabled(b);
|
||||
exportPDFAction->setEnabled(b);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ public:
|
|||
private:
|
||||
|
||||
static KInstance *s_instance;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -93,20 +92,21 @@ protected:
|
|||
|
||||
signals:
|
||||
|
||||
/// Emitted to indicate the number of pages in the file. The
|
||||
//receiver will set the current page to zero and call the
|
||||
//gotoPage()-method.
|
||||
/** Emitted to indicate the number of pages in the file. The
|
||||
receiver will set the current page to zero and call the
|
||||
gotoPage()-method. */
|
||||
void numberOfPages(int nr);
|
||||
|
||||
/// Emitted to indicate the number of pages in the file and the
|
||||
//current page. The receiver will not change or update the display,
|
||||
//nor call the gotoPage()-method.
|
||||
/** Emitted to indicate the number of pages in the file and the
|
||||
current page. The receiver will not change or update the
|
||||
display, nor call the gotoPage()-method. */
|
||||
void pageInfo(int nr, int currpg);
|
||||
|
||||
protected slots:
|
||||
|
||||
void doSettings();
|
||||
void doInfo();
|
||||
void doExportPS();
|
||||
void doExportPDF();
|
||||
void about();
|
||||
void helpme();
|
||||
void bugform();
|
||||
|
@ -116,9 +116,18 @@ protected slots:
|
|||
|
||||
private:
|
||||
|
||||
dviWindow *window;
|
||||
dviWindow *window;
|
||||
OptionDialog *options;
|
||||
|
||||
/** Pointers to several actions which are disabled if no file is
|
||||
loaded. */
|
||||
KAction *docInfoAction;
|
||||
KAction *exportPSAction;
|
||||
KAction *exportPDFAction;
|
||||
|
||||
/** Used to enable the export menu when a file is successfully
|
||||
loaded. */
|
||||
void enableActions(bool);
|
||||
};
|
||||
|
||||
|
||||
|
|
10
kdvi_part.rc
10
kdvi_part.rc
|
@ -3,18 +3,20 @@
|
|||
<MenuBar>
|
||||
<Menu name="file"><text>File</text>
|
||||
<Action name="info_dvi" group="file_print" append="options_show_merge"/>
|
||||
<Menu name="export" group="file_save" ><text>Export as...</text>
|
||||
<Action name="export_postscript" append="options_show_merge"/>
|
||||
<Action name="export_pdf" append="options_show_merge"/>
|
||||
</Menu>
|
||||
</Menu>
|
||||
|
||||
<Menu name="settings"><text>Settings</text>
|
||||
<Action name="settings_dvi" append="options_show_merge"/>
|
||||
</Menu>
|
||||
|
||||
<Menu name="help"><text>Help</text>
|
||||
<Separator/>
|
||||
<Action name="help_dvi" append="options_show_merge"/>
|
||||
</Menu>
|
||||
<Menu name="help"><text>Help</text>
|
||||
<Action name="about_kdvi" append="options_show_merge"/>
|
||||
</Menu>
|
||||
<Menu name="help"><text>Help</text>
|
||||
<Action name="bug_dvi" append="options_show_merge"/>
|
||||
</Menu>
|
||||
</MenuBar>
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
#include "marklist.h"
|
||||
#include <qfile.h>
|
||||
|
||||
#include <kmessagebox.h>
|
||||
#include <kdebug.h>
|
||||
#include <kapp.h>
|
||||
#include <kconfig.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kprocess.h>
|
||||
|
||||
Print::Print
|
||||
(
|
||||
|
@ -138,7 +138,7 @@ void Print::okPressed()
|
|||
}
|
||||
}
|
||||
|
||||
cmd += " " + ifile;
|
||||
cmd += " " + KShellProcess::quote(ifile);
|
||||
|
||||
if ( nup != 1 ) {
|
||||
cmd += nupProgram == "mpage" ? " | mpage -" : " | psnup -";
|
||||
|
|
Loading…
Reference in a new issue