[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klflatexpreviewthread.h
1 /***************************************************************************
2  * file klflatexpreviewthread.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id$ */
23 
24 #ifndef klflatexpreviewthread_H__
25 #define klflatexpreviewthread_H__
26 
27 #include <QThread>
28 #include <QMutex>
29 #include <QWaitCondition>
30 
31 #include <klfdefs.h>
32 #include <klfbackend.h>
33 
34 
35 struct KLFLatexPreviewThreadPrivate;
36 
38 {
39  Q_OBJECT
40 public:
41  KLFLatexPreviewHandler(QObject * parent = NULL) ;
42  virtual ~KLFLatexPreviewHandler();
43 
44 public slots:
46  virtual void latexPreviewReset();
47 
53  virtual void latexOutputAvailable(const KLFBackend::klfOutput& output) ;
56  virtual void latexPreviewAvailable(const QImage& preview, const QImage& largePreview, const QImage& fullPreview);
59  virtual void latexPreviewImageAvailable(const QImage& preview);
62  virtual void latexPreviewLargeImageAvailable(const QImage& largePreview);
64  virtual void latexPreviewFullImageAvailable(const QImage& fullPreview);
65 
68  virtual void latexPreviewError(const QString& errorString, int errorCode);
69 };
70 
71 
72 
74 {
75  Q_OBJECT
76 
77  Q_PROPERTY(QSize previewSize READ previewSize WRITE setPreviewSize) ;
78  Q_PROPERTY(QSize largePreviewSize READ largePreviewSize WRITE setLargePreviewSize) ;
79 
80 public:
81  KLFLatexPreviewThread(QObject *parent = NULL);
82  virtual ~KLFLatexPreviewThread();
83 
84  typedef qint64 TaskId;
85 
86  QSize previewSize() const;
87  QSize largePreviewSize() const;
88  void getPreviewSizes(QSize *previewsize, QSize *largepreviewsize) const;
89 
90  void setPreviewSize(const QSize& previewSize);
91  void setLargePreviewSize(const QSize& largePreviewSize);
92  void setPreviewSizes(const QSize& previewsize, const QSize& largepreviewsize) const;
93 
94  void cancelTask(TaskId task);
95  void clearPendingTasks();
96 
97  void start(Priority priority = InheritPriority);
98  void stop();
99 
100 public slots:
101 
102  TaskId submitPreviewTask(const KLFBackend::klfInput& input,
103  const KLFBackend::klfSettings& settings,
104  KLFLatexPreviewHandler * outputhandler,
105  const QSize& previewSize, const QSize& largePreviewSize);
106  TaskId submitPreviewTask(const KLFBackend::klfInput& input,
107  const KLFBackend::klfSettings& settings,
108  KLFLatexPreviewHandler * outputhandler);
109  TaskId clearAndSubmitPreviewTask(const KLFBackend::klfInput& input,
110  const KLFBackend::klfSettings& settings,
111  KLFLatexPreviewHandler * outputhandler,
112  const QSize& previewSize, const QSize& largePreviewSize);
113  TaskId clearAndSubmitPreviewTask(const KLFBackend::klfInput& input,
114  const KLFBackend::klfSettings& settings,
115  KLFLatexPreviewHandler * outputhandler);
116  TaskId replaceSubmitPreviewTask(TaskId replaceId,
117  const KLFBackend::klfInput& input,
118  const KLFBackend::klfSettings& settings,
119  KLFLatexPreviewHandler * outputhandler,
120  const QSize& previewSize, const QSize& largePreviewSize);
121  TaskId replaceSubmitPreviewTask(TaskId replaceId,
122  const KLFBackend::klfInput& input,
123  const KLFBackend::klfSettings& settings,
124  KLFLatexPreviewHandler * outputhandler);
125 
126 protected:
127  virtual void run();
128 
129 private:
131 
132  QMutex _startupmutex;
133  QWaitCondition _startupWaitCondition;
134 };
135 
136 
137 
138 
139 
140 struct KLFContLatexPreviewPrivate;
141 
153 {
154  Q_OBJECT
155 
156  Q_PROPERTY(QSize previewSize READ previewSize WRITE setPreviewSize) ;
157  Q_PROPERTY(QSize largePreviewSize READ largePreviewSize WRITE setLargePreviewSize) ;
158 
159 public:
161  virtual ~KLFContLatexPreview();
162 
163  bool enabled() const;
164 
165  KLFBackend::klfInput intput() const;
166  KLFBackend::klfSettings settings() const;
167 
168  QSize previewSize() const;
169  QSize largePreviewSize() const;
170 
171  void setThread(KLFLatexPreviewThread * thread);
172 
173 signals:
175  void previewReset();
176 
182  void outputAvailable(const KLFBackend::klfOutput& output) ;
185  void previewAvailable(const QImage& preview, const QImage& largePreview, const QImage& fullPreview);
188  void previewImageAvailable(const QImage& preview);
191  void previewLargeImageAvailable(const QImage& largePreview);
193  void previewFullImageAvailable(const QImage& fullPreview);
194 
197  void previewError(const QString& errorString, int errorCode);
198 
200  void compiling(bool isCompiling);
201 
202 public slots:
203 
204  void setEnabled(bool enabled);
205 
209  bool setInput(const KLFBackend::klfInput& input);
211  bool setSettings(const KLFBackend::klfSettings& settings, bool disableExtraFormats = true);
214  bool setPreviewSize(const QSize& previewSize);
217  bool setLargePreviewSize(const QSize& largePreviewSize);
218 
219 private:
221 };
222 
223 
224 
225 #endif
Specific input to KLFBackend::getLatexFormula()
Definition: klfbackend.h:306
void start(Priority priority)
#define KLF_EXPORT
#define KLF_DECLARE_PRIVATE(ClassName)
virtual void run()
Definition of class KLFBackend.
KLFBackend::getLatexFormula() result.
Definition: klfbackend.h:370
General settings for KLFBackend::getLatexFormula()
Definition: klfbackend.h:218

Generated by doxygen 1.8.15