1 /***************************************************************************
2  *   copyright       : (C) 2003-2017 by Pascal Brachet                     *
3  *   http://www.xm1math.net/texmaker/                                      *
4  *   addons by Luis Silvestre                           *
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  ***************************************************************************/
12 
13 #ifndef TEXMAKER_H
14 #define TEXMAKER_H
15 
16 #include <QMainWindow>
17 #include <QDockWidget>
18 #include <QMenuBar>
19 #include <QToolBar>
20 #include <QListWidget>
21 #include <QStackedWidget>
22 #include <QTabWidget>
23 #include <QTreeWidget>
24 #include <QListWidget>
25 #include <QLabel>
26 #include <QAction>
27 #include <QActionGroup>
28 #include <QTreeWidgetItem>
29 #include <QListWidgetItem>
30 #include <QTableWidgetItem>
31 #include <QPointer>
32 #include <QProcess>
33 #include <QPushButton>
34 #include <QColor>
35 #include <QCompleter>
36 #include <QTextTable>
37 #include <QVBoxLayout>
38 #include <QTableWidget>
39 #include <QTranslator>
40 #include <QToolButton>
41 #include <QTimer>
42 #include <QKeySequence>
43 #include <QWidgetAction>
44 
45 #include "latexeditorview.h"
46 #include "minisplitter.h"
47 #include "playerbutton.h"
48 #include "symbollistwidget.h"
49 #include "usertagslistwidget.h"
50 #include "xmltagslistwidget.h"
51 #include "logeditor.h"
52 #include "hunspell/hunspell.hxx"
53 #include "pdfviewerwidget.h"
54 #include "pdfviewer.h"
55 #include "sourceview.h"
56 #include "encodingprober/qencodingprober.h"
57 #include "scandialog.h"
58 #include "dropshadowlabel.h"
59 
60 #ifdef INTERNAL_BROWSER
61 #include "browser.h"
62 #endif
63 
64 typedef  QMap<LatexEditorView*, QString> FilesMap;
65 typedef  QMap<QString,QString> KeysMap;
66 typedef  QString Userlist[10];
67 typedef  QString UserCd[5];
68 typedef int SymbolList[412];
69 typedef QString foldlist[5];
70 const foldlist foldClasses=
71 {
72 "\\part",
73 "\\chapter",
74 "\\section",
75 "\\subsection",
76 "\\subsubsection"
77 };
78 
79 
80 class Texmaker : public QMainWindow
81 {
82     Q_OBJECT
83 
84 public:
85     Texmaker(QWidget *parent = 0);
86     ~Texmaker();
87 QString getName();
88 QFont EditorFont;
89 QByteArray windowstate,splitter1state,splitter2state,splitter3state,fullscreenstate;
90 void mainWindowActivated();
91 //virtual QMenu* createPopupMenu();
92 
93 public slots:
94 void load( const QString &f );
95 void setLine( const QString &line );
96 void ToggleMode();
97 void insertFromCommandLine(const QString &entity);
98 void onOtherInstanceMessage(const QString &);  // For messages for the single instance
99 
100 private:
101 void setupMenus();
102 void setupToolBars();
103 void createStatusBar();
104 bool FileAlreadyOpen(QString f);
105 void closeEvent(QCloseEvent *e);
106 int LevelItem(const QTreeWidgetItem *item);
107 int LineItem(const QTreeWidgetItem *item);
108 bool currentfileSaved();
109 bool isCurrentModifiedOutside();
110 bool copyFile(QString origin,QString destination);
111 //void removeDir(QDir thedir);
112 void createBuildSubdirectory(QString fn);
113 QString outputName(QString finame,QString extension);
114 QString outputBaseName(QString finame);
115 bool gtkSession();
116 void setMasterDocument(const QString &fn);
117 
118 int untitled_id;
119 
120 FilesMap filenames;
121 KeysMap shortcuts, actionstext;
122 //gui
123 QFrame *LeftPanelFrameBis, *Outputframe, *separatorline;
124 
125 MiniSplitter *splitter1, *splitter2, *splitter3 ;
126 
127 PlayerButton *toggleStructureButton, *toggleLogButton, *togglePdfButton, *toggleSourceButton;
128 bool embedinternalpdf,winmaximized;
129 
130 QStackedWidget *EditorView;
131 QStackedWidget *StackedViewers;
132 LogEditor* OutputTextEdit;
133 
134 QStackedWidget *LeftPanelStackedWidget;
135 QListWidget *OpenedFilesListWidget;
136 UserTagsListWidget *usertagsListWidget;
137 XmlTagsListWidget *MpListWidget, *PsListWidget, *leftrightWidget, *tikzWidget, *asyWidget;
138 SymbolListWidget *RelationListWidget, *ArrowListWidget, *MiscellaneousListWidget, *DelimitersListWidget, *GreekListWidget, *MostUsedListWidget, *FavoriteListWidget;
139 QTreeWidget *StructureTreeWidget;
140 QVBoxLayout *OutputLayoutV, *CentralLayoutBis,*LeftPanelLayoutBis;
141 QHBoxLayout *OutputLayoutH, *LeftPanelLayout, *CentralLayout;
142 QTableWidget *OutputTableWidget;
143 //menu-toolbar
144 QMenu *fileMenu, *recentMenu, *editMenu, *toolMenu, *sessionMenu;
145 QMenu *latex1Menu, *latex11Menu, *latex12Menu, *latex13Menu, *latex14Menu, *latex15Menu, *latex16Menu, *latex17Menu, *latex18Menu ;
146 QMenu *math1Menu, *math11Menu, *math12Menu, *math13Menu, *math14Menu;
147 
148 QMenu *foldMenu, *unfoldMenu;
149 
150 QMenu *wizardMenu;
151 QMenu *bibMenu, *bibtexMenu, *biblatexMenu;
152 QMenu *user1Menu, *user11Menu, *user12Menu;
153 QMenu *viewMenu;
154 QMenu *optionsMenu, *translationMenu, /**appearanceMenu,*/ *settingsMenu, *scriptMenu;
155 QMenu *helpMenu;
156 QMenu *sectionMenu, *sizeMenu, *refMenu;
157 
158 QToolBar *fileToolBar, *editToolBar, *runToolBar, /* *formatToolBar ,*/ *logToolBar, *LeftPanelToolBar,*LeftPanelToolBarBis, *centralToolBar, *centralToolBarBis;
159 QAction *recentFileActs[10];
160 QAction *ToggleAct, *StopAct, *UndoAct, *RedoAct, *SaveAct, *CutAct, *CopyAct,*PasteAct, *ToggleDocAct, *ViewStructurePanelAct, *ViewLogPanelAct, *ViewPdfPanelAct, *ViewSourcePanelAct, *FullScreenAct, *NextDocAct, *PrevDocAct, *ViewOpenedFilesPanelAct ;
161 
162 QAction *relationAct, *arrowAct, *miscAct, *delimAct, *greekAct, *usedAct, *favAct, *leftrightAct, *pstricksAct, *mpAct, *tikzAct, *asyAct, *userpanelAct;
163 bool showPstricks, showMp, showTikz, showAsy;
164 QAction *viewPstricksAct, *viewMpAct, *viewTikzAct, *viewAsyAct;
165 
166 QAction *emphasisAct, *newlineAct, *mathmodeAct, *indiceAct, *puissanceAct, *smallfracAct, *dfracAct, *racineAct;
167 QAction *showemphasisAct, *shownewlineAct, *showmathmodeAct, *showindiceAct, *showpuissanceAct, *showsmallfracAct, *showdfracAct, *showracineAct;
168 bool showEmphasis, showNewline, showMathmode, showIndice, showPuissance, showSmallfrac, showDfrac, showRacine;
169 
170 
171 QComboBox *comboCompil, *comboView, *comboFiles;
172 DropShadowLabel *titleLeftPanel, *posLabel, *stat1, *stat2, *stat3;
173 
174 QPushButton *pb1, *pb2, *pb3;
175 QString MasterName;
176 bool logpresent;
177 QStringList recentFilesList;
178 QString sessionTempFile;
179 
180 //settings
181 bool eraseSettings, replaceSettings;
182 QString settingsFileName;
183 int split1_right, split1_left, split2_top, split2_bottom, quickmode, tabwidth;
184 bool singlemode, wordwrap, parenmatch, showline, showoutputview, showstructview, showpdfview, showsourceview, showfilesview, ams_packages, makeidx_package, completion, inlinespellcheck, modern_style, new_gui, builtinpdfview, singleviewerinstance, babel_package, geometry_package, graphicx_package, watchfiles, autosave, tabspaces, useoutputdir ;
185 bool lmodern_package, kpfonts_package, fourier_package;
186 QString document_class, typeface_size, paper_size, document_encoding, author, geometry_options, babel_default;
187 QString latex_command, viewdvi_command, dvips_command, dvipdf_command, metapost_command, psize, xelatex_command, lualatex_command, htlatex_command, htlatex_options;
188 QString viewps_command, ps2pdf_command, makeindex_command, bibtex_command, pdflatex_command, viewpdf_command, userquick_command, ghostscript_command, asymptote_command, latexmk_command, sweave_command, texdoc_command, quick_asy_command, lp_options;
189 QString spell_dic, spell_ignored_words;
190 QString lastDocument, input_encoding, lastChild, lastTemplate, lastScript;
191 QString struct_level1, struct_level2, struct_level3, struct_level4, struct_level5;
192 QStringList userClassList, userPaperList, userEncodingList, userOptionsList, userCompletionList, userBabelList;
193 QStringList labelitem, bibitem, listbibfiles, listchildfiles;
194 Userlist UserMenuName, UserMenuTag;
195 UserCd UserToolName, UserToolCommand;
196 QString keyToggleFocus;
197 QString extra_path;
198 QString beamer_theme, beamer_size, beamer_encoding, beamer_author, beamer_babel;
199 qreal lastScale;
200 bool clean_exit;
201 
202 bool svnEnable;
203 QString svnPath;
204 //dialogs
205 QPointer<ScanDialog> scanDialog;
206 #ifdef INTERNAL_BROWSER
207 QPointer<Browser> browserWindow, diffWindow;
208 #endif
209 QPointer<PdfViewerWidget> pdfviewerWidget;
210 QPointer<PdfViewer> pdfviewerWindow;
211 SourceView* sourceviewerWidget;
212 //tools
213 QProcess *proc;
214 bool FINPROCESS, ERRPROCESS, STOPPROCESS;
215 QStringList listViewerCommands;
216 bool checkViewerInstance;
217 //latex errors
218 QStringList errorFileList, errorTypeList, errorLineList, errorMessageList, errorLogList;
219 QList<int> onlyErrorList;
220 int errorIndex, runIndex, viewIndex;
221 QString pdfCheckerLang;
222 //X11
223 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
224 QString x11style;
225 QString x11fontfamily;
226 int x11fontsize;
227 #endif
228 SymbolList symbolScore;
229 usercodelist symbolMostused;
230 QList<int> favoriteSymbolList;
231 QStringList userTagsList;
232 
233 QColor colorBackground, colorLine, colorHighlight, colorStandard, colorComment, colorMath, colorCommand, colorKeyword, colorVerbatim, colorTodo, colorKeywordGraphic, colorNumberGraphic;
234 
edcolors()235 QList<QColor> edcolors() {QList<QColor> e; e << colorBackground << colorLine << colorHighlight << colorStandard; return e;}
hicolors()236 QList<QColor> hicolors() {QList<QColor> h; h << colorStandard << colorComment << colorMath << colorCommand << colorKeyword << colorVerbatim << colorTodo << colorKeywordGraphic << colorNumberGraphic; return h;}
237 
238 QCompleter *completer;
239 Hunspell * spellChecker;
240 bool spelldicExist();
241 QStringList translationList, scriptList;
242 QActionGroup *translationGroup/*, *appearanceGroup*/;
243 QTimer *autosaveTimer;
244 
245 private slots:
246 LatexEditorView *currentEditorView() const;
247 void fileNew();
248 void fileNewFromFile();
249 void fileOpen();
250 void checkModifiedOutsideAll();
251 void fileSave();
252 void fileSaveAll();
253 void fileBackupAll();
254 void fileSaveAs();
255 void fileSaveACopy();
256 void fileClose();
257 void fileCloseRequested( int index);
258 void fileCloseAll();
259 void fileExit();
260 void fileOpenRecent();
261 void AddRecentFile(const QString &f);
262 void UpdateRecentFile();
263 void CleanRecent();
264 void filePrint();
265 void fileOpenAndGoto(const QString &f, int line, bool focus);
266 void getFocusToEditor();
267 void fileReload();
268 void allReload();
269 void listSelectionActivated(int index);
270 void ComboFilesInsert(const QString & file);
271 void ToggleMasterCurrent();
272 
273 void editUndo();
274 void editRedo();
275 void editCut();
276 void editCopy();
277 void editPaste();
278 void editSelectAll();
279 void editFind();
280 void editFindNext();
281 void editFindInDirectory();
282 void editReplace();
283 void editGotoLine();
284 void editComment();
285 void editUncomment();
286 void editIndent();
287 void editUnindent();
288 void editSpell();
289 void editTipTab();
290 void editRunScript();
291 void editRunFurnishedScript();
292 
293 
294 void doFoldAll(int i);
295 void doUnfoldAll(int i);
296 void foldAll();
297 void unfoldAll();
298 void foldAllUnder();
299 void unfoldAllUnder();
300 void foldEnclosing();
301 void unfoldEnclosing();
302 
303 void ReadSettings();
304 void SaveSettings();
305 void DeleteSettings();
306 void CopySettings();
307 void ReplaceSettings();
308 void setPrintPaperSize(const QString &p);
309 
310 void NewDocumentStatus(bool m);
311 void UpdateCaption();
312 
313 void UpdateStructure();
314 void UpdateChildsLabels(QStringList listfiles);
315 void UpdateBibliography();
316 void ParseTree(QTreeWidgetItem *item);
317 void ItemToRange(QTreeWidgetItem *item);
318 
319 void ShowOpenedFiles();
320 void OpenedFileActivated(QListWidgetItem *item);
321 void ShowStructure();
322 void ShowRelation(); //RelationListWidget
323 void ShowArrow(); //ArrowListWidget
324 void ShowMisc(); //MiscellaneousListWidget
325 void ShowDelim(); //DelimitersListWidget
326 void ShowGreek(); //GreekListWidget
327 void ShowMostUsed(); //MostUsedListWidget
328 void ShowFavorite(); //FavoriteListWidget
329 void ShowPstricks(); //PsListWidget
330 void ShowLeftRight(); //leftrightWidget
331 void ShowMplist(); //MpListWidget
332 void ShowTikz(); //tikzWidget
333 void ShowAsy(); //asyWidget
334 void ShowUserPanel(); //userPanel
335 void ClickedOnStructure(QTreeWidgetItem *item,int);
336 
337 void InsertTag(QString Entity, int dx, int dy);
338 void InsertSymbol(QTableWidgetItem *item);
339 void InsertXmlTag(QListWidgetItem *item);
340 void InsertUserElement(QListWidgetItem *item);
341 void InsertFromAction();
342 void InsertWithSelectionFromAction();
343 void InsertWithSelectionFromString(const QString& text);
344 void InsertFromString(const QString& text);
345 void InsertBib();
346 void InsertBibLatex();
347 void InsertStruct();
348 void InsertStructFromString(const QString& text);
349 void InsertImage();
350 void InsertInclude();
351 void InsertInput();
352 
353 void InsertBib1();
354 void InsertBib2();
355 void InsertBib3();
356 void InsertBib4();
357 void InsertBib5();
358 void InsertBib6();
359 void InsertBib7();
360 void InsertBib8();
361 void InsertBib9();
362 void InsertBib10();
363 void InsertBib11();
364 void InsertBib12();
365 void InsertBib13();
366 
367 void InsertBibLatex1(); //Article in Journal
368 void InsertBibLatex2(); //Single-volume book
369 void InsertBibLatex3(); //Multi-volume book
370 void InsertBibLatex4(); //Part of a book
371 void InsertBibLatex5(); //Booklet
372 void InsertBibLatex6(); //Single-volume collection
373 void InsertBibLatex7(); //Multi-volume collection
374 void InsertBibLatex8(); //Part of a collection
375 void InsertBibLatex9(); //Technical documentation
376 void InsertBibLatex10(); //Miscellaneous
377 void InsertBibLatex11(); //Online resource
378 void InsertBibLatex12(); //Issue of a periodical
379 void InsertBibLatex13(); //Single-volume conference proceedings
380 void InsertBibLatex14(); //Multi-volume conference proceedings
381 void InsertBibLatex15(); //Article in conference proceedings
382 void InsertBibLatex16(); //Technical report
383 void InsertBibLatex17(); //Thesis
384 void InsertBibLatex18(); //Patent
385 
386 void CleanBib();
387 
388 void InsertUserTag(QString Entity);
389 void InsertUserTag1();
390 void InsertUserTag2();
391 void InsertUserTag3();
392 void InsertUserTag4();
393 void InsertUserTag5();
394 void InsertUserTag6();
395 void InsertUserTag7();
396 void InsertUserTag8();
397 void InsertUserTag9();
398 void InsertUserTag10();
399 void EditUserMenu();
400 
401 void SectionCommand();
402 void OtherCommand();
403 void InsertCite();
404 void InsertRef();
405 void InsertPageRef();
406 void SizeCommand();
407 
408 void ShowSectionMenu();
409 void ShowRefMenu();
410 void ShowSizeMenu();
411 
412 void QuickTabular();
413 void QuickArray();
414 void QuickTabbing();
415 void QuickLetter();
416 void QuickDocument();
417 void QuickXelatex();
418 void QuickBeamer();
419 
420 void RunCommand(QString comd,bool waitendprocess);
421 void readFromStderr();
422 void stopProcess();
423 void readFromStdoutput();
424 void SlotEndProcess(int err);
425 void SlotEndViewerProcess(int err);
426 void QuickBuild();
427 void Latex();
428 void ViewDvi();
429 void DviToPS();
430 void ViewPS();
431 void PDFLatex();
432 void ViewPDF();
433 void CleanAll();
434 void AutoCleanAll();
435 void MakeBib();
436 void MakeIndex();
437 void PStoPDF();
438 void DVItoPDF();
439 void MetaPost();
440 void Asymptote();
441 void LatexMk();
442 void Sweave();
443 void Xelatex();
444 void Lualatex();
445 void AsyFile(QString asyfile);
446 void UserTool1();
447 void UserTool2();
448 void UserTool3();
449 void UserTool4();
450 void UserTool5();
451 void EditUserTool();
452 void doCompile();
453 void doView();
454 void jumpToPdfline(int line);
455 void OpenTerminal();
456 void Export();
457 void ConvertToUnicode();
458 
459 void LoadLog();
460 void ViewLog();
461 void ClickedOnOutput(int l);
462 void ClickedOnLogLine(QTableWidgetItem *item);
463 void LatexError();
464 void DisplayLatexError();
465 void NextError();
466 void PreviousError();
467 bool NoLatexErrors();
468 bool LogExists();
469 
470 /////
471 void LatexHelp();
472 void UserManualHelp();
473 void TexDocHelp();
474 void HelpAbout();
475 void CheckVersion();
476 void Doculatex();
477 //void Docufrlatex();
478 
479 void GeneralOptions();
480 
481 void gotoNextDocument();
482 void gotoPrevDocument();
483 
484 void SetInterfaceFont();
485 
486 void gotoBookmark1();
487 void gotoBookmark2();
488 void gotoBookmark3();
489 
490 void SetMostUsedSymbols();
491 void InsertFavoriteSymbols();
492 void RemoveFavoriteSymbols();
493 
494 void RemoveUserTag();
495 void AddUserTag();
496 void ChangeUserTag();
497 void UpdateUserTag();
498 
499 void ModifyShortcuts();
500 
501 void initCompleter();
502 void updateCompleter();
503 void updateTranslation();
504 // void updateAppearance();
505 
506 void disableToolsActions();
507 void enableToolsActions();
508 
509 void clipboardDataChanged();
510 void refreshAll();
511 void refreshAllFromCursor(int newnumlines);
512 void refreshRange();
513 void jumpToStructure(int line);
514 
515 
516 void ToggleStructurePanel();
517 void ToggleLogPanel();
518 void TogglePdfPanel();
519 void ToggleSourcePanel();
520 void ToggleFilesPanel();
521 void ShowStructView(bool change);
522 void ShowOutputView(bool change);
523 void ShowPdfView(bool change);
524 void ShowSourceView(bool change);
525 void ShowFilesView(bool change);
526 void ToggleFullScreen();
527 void EditUserCompletion();
528 void addBibFiles(QString param);
529 void addIncludeFiles(QString param);
530 void loadIncludeFiles(QString param, QString extension);
531 void showCursorPos(int li, int col);
532 void customContentsMenuStructure( const QPoint &pos );
533 void customContentsMenuMain( const QPoint &pos );
534 void TogglePstricks();
535 void ToggleMetapost();
536 void ToggleTikz();
537 void ToggleAsymptote();
538 void ToggleEmphasis();
539 void ToggleNewline();
540 void ToggleMathmode();
541 void ToggleIndice();
542 void TogglePuissance();
543 void ToggleSmallfrac();
544 void ToggleDfrac();
545 void ToggleRacine();
546 void splitter2Changed();
547 
548 void SaveSession();
549 void LoadSessionFile(const QString &fn);
550 void LoadSession();
551 void SaveLastSession();
552 void LoadLastSession();
553 
554 void compareDocuments();
555 
556 protected:
557 void dragEnterEvent(QDragEnterEvent *event);
558 void dropEvent(QDropEvent *event);
559 void keyPressEvent(QKeyEvent * event);
560 
561 };
562 
563 #endif
564