2010-12-09 12:31:50 +00:00
|
|
|
/* This file is (c) 2008-2011 Konstantin Isakov <ikm@goldendict.org>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __EXTERNALVIEWER_HH_INCLUDED__
|
|
|
|
#define __EXTERNALVIEWER_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QTemporaryFile>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <vector>
|
|
|
|
#include "ex.hh"
|
|
|
|
|
|
|
|
/// An external viewer, opens resources in other programs
|
|
|
|
class ExternalViewer: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QTemporaryFile tempFile;
|
|
|
|
QProcess viewer;
|
2011-05-30 01:05:28 +00:00
|
|
|
QString viewerCmdLine;
|
2009-01-28 20:55:45 +00:00
|
|
|
QString tempFileName;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DEF_EX( Ex, "External viewer exception", std::exception )
|
|
|
|
DEF_EX( exCantCreateTempFile, "Couldn't create temporary file.", Ex )
|
|
|
|
DEF_EX_STR( exCantRunViewer, "Couldn't run external viewer:", Ex )
|
|
|
|
|
|
|
|
ExternalViewer( QObject * parent, std::vector< char > const & data,
|
2011-05-30 01:05:28 +00:00
|
|
|
QString const & extension, QString const & viewerCmdLine )
|
2009-01-28 20:55:45 +00:00
|
|
|
throw( exCantCreateTempFile );
|
|
|
|
|
2011-05-29 05:08:37 +00:00
|
|
|
// Once this is called, the object will be deleted when it's done, even if
|
|
|
|
// the function throws.
|
2009-01-28 20:55:45 +00:00
|
|
|
void start() throw( exCantRunViewer );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|