Scribus
Open source desktop publishing at your fingertips
latexeditor.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  latexeditor.h - description
9  -------------------
10 copyright : Scribus Team
11 ***************************************************************************/
12 
13 /***************************************************************************
14 * *
15 * This program is free software; you can redistribute it and/or modify *
16 * it under the terms of the GNU General Public License as published by *
17 * the Free Software Foundation; either version 2 of the License, or *
18 * (at your option) any later version. *
19 * *
20 ***************************************************************************/
21 
22 #ifndef LATEXEDITOR_H
23 #define LATEXEDITOR_H
24 
25 #include "ui_latexeditor.h"
26 #include "scribusapi.h"
27 #include <QWidget>
28 #include <QProcess>
29 #include <QMap>
30 #include <QPushButton>
31 #include <QStringList>
32 
34 class LatexHighlighter;
36 class QComboBox;
37 class QListWidgetItem;
38 class QFile;
39 class XmlWidget;
40 class FileWatcher;
41 
42 class SCRIBUS_API LatexEditor : public QDialog, Ui::LatexEditor
43 {
44  Q_OBJECT
45  public:
47  ~LatexEditor();
48  virtual void changeEvent ( QEvent *e );
49  void startEditor();
50  void exitEditor();
51  void revert();
52  void apply ( bool force=false );
53  void initialize();
54  static QIcon icon ( QString config, QString fn );
55  static QString iconFile ( QString config );
56  protected:
57  PageItem_LatexFrame *frame;
58  LatexHighlighter *highlighter;
59  void loadSettings();
60  void createNewSettingsTab ( I18nXmlStreamReader *xml );
61  void createNewItemsTab ( I18nXmlStreamReader *xml );
62  QMap<QString, XmlWidget *> widgetMap;
63  QString currentConfigFile, currentIconFile;
64  /*External Editor*/
65  QString extEditorFile;
66  void loadExternalEditorFile();
67  void writeExternalEditorFile();
68  QProcess *extEditor;
69  FileWatcher *fileWatcher;
70  protected slots:
71  void extEditorFinished ( int exitCode, QProcess::ExitStatus exitStatus );
72  void extEditorFileChanged ( QString filename );
73  void extEditorError ( QProcess::ProcessError error );
74  public slots:
75  void okClicked();
76  void cancelClicked();
77  void updateClicked ( bool );
78  void revertClicked ( bool );
79  void formulaChanged ( QString, QString );
80  void applicationChanged();
81  void latexFinished();
82  void stateChanged ( QProcess::ProcessState );
83  //Slots for the dynamic interface
84  void tagButtonClicked ( QString );
85  void insertButtonClicked ( QObject * );
86  void newItemSelected ( QListWidgetItem *, QListWidgetItem * );
87  void itemDoubleClicked ( QListWidgetItem * );
88  void updateConfigFile();
89  void extEditorClicked();
90 };
91 
92 
93 class SCRIBUS_API DataPushButton : public QPushButton
94 {
95  Q_OBJECT
96  public:
97  DataPushButton ( QString caption, QObject *data, bool deleteOnDestroy=false ) :
98  QPushButton ( caption ), data ( data ), del ( deleteOnDestroy )
99  {
100  connect ( this, SIGNAL ( clicked ( bool ) ), this, SLOT ( buttonClicked ( bool ) ) );
101  }
102  ~DataPushButton()
103  {
104  if ( del ) delete data;
105  }
106  protected:
107  QObject *data;
108  bool del;
109  private slots:
110  void buttonClicked ( bool checked )
111  {
112  emit clickedWithData ( data );
113  }
114  signals:
115  void clickedWithData ( QObject *data );
116 };
117 
118 class SCRIBUS_API StringPushButton : public QPushButton
119 {
120  Q_OBJECT
121  public:
122  StringPushButton ( QString caption, QString data ) :
123  QPushButton ( caption ), data ( data )
124  {
125  connect ( this, SIGNAL ( clicked ( bool ) ), this, SLOT ( buttonClicked ( bool ) ) );
126  }
127  protected:
128  QString data;
129  private slots:
130  void buttonClicked ( bool checked )
131  {
132  emit clickedWithData ( data );
133  }
134  signals:
135  void clickedWithData ( QString data );
136 };
137 
138 class SCRIBUS_API XmlWidget
139 {
140  public:
141  static XmlWidget *fromXml ( I18nXmlStreamReader *xml );
142  XmlWidget ( I18nXmlStreamReader *xml, bool readDescription=true );
143  virtual ~XmlWidget() {};
144  QString name() const { return m_name; }
145  QString description() const { return m_description; }
146  QString defaultValue() const { return m_defaultValue; }
147  virtual QString toString() const { return ""; }
148  virtual void fromString ( QString str ) {};
149  protected:
150  QString m_name;
151  QString m_description;
152  QString m_defaultValue;
153 };
154 
155 class SCRIBUS_API IconBuffer
156 {
157  public:
158  IconBuffer() { len = 0; basePos = 0; file = 0; }
159  static IconBuffer *instance();
160  void loadFile ( QString filename );
161  QIcon *icon ( QString filename, QString name );
162  protected:
163  QFile *file;
164  QMap<QString, QIcon> icons;
165  QStringList loadedFiles;
166  QString readHeader();
167  QIcon readData();
168  int len, basePos;
169  static IconBuffer *_instance;
170 };
171 
172 #endif
Displays all kinds of content generated by external programs. Named LatexFrame because it initally on...
Definition: pageitem_latexframe.h:43
Definition: latexhelpers.h:41
Definition: filewatcher.h:20
Definition: latexeditor.h:118
Definition: latexeditor.h:42
Definition: latexeditor.h:93
Definition: latexeditor.h:155
Definition: latexeditor.h:138
Definition: latexhelpers.h:54