1 /***************************************************************************
2  *   copyright       : (C) 2003-2007 by Pascal Brachet                     *
3  *   http://www.xm1math.net/texmaker/                                      *
4  *                         2008-2009 by Benito van der Zander              *
5  *   http://texstudio.sourceforge.net
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  ***************************************************************************/
13 
14 #ifndef Header_TexStudio
15 #define Header_TexStudio
16 
17 #include "mostQtHeaders.h"
18 
19 #include "bibtexparser.h"
20 #include "buildmanager.h"
21 #include "bookmarks.h"
22 #include "codesnippet.h"
23 #include "configmanager.h"
24 #include "cursorhistory.h"
25 #include "latexlog.h"
26 #include "latexdocument.h"
27 #include "latexeditorview.h"
28 #include "latexcompleter.h"
29 #include "xmltagslistwidget.h"
30 #include "spellerdialog.h"
31 #include "textanalysis.h"
32 #include "toolwidgets.h"
33 #include "txstabwidget.h"
34 #include "editors.h"
35 #include "searchresultwidget.h"
36 #include "unicodeinsertion.h"
37 #include "tablemanipulation.h"
38 #include "PDFDocument.h"
39 #include <QSplashScreen>
40 #include "session.h"
41 #include "sessionlist.h"
42 #include "qformatfactory.h"
43 #include "qlanguagefactory.h"
44 #include "qlinemarksinfocenter.h"
45 #include "latexstyleparser.h"
46 #include "kpathseaParser.h"
47 #include "diffoperations.h"
48 #include "svn.h"
49 #include "git.h"
50 #include "help.h"
51 
52 #include <QProgressDialog>
53 
54 /*!
55  * \file texstudio.h
56  * \brief Definition for Mainwindow
57  */
58 
59 class UserMenuDialog;
60 class GrammarCheck;
61 class FileSelector;
62 class LatexReference;
63 class SymbolListModel;
64 class SymbolWidget;
65 class StructureTreeView;
66 
67 Q_DECLARE_METATYPE(QSet<QString>)
Q_DECLARE_METATYPE(std::set<QString>)68 Q_DECLARE_METATYPE(std::set<QString>)
69 
70 class Texstudio : public QMainWindow
71 {
72 	Q_OBJECT
73 
74 public:
75     Texstudio(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), QSplashScreen *splash = nullptr);
76 	~Texstudio();
77 
78 	Q_INVOKABLE QString getCurrentFileName(); ///< returns the absolute file name of the current file or "" if none is opene
79 	Q_INVOKABLE QString getAbsoluteFilePath(const QString &relName, const QString &extension = ""); ///< treats the path relative to the compiled .tex file
80 	Q_INVOKABLE QString getRelativeFileName(const QString &file, QString basepath, bool keepSuffix = false); ///< provide function for scripts
81     Q_INVOKABLE bool fileExists(const QString &file); ///< provide function for scripts
82 	QByteArray windowstate; ///< qt window state, used for state-restoring
83 	bool tobemaximized, tobefullscreen;
84 
85     Q_INVOKABLE void runInternalCommand(const QString &cmd, const QString &master, const QString &options);
86 
87 public slots:
88 	LatexEditorView *load(const QString &f , bool asProject = false, bool hidden = false, bool recheck = true, bool dontAsk = false);
89     void executeCommandLine(const QStringList &args, bool realCmdLine);
90 	void hideSplash(); ///< hide splash screen
91 	void startupCompleted();
92 	void onOtherInstanceMessage(const QString &);  ///< For messages for the single instance
93 	void fuzzCursorHistory();
94 	void fuzzBackForward();
95     void setBuildButtonsDisabled(bool c);
96 
97 
98 protected:
99 	//these are just wrappers around configManager so we don't have to type so much (todo??? move them to configmanager.h and use a singleton design???)
100 	Q_INVOKABLE inline QMenu *newManagedMenu(const QString &id, const QString &text) { return configManager.newManagedMenu(id, text); }
101 	Q_INVOKABLE inline QMenu *newManagedMenu(QMenu *menu, const QString &id, const QString &text) { return configManager.newManagedMenu(menu, id, text); }
102     Q_INVOKABLE QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "", const QList<QVariant> &args = QList<QVariant>());
103 	Q_INVOKABLE QAction *newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts, const QString &iconFile = "", const QList<QVariant> &args = QList<QVariant>());
104     Q_INVOKABLE QAction *newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "", const QList<QVariant> &args = QList<QVariant>());
105 	Q_INVOKABLE QAction *newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts, const QString &iconFile = "", const QList<QVariant> &args = QList<QVariant>());
106 	Q_INVOKABLE inline QAction *newManagedAction(QWidget *menu, const QString &id, QAction *act) { return configManager.newManagedAction(menu, id, act); }
107 	Q_INVOKABLE inline QMenu *getManagedMenu(const QString &id) { return configManager.getManagedMenu(id); }
108 	Q_INVOKABLE inline QAction *getManagedAction(const QString &id) { return configManager.getManagedAction(id); }
109 	Q_INVOKABLE inline QList<QAction *> getManagedActions(const QStringList &ids, const QString &commonPrefix = "") { return configManager.getManagedActions(ids, commonPrefix); }
110     Q_INVOKABLE QAction *insertManagedAction(QAction *before, const QString &id, const QString &text, const char *slotName = nullptr, const QKeySequence &shortCut = 0, const QString &iconFile = "");
111 
112 	void addTagList(const QString &id, const QString &iconName, const QString &text, const QString &tagFile);
113     void addMacrosAsTagList();
114 
115 private slots:
116 	void updateToolBarMenu(const QString &menuName);
117 	void showTestProgress(const QString &message);
118     void leftPanelChanged(QWidget* widget);
119 private:
120     bool executeTests(const QStringList &args); ///< execute self-tests. Only works for debug-builds.
121 	void generateAddtionalTranslations();
122 	void setupMenus();
123 	void setupDockWidgets();
124 	void setupToolBars();
125 	void createStatusBar();
126 	bool activateEditorForFile(QString f, bool checkTemporaryNames = false, bool setFocus = true);
127 	bool saveAllFilesForClosing(); ///< checks for unsaved files and asks the user if they should be saved
128     bool saveFilesForClosing(const QList<LatexDocument *> &documentList); ///< checks for unsaved files and asks the user if they should be saved
129 	void closeAllFiles();
130 	bool canCloseNow(bool saveSettings = true); ///< asks the user and close all files, and prepares to exit txs
131 	void closeEvent(QCloseEvent *e);
132 
133 	void updateUserMacros(bool updateMenu = true);
134 
135 	void updateEmphasizedRegion(QDocumentCursor c, int sid);
136 
137 	QSplashScreen *splashscreen;  ///< only used during startup
138 	QFormatScheme *m_formats, *m_formatsOldDefault;
139 	QLanguageFactory *m_languages;
140 	LatexCompleter *completer;
141 	LatexReference *latexReference;
142 
143 	QPointer<UnicodeInsertion> unicodeInsertionDialog;
144 
145 	//gui
146 	Editors *editors;
147 	QSplitter *sidePanelSplitter;
148 	QSplitter *mainHSplitter;
149 	QSplitter *centralVSplitter;
150 	QFrame *centralFrame;
151 	QToolBar *centralToolBar;
152 	CustomWidgetList *leftPanel;
153 	TitledPanel *sidePanel;
154 	SymbolListModel *symbolListModel;
155 	SymbolWidget *symbolWidget;
156 	QString hiddenLeftPanelWidgets;
157 
158     //StructureTreeView *structureTreeView;
159     QTreeWidget *structureTreeWidget;
160     QTreeWidget *topTOCTreeWidget;
161 	LatexParser latexParser;
162 
163     QVector<QIcon> iconSection;
164 public:
165 	LatexDocuments documents;
166 
167     Q_INVOKABLE bool completerIsVisible();
168 private:
169 	OutputViewWidget *outputView; ///< contains output widgets (over OutputLayout)
170 
171 	//menu
172 	QActionGroup *bibtexEntryActions;
173 	QActionGroup *biblatexEntryActions;
174 	QActionGroup *bibTypeActions;
175 	QActionGroup *highlightLanguageActions;
176 	QActionGroup *actgroupRootDocMode;
177 	QAction *actRootDocAutomatic;
178 	QAction *actRootDocExplicit;
179 	QAction *actRootDocSetExplicit;
180 
181 	//toolbars
182 	QAction *actSave, *actUndo, *actRedo;
183 
184 	QLabel *statusLabelMode, *statusLabelProcess, *statusLabelLanguageTool;
185 	QToolButton *statusTbLanguage;
186 	QToolButton *statusTbEncoding;
187 	QActionGroup *spellLanguageActions;
188 
189 	CursorHistory *cursorHistory;
190 
191 	//settings
192 	ConfigManager configManager;
193 public:
194 	BuildManager buildManager;
195 private:
196 	QStringList struct_level;
197 
198 	qreal pdfSplitterRel;
199 
200 	SpellerManager spellerManager;
201 	SVN svn;
202     GIT git;
203     Help help;
204 	SafeThread grammarCheckThread;
205 	GrammarCheck *grammarCheck;
206 	Bookmarks *bookmarks;
207 	SessionList *recentSessionList;
208 
209 	//dialogs
210 	TextAnalysisDialog *textAnalysisDlg;
211 	SpellerDialog *spellDlg;
212 
213 	Q_INVOKABLE LatexEditorView *currentEditorView() const;
214 	Q_INVOKABLE QEditor *currentEditor() const;
215 	void configureNewEditorView(LatexEditorView *edit);
216 	void configureNewEditorViewEnd(LatexEditorView *edit, bool asMaster = false, bool hidden = false);
217 	LatexEditorView *getEditorViewFromFileName(const QString &fileName, bool checkTemporaryNames = false);
218 	LatexEditorView *getEditorViewFromHandle(const QDocumentLineHandle *dlh);
219 
220 	QAction *fullscreenModeAction;
221 
222 	int runningPDFCommands, runningPDFAsyncCommands;
223 	QEditor *previewEditorPending; bool previewIsAutoCompiling;
224 
225 	void updateUserToolMenu();
226 	void linkToEditorSlot(QAction *act, const char *slot, const QList<QVariant> &args);
227 
228     bool parseStruct(StructureEntry* se, QVector<QTreeWidgetItem *> &rootVector, QSet<LatexDocument*> *visited=nullptr, QList<QTreeWidgetItem *> *todoList=nullptr, int currentColor=0);
229     void parseStructLocally(StructureEntry* se, QVector<QTreeWidgetItem *> &rootVector, QList<QTreeWidgetItem *> *todoList=nullptr, QList<QTreeWidgetItem *> *labelList=nullptr, QList<QTreeWidgetItem *> *magicList=nullptr, QList<QTreeWidgetItem *> *biblioList=nullptr);
230 private slots:
231     void updateTOCs();
232 
233     void updateTOC();
234     void updateCurrentPosInTOC(QTreeWidgetItem *root=nullptr,StructureEntry *old=nullptr,StructureEntry *selected=nullptr);
235     void syncExpanded(QTreeWidgetItem *item);
236     void syncCollapsed(QTreeWidgetItem *item);
237     void editSectionCopy();
238     void editSectionCut();
239     void editSectionPasteAfter();
240     void editSectionPasteBefore();
241     void editIndentSection();
242     void editUnIndentSection();
243     void gotoLineFromAction();
244     void openAllRelatedDocuments();
245     void closeAllRelatedDocuments();
246     void toggleMasterDocument();
247     void closeDocument();
248     void copyFileName();
249     void copyFilePath();
250     void toggleSingleDocMode();
251     void expandSubitems();
252     void collapseSubitems();
253     StructureEntry *labelForStructureEntry(const StructureEntry *entry);
254 
255     void updateStructureLocally();
256     void customMenuStructure(const QPoint &pos);
257     void createLabelFromAction();
258 
259 	void relayToEditorSlot();
260 	void relayToOwnSlot();
261 	void autoRunScripts();
262 	void runScripts(int trigger);
263 	void runScriptsInList(int trigger, const QList<Macro> &scripts);
264 
265 protected slots:
266 	void fileNew(QString fileName = "");
267 	void fileNewFromTemplate();
268 	void fileMakeTemplate();
269 	void fileOpen();
270 	void fileRestoreSession(bool showProgress = true, bool warnMissing = true);
271 	void fileSave(const bool saveSilently = false);
272 	void fileSaveAll();
273     void fileSaveAllFromTimer();
274 	void fileSaveAll(bool alsoUnnamedFiles, bool alwaysCurrentFile);
275 	void fileSaveAs(const QString &fileName = "") { fileSaveAs(fileName, false); }
276 private slots:
277 	void fileSaveAs(const QString &fileName, const bool saveSilently);
278 	void fileNewInternal(QString fileName = "");
279 protected slots:
280 	void fileUtilCopyMove(bool move); ///< call dialog to copy/move files
281 	void fileUtilDelete(); ///< call dialog to remove file
282 	void fileUtilRevert(); ///< reload file from disc, undoing all changes in memory
283 	void fileUtilPermissions(); ///< call dialog to set file permissions
284 	void fileUtilCopyFileName(); ///< copy file name into clipboard
285 	void fileUtilCopyMasterFileName(); ///< copy file name of master file into clipboard
286 	void fileClose(); ///< close current editor
287 	void fileCloseAll(); ///< close all open editors
288 	void fileExit(); ///< exit application
289 	void fileExitWithError(); ///< exit application with error code, used for auto-tests
290 protected slots:
291 	void fileOpenRecent();
292 	void fileOpenAllRecent(); ///< open all files in recent file list
293 	void fileRecentList();
294 	void viewDocumentListHidden(); ///< show names of all hidden document (for debug)
295 	void fileDocumentOpenFromChoosen(const QString &doc, int duplicate, int lineNr, int column);
296 	void viewDocumentList();
297 	void viewDocumentOpenFromChoosen(const QString &doc, int duplicate, int lineNr, int column);
298 	void fileOpenFirstNonOpen();
299 	void fileOpenRecentProject();
300 	void fileLoadSession();
301 	void loadSession(const QString &fileName);
302 	void fileSaveSession();
303 private slots:
304 	void restoreSession(const Session &s, bool showProgress = true, bool warnMissing = true);
305 	Session getCurrentSession();
306 protected slots:
307 	void MarkCurrentFileAsRecent();
308 private slots:
309 	void fileCheckin(QString filename = "");
310 	void fileLockPdf(QString filename = "");
311 	void fileCheckinPdf(QString filename = "");
312 	void fileUpdate(QString filename = "");
313 	void fileUpdateCWD(QString filename = "");
314 	void checkinAfterSave(QString filename, int checkIn = 0);
315 	void checkin(QString fn, QString text = "txs auto checkin", bool blocking = false);
316 	bool svnadd(QString fn, int stage = 0);
317 	void svnUndo(bool redo = false);
318 	void svnPatch(QEditor *ed, QString diff);
319 	void showOldRevisions();
320 	void changeToRevision(QString rev, QString old_rev = "");
321     void svnDialogClosed(int);
322 	void fileDiff();
323 	void fileDiff3();
324 	bool checkSVNConflicted(bool substituteContents = true);
325 	void removeDiffMarkers(bool theirs = false);
326 	void editChangeDiff(QPoint pt);
327 	void jumpNextDiff();
328 	void jumpPrevDiff();
329 	void fileDiffMerge();
330 	void declareConflictResolved();
331 protected slots:
332     void openExternalFile(QString name, const QString &defaultExt = "tex", LatexDocument *doc = nullptr); // signaled by latexViewer to open specific file
333     void openExternalFileFromAction();
334 
335 	void editUndo(); ///< undo changes in text editor
336 	void editRedo(); ///< redo changes in text editor
337 	void editDebugUndoStack(); ///< print undo-stack content into a new text editor window
338 	void editCopy(); ///< copy text
339 	void editPaste(); ///< paste text
340 	void editPasteImage(QImage image);
341 	void editTextToLowercase();
342 	void editTextToUppercase();
343 	void editTextToTitlecase(bool smart = false);
344 	void editTextToTitlecaseSmart();
345 	void editFind(); ///< open search panel
346 	void editPasteLatex();
347 	void convertToLatex();
348 	void editHardLineBreak();
349 	void editHardLineBreakRepeat();
350 	void editDeleteLine(); ///< delete current line in current text editor
351 	void editDeleteToEndOfLine();
352 	void editDeleteFromStartOfLine();
353 	void editMoveLineUp();
354 	void editMoveLineDown();
355 	void editDuplicateLine();
356 	void editSortLines();
357 	void editAlignMirrors();
358 	void editEraseWordCmdEnv();
359 	void editGotoDefinition(QDocumentCursor c = QDocumentCursor());
360 	void editSpell();
361 	void editThesaurus(int line = -1, int col = -1);
362 	void editChangeLineEnding();
363 	void editSetupEncoding();
364 	void editInsertUnicode(); ///< open dialog to insert a unicode character
365 	void editInsertRefToNextLabel(const QString &refCmd = "\\ref", bool backward = false);
366 	void editInsertRefToPrevLabel(const QString &refCmd = "\\ref");
367 	void runSearch(SearchQuery *query);
368 	void findLabelUsages(LatexDocument *doc, const QString &labelText);
369     void findLabelUsagesFromAction();
370 	SearchResultWidget *searchResultWidget();
371 
372 	void findWordRepetions();
373 	void findNextWordRepetion();
374 
375 	void addDocToLoad(QString filename);
376 
377 	void LTErrorMessage(QString message);
378 
379     void paletteChanged(const QPalette &palette);
380 
381 private slots:
382 	void readSettings(bool reread = false); ///< read configured/default settings from ini
383 	void saveSettings(const QString &configName = ""); ///< save all setting to ini
384 	void restoreDefaultSettings(); ///< restore default settings, removing all changed values
385 
386 protected slots:
387 	void showMarkTooltipForLogMessage(QList<int> errors);
388 	void newDocumentLineEnding();
389 	void updateCaption();
390 	void updateMasterDocumentCaption();
391 	void updateUndoRedoStatus();
392 	void currentEditorChanged();
393 	void editorTabMoved(int from, int to);
394 	void editorAboutToChangeByTabClick(LatexEditorView *edFrom, LatexEditorView *edTo);
395 
396     void updateStructure(bool initial = false, LatexDocument *doc = nullptr, bool hidden = false);
397 	void structureContextMenuToggleMasterDocument(LatexDocument *document);
398 
399 	void editRemovePlaceHolders();
400 	void editRemoveCurrentPlaceHolder();
401 
402 	void normalCompletion(); ///< activate normal completion
403 	void insertEnvironmentCompletion(); ///< activate environment completion
404 	void insertTextCompletion(); ///< activate normal text completion
405 	void insertText(const QString &text);
406 	void insertTag(const QString &Entity, int dx = 0, int dy = 0);
407 	void insertCitation(const QString &text);
408 	void insertFormula(const QString &formula);
409 	void insertSymbol(const QString &text);
410 	void insertXmlTag(QListWidgetItem *item);
411 	void insertXmlTagFromToolButtonAction();
412 	void callToolButtonAction();
413 	void insertFromAction();
414     void insertTextFromAction();
415     void insertFromTagList(QListWidgetItem *item);
416 	void insertBib();
417 	void closeEnvironment();
418 
419 	void insertBibEntryFromAction();
420 	void insertBibEntry(const QString &id = "");
421 	void setBibTypeFromAction();
422 
423 	void insertUserTag();
424 	void execMacro(const Macro &m, const MacroExecContext &context = MacroExecContext(), bool allowWrite = false);
425 	void runScript(const QString &script, const MacroExecContext &context = MacroExecContext(), bool allowWrite = false);
426 
427 	void editMacros(); ///< open edit macros dialog
428 	void macroDialogAccepted(); ///< macro dialog was closed with ok
429 	void macroDialogRejected(); ///< macro dialog was closed with cancel
430 
431 	void insertRef(const QString &refCmd);
432 	void insertRef();
433 	void insertEqRef();
434 	void insertPageRef();
435 
436 	void changeTextCodec();
437 	void updateAvailableLanguages();
438 	void updateLanguageToolStatus();
439 	void editorSpellerChanged(const QString &name);
440 	void changeEditorSpeller();
441 	void insertSpellcheckMagicComment();
442 	void updateStatusBarEncoding();
443 	void addMagicRoot();
444 	void addMagicCoding();
445     void addMagicBibliography();
446     void addMagicProgram();
447 
448 	void quickTabular(); ///< start quick tabular wizard
449 	void quickArray(); ///< start quick array wizard
450 	void quickTabbing(); ///< start quick tabbing wizard
451 	void quickLetter(); ///< start quick leter wizard
452 	void quickDocument(); ///< start quick document wizard
453 	void quickBeamer(); ///< start quick beamer wizard
454 	void quickGraphics(const QString &graphicsFile = QString()); ///< start quick graphics wizard
455 	void quickMath(); ///< start quick math wizard
456 
457 	bool checkProgramPermission(const QString &program, const QString &cmdId, LatexDocument *master);
458 	void runInternalPdfViewer(const QFileInfo &master, const QString &options);
459 	void runBibliographyIfNecessary(const QFileInfo &cmd);
460 	QDateTime GetBblLastModified(void);
461 
462 	void showExtendedSearch();
463 
464 	void changeIconSize(int value);
465 	void changeSecondaryIconSize(int value);
466     void changePDFIconSize(int value);
467 	void changeSymbolGridIconSize(int value, bool changePanel = true);
468 
469 public slots:
470 	void connectSubCommand(ProcessX *p, bool showStdoutLocallyDefault);
471 private slots:
472     void runInternalCommand(const QString &cmd, const QFileInfo &master, const QString &options);
473 	void commandLineRequested(const QString &cmdId, QString *result, bool *);
474 	void beginRunningCommand(const QString &commandMain, bool latex, bool pdf, bool async);
475 	void beginRunningSubCommand(ProcessX *p, const QString &commandMain, const QString &subCommand, const RunCommandFlags &flags);
476 	void endRunningSubCommand(ProcessX *p, const QString &commandMain, const QString &subCommand, const RunCommandFlags &flags);
477 	void endRunningCommand(const QString &commandMain, bool latex, bool pdf, bool async);
478 
479 
480     bool runCommand(const QString &commandline, QString *buffer = nullptr, QTextCodec *codecForBuffer = nullptr, bool saveAll=true);
481     bool runCommandNoSpecialChars(QString commandline, QString *buffer = nullptr, QTextCodec *codecForBuffer = nullptr);
482 	void setStatusMessageProcess(const QString &message);
483     bool runCommandAsync(const QString &commandline, const char *returnCMD);
484 protected slots:
485 	void processNotification(const QString &message);
486     void clearLogs();
487 	void openExternalTerminal(void); ///< open external terminal
488 	void cleanAll();
489 	void commandFromAction();  ///< calls a command given by sender.data, doesn't wait
490 
491 	void webPublish();
492 	void webPublishSource();
493 	void analyseText();
494 	void analyseTextFormDestroyed();
495 	void generateRandomText();
496 
497 	bool loadLog();
498 	void onCompileError();
499 	void setLogMarksVisible(bool visible);
500 	void clearLogEntriesInEditors();
501 	void updateLogEntriesInEditors();
502 	void showLog(); ///< show log viewer in bottom panel
503 	void viewLog();
504 	void viewLogOrReRun(LatexCompileResult *result);
505 	bool gotoNearLogEntry(int lt, bool backward, QString notFoundMessage);
506 	bool hasLatexErrors();
507 	bool logExists();
508 	void clearMarkers();
509 	/////
510 	void latexHelp(); ///< open latex help document
511 	void userManualHelp(); ///< open txs user manual
512 	void texdocHelp();
513 	void helpAbout(); ///< open about dialog
514 
515 	void generalOptions(); ///< open config dialog
516 	void setAutomaticRootDetection();
517 	void setExplicitRootDocument(LatexDocument *doc);
518 	void setCurrentDocAsExplicitRoot();
519 
520 	void gotoNextDocument();
521 	void gotoPrevDocument();
522 	void gotoOpenDocument();
523 	void updateOpenDocumentMenu(bool localChange = false);
524 	void onEditorsReordered();
525 
526 	void focusEditor();
527 	void focusViewer();
528 	void enlargeEmbeddedPDFViewer();
529 	void shrinkEmbeddedPDFViewer(bool preserveConfig = false);
530 
531 	void showStatusbar();
532 	void viewCloseElement();
533 	void setFullScreenMode();
534 	void viewSetHighlighting(QAction *act);
535 	void showHighlightingMenu();
536 
537 	void viewCollapseBlock();
538 	void viewExpandBlock();
539 
540 #ifndef NO_POPPLER_PREVIEW
541 	QObject *newPdfPreviewer(bool embedded = false);
542 #endif
543 	void pdfClosed();
544 
545 	void masterDocumentChanged(LatexDocument *doc);
546 	void aboutToDeleteDocument(LatexDocument *doc);
547 
548     void updateCompleter(LatexEditorView *edView = nullptr);
549 	void completerNeedsUpdate();
550 	void needUpdatedCompleter();
551 
552 	void outputPageChanged(const QString &id);
553 
554     void gotoLine(int line, int col = 0, LatexEditorView *edView = nullptr, QEditor::MoveFlags mflags = QEditor::Navigation, bool setFocus = true); // line is 0 based
555 	bool gotoLine(int line, const QString &fileName);  // line is 0 based, absolute file name
556 	void gotoLine(LatexDocument *doc, int line, int col=0);
557     void gotoLine(QTreeWidgetItem * item,int col);
558 	void gotoLogEntryEditorOnly(int logEntryNumber);
559 	QDocumentCursor getLogEntryContextCursor(const QDocumentLineHandle *dlh, const LatexLogEntry &entry);
560 	bool gotoLogEntryAt(int newLineNumber);
561 	bool gotoMark(bool backward, int id = -1);
562 	QList<int> findOccurencesApproximate(QString checkLine, const QString &guessedWord);
563 	void syncFromViewer(const QString &fileName, int lineNr, bool activate, const QString &guessedWord);  //0 based, absolute file name, raise window
564 
565 	void goBack();
566 	void goForward();
567 	void setGlobalCursor(const QDocumentCursor &c);
568 	void saveCurrentCursorToHistory();
569 	void saveEditorCursorToHistory(LatexEditorView *edView);
570 
571 	void previewLatex();
572 	void previewAvailable(const QString &imageFile, const PreviewSource &source);
573 	void clearPreview();
574 	void showPreview(const QString &text);
575 	void showPreview(const QDocumentCursor &c);
576 	void showPreview(const QDocumentCursor &c, bool addToList);
577 	QStringList makePreviewHeader(const LatexDocument *rootDoc);
578 	void showPreviewQueue();
579 	void showImgPreview(const QString &fname);
580 	void showImgPreviewFinished(const QPixmap &pm, int page);
581 	void recompileForPreview();
582 	void recompileForPreviewNow();
583 
584 	void templateEdit(const QString &fname);
585 
586 	void fileReloaded();
587 	void fileInConflictShowDiff();
588 	void fileAutoReloading(QString fname);
589 
590 	void jumpToSearchResult(QDocument *doc, int lineNumber, const SearchQuery *query);
591 
592 	void cursorPositionChanged();
593 	void syncPDFViewer(QDocumentCursor cur, bool inForeground = true);
594 	//	void treeWidgetChanged();
595 
596 	bool generateMirror(bool setCur = false);
597 	void generateBracketInverterMirror();
598 	void jumpToBracket();
599 	void selectBracket();
600 	void findMissingBracket();
601 	void cursorHovered();
602 	void loadProfile();
603 	void saveProfile();
604 
605 	void addRowCB();
606 	void addColumnCB();
607 	void removeColumnCB();
608 	void removeRowCB();
609 	void cutColumnCB();
610 	void pasteColumnCB();
611 	void addHLineCB();
612 	void remHLineCB();
613 	void insertTableTemplate();
614 	void alignTableCols();
615 
616 	void updateTexQNFA();
617 	void updateTexLikeQNFA(QString languageName, QString filename);
618 
619 	void toggleGrammar(int type);
620 
621 	void openInternalDocViewer(QString package, const QString command = "");
622 
623 private slots:
624 	void importPackage(QString name);
625 	void packageScanCompleted(QString name);
626 	void stopPackageParser();
627 	void packageParserFinished();
628 	void readinAllPackageNames();
629     void packageListReadCompleted(std::set<QString> packages);
630 protected:
631 	void dragEnterEvent(QDragEnterEvent *event);
632 	void dropEvent(QDropEvent *event);
633 	virtual void changeEvent(QEvent *e);
634 
635     bool eventFilter(QObject *obj, QEvent *event);
636 
637 	bool mCompleterNeedsUpdate;
638 
639 	int currentLine;
640 	QBrush oldBackground;
641 	bool mDontScrollToItem;
642 
643 	QByteArray stateFullScreen;
644 
645 	QDialog *svndlg;
646 	UserMenuDialog *userMacroDialog;
647 	QComboBox *cmbLog;
648 
649 	QStringList m_columnCutBuffer;
650 
651 	QTimer autosaveTimer,previewDelayTimer,previewFullCompileDelayTimer;
652 
653 	bool completionBaseCommandsUpdated;
654 
655 	QSet<int> previewQueue;
656 	LatexEditorView *previewQueueOwner;
657 
658 	QString fileFilters;
659 	QString selectedFileFilter;
660 
661 	QPointer<FileSelector> fileSelector;
662 
663 	bool runBibliographyIfNecessaryEntered;
664 
665 	LatexStyleParser *latexStyleParser;
666 	PackageScanner *packageListReader;
667 
668 	QMap<QString, QString> detectedEnvironmentsForHighlighting;
669 
670 	LatexDocument *diffLoadDocHidden(QString f);
671 	void showDiff3(const QString file1, const QString file2);
672 
673 	void restoreBookmarks(LatexEditorView *edView);
674 
675 	bool completerPreview;
676     QPixmapCache previewCache;
677 
678 	bool recheckLabels;
679 
680     bool rememberFollowFromScroll,enlargedViewer;
681 
682     std::set<QString> latexPackageList, currentPackageList;
683 
684 	QMap<QString, QString> *mReplacementList;
685 
686     StructureEntry *currentSection;
687 
688 public:
689     Q_PROPERTY(QString clipboard READ clipboardText WRITE setClipboardText)
690 	Q_INVOKABLE QString clipboardText(const QClipboard::Mode &mode = QClipboard::Clipboard) const;
691 	Q_INVOKABLE void setClipboardText(const QString &text, const QClipboard::Mode &mode = QClipboard::Clipboard);
692 	Q_INVOKABLE int getVersion() const; ///< return current version number of txs (coded in hex,32 bit)
693 	Q_INVOKABLE void simulateKeyPress(const QString &shortcut);
694 
695 	static void recoverFromCrash();
696 
697 public slots:
698 	void threadCrashed();
699 	void iamalive();
700 	void checkLatexInstall();
701 	void checkCWLs();
702     void checkLanguageTool();
703 
704 	void slowOperationStarted();
705 	void slowOperationEnded();
706 
707 	void openBugsAndFeatures();
708 
709 signals:
710 	void infoNewFile(); ///< signal that a new file has been generated. Used for scritps as trigger.
711 	void infoNewFromTemplate(); ///< signal that a new file from template has been generated. Used for scritps as trigger.
712 	void infoLoadFile(const QString &filename); ///< signal that a file has been loaded. Used for scritps as trigger.
713 	void infoFileSaved(const QString &filename,const int checkin = 0); ///< signal that a file has been saved. Used for scritps as trigger.
714 	void infoFileClosed(); ///< signal that a file has been closed. Used for scritps as trigger.
715 	void infoAfterTypeset(); ///< signal that a file has been compiled. Used for scritps as trigger.
716 	void imgPreview(const QString &fn);
717 };
718 
719 //Q_DECLARE_METATYPE(Texstudio *)
720 
721 #endif
722 
723