00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef klflatexpreviewthread_H__
00025 #define klflatexpreviewthread_H__
00026
00027 #include <QThread>
00028 #include <QMutex>
00029 #include <QWaitCondition>
00030
00031 #include <klfdefs.h>
00032 #include <klfbackend.h>
00033
00034
00035 struct KLFLatexPreviewThreadPrivate;
00036
00037 class KLF_EXPORT KLFLatexPreviewHandler : public QObject
00038 {
00039 Q_OBJECT
00040 public:
00041 KLFLatexPreviewHandler(QObject * parent = NULL) ;
00042 virtual ~KLFLatexPreviewHandler();
00043
00044 public slots:
00046 virtual void latexPreviewReset();
00047
00053 virtual void latexOutputAvailable(const KLFBackend::klfOutput& output) ;
00056 virtual void latexPreviewAvailable(const QImage& preview, const QImage& largePreview, const QImage& fullPreview);
00059 virtual void latexPreviewImageAvailable(const QImage& preview);
00062 virtual void latexPreviewLargeImageAvailable(const QImage& largePreview);
00064 virtual void latexPreviewFullImageAvailable(const QImage& fullPreview);
00065
00068 virtual void latexPreviewError(const QString& errorString, int errorCode);
00069 };
00070
00071
00072
00073 class KLF_EXPORT KLFLatexPreviewThread : public QThread
00074 {
00075 Q_OBJECT
00076
00077 Q_PROPERTY(QSize previewSize READ previewSize WRITE setPreviewSize) ;
00078 Q_PROPERTY(QSize largePreviewSize READ largePreviewSize WRITE setLargePreviewSize) ;
00079
00080 public:
00081 KLFLatexPreviewThread(QObject *parent = NULL);
00082 virtual ~KLFLatexPreviewThread();
00083
00084 typedef qint64 TaskId;
00085
00086 QSize previewSize() const;
00087 QSize largePreviewSize() const;
00088 void getPreviewSizes(QSize *previewsize, QSize *largepreviewsize) const;
00089
00090 void setPreviewSize(const QSize& previewSize);
00091 void setLargePreviewSize(const QSize& largePreviewSize);
00092 void setPreviewSizes(const QSize& previewsize, const QSize& largepreviewsize) const;
00093
00094 void cancelTask(TaskId task);
00095 void clearPendingTasks();
00096
00097 void start(Priority priority = InheritPriority);
00098 void stop();
00099
00100 public slots:
00101
00102 TaskId submitPreviewTask(const KLFBackend::klfInput& input,
00103 const KLFBackend::klfSettings& settings,
00104 KLFLatexPreviewHandler * outputhandler,
00105 const QSize& previewSize, const QSize& largePreviewSize);
00106 TaskId submitPreviewTask(const KLFBackend::klfInput& input,
00107 const KLFBackend::klfSettings& settings,
00108 KLFLatexPreviewHandler * outputhandler);
00109 TaskId clearAndSubmitPreviewTask(const KLFBackend::klfInput& input,
00110 const KLFBackend::klfSettings& settings,
00111 KLFLatexPreviewHandler * outputhandler,
00112 const QSize& previewSize, const QSize& largePreviewSize);
00113 TaskId clearAndSubmitPreviewTask(const KLFBackend::klfInput& input,
00114 const KLFBackend::klfSettings& settings,
00115 KLFLatexPreviewHandler * outputhandler);
00116 TaskId replaceSubmitPreviewTask(TaskId replaceId,
00117 const KLFBackend::klfInput& input,
00118 const KLFBackend::klfSettings& settings,
00119 KLFLatexPreviewHandler * outputhandler,
00120 const QSize& previewSize, const QSize& largePreviewSize);
00121 TaskId replaceSubmitPreviewTask(TaskId replaceId,
00122 const KLFBackend::klfInput& input,
00123 const KLFBackend::klfSettings& settings,
00124 KLFLatexPreviewHandler * outputhandler);
00125
00126 protected:
00127 virtual void run();
00128
00129 private:
00130 KLF_DECLARE_PRIVATE(KLFLatexPreviewThread) ;
00131
00132 QMutex _startupmutex;
00133 QWaitCondition _startupWaitCondition;
00134 };
00135
00136
00137
00138
00139
00140 struct KLFContLatexPreviewPrivate;
00141
00152 class KLF_EXPORT KLFContLatexPreview : public QObject
00153 {
00154 Q_OBJECT
00155
00156 Q_PROPERTY(QSize previewSize READ previewSize WRITE setPreviewSize) ;
00157 Q_PROPERTY(QSize largePreviewSize READ largePreviewSize WRITE setLargePreviewSize) ;
00158
00159 public:
00160 KLFContLatexPreview(KLFLatexPreviewThread * thread = NULL);
00161 virtual ~KLFContLatexPreview();
00162
00163 bool enabled() const;
00164
00165 KLFBackend::klfInput intput() const;
00166 KLFBackend::klfSettings settings() const;
00167
00168 QSize previewSize() const;
00169 QSize largePreviewSize() const;
00170
00171 void setThread(KLFLatexPreviewThread * thread);
00172
00173 signals:
00175 void previewReset();
00176
00182 void outputAvailable(const KLFBackend::klfOutput& output) ;
00185 void previewAvailable(const QImage& preview, const QImage& largePreview, const QImage& fullPreview);
00188 void previewImageAvailable(const QImage& preview);
00191 void previewLargeImageAvailable(const QImage& largePreview);
00193 void previewFullImageAvailable(const QImage& fullPreview);
00194
00197 void previewError(const QString& errorString, int errorCode);
00198
00200 void compiling(bool isCompiling);
00201
00202 public slots:
00203
00204 void setEnabled(bool enabled);
00205
00209 bool setInput(const KLFBackend::klfInput& input);
00211 bool setSettings(const KLFBackend::klfSettings& settings, bool disableExtraFormats = true);
00214 bool setPreviewSize(const QSize& previewSize);
00217 bool setLargePreviewSize(const QSize& largePreviewSize);
00218
00219 private:
00220 KLF_DECLARE_PRIVATE(KLFContLatexPreview) ;
00221 };
00222
00223
00224
00225 #endif