-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathtexstudio.cpp
12974 lines (11880 loc) · 489 KB
/
texstudio.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
* copyright : (C) 2003-2008 by Pascal Brachet *
* addons by Luis Silvestre *
* http://www.xm1math.net/texmaker/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
//#include <stdlib.h>
//#include "/usr/include/valgrind/callgrind.h"
#include "texstudio.h"
#include "latexeditorview.h"
#include "smallUsefulFunctions.h"
#include "cleandialog.h"
#include "debughelper.h"
#include "debuglogger.h"
#include "dblclickmenubar.h"
#include "filechooser.h"
#include "filedialog.h"
#include "findindirs.h"
#include "tabdialog.h"
#include "arraydialog.h"
#include "bibtexdialog.h"
#include "tabbingdialog.h"
#include "letterdialog.h"
#include "quickdocumentdialog.h"
#include "quickbeamerdialog.h"
#include "mathassistant.h"
#include "maketemplatedialog.h"
#include "PDFDocument.h"
#include "templateselector.h"
#include "templatemanager.h"
#include "usermenudialog.h"
#include "aboutdialog.h"
#include "encodingdialog.h"
#include "encoding.h"
#include "randomtextgenerator.h"
#include "webpublishdialog.h"
#include "thesaurusdialog.h"
#include "qsearchreplacepanel.h"
#include "latexcompleter_config.h"
#include "universalinputdialog.h"
#include "insertgraphics.h"
#include "latexeditorview_config.h"
#include "scriptengine.h"
#include "grammarcheck.h"
#include "qmetautils.h"
#include "updatechecker.h"
#include "session.h"
#include "searchquery.h"
#include "fileselector.h"
#include "utilsUI.h"
#include "utilsSystem.h"
#include "minisplitter.h"
#include "latexpackage.h"
#include "latexparser/argumentlist.h"
#include "latexparser/latextokens.h"
#include "latexparser/latexparser.h"
#include "latexparser/latexparsing.h"
#include "latexstructure.h"
#include "symbollistmodel.h"
#include "symbolwidget.h"
#include "execprogram.h"
#include <QScreen>
#ifndef QT_NO_DEBUG
#include "tests/testmanager.h"
#endif
#include "qdocument.h"
#include "qdocumentcursor.h"
#include "qdocumentline.h"
#include "qdocumentline_p.h"
#include "qnfadefinition.h"
#include "PDFDocument_config.h"
#include <set>
#include <QStyleHints>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
/*! \file texstudio.cpp
* contains the GUI definition as well as some helper functions
*/
/*!
\defgroup txs Mainwindow
\ingroup txs
@{
*/
/*! \class Texstudio
* This class sets up the GUI and handles the GUI interaction (menus and toolbar).
* It uses QEditor with LatexDocument as actual text editor and PDFDocument for viewing pdf.
*
* \see QEditor
* \see LatexDocument
* \see PDFDocument
*/
const QString APPICON(":appicon");
bool programStopped = false;
Texstudio *txsInstance = nullptr;
QCache<QString, QIcon> iconCache;
// workaround needed on OSX due to https://bugreports.qt.io/browse/QTBUG-49576
void hideSplash()
{
#ifdef Q_OS_MAC
if (txsInstance)
txsInstance->hideSplash();
#endif
}
/*!
* \brief constructor
*
* set-up GUI
*
* \param parent
* \param flags
* \param splash
*/
Texstudio::Texstudio(QWidget *parent, Qt::WindowFlags flags, QSplashScreen *splash)
: QMainWindow(parent, flags), textAnalysisDlg(nullptr), spellDlg(nullptr), mDontScrollToItem(false), runBibliographyIfNecessaryEntered(false)
{
splashscreen = splash;
programStopped = false;
spellLanguageActions = nullptr;
currentLine = -1;
svndlg = nullptr;
userMacroDialog = nullptr;
mCompleterNeedsUpdate = false;
latexStyleParser = nullptr;
packageListReader = nullptr;
bibtexEntryActions = nullptr;
biblatexEntryActions = nullptr;
bibTypeActions = nullptr;
highlightLanguageActions = nullptr;
runningPDFCommands = runningPDFAsyncCommands = 0;
previewEditorPending = nullptr;
previewIsAutoCompiling = false;
completerPreview = false;
cursorHistory = nullptr;
recentSessionList = nullptr;
editors = nullptr;
m_languages = nullptr; //initial state to avoid crash on OSX
currentSection=nullptr;
connect(&buildManager, SIGNAL(hideSplash()), this, SLOT(hideSplash()));
readSettings();
#ifdef Q_OS_WIN
// work-around for ´+t bug
QCoreApplication::instance()->installEventFilter(this);
#endif
latexReference = new LatexReference();
latexReference->setFile(findResourceFile("latex2e.html"));
qRegisterMetaType<QSet<QString> >();
qRegisterMetaType<std::set<QString> >();
txsInstance = this;
static int crashHandlerType = 1;
configManager.registerOption("Crash Handler Type", &crashHandlerType, 1);
initCrashHandler(crashHandlerType);
QTimer *t = new QTimer(this);
connect(t, SIGNAL(timeout()), SLOT(iamalive()));
t->start(9500);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
QFile styleSheetFile(configManager.configBaseDir + "stylesheet.qss");
if (styleSheetFile.exists()) {
if(styleSheetFile.open(QFile::ReadOnly)){
setStyleSheet(styleSheetFile.readAll());
styleSheetFile.close();
}
}
// dpi aware icon scaling
// screen dpi is read and the icon are scaled up in reference to 96 dpi
// this should be helpful on X11 (Xresouces) and possibly windows
double dpi=QGuiApplication::primaryScreen()->logicalDotsPerInch();
double scale=dpi/96;
setWindowIcon(QIcon(":/images/logo128.png"));
int iconSize = qRound(qMax(16, configManager.guiToolbarIconSize)*scale);
setIconSize(QSize(iconSize, iconSize));
m_toggleDocksAction = nullptr;
structureTreeWidget = nullptr;
topTOCTreeWidget = nullptr;
outputView = nullptr;
qRegisterMetaType<LatexParser>();
latexParser.importCwlAliases(findResourceFile("completion/cwlAliases.dat"));
m_formatsOldDefault = QDocument::defaultFormatScheme();
QDocument::setDefaultFormatScheme(m_formats);
SpellerUtility::spellcheckErrorFormat = m_formats->id("spellingMistake");
qRegisterMetaType<QList<LineInfo> >();
qRegisterMetaType<QList<GrammarError> >();
qRegisterMetaType<LatexParser>();
qRegisterMetaType<GrammarCheckerConfig>();
qRegisterMetaType<QDocumentLineHandle*>();
grammarCheck = new GrammarCheck();
grammarCheck->moveToThread(&grammarCheckThread);
GrammarCheck::staticMetaObject.invokeMethod(grammarCheck, "init", Qt::QueuedConnection, Q_ARG(LatexParser, latexParser), Q_ARG(GrammarCheckerConfig, *configManager.grammarCheckerConfig));
//connect(grammarCheck, SIGNAL(checked(LatexDocument*,QDocumentLineHandle*,int,QList<GrammarError>)), &documents, SLOT(lineGrammarChecked(LatexDocument*,QDocumentLineHandle*,int,QList<GrammarError>)));
connect(grammarCheck, &GrammarCheck::checked, &documents, &LatexDocuments::lineGrammarChecked);
connect(grammarCheck, SIGNAL(errorMessage(QString)),this,SLOT(LTErrorMessage(QString)));
connect(&documents, SIGNAL(updateQNFA()), this, SLOT(updateTexQNFA()));
grammarCheckThread.start();
if (configManager.autoDetectEncodingFromLatex || configManager.autoDetectEncodingFromChars) QDocument::setDefaultCodec(nullptr);
else QDocument::setDefaultCodec(configManager.newFileEncoding);
if (configManager.autoDetectEncodingFromLatex)
QDocument::addGuessEncodingCallback(&Encoding::guessEncoding); // encodingcallbacks before restoer session !!!
if (configManager.autoDetectEncodingFromChars)
QDocument::addGuessEncodingCallback(&ConfigManager::getDefaultEncoding);
QString qxsPath = QFileInfo(findResourceFile("qxs/tex.qnfa")).path();
m_languages = new QLanguageFactory(m_formats, this);
m_languages->addDefinitionPath(qxsPath);
m_languages->addDefinitionPath(configManager.configBaseDir + "languages"); // definitions here overwrite previous ones
// custom evironments & structure commands
updateTexQNFA();
QLineMarksInfoCenter::instance()->loadMarkTypes(qxsPath + "/marks.qxm");
QList<QLineMarkType> &marks = QLineMarksInfoCenter::instance()->markTypes();
for (int i = 0; i < marks.size(); i++)
if (m_formats->format("line:" + marks[i].id).background.isValid())
marks[i].color = m_formats->format("line:" + marks[i].id).background;
else
marks[i].color = Qt::transparent;
LatexEditorView::updateFormatSettings();
// TAB WIDGET EDITEUR
documents.setCachingFolder(joinPath(configManager.configBaseDir,"cache"));
documents.indentationInStructure = configManager.indentationInStructure;
documents.showCommentedElementsInStructure = configManager.showCommentedElementsInStructure;
documents.indentIncludesInStructure = configManager.indentIncludesInStructure;
documents.markStructureElementsBeyondEnd = configManager.markStructureElementsBeyondEnd;
documents.markStructureElementsInAppendix = configManager.markStructureElementsInAppendix;
documents.showLineNumbersInStructure = configManager.showLineNumbersInStructure;
connect(&documents, SIGNAL(masterDocumentChanged(LatexDocument*)), SLOT(masterDocumentChanged(LatexDocument*)));
connect(&documents, SIGNAL(aboutToDeleteDocument(LatexDocument*)), SLOT(aboutToDeleteDocument(LatexDocument*)));
centralFrame = new QFrame(this);
centralFrame->setLineWidth(0);
centralFrame->setFrameShape(QFrame::NoFrame);
centralFrame->setFrameShadow(QFrame::Plain);
//edit
centralToolBar = new QToolBar(tr("Central"), this);
centralToolBar->setFloatable(false);
centralToolBar->setOrientation(Qt::Vertical);
centralToolBar->setMovable(false);
iconSize = qRound(configManager.guiSecondaryToolbarIconSize*scale);
centralToolBar->setIconSize(QSize(iconSize, iconSize));
editors = new Editors(centralFrame);
editors->setFocus();
TxsTabWidget *leftEditors = new TxsTabWidget(this);
leftEditors->setActive(true);
editors->addTabWidget(leftEditors);
TxsTabWidget *rightEditors = new TxsTabWidget(this);
editors->addTabWidget(rightEditors);
connect(&documents, SIGNAL(docToHide(LatexEditorView*)), editors, SLOT(removeEditor(LatexEditorView*)));
connect(editors, SIGNAL(currentEditorChanged()), SLOT(currentEditorChanged()));
connect(editors, SIGNAL(listOfEditorsChanged()), SLOT(updateOpenDocumentMenu()));
connect(editors, SIGNAL(editorsReordered()), SLOT(onEditorsReordered()));
connect(editors, SIGNAL(closeCurrentEditorRequested()), this, SLOT(fileClose()));
connect(editors, SIGNAL(editorAboutToChangeByTabClick(LatexEditorView*,LatexEditorView*)), this, SLOT(editorAboutToChangeByTabClick(LatexEditorView*,LatexEditorView*)));
cursorHistory = new CursorHistory(&documents);
bookmarks = new Bookmarks(&documents, this);
QLayout *centralLayout = new QHBoxLayout(centralFrame);
centralLayout->setSpacing(0);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
centralLayout->setMargin(0);
#else
centralLayout->setContentsMargins(0,0,0,0);
#endif
centralLayout->addWidget(centralToolBar);
centralLayout->addWidget(editors);
centralVSplitter = new MiniSplitter(Qt::Vertical, this);
centralVSplitter->setChildrenCollapsible(false);
centralVSplitter->addWidget(centralFrame);
centralVSplitter->setStretchFactor(0, 1); // all stretch goes to the editor (0th widget)
mainHSplitter = new MiniSplitter(Qt::Horizontal, this); // top-level element: splits: [ everything else | PDF ]
mainHSplitter->addWidget(centralVSplitter);
mainHSplitter->setChildrenCollapsible(false);
setCentralWidget(mainHSplitter);
setContextMenuPolicy(Qt::ActionsContextMenu);
setupDockWidgets();
setMenuBar(new DblClickMenuBar());
setupMenus();
#ifndef QT_NO_DEBUG
checkForShortcutDuplicate();
#endif
TitledPanelPage *logPage = outputView->pageFromId(outputView->LOG_PAGE);
if (logPage) {
logPage->addToolbarAction(getManagedAction("main/tools/logmarkers"));
logPage->addToolbarAction(getManagedAction("main/edit2/goto/errorprev"));
logPage->addToolbarAction(getManagedAction("main/edit2/goto/errornext"));
}
setupToolBars();
connect(&configManager, SIGNAL(watchedMenuChanged(QString)), SLOT(updateToolBarMenu(QString)));
restoreState(windowstate, 0);
//workaround as toolbar central seems not be be handled by windowstate
centralToolBar->setVisible(configManager.centralVisible);
//check if config was written before txs 4.8.0, resetDock if yes
QSettings *config=configManager.getSettings();
QString txsVersionConfigWritten=config->value("version/written_by_TXS_version").toString();
if(Version::compareStringVersion(txsVersionConfigWritten,"4.8.0")==Version::Lower){
resetDocks();
}
#ifdef Q_OS_MAC
bool disable_OSX_workaround=config->value("texmaker/Editor/Disable_OSX_DockFallback",false).toBool();
if(qApp->primaryScreen()->size().height()<=900 && !disable_OSX_workaround){
// on OSX only, force style to FUSION if style is MACOS (https://github.com/texstudio-org/texstudio/issues/3637)
if(configManager.interfaceStyle.isEmpty() || configManager.interfaceStyle == "macOS"){
configManager.interfaceStyle = "Fusion";
configManager.setInterfaceStyle();
}
}
#endif
// check if dock widgets are all spread and force a reset
if(checkDockSpread()){
#ifdef Q_OS_MAC
// on OSX only, force style to FUSION if style is MACOS (https://github.com/texstudio-org/texstudio/issues/3637)
if( (configManager.interfaceStyle.isEmpty() || configManager.interfaceStyle == "macOS")&& !disable_OSX_workaround){
configManager.interfaceStyle = "Fusion";
configManager.setInterfaceStyle();
}
#endif
resetDocks();
}
createStatusBar();
completer = nullptr;
updateCaption();
updateMasterDocumentCaption();
setStatusMessageProcess(QString(" %1 ").arg(tr("Ready")));
if (tobefullscreen) {
showFullScreen();
restoreState(stateFullScreen, 1);
fullscreenModeAction->setChecked(true);
} else if (tobemaximized) {
#ifdef Q_OS_WIN
// Workaround a Qt/Windows bug which prevents too small windows from maximizing
// For more details see:
// https://stackoverflow.com/questions/27157312/qt-showmaximized-not-working-in-windows
// https://bugreports.qt.io/browse/QTBUG-77077
resize(800, 600);
#endif
showMaximized();
} else {
show();
}
if (splash)
splash->raise();
setAcceptDrops(true);
//installEventFilter(this);
completer = new LatexCompleter(latexParser, this);
completer->setConfig(configManager.completerConfig);
completer->setPackageList(&latexPackageList);
connect(completer, &LatexCompleter::showImagePreview, this, &Texstudio::showImgPreview);
connect(completer, SIGNAL(showPreview(QString)), this, SLOT(showPreview(QString)));
connect(this, &Texstudio::imgPreview, completer, &LatexCompleter::bibtexSectionFound);
//updateCompleter();
LatexEditorView::setCompleter(completer);
completer->setLatexReference(latexReference);
completer->updateAbbreviations();
TemplateManager::setConfigBaseDir(configManager.configBaseDir);
TemplateManager::ensureUserTemplateDirExists();
TemplateManager::checkForOldUserTemplates();
/* The encoding detection works as follow:
If QDocument detects the file is UTF16LE/BE, use that encoding
Else If QDocument detects UTF-8 {
If LatexParser::guessEncoding finds an encoding, use that
Else use UTF-8
} Else {
If LatexParser::guessEncoding finds an encoding use that
Else if QDocument detects ascii (only 7bit characters) {
if default encoding == utf16: use utf-8 as fallback (because utf16 can be reliable detected and the user seems to like unicode)
else use default encoding
}
Else {
if default encoding == utf16/8: use latin1 (because the file contains invalid unicode characters )
else use default encoding
}
}
*/
connect(&svn, &SVN::statusMessage, this, &Texstudio::setStatusMessageProcess);
connect(&svn, SIGNAL(runCommand(QString,QString*)), this, SLOT(runCommandNoSpecialChars(QString,QString*)));
connect(&git, &GIT::statusMessage, this, &Texstudio::setStatusMessageProcess);
connect(&git, SIGNAL(runCommand(QString,QString*)), this, SLOT(runCommandNoSpecialChars(QString,QString*)));
connect(&help, &Help::statusMessage, this, &Texstudio::setStatusMessageProcess);
connect(&help, SIGNAL(runCommand(QString,QString*)), this, SLOT(runCommandNoSpecialChars(QString,QString*)));
connect(&help, SIGNAL(runCommandAsync(QString,const char*)), this, SLOT(runCommandAsync(QString,const char*)));
connect(qGuiApp,&QGuiApplication::paletteChanged,this,&Texstudio::paletteChanged);
#if (QT_VERSION >= 0x060500) && (defined( Q_OS_WIN )||defined( Q_OS_LINUX ))
connect(qGuiApp->styleHints(),&QStyleHints::colorSchemeChanged,this,&Texstudio::colorSchemeChanged);
#endif
QStringList filters;
filters << tr("TeX files") + " (*.tex *.bib *.sty *.cls *.mp *.dtx *.cfg *.ins *.ltx *.tikz *.pdf_tex *.ctx)";
filters << tr("LilyPond files") + " (*.lytex)";
filters << tr("Plaintext files") + " (*.txt)";
filters << tr("Pweave files") + " (*.Pnw)";
filters << tr("Sweave files") + " (*.Snw *.Rnw)";
filters << tr("Asymptote files") + " (*.asy)";
filters << tr("PDF files") + " (*.pdf)";
filters << tr("All files") + " (*)";
fileFilters = filters.join(";;");
if (!configManager.rememberFileFilter)
selectedFileFilter = filters.first();
enlargedViewer=false;
//setup autosave timer
connect(&autosaveTimer, SIGNAL(timeout()), this, SLOT(fileSaveAllFromTimer()));
if (configManager.autosaveEveryMinutes > 0) {
autosaveTimer.start(configManager.autosaveEveryMinutes * 1000 * 60);
}
connect(&previewDelayTimer,SIGNAL(timeout()),this,SLOT(showPreviewQueue()));
previewDelayTimer.setSingleShot(true);
connect(&previewFullCompileDelayTimer,SIGNAL(timeout()),this,SLOT(recompileForPreviewNow()));
previewFullCompileDelayTimer.setSingleShot(true);
connect(this, SIGNAL(infoFileSaved(QString,int)), this, SLOT(checkinAfterSave(QString,int)));
//script things
setProperty("applicationName", TEXSTUDIO);
QTimer::singleShot(500, this, SLOT(autoRunScripts()));
connectWithAdditionalArguments(this, SIGNAL(infoNewFile()), this, "runScripts", QList<QVariant>() << Macro::ST_NEW_FILE);
connectWithAdditionalArguments(this, SIGNAL(infoNewFromTemplate()), this, "runScripts", QList<QVariant>() << Macro::ST_NEW_FROM_TEMPLATE);
connectWithAdditionalArguments(this, SIGNAL(infoLoadFile(QString)), this, "runScripts", QList<QVariant>() << Macro::ST_LOAD_FILE);
connectWithAdditionalArguments(this, SIGNAL(infoFileSaved(QString)), this, "runScripts", QList<QVariant>() << Macro::ST_FILE_SAVED);
connectWithAdditionalArguments(this, SIGNAL(infoFileClosed()), this, "runScripts", QList<QVariant>() << Macro::ST_FILE_CLOSED);
connectWithAdditionalArguments(&documents, SIGNAL(masterDocumentChanged(LatexDocument *)), this, "runScripts", QList<QVariant>() << Macro::ST_MASTER_CHANGED);
connectWithAdditionalArguments(this, SIGNAL(infoAfterTypeset()), this, "runScripts", QList<QVariant>() << Macro::ST_AFTER_TYPESET);
connectWithAdditionalArguments(&buildManager, SIGNAL(endRunningCommands(QString, bool, bool, bool)), this, "runScripts", QList<QVariant>() << Macro::ST_AFTER_COMMAND_RUN);
if (configManager.sessionRestore && !ConfigManager::dontRestoreSession) {
fileRestoreSession(false, false);
}
splashscreen = nullptr;
}
/*!
* \brief destructor
*/
Texstudio::~Texstudio()
{
//structureTreeView->setModel(nullptr);
iconCache.clear();
QDocument::setDefaultFormatScheme(m_formatsOldDefault); //prevents crash when deleted latexeditorview accesses the default format scheme, as m_format is going to be deleted
programStopped = true;
Guardian::shutdown();
if (latexStyleParser) latexStyleParser->stop();
if (packageListReader) packageListReader->stop();
GrammarCheck::staticMetaObject.invokeMethod(grammarCheck, "shutdown", Qt::BlockingQueuedConnection);
grammarCheckThread.quit();
if (latexStyleParser) latexStyleParser->wait();
if (packageListReader) packageListReader->wait();
grammarCheckThread.wait(5000); //TODO: timeout causes sigsegv, is there any better solution?
}
/*!
* \brief code to be executed at end of start-up
*
* Check for Latex installation.
* Read in all package names for usepackage completion.
*/
void Texstudio::startupCompleted()
{
if (configManager.checkLatexConfiguration) {
bool noWarnAgain = false;
buildManager.checkLatexConfiguration(noWarnAgain);
configManager.checkLatexConfiguration = !noWarnAgain;
}
UpdateChecker::instance()->autoCheck();
// package reading (at least with Miktex) apparently slows down the startup
// the first rendering of lines in QDocumentPrivate::draw() gets very slow
// therefore we defer it until the main window is completely loaded
readinAllPackageNames(); // asynchrnous read in of all available sty/cls
}
QAction *Texstudio::newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QKeySequence &shortCut, const QString &iconFile, const QList<QVariant> &args)
{
QAction *tmp = configManager.newManagedAction(menu, id, text, args.isEmpty() ? slotName : SLOT(relayToOwnSlot()), QList<QKeySequence>() << shortCut, iconFile);
if (!args.isEmpty()) {
QString slot = QString(slotName).left(QString(slotName).indexOf("("));
Q_ASSERT(staticMetaObject.indexOfSlot(createMethodSignature(qPrintable(slot), args)) != -1);
tmp->setProperty("slot", qPrintable(slot));
tmp->setProperty("args", QVariant::fromValue<QList<QVariant> >(args));
}
return tmp;
}
QAction *Texstudio::newManagedAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts, const QString &iconFile, const QList<QVariant> &args)
{
QAction *tmp = configManager.newManagedAction(menu, id, text, args.isEmpty() ? slotName : SLOT(relayToOwnSlot()), shortCuts, iconFile);
if (!args.isEmpty()) {
QString slot = QString(slotName).left(QString(slotName).indexOf("("));
Q_ASSERT(staticMetaObject.indexOfSlot(createMethodSignature(qPrintable(slot), args)) != -1);
tmp->setProperty("slot", qPrintable(slot));
tmp->setProperty("args", QVariant::fromValue<QList<QVariant> >(args));
}
return tmp;
}
QAction *Texstudio::newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QKeySequence &shortCut, const QString &iconFile, const QList<QVariant> &args)
{
QAction *tmp = configManager.newManagedAction(menu, id, text, nullptr, QList<QKeySequence>() << shortCut, iconFile);
linkToEditorSlot(tmp, slotName, args);
return tmp;
}
QAction *Texstudio::newManagedEditorAction(QWidget *menu, const QString &id, const QString &text, const char *slotName, const QList<QKeySequence> &shortCuts, const QString &iconFile, const QList<QVariant> &args)
{
QAction *tmp = configManager.newManagedAction(menu, id, text, nullptr, shortCuts, iconFile);
linkToEditorSlot(tmp, slotName, args);
return tmp;
}
QAction *Texstudio::insertManagedAction(QAction *before, const QString &id, const QString &text, const char *slotName, const QKeySequence &shortCut, const QString &iconFile)
{
QMenu *menu = before->menu();
REQUIRE_RET(menu, nullptr);
QAction *inserted = newManagedAction(menu, id, text, slotName, shortCut, iconFile);
menu->removeAction(inserted);
menu->insertAction(before, inserted);
return inserted;
}
/*!
* \brief loadManagedMenu for script use
* \param fn
*/
void Texstudio::loadManagedMenu(const QString &fn)
{
configManager.loadManagedMenus(fn);
}
/*!
* \brief add TagList to side panel
*
* add Taglist to side panel.
*
* \param id
* \param iconName icon used for selecting taglist
* \param text name of taglist
* \param tagFile file to be read as tag list
*/
void Texstudio::addTagList(const QString &id, const QString &iconName, const QString &text, const QString &tagFile)
{
QDockWidget *oldDock=findChild<QDockWidget *>(id,Qt::FindDirectChildrenOnly);
XmlTagsListWidget *list = nullptr;
if(oldDock){
list = qobject_cast<XmlTagsListWidget *>(oldDock->widget());
}
if (!list) {
// check for user tags
QString configBaseDir = configManager.configBaseDir;
QString pathPrefix=joinPath(configBaseDir,"tags/");
QFileInfo userTagFile(pathPrefix+tagFile);
if(!QFileInfo::exists(pathPrefix+tagFile) || !userTagFile.isReadable()) {
pathPrefix = ":/tags/";
}
list = new XmlTagsListWidget(this, pathPrefix + tagFile);
list->setObjectName("tags/" + tagFile.left(tagFile.indexOf("_tags.xml")));
UtilsUi::enableTouchScrolling(list);
connect(list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertXmlTag(QListWidgetItem*)));
addDock(id,iconName,text,list);
}
}
/*!
* \brief add all macros as TagList to side panel
*
* add Macros as Taglist to side panel as an alternative way to call them.
* This may be helpful if the number of macros becomes large and overcrowd the menu or are too many for generic keyboard shortcuts
*
*/
void Texstudio::addMacrosAsTagList()
{
bool addToPanel=true;
QDockWidget *oldDock=findChild<QDockWidget *>("txs-macro",Qt::FindDirectChildrenOnly);
QListWidget *list = nullptr;
if(oldDock){
list=qobject_cast<QListWidget *>(oldDock->widget());
}
if (!list) {
list = new QListWidget(this);
list->setObjectName("tags/txs-macros");
}else{
list->clear();
addToPanel=false;
}
// add elements
for(const auto &m:configManager.completerConfig->userMacros) {
if (m.name == "TMX:Replace Quote Open" || m.name == "TMX:Replace Quote Close" || m.document)
continue;
QListWidgetItem* item=new QListWidgetItem(m.name);
item->setData(Qt::UserRole, m.typedTag());
list->addItem(item);
}
UtilsUi::enableTouchScrolling(list);
connect(list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertFromTagList(QListWidgetItem*)),Qt::UniqueConnection);
if(addToPanel){
addDock("txs-macro","executeMacro_R90",tr("Macros"),list);
}
}
/*! set-up side- and bottom-panel
*/
void Texstudio::setupDockWidgets()
{
//to allow retranslate this function must be able to be called multiple times
// adapt icon size to dpi
double dpi=QGuiApplication::primaryScreen()->logicalDotsPerInch();
double scale=dpi/96;
setTabPosition(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea, QTabWidget::West);
if (!m_toggleDocksAction) {
m_toggleDocksAction=new QAction(this);
m_toggleDocksAction->setCheckable(true);
m_toggleDocksAction->setIcon(getRealIcon("sidebar"));
m_toggleDocksAction->setText(tr("Side Panel"));
m_toggleDocksAction->setChecked(configManager.getOption("GUI/sidePanel/visible", true).toBool());
connect(m_toggleDocksAction, &QAction::toggled,this, &Texstudio::toggleDocks);
}else{
m_toggleDocksAction->setIcon(getRealIcon("sidebar"));
}
// load icons for structure view
setStructureSectionIcons();
if(!structureTreeWidget){
structureTreeWidget = new QTreeWidget();
connect(structureTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(gotoLine(QTreeWidgetItem*,int)));
connect(structureTreeWidget, &QTreeWidget::itemExpanded, this, &Texstudio::syncExpanded);
connect(structureTreeWidget, &QTreeWidget::itemCollapsed, this, &Texstudio::syncCollapsed);
connect(structureTreeWidget, &QTreeWidget::customContextMenuRequested, this, &Texstudio::customMenuStructure);
structureTreeWidget->setHeaderHidden(true);
structureTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
structureTreeWidget->installEventFilter(this);
addDock("structure", "structure_R90",tr("Structure"), structureTreeWidget);
}
if(!topTOCTreeWidget){
topTOCTreeWidget = new QTreeWidget();
connect(topTOCTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(gotoLine(QTreeWidgetItem*,int)));
connect(topTOCTreeWidget, &QTreeWidget::itemExpanded, this, &Texstudio::syncExpanded);
connect(topTOCTreeWidget, &QTreeWidget::itemCollapsed, this, &Texstudio::syncCollapsed);
connect(topTOCTreeWidget, &QTreeWidget::customContextMenuRequested, this, &Texstudio::customMenuStructure);
topTOCTreeWidget->setHeaderHidden(true);
topTOCTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
topTOCTreeWidget->installEventFilter(this);
addDock("TOC", "toc_R90",tr("TOC"), topTOCTreeWidget);
}
QDockWidget *dock=findChild<QDockWidget *>("bookmarks",Qt::FindDirectChildrenOnly);
if (!dock) {
QListWidget *bookmarksWidget = bookmarks->widget();
bookmarks->setDarkMode(darkMode);
connect(bookmarks, SIGNAL(loadFileRequest(QString)), this, SLOT(load(QString)));
connect(bookmarks, SIGNAL(gotoLineRequest(int,int,LatexEditorView*)), this, SLOT(gotoLine(int,int,LatexEditorView*)));
addDock("bookmarks", "bookmarks_R90",tr("Bookmarks"), bookmarksWidget);
} else {
bookmarks->setDarkMode(darkMode);
}
dock=findChild<QDockWidget *>("symbols",Qt::FindDirectChildrenOnly);
if (!dock) {
symbolWidget = new SymbolWidget(symbolListModel, configManager.insertSymbolsAsUnicode, this);
symbolWidget->restoreSplitter(configManager.stateSymbolsWidget);
symbolWidget->setSymbolSize(qRound(configManager.guiSymbolGridIconSize*scale));
connect(symbolWidget, SIGNAL(insertSymbol(QString)), this, SLOT(insertSymbol(QString)));
addDock("symbols", "symbols_R90",tr("Symbols"), symbolWidget);
} else {
symbolListModel->setDarkmode(darkMode);
symbolWidget->reloadData();
}
// setup a dock widget with a file explorer
dock=findChild<QDockWidget *>("explorer",Qt::FindDirectChildrenOnly);
if(!dock){
fileView=new QTreeView();
fileExplorerModel = new QFileSystemModel(this);
QString rootDir = QDir::currentPath();
if (rootDir == "/tmp")
rootDir = "/";
fileExplorerModel->setRootPath(rootDir);
fileView->setModel(fileExplorerModel);
fileView->setColumnHidden(1,true);
fileView->setColumnHidden(2,true);
fileView->setColumnHidden(3,true);
fileView->setRootIndex(fileExplorerModel->index(rootDir));
QAction *act=new QAction();
act->setText(tr("Insert filename"));
connect(act,&QAction::triggered,this,&Texstudio::insertFromExplorer);
fileView->addAction(act);
fileView->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(fileView,&QAbstractItemView::doubleClicked,this,&Texstudio::openFromExplorer);
addDock("explorer", "folder_R90",tr("Files"), fileView);
}
addTagList("brackets", getRealIconFile("leftright_R90"), tr("Left/Right Brackets"), "brackets_tags.xml");
addTagList("pstricks", getRealIconFile("pstricks_R90"), tr("PSTricks Commands"), "pstricks_tags.xml");
addTagList("metapost", getRealIconFile("metapost_R90"), tr("MetaPost Commands"), "metapost_tags.xml");
addTagList("tikz", getRealIconFile("tikz_R90"), tr("TikZ Commands"), "tikz_tags.xml");
addTagList("asymptote", getRealIconFile("asymptote_R90"), tr("Asymptote Commands"), "asymptote_tags.xml");
addTagList("beamer", getRealIconFile("beamer_R90"), tr("Beamer Commands"), "beamer_tags.xml");
addTagList("xymatrix", getRealIconFile("xy_R90"), tr("XY Commands"), "xymatrix_tags.xml");
addMacrosAsTagList();
m_firstDockWidget->raise(); // make sure on first run structure view is topmost
// in case of hidden sidepanel, mark docks which are to be raised
QStringList toRaise=docksToBeRaised.split("|");
QList<QDockWidget *> docks=findChildren<QDockWidget *>();
foreach(QDockWidget *dw,docks){
if(toRaise.contains(dw->objectName())){
dw->setProperty("toBeRaised",true);
}
}
// OUTPUT WIDGETS
if (!outputView) {
outputView = new OutputViewWidget(this, configManager.terminalConfig);
outputView->setObjectName("OutputView");
centralVSplitter->addWidget(outputView);
outputView->toggleViewAction()->setChecked(configManager.getOption("GUI/outputView/visible", true).toBool());
centralVSplitter->setStretchFactor(1, 0);
centralVSplitter->restoreState(configManager.getOption("centralVSplitterState").toByteArray());
connect(outputView->getLogWidget(), SIGNAL(logEntryActivated(int)), this, SLOT(gotoLogEntryEditorOnly(int)));
connect(outputView->getLogWidget(), SIGNAL(logLoaded()), this, SLOT(updateLogEntriesInEditors()));
connect(outputView->getLogWidget(), SIGNAL(logResetted()), this, SLOT(clearLogEntriesInEditors()));
connect(outputView, SIGNAL(pageChanged(QString)), this, SLOT(outputPageChanged(QString)));
connect(outputView->getSearchResultWidget(), &SearchResultWidget::jumpToSearchResult, this, &Texstudio::jumpToSearchResult);
connect(outputView->getSearchResultWidget(), &SearchResultWidget::jumpToFileSearchResult, this, &Texstudio::jumpToFileSearchResult);
connect(outputView->getSearchResultWidget(), SIGNAL(runSearch(SearchQuery*)), this, SLOT(runSearch(SearchQuery*)));
connect(&buildManager, SIGNAL(previewAvailable(const QString&,const PreviewSource&)), this, SLOT(previewAvailable(const QString&,const PreviewSource&)));
connect(&buildManager, SIGNAL(processNotification(QString)), SLOT(processNotification(QString)));
connect(&buildManager, SIGNAL(clearLogs()), SLOT(clearLogs()));
connect(&buildManager, SIGNAL(beginRunningCommands(QString,bool,bool,bool)), SLOT(beginRunningCommand(QString,bool,bool,bool)));
connect(&buildManager, SIGNAL(beginRunningSubCommand(ProcessX*,QString,QString,RunCommandFlags)), SLOT(beginRunningSubCommand(ProcessX*,QString,QString,RunCommandFlags)));
connect(&buildManager, SIGNAL(endRunningSubCommand(ProcessX*,QString,QString,RunCommandFlags)), SLOT(endRunningSubCommand(ProcessX*,QString,QString,RunCommandFlags)));
connect(&buildManager, SIGNAL(endRunningCommands(QString,bool,bool,bool)), SLOT(endRunningCommand(QString,bool,bool,bool)));
connect(&buildManager, SIGNAL(latexCompiled(LatexCompileResult*)), SLOT(viewLogOrReRun(LatexCompileResult*)));
connect(&buildManager, SIGNAL(runInternalCommand(QString,QFileInfo,QString)), SLOT(runInternalCommand(QString,QFileInfo,QString)));
connect(&buildManager, SIGNAL(commandLineRequested(QString,QString*,bool*)), SLOT(commandLineRequested(QString,QString*,bool*)));
}else{
outputView->updateIcon();
}
}
void Texstudio::updateToolBarMenu(const QString &menuName)
{
QMenu *menu = configManager.getManagedMenu(menuName);
if (!menu) return;
LatexEditorView *edView = currentEditorView();
foreach (const ManagedToolBar &tb, configManager.managedToolBars){
if (tb.toolbar && tb.actualActions.contains(menuName)){
foreach (QObject *w, tb.toolbar->children()){
if (w->property("menuID").toString() == menuName) {
QToolButton *combo = qobject_cast<QToolButton *>(w);
REQUIRE(combo);
QStringList actionTexts;
QStringList actionInfos;
QList<QIcon> actionIcons;
int defaultIndex = -1;
foreach (const QAction *act, menu->actions()) {
if (!act->isSeparator()) {
actionTexts.append(act->text());
actionInfos.append(act->toolTip());
actionIcons.append(act->icon());
if (menuName == "main/view/documents" && edView == act->data().value<LatexEditorView *>()) {
defaultIndex = actionTexts.length() - 1;
}
}
else {
actionTexts.append("");
actionInfos.append("");
actionIcons.append(QIcon());
}
}
UtilsUi::createComboToolButton(tb.toolbar, actionTexts, actionInfos, actionIcons, -1, this, SLOT(callToolButtonAction()), defaultIndex, combo);
if (menuName == "main/view/documents") {
// workaround to select the current document
// combobox uses separate actions. So we have to get the current action from the menu (by comparing its data()
// attribute to the currentEditorView(). Then map it to a combobox action using the index.
// TODO: should this menu be provided by Editors?
LatexEditorView *edView = currentEditorView();
foreach (QAction* act, menu->actions()) {
if (edView == act->data().value<LatexEditorView *>()) {
int i = menu->actions().indexOf(act);
if (i < 0 || i>= combo->menu()->actions().length()) continue;
combo->setDefaultAction(combo->menu()->actions()[i]);
}
}
}
}
}
}
}
}
// we different native shortcuts on OSX and Win/Linux
// note: in particular many key combination with arrows are reserved for text navigation in OSX
// and we already set them in QEditor. Don't overwrite them here.
#ifdef Q_OS_MAC
#define MAC_OR_DEFAULT(shortcutMac, shortcutOther) shortcutMac
#else
#define MAC_OR_DEFAULT(shortcutMac, shortcutOther) shortcutOther
#endif
/*! \brief set-up all menus in the menu-bar
*
* This function is called whenever the menu changes (= start and retranslation)
* This means if you call it repeatedly with the same language setting it should not change anything
* Currently this is not true, because it adds additional separator, which are invisible
* creates new action groups and new context menu, although all invisible, they are a memory leak
* But not a bad one, because no one is expected to change the language multiple times
*/
void Texstudio::setupMenus()
{
//This function is called whenever the menu changes (= start and retranslation)
//This means if you call it repeatedly with the same language setting it should not change anything
//Currently this is not true, because it adds additional separator, which are invisible
//creates new action groups and new context menu, although all invisible, they are a memory leak
//But not a bad one, because no one is expected to change the language multiple times
//TODO: correct somewhen
configManager.menuParent = this;
if(configManager.menuParents.isEmpty()){
configManager.menuParents.append(this);
}
configManager.menuParentsBar = menuBar();
//file
QMenu *menu = newManagedMenu("main/file", tr("&File"));
//getManagedMenu("main/file");
newManagedAction(menu, "new", tr("&New"), SLOT(fileNew()), QKeySequence::New, "document-new");
newManagedAction(menu, "newfromtemplate", tr("New From &Template..."), SLOT(fileNewFromTemplate()));
newManagedAction(menu, "open", tr("&Open..."), SLOT(fileOpen()), QKeySequence::Open, "document-open");
QMenu *submenu = newManagedMenu(menu, "openrecent", tr("Open &Recent")); //only create the menu here, actions are created by config manager
submenu = newManagedMenu(menu, "session", tr("Session"));
newManagedAction(submenu, "loadsession", tr("Load Session..."), SLOT(fileLoadSession()));
newManagedAction(submenu, "savesession", tr("Save Session..."), SLOT(fileSaveSession()));
newManagedAction(submenu, "restoresession", tr("Restore Previous Session"), SLOT(fileRestoreSession()));
submenu->addSeparator();
if (!recentSessionList) {
recentSessionList = new SessionList(submenu, this);
connect(recentSessionList, SIGNAL(loadSessionRequest(QString)), this, SLOT(loadSession(QString)));
}
recentSessionList->updateMostRecentMenu();
menu->addSeparator();
actSave = newManagedAction(menu, "save", tr("&Save"), SLOT(fileSave()), QKeySequence::Save, "document-save");
newManagedAction(menu, "saveas", tr("Save &As..."), SLOT(fileSaveAs()), filterLocaleShortcut(Qt::CTRL | Qt::ALT | Qt::Key_S));
newManagedAction(menu, "saveall", tr("Save A&ll"), SLOT(fileSaveAll()), Qt::CTRL | Qt::SHIFT | Qt::Key_S);
newManagedAction(menu, "maketemplate", tr("&Make Template..."), SLOT(fileMakeTemplate()));
submenu = newManagedMenu(menu, "utilities", tr("Fifi&x"));
newManagedAction(submenu, "rename", tr("Save renamed/&moved file..."), "fileUtilCopyMove", 0, QString(), QList<QVariant>() << true);
newManagedAction(submenu, "copy", tr("Save copied file..."), "fileUtilCopyMove", 0, QString(), QList<QVariant>() << false);
newManagedAction(submenu, "delete", tr("&Delete file"), SLOT(fileUtilDelete()));
newManagedAction(submenu, "chmod", tr("Set &permissions..."), SLOT(fileUtilPermissions()));
submenu->addSeparator();
newManagedAction(submenu, "revert", tr("&Revert to saved..."), SLOT(fileUtilRevert()));
submenu->addSeparator();
newManagedAction(submenu, "copyfilename", tr("Copy filename to &clipboard"), SLOT(fileUtilCopyFileName()));
newManagedAction(submenu, "copymasterfilename", tr("Copy root filename to clipboard"), SLOT(fileUtilCopyMasterFileName()));
QMenu *svnSubmenu = newManagedMenu(menu, "svn", tr("S&VN/GIT..."));
newManagedAction(svnSubmenu, "checkin", tr("Check &in..."), SLOT(fileCheckin()));
newManagedAction(svnSubmenu, "svnupdate", tr("SVN &update..."), SLOT(fileUpdate()));
newManagedAction(svnSubmenu, "svnupdatecwd", tr("SVN update &work directory"), SLOT(fileUpdateCWD()));
newManagedAction(svnSubmenu, "showrevisions", tr("Sh&ow old Revisions"), SLOT(showOldRevisions()));
newManagedAction(svnSubmenu, "lockpdf", tr("Lock &PDF"), SLOT(fileLockPdf()));
newManagedAction(svnSubmenu, "checkinpdf", tr("Check in P&DF"), SLOT(fileCheckinPdf()));
newManagedAction(svnSubmenu, "difffiles", tr("Show difference between two files"), SLOT(fileDiff()));
newManagedAction(svnSubmenu, "diff3files", tr("Show difference between two files in relation to base file"), SLOT(fileDiff3()));
newManagedAction(svnSubmenu, "checksvnconflict", tr("Check SVN Conflict"), SLOT(checkSVNConflicted()));
newManagedAction(svnSubmenu, "mergediff", tr("Try to merge differences"), SLOT(fileDiffMerge()));
newManagedAction(svnSubmenu, "removediffmakers", tr("Remove Difference-Markers"), SLOT(removeDiffMarkers()));
newManagedAction(svnSubmenu, "declareresolved", tr("Declare Conflict Resolved"), SLOT(declareConflictResolved()));
newManagedAction(svnSubmenu, "nextdiff", tr("Jump to next difference"), SLOT(jumpNextDiff()), 0, "go-next-diff");
newManagedAction(svnSubmenu, "prevdiff", tr("Jump to previous difference"), SLOT(jumpPrevDiff()), 0, "go-previous-diff");
menu->addSeparator();
newManagedAction(menu, "close", tr("&Close"), SLOT(fileClose()), Qt::CTRL | Qt::Key_W, "document-close");
newManagedAction(menu, "closeall", tr("Clos&e All"), SLOT(fileCloseAll()));
menu->addSeparator();
newManagedEditorAction(menu, "print", tr("Print Source Code..."), "print");
menu->addSeparator();
newManagedAction(menu, "exit", tr("Exit"), SLOT(fileExit()), Qt::CTRL | Qt::Key_Q)->setMenuRole(QAction::QuitRole);
//edit
menu = newManagedMenu("main/edit", tr("&Edit"));
actUndo = newManagedAction(menu, "undo", tr("&Undo"), SLOT(editUndo()), QKeySequence::Undo, "edit-undo");
actRedo = newManagedAction(menu, "redo", tr("&Redo"), SLOT(editRedo()), QKeySequence::Redo, "edit-redo");
#ifndef QT_NO_DEBUG
newManagedAction(menu, "debughistory", tr("Debug undo stack"), SLOT(editDebugUndoStack()));
#endif
menu->addSeparator();
newManagedEditorAction(menu, "cut", tr("C&ut"), "cut", QKeySequence::Cut, "edit-cut");
newManagedAction(menu, "copy", tr("&Copy"), SLOT(editCopy()), QKeySequence::Copy, "edit-copy");
newManagedAction(menu, "paste", tr("&Paste"), SLOT(editPaste()), QKeySequence::Paste, "edit-paste");
submenu = newManagedMenu(menu, "selection", tr("&Selection"));
newManagedEditorAction(submenu, "selectAll", tr("Select &All"), "selectAll", Qt::CTRL | Qt::Key_A);
newManagedEditorAction(submenu, "selectAllOccurences", tr("Select All &Occurrences"), "selectAllOccurences");
newManagedEditorAction(submenu, "selectPrevOccurence", tr("Select &Prev Occurrence"), "selectPrevOccurence");
newManagedEditorAction(submenu, "selectNextOccurence", tr("Select &Next Occurrence"), "selectNextOccurence");
newManagedEditorAction(submenu, "selectPrevOccurenceKeepMirror", tr("Also Select Prev Occurrence"), "selectPrevOccurenceKeepMirror");
newManagedEditorAction(submenu, "selectNextOccurenceKeepMirror", tr("Also Select Next Occurrence"), "selectNextOccurenceKeepMirror");
newManagedEditorAction(submenu, "expandSelectionToWord", tr("Expand Selection to Word"), "selectExpandToNextWord", Qt::CTRL | Qt::Key_D);
newManagedEditorAction(submenu, "expandSelectionToLine", tr("Expand Selection to Line"), "selectExpandToNextLine", Qt::CTRL | Qt::Key_L);
submenu = newManagedMenu(menu, "lineoperations", tr("&Line Operations"));
newManagedAction(submenu, "deleteLine", tr("Delete &Line"), SLOT(editDeleteLine()), Qt::CTRL | Qt::Key_K);
newManagedAction(submenu, "cutLine", tr("C&ut Line or Selection"), SLOT(editCutLine()), Qt::SHIFT | Qt::Key_Delete);
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
newManagedAction(submenu, "deleteToEndOfLine", tr("Delete To &End Of Line"), SLOT(editDeleteToEndOfLine()), MAC_OR_DEFAULT(Qt::CTRL | Qt::Key_Delete, Qt::AltModifier | Qt::Key_K));
#else
newManagedAction(submenu, "deleteToEndOfLine", tr("Delete To &End Of Line"), SLOT(editDeleteToEndOfLine()), MAC_OR_DEFAULT(Qt::CTRL | Qt::Key_Delete, Qt::AltModifier + Qt::Key_K));
#endif
newManagedAction(submenu, "deleteFromStartOfLine", tr("Delete From &Start Of Line"), SLOT(editDeleteFromStartOfLine()), MAC_OR_DEFAULT(Qt::CTRL | Qt::Key_Backspace, 0));
newManagedAction(submenu, "moveLineUp", tr("Move Line &Up"), SLOT(editMoveLineUp()));
newManagedAction(submenu, "moveLineDown", tr("Move Line &Down"), SLOT(editMoveLineDown()));
newManagedAction(submenu, "duplicateLine", tr("Du&plicate Line"), SLOT(editDuplicateLine()));
newManagedAction(submenu, "sortLines", tr("S&ort Lines"), SLOT(editSortLines()));
newManagedAction(submenu, "alignMirrors", tr("&Align Cursors"), SLOT(editAlignMirrors()));
submenu = newManagedMenu(menu, "textoperations", tr("&Text Operations"));
newManagedAction(submenu, "textToLowercase", tr("To Lowercase"), SLOT(editTextToLowercase()));