forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 1
/
externalviewer.hh
39 lines (29 loc) · 1.06 KB
/
externalviewer.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* This file is (c) 2008-2012 Konstantin Isakov <[email protected]>
* 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;
QString viewerCmdLine;
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,
QString const & extension, QString const & viewerCmdLine )
throw( exCantCreateTempFile );
// Once this is called, the object will be deleted when it's done, even if
// the function throws.
void start() throw( exCantRunViewer );
};
#endif